XTable.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 "TreeComboBox2.h"
  7. class XTableComboBox : public CComboBox
  8. {
  9. // Construction
  10. public:
  11. XTableComboBox();
  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(XTableComboBox)
  21. public:
  22. virtual BOOL PreTranslateMessage(MSG* pMsg);
  23. //}}AFX_VIRTUAL
  24. // Implementation
  25. public:
  26. virtual ~XTableComboBox();
  27. // Generated message map functions
  28. protected:
  29. //{{AFX_MSG(XTableComboBox)
  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 XTableEdit : public CEdit
  40. {
  41. // Construction
  42. public:
  43. XTableEdit();
  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(XTableEdit)
  53. public:
  54. virtual BOOL PreTranslateMessage(MSG* pMsg);
  55. //}}AFX_VIRTUAL
  56. // Implementation
  57. public:
  58. virtual ~XTableEdit();
  59. // Generated message map functions
  60. protected:
  61. //{{AFX_MSG(XTableEdit)
  62. afx_msg void OnKillFocus(CWnd* pNewWnd);
  63. afx_msg void OnSetFocus(CWnd* pOldWnd);
  64. //}}AFX_MSG
  65. DECLARE_MESSAGE_MAP()
  66. private:
  67. DWORD m_dwData;
  68. BOOL m_bExchange;
  69. };
  70. // XTable
  71. class XTable : public CWnd
  72. {
  73. DECLARE_DYNAMIC(XTable)
  74. CArray<CStringArray, CStringArray>*m_pClientArray;
  75. CArray<CStringArray, CStringArray>*pTxtypearray;
  76. CArray<CStringArray, CStringArray>*m_pListArray;
  77. friend class XCell;
  78. CAutoComplete m_acCombo;
  79. XTableComboBox m_combobox;
  80. XTableComboBox m_combobox2;
  81. int m_nCurShow;
  82. int m_nticks;
  83. CStringArray m_datearray;
  84. CArray<int,int>m_daterowposarray;
  85. int m_mode;
  86. CString m_id;
  87. public:
  88. XTable(int rows = 0, int cols = 0);
  89. virtual ~XTable();
  90. BOOL m_bFocusFrame;
  91. BOOL Create(const RECT& rect, CWnd* parent, UINT nID,
  92. DWORD dwStyle = WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VISIBLE);
  93. int ToXML (CMarkup& markup);
  94. int FromXML (CMarkup& markup);
  95. public:
  96. XCell* cells;
  97. int* rowHeight;
  98. int* colWidth;
  99. CTreeComboBox2 *m_pComboBox;
  100. int rows;
  101. int cols;
  102. int focusRow;
  103. int focusCol;
  104. XCell defaultCell;
  105. int defaultHeight;
  106. int defaultWidth;
  107. public:
  108. int SetRows(int rows);
  109. int GetRows();
  110. int SetCols(int cols);
  111. int GetCols();
  112. int SetRowHeight(int row, int height);
  113. int GetRowHeight(int row);
  114. int SetColWidth(int col, int width);
  115. int GetColWidth(int col);
  116. int GetRowsHeight(int startRow, int endRow);
  117. int GetColsWidth(int startCol, int endCol);
  118. int AppendRow() {return SetRows(GetRows() + 1);}
  119. int AppendCol() {return SetCols(GetCols() + 1);}
  120. int deleteRow() {return SetRows(GetRows() - 1);}
  121. int deleteCol() {return SetCols(GetCols() - 1);}
  122. int JoinCells (int startRow, int startCol, int endRow, int endCol);
  123. int UnjoinCells (int row, int col);
  124. int SetCells(int row, int col, XCell& cell);
  125. XCell* GetCells(int row, int col);
  126. int SetText(int row, int col, CString str);
  127. CString GetText(int row, int col);
  128. int SetTextColor(int row, int col, COLORREF color);
  129. COLORREF GetTextColor(int row, int col);
  130. int SetTextFont(int row, int col, CFont& font);
  131. CFont* GetTextFont(int row, int col);
  132. int SetTextFontSize(int row, int col, int size);
  133. int GetTextFontSize(int row, int col);
  134. int SetBackColor(int row, int col, COLORREF color);
  135. COLORREF GetBackColor(int row, int col);
  136. int SetBackMode(int row, int col, int mode);
  137. int GetBackMode(int row, int col);
  138. int SetOverlap (int row, int col, bool enable);
  139. bool GetOverlap (int row, int col);
  140. int SetAlignment (int row, int col, int align);
  141. int GetAlignment (int row, int col);
  142. int SetWordbreak (int row, int col, bool enable);
  143. bool GetWordbreak (int row, int col);
  144. public:
  145. int Draw(CDC* pDC);
  146. RECT GetRect(int row, int col);
  147. bool HitTest (CPoint point, int& row, int& col);
  148. int Test ();
  149. int Test2 ();
  150. int Test3 ();
  151. protected:
  152. DECLARE_MESSAGE_MAP()
  153. public:
  154. void HidePrice();
  155. void AddName(int row, int col, CString str);
  156. void ModeChange(int mode);
  157. CString GetWeek(CString date);
  158. BOOL IsDateRow(int row);
  159. void OtherDate();
  160. CString GetCurPhone(CString &name);
  161. void DeleteCur();
  162. void Save(int row);
  163. void Save2(int row);
  164. void Save3(int row);
  165. void CalRowHeight();
  166. afx_msg void OnPaint();
  167. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  168. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  169. virtual void OnDraw(CDC* pDC);
  170. static BOOL RegisterWindowClass();
  171. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  172. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  173. afx_msg void OnEditEnd(WPARAM ,LPARAM lParam = FALSE);
  174. void ShowEdit(BOOL bShow,int nItem,int nIndex,CRect rc = CRect(0,0,0,0));
  175. void ShowSearchClientComboBox(BOOL bShow,int nItem,int nIndex,CRect rc = CRect(0,0,0,0));
  176. void ShowSearchClientComboBoxTime(BOOL bShow,int nItem,int nIndex,int type,CRect rc = CRect(0,0,0,0));
  177. void ShowSearchClientComboBoxTree(BOOL bShow,int nItem,int nIndex,int type,CRect rc = CRect(0,0,0,0));
  178. XTableEdit m_edit;
  179. int m_nItem;
  180. int m_nSub;
  181. };