Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

351 lines
11 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // comctrls.h
  4. //
  5. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  6. #include "FontInfo.H"
  7. #ifndef MDT_COMON_CONTROLS
  8. #define MDT_COMON_CONTROLS 1
  9. /////////////////////////////////////////////////////////////////////////////
  10. // The classes defined below (CEditControlEditBox, CEditControlListBox) are
  11. // used to implement a lighter weight, general purpose Edit control than the
  12. // UFM Editor specific classes that are defined above. (A normal Edit Box is
  13. // part of this Edit Control, too.)
  14. class CEditControlListBox ; // Forward class declaration
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CEditControlEditBox window
  17. class CEditControlEditBox : public CEdit
  18. {
  19. CEditControlListBox* m_pceclb ; // Pointer to related list box control
  20. // Construction
  21. public:
  22. CEditControlEditBox(CEditControlListBox* pceclb) ;
  23. // Attributes
  24. public:
  25. // Operations
  26. public:
  27. // Overrides
  28. // ClassWizard generated virtual function overrides
  29. //{{AFX_VIRTUAL(CEditControlEditBox)
  30. //}}AFX_VIRTUAL
  31. // Implementation
  32. public:
  33. virtual ~CEditControlEditBox();
  34. // Generated message map functions
  35. protected:
  36. //{{AFX_MSG(CEditControlEditBox)
  37. afx_msg void OnKillfocus();
  38. //}}AFX_MSG
  39. DECLARE_MESSAGE_MAP()
  40. };
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CEditControlListBox window
  43. class CEditControlListBox : public CListBox
  44. {
  45. CEdit* m_pceName ;
  46. CEditControlEditBox* m_pcecebValue ;
  47. bool m_bReady ; // True iff ready for operations
  48. int m_nCurSelIdx ; // Currently selected item's index
  49. // Construction
  50. public:
  51. CEditControlListBox(CEdit* pce, CEditControlEditBox* pceceb) ;
  52. // Attributes
  53. public:
  54. // Operations
  55. public:
  56. bool Init(CStringArray& csamodels, CStringArray& csafiles, int ntabstop) ;
  57. void SaveValue(void) ;
  58. bool GetGPDInfo(CStringArray& csavalues, CStringArray* pcsanames = NULL) ;
  59. void SelectLBEntry(int nidx, bool bsave = false) ;
  60. // Overrides
  61. // ClassWizard generated virtual function overrides
  62. //{{AFX_VIRTUAL(CEditControlListBox)
  63. //}}AFX_VIRTUAL
  64. // Implementation
  65. public:
  66. virtual ~CEditControlListBox();
  67. // Generated message map functions
  68. protected:
  69. //{{AFX_MSG(CEditControlListBox)
  70. afx_msg void OnSelchange();
  71. afx_msg void OnDblclk();
  72. //}}AFX_MSG
  73. DECLARE_MESSAGE_MAP()
  74. };
  75. /////////////////////////////////////////////////////////////////////////////
  76. // The classes defined below are for the CFullEditListCtrl and CFELCEditBox
  77. // classes. Together, they support a List Control in Report View
  78. // in which subitems can be edited too, complete rows can be selected, and
  79. // the data can be sorted by numeric or text columns. CFELCEditBox is a
  80. // helper class that is only used by CFullEditListCtrl.
  81. //
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CFELCEditBox Class
  84. class CFELCEditBox : public CEdit
  85. {
  86. // Construction
  87. public:
  88. CFELCEditBox() ;
  89. // Attributes
  90. public:
  91. // Operations
  92. public:
  93. // Overrides
  94. // ClassWizard generated virtual function overrides
  95. //{{AFX_VIRTUAL(CFELCEditBox)
  96. //}}AFX_VIRTUAL
  97. // Implementation
  98. public:
  99. virtual ~CFELCEditBox() ;
  100. // Generated message map functions
  101. protected:
  102. //{{AFX_MSG(CFELCEditBox)
  103. afx_msg void OnKillFocus(CWnd* pNewWnd) ;
  104. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  105. //}}AFX_MSG
  106. DECLARE_MESSAGE_MAP()
  107. };
  108. // The following structure(s), enumeration(s), and definitions are used with
  109. // CFullEditListCtrl.
  110. typedef enum {
  111. COLDATTYPE_INT = 0, COLDATTYPE_STRING, COLDATTYPE_FLOAT, COLDATTYPE_TOGGLE,
  112. COLDATTYPE_CUSTEDIT
  113. } COLDATTYPE ;
  114. typedef struct _COLINFO { // Maintains info on each column
  115. int nwidth ; // The column width
  116. bool beditable ; // True iff the column is editable
  117. COLDATTYPE cdttype ; // The type of data in the column
  118. bool bsortable ; // True iff the rows can be sorted on this column
  119. bool basc ; // True iff the column has been sort ascended
  120. LPCTSTR lpctstrtoggle ; // If toggle type, pointer to toggle string
  121. } COLINFO, *PCOLINFO ;
  122. #define COMPUTECOLWIDTH -1
  123. #define SETWIDTHTOREMAINDER -2
  124. // The following flags are used to indicate the toggle state of the list's
  125. // columns. These values are assigned to m_dwToggleFlags.
  126. #define TF_HASTOGGLECOLUMNS 1 // The list has toggle column(s)
  127. #define TF_CLICKONROW 2 // Dbl-Clking on row toggles single column
  128. #define TF_CLICKONCOLUMN 4 // Must dbl-clk on column (cell) to toggle it
  129. // The following flags are used to indicate which one - if any - of the list's
  130. // column's data may be modified via a custom edit routine in the class'
  131. // owner. These values are assigned to m_dwCustEditFlags.
  132. #define CEF_HASTOGGLECOLUMNS 1 // The list has a custom edit column
  133. #define CEF_CLICKONROW 2 // Dbl-Clking on row activates single column
  134. #define CEF_CLICKONCOLUMN 4 // Must dbl-clk on cell to activate dialog
  135. // Miscellaneous flags used to control the behaviour of CFullEditListCtrl.
  136. // These flags are passed to InitControl() in its dwmiscflags parameter.
  137. #define MF_SENDCHANGEMESSAGE 1 // Send WM_LISTCELLCHANGED messages
  138. #define MF_IGNOREINSERT 2 // Ignore INS key
  139. #define MF_IGNOREDELETE 4 // Ignore DEL key
  140. #define MF_IGNOREINSDEL 6 // Ignore INS and DEL key
  141. // This message is sent - when requested - to a CFullEditListCtrl class
  142. // instance's owner whenever a list cell is changed after the list had been
  143. // initialized. (Yes, this really is better than having the owner handle
  144. // LVN_ITEMCHANGED messages.)
  145. #define WM_LISTCELLCHANGED (WM_USER + 999)
  146. // A function of this type is passed to ExtraInit_CustEditCol() and called by
  147. // CheckHandleCustEditColumn() when nonstandard editting is needed for a
  148. // specific cell.
  149. typedef bool (CALLBACK* LPCELLEDITPROC) (CObject* pcoowner, int nrow, int ncol,
  150. CString* pcscontents) ;
  151. /////////////////////////////////////////////////////////////////////////////
  152. // CFullEditListCtrl Class
  153. class CFullEditListCtrl : public CListCtrl
  154. {
  155. // Constructor
  156. public:
  157. CFullEditListCtrl();
  158. ~CFullEditListCtrl();
  159. // Overrides
  160. // ClassWizard generated virtual function overrides
  161. //{{AFX_VIRTUAL(CFullEditListCtrl)
  162. public:
  163. virtual BOOL PreTranslateMessage(MSG* pMsg);
  164. //}}AFX_VIRTUAL
  165. // Implementation
  166. protected:
  167. CFELCEditBox m_edit;
  168. // Message maps
  169. //{{AFX_MSG(CFullEditListCtrl)
  170. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  171. afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
  172. afx_msg void OnDblclk(NMHDR* pNMHDR, LRESULT* pResult);
  173. afx_msg void OnKeydown(NMHDR* pNMHDR, LRESULT* pResult);
  174. afx_msg void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
  175. afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  176. afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  177. //}}AFX_MSG
  178. DECLARE_MESSAGE_MAP()
  179. private:
  180. PCOLINFO m_pciColInfo ; // Ptr to array of structs with column info
  181. int m_nNumColumns ; // The number of columns in the list
  182. int m_nSortColumn ; // Number of column being sorted
  183. int m_nNextItemData ; // Next item data number to use
  184. int m_nRow ; // Row being edited
  185. int m_nColumn ; // Column being edited
  186. DWORD m_dwToggleFlags ; // Flags indicating toggle flag for list
  187. DWORD m_dwMiscFlags ; // Misc flags used to control list's actions
  188. CObject* m_pcoOwner ; // Pointer to class that owns this one
  189. DWORD m_dwCustEditFlags ; // Flags describing custom edit column
  190. CUIntArray m_cuiaCustEditRows ;// Array indicating specific cust edit rows
  191. LPCELLEDITPROC m_lpCellEditProc ; // Ptr to custom cell editing proc
  192. public:
  193. bool CheckHandleToggleColumns(int nrow, int ncol, PCOLINFO pci) ;
  194. void InitControl(DWORD dwaddlexstyles, int numrows, int numcols,
  195. DWORD dwtoggleflags = 0, int neditlen = 0,
  196. int dwmiscflags = 0) ;
  197. int InitLoadColumn(int ncolnum, LPCSTR strlabel, int nwidth, int nwidthpad,
  198. bool beditable, bool bsortable, COLDATTYPE cdtdatatype,
  199. CObArray* pcoadata, LPCTSTR lpctstrtoggle = NULL) ;
  200. bool ExtraInit_CustEditCol(int ncolnum, CObject* pcoowner,
  201. DWORD dwcusteditflags,
  202. CUIntArray& cuiacusteditrows,
  203. LPCELLEDITPROC lpcelleditproc) ;
  204. bool CheckHandleCustEditColumn(int nrow, int ncol, PCOLINFO pci) ;
  205. BOOL GetPointRowCol(LPPOINT lpPoint, int& iRow, int& iCol, CRect& rect) ;
  206. BOOL GetColCellRect(LPPOINT lpPoint, int& iRow, int& iCol, CRect& rect) ;
  207. bool SaveValue() ;
  208. void HideEditBox() ;
  209. bool GetColumnData(CObArray* pcoadata, int ncolnum) ;
  210. bool SetColumnData(CObArray* pcoadata, int ncolnum) ;
  211. static int CALLBACK SortListData(LPARAM lp1, LPARAM lp2, LPARAM lp3) ;
  212. bool SortControl(int nsortcolumn) ;
  213. void SingleSelect(int nitem) ;
  214. bool GetRowData(int nrow, CStringArray& csafields) ;
  215. int GetNumColumns() { return m_nNumColumns ; }
  216. bool GetColSortOrder(int ncol) {
  217. ASSERT(ncol >= 0 && ncol <= m_nNumColumns) ;
  218. return ((m_pciColInfo + ncol)->basc) ;
  219. } ;
  220. bool EndEditing(bool bsave) ;
  221. bool EditCurRowSpecCol(int ncolumn) ;
  222. int GetCurRow() { return m_nRow ; }
  223. void SetCurRow(int nrow) ;
  224. int GetCurCol() { return m_nColumn ; }
  225. void SendChangeNotification(int nrow, int ncol) ;
  226. } ;
  227. /////////////////////////////////////////////////////////////////////////////
  228. // CFlagsListBox window
  229. class CFlagsListBox : public CListBox
  230. {
  231. // Construction
  232. public:
  233. CFlagsListBox();
  234. // Attributes
  235. public:
  236. bool m_bReady ; // True iff listbox has been initialized
  237. CUIntArray m_cuiaFlagGroupings ; // Flag groupings array
  238. int m_nGrpCnt ; // Number of flag groupings
  239. CString m_csSetString ; // String used to indicate a bit is set
  240. int m_nNumFields ; // Number of flag fields in list box
  241. bool m_bNoClear ; // True iff can't clear flags directly
  242. int m_nNoClearGrp ; // Group for which m_bNoClear applies
  243. // Operations
  244. public:
  245. bool Init(CStringArray& csafieldnames, DWORD dwsettings,
  246. CUIntArray& cuiaflaggroupings, int ngrpcnt,
  247. LPTSTR lptstrsetstring, int ntabstop, bool bnoclear = false,
  248. int nocleargrp = -1) ;
  249. bool Init2(CStringArray& csafieldnames, CString* pcssettings,
  250. CUIntArray& cuiaflaggroupings, int ngrpcnt,
  251. LPTSTR lptstrsetstring, int ntabstop, bool bnoclear = false,
  252. int nocleargrp = -1) ;
  253. DWORD GetNewFlagDWord() ;
  254. void GetNewFlagString(CString* pcsflags, bool badd0x = true) ;
  255. // Overrides
  256. // ClassWizard generated virtual function overrides
  257. //{{AFX_VIRTUAL(CFlagsListBox)
  258. //}}AFX_VIRTUAL
  259. // Implementation
  260. public:
  261. virtual ~CFlagsListBox();
  262. // Generated message map functions
  263. protected:
  264. //{{AFX_MSG(CFlagsListBox)
  265. afx_msg void OnDblclk();
  266. //}}AFX_MSG
  267. DECLARE_MESSAGE_MAP()
  268. };
  269. /////////////////////////////////////////////////////////////////////////////
  270. //{{AFX_INSERT_LOCATION}}
  271. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  272. #endif // #define MDT_COMON_CONTROLS