XTable - 副本.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. #pragma once
  2. #include "XCell.h"
  3. #include "AutoCompl.h"
  4. const int MAX_ROWS = 256;
  5. const int MAX_COLS = 128;
  6. #include "TreeComboBox.h"
  7. class XTableTreeComboBox : public CTreeComboBox
  8. {
  9. // Construction
  10. public:
  11. XTableTreeComboBox();
  12. // Attributes
  13. public:
  14. void SetCtrlData(DWORD dwData);
  15. DWORD GetCtrlData();
  16. // Operations
  17. public:
  18. // Overrides
  19. // ClassWizard generated virtual function overrides
  20. //{{AFX_VIRTUAL(XTableTreeComboBox)
  21. public:
  22. virtual BOOL PreTranslateMessage(MSG* pMsg);
  23. //}}AFX_VIRTUAL
  24. // Implementation
  25. public:
  26. virtual ~XTableTreeComboBox();
  27. // Generated message map functions
  28. protected:
  29. //{{AFX_MSG(XTableTreeComboBox)
  30. afx_msg void OnKillFocus(CWnd* pNewWnd);
  31. afx_msg void OnSetFocus(CWnd* pOldWnd);
  32. afx_msg void OnCloseup();
  33. //}}AFX_MSG
  34. DECLARE_MESSAGE_MAP()
  35. private:
  36. DWORD m_dwData;
  37. BOOL m_bExchange;
  38. };
  39. class XTableComboBox : public CComboBox
  40. {
  41. // Construction
  42. public:
  43. XTableComboBox();
  44. // Attributes
  45. public:
  46. void SetCtrlData(DWORD dwData);
  47. DWORD GetCtrlData();
  48. // Operations
  49. public:
  50. // Overrides
  51. // ClassWizard generated virtual function overrides
  52. //{{AFX_VIRTUAL(XTableComboBox)
  53. public:
  54. virtual BOOL PreTranslateMessage(MSG* pMsg);
  55. //}}AFX_VIRTUAL
  56. // Implementation
  57. public:
  58. virtual ~XTableComboBox();
  59. // Generated message map functions
  60. protected:
  61. //{{AFX_MSG(XTableComboBox)
  62. afx_msg void OnKillFocus(CWnd* pNewWnd);
  63. afx_msg void OnSetFocus(CWnd* pOldWnd);
  64. afx_msg void OnCloseup();
  65. //}}AFX_MSG
  66. DECLARE_MESSAGE_MAP()
  67. private:
  68. DWORD m_dwData;
  69. BOOL m_bExchange;
  70. };
  71. class XTableEdit : public CEdit
  72. {
  73. // Construction
  74. public:
  75. XTableEdit();
  76. // Attributes
  77. public:
  78. void SetCtrlData(DWORD dwData);
  79. DWORD GetCtrlData();
  80. // Operations
  81. public:
  82. // Overrides
  83. // ClassWizard generated virtual function overrides
  84. //{{AFX_VIRTUAL(XTableEdit)
  85. public:
  86. virtual BOOL PreTranslateMessage(MSG* pMsg);
  87. //}}AFX_VIRTUAL
  88. // Implementation
  89. public:
  90. virtual ~XTableEdit();
  91. // Generated message map functions
  92. protected:
  93. //{{AFX_MSG(XTableEdit)
  94. afx_msg void OnKillFocus(CWnd* pNewWnd);
  95. afx_msg void OnSetFocus(CWnd* pOldWnd);
  96. //}}AFX_MSG
  97. DECLARE_MESSAGE_MAP()
  98. private:
  99. DWORD m_dwData;
  100. BOOL m_bExchange;
  101. };
  102. // XTable
  103. class XTable : public CWnd
  104. {
  105. DECLARE_DYNAMIC(XTable)
  106. CArray<CStringArray, CStringArray>*m_pClientArray;
  107. CArray<CStringArray, CStringArray>*pTxtypearray;
  108. CArray<CStringArray, CStringArray>*m_pListArray;
  109. friend class XCell;
  110. CAutoComplete m_acCombo;
  111. XTableComboBox m_combobox;
  112. XTableComboBox m_combobox2;
  113. int m_nCurShow;
  114. int m_nticks;
  115. CStringArray m_datearray;
  116. CArray<int,int>m_daterowposarray;
  117. int m_mode;
  118. CString m_id;
  119. public:
  120. XTable(int rows = 0, int cols = 0);
  121. virtual ~XTable();
  122. BOOL m_bFocusFrame;
  123. BOOL Create(const RECT& rect, CWnd* parent, UINT nID,
  124. DWORD dwStyle = WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VISIBLE);
  125. int ToXML (CMarkup& markup);
  126. int FromXML (CMarkup& markup);
  127. public:
  128. XCell* cells;
  129. int* rowHeight;
  130. int* colWidth;
  131. int rows;
  132. int cols;
  133. int focusRow;
  134. int focusCol;
  135. XCell defaultCell;
  136. int defaultHeight;
  137. int defaultWidth;
  138. public:
  139. int SetRows(int rows);
  140. int GetRows();
  141. int SetCols(int cols);
  142. int GetCols();
  143. int SetRowHeight(int row, int height);
  144. int GetRowHeight(int row);
  145. int SetColWidth(int col, int width);
  146. int GetColWidth(int col);
  147. int GetRowsHeight(int startRow, int endRow);
  148. int GetColsWidth(int startCol, int endCol);
  149. int AppendRow() {return SetRows(GetRows() + 1);}
  150. int AppendCol() {return SetCols(GetCols() + 1);}
  151. int deleteRow() {return SetRows(GetRows() - 1);}
  152. int deleteCol() {return SetCols(GetCols() - 1);}
  153. int JoinCells (int startRow, int startCol, int endRow, int endCol);
  154. int UnjoinCells (int row, int col);
  155. int SetCells(int row, int col, XCell& cell);
  156. XCell* GetCells(int row, int col);
  157. int SetText(int row, int col, CString str);
  158. CString GetText(int row, int col);
  159. int SetTextColor(int row, int col, COLORREF color);
  160. COLORREF GetTextColor(int row, int col);
  161. int SetTextFont(int row, int col, CFont& font);
  162. CFont* GetTextFont(int row, int col);
  163. int SetTextFontSize(int row, int col, int size);
  164. int GetTextFontSize(int row, int col);
  165. int SetBackColor(int row, int col, COLORREF color);
  166. COLORREF GetBackColor(int row, int col);
  167. int SetBackMode(int row, int col, int mode);
  168. int GetBackMode(int row, int col);
  169. int SetOverlap (int row, int col, bool enable);
  170. bool GetOverlap (int row, int col);
  171. int SetAlignment (int row, int col, int align);
  172. int GetAlignment (int row, int col);
  173. int SetWordbreak (int row, int col, bool enable);
  174. bool GetWordbreak (int row, int col);
  175. public:
  176. int Draw(CDC* pDC);
  177. RECT GetRect(int row, int col);
  178. bool HitTest (CPoint point, int& row, int& col);
  179. int Test ();
  180. int Test2 ();
  181. protected:
  182. DECLARE_MESSAGE_MAP()
  183. public:
  184. void AddName(int row, int col, CString str);
  185. void ModeChange(int mode);
  186. CString GetWeek(CString date);
  187. BOOL IsDateRow(int row);
  188. void OtherDate();
  189. void DeleteCur();
  190. void Save(int row);
  191. void Save2(int row);
  192. void CalRowHeight();
  193. afx_msg void OnPaint();
  194. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  195. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  196. virtual void OnDraw(CDC* pDC);
  197. static BOOL RegisterWindowClass();
  198. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  199. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  200. afx_msg void OnEditEnd(WPARAM ,LPARAM lParam = FALSE);
  201. void ShowEdit(BOOL bShow,int nItem,int nIndex,CRect rc = CRect(0,0,0,0));
  202. void ShowSearchClientComboBox(BOOL bShow,int nItem,int nIndex,CRect rc = CRect(0,0,0,0));
  203. void ShowSearchClientComboBoxTime(BOOL bShow,int nItem,int nIndex,int type,CRect rc = CRect(0,0,0,0));
  204. XTableEdit m_edit;
  205. int m_nItem;
  206. int m_nSub;
  207. };