Source code of Windows XP (NT5)
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.

222 lines
6.4 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // LCPair.h
  7. //
  8. // Abstract:
  9. // Definition of the CListCtrlPair dialog.
  10. //
  11. // Implementation File:
  12. // LCPair.cpp
  13. //
  14. // Author:
  15. // David Potter (davidp) August 8, 1996
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef _LCPAIR_H_
  23. #define _LCPAIR_H_
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Include Files
  26. /////////////////////////////////////////////////////////////////////////////
  27. #ifndef _CLUSITEM_H_
  28. #include "ClusItem.h" // for CClusterItemList
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. // Forward Class Declarations
  32. /////////////////////////////////////////////////////////////////////////////
  33. class CListCtrlPair;
  34. /////////////////////////////////////////////////////////////////////////////
  35. // Type Definitions
  36. /////////////////////////////////////////////////////////////////////////////
  37. typedef void (*PFNLCPGETCOLUMN)(
  38. IN OUT CObject * pobj,
  39. IN int iItem,
  40. IN int icol,
  41. IN OUT CDialog * pdlg,
  42. OUT CString & rstr,
  43. OUT int * piimg
  44. );
  45. typedef int (*PFNLCPDISPPROPS)(
  46. IN OUT CObject * pobj
  47. );
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CListCtrlPair command target
  50. /////////////////////////////////////////////////////////////////////////////
  51. class CListCtrlPair : public CCmdTarget
  52. {
  53. DECLARE_DYNAMIC(CListCtrlPair)
  54. friend class CListCtrlPairDlg;
  55. friend class CListCtrlPairPage;
  56. friend class CListCtrlPairWizPage;
  57. // Construction
  58. public:
  59. CListCtrlPair(void); // protected constructor used by dynamic creation
  60. CListCtrlPair(
  61. IN OUT CDialog * pdlg,
  62. IN OUT CClusterItemList * rlpobjRight,
  63. IN const CClusterItemList * rlpobjLeft,
  64. IN DWORD dwStyle,
  65. IN PFNLCPGETCOLUMN pfnGetColumn,
  66. IN PFNLCPDISPPROPS pfnDisplayProps
  67. );
  68. void CommonConstruct(void);
  69. // Attributes
  70. protected:
  71. CDialog * m_pdlg;
  72. CClusterItemList * m_plpobjRight;
  73. const CClusterItemList * m_plpobjLeft;
  74. IDS m_idsRightLabel;
  75. IDS m_idsLeftLabel;
  76. DWORD m_dwStyle;
  77. #define LCPS_SHOW_IMAGES 0x1
  78. #define LCPS_ALLOW_EMPTY 0x2
  79. #define LCPS_CAN_BE_ORDERED 0x4
  80. #define LCPS_ORDERED 0x8
  81. #define LCPS_DONT_OUTPUT_RIGHT_LIST 0x10
  82. #define LCPS_READ_ONLY 0x20
  83. #define LCPS_PROPERTIES_BUTTON 0x40
  84. #define LCPS_MAX 0x40
  85. PFNLCPGETCOLUMN m_pfnGetColumn;
  86. PFNLCPDISPPROPS m_pfnDisplayProps;
  87. BOOL BIsStyleSet(IN DWORD dwStyle) const { return (m_dwStyle & dwStyle) == dwStyle; }
  88. void ModifyStyle(IN DWORD dwRemove, IN DWORD dwAdd)
  89. {
  90. ASSERT((dwRemove & dwAdd) == 0);
  91. if (dwRemove != 0)
  92. m_dwStyle &= ~dwRemove;
  93. if (dwAdd != 0)
  94. m_dwStyle |= dwAdd;
  95. }
  96. public:
  97. CDialog * Pdlg(void) const { return m_pdlg; }
  98. CClusterItemList * PlpobjRight(void) const { return m_plpobjRight; }
  99. const CClusterItemList * PlpobjLeft(void) const { return m_plpobjLeft; }
  100. IDS IdsRightLabel(void) const { return m_idsRightLabel; }
  101. IDS IdsLeftLabel(void) const { return m_idsLeftLabel; }
  102. DWORD DwStyle(void) const { return m_dwStyle; }
  103. BOOL BShowImages(void) const { return BIsStyleSet(LCPS_SHOW_IMAGES); }
  104. BOOL BAllowEmpty(void) const { return BIsStyleSet(LCPS_ALLOW_EMPTY); }
  105. BOOL BCanBeOrdered(void) const { return BIsStyleSet(LCPS_CAN_BE_ORDERED); }
  106. BOOL BOrdered(void) const { return BIsStyleSet(LCPS_ORDERED); }
  107. BOOL BReadOnly(void) const { return BIsStyleSet(LCPS_READ_ONLY); }
  108. BOOL BPropertiesButton(void) const { return BIsStyleSet(LCPS_PROPERTIES_BUTTON); }
  109. void SetDlg(CDialog * pdlg) { ASSERT_VALID(pdlg); m_pdlg = pdlg; }
  110. void SetLists(IN OUT CClusterItemList * plpobjRight, IN const CClusterItemList * plpobjLeft);
  111. void SetLists(IN const CClusterItemList * plpobjRight, IN const CClusterItemList * plpobjLeft);
  112. // Operations
  113. public:
  114. int NAddColumn(IN IDS idsText, IN int nWidth);
  115. int NInsertItemInListCtrl(
  116. IN int iitem,
  117. IN OUT CObject * pobj,
  118. IN OUT CListCtrl & rlc
  119. );
  120. // Overrides
  121. // ClassWizard generated virtual function overrides
  122. //{{AFX_VIRTUAL(CListCtrlPair)
  123. //}}AFX_VIRTUAL
  124. virtual BOOL OnSetActive(void);
  125. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  126. // Implementation
  127. protected:
  128. CClusterItemList m_lpobjRight;
  129. CClusterItemList m_lpobjLeft;
  130. CListCtrl m_lcRight;
  131. CListCtrl m_lcLeft;
  132. CListCtrl * m_plcFocusList;
  133. CButton m_pbAdd;
  134. CButton m_pbRemove;
  135. CButton m_pbProperties;
  136. public:
  137. CClusterItemList & LpobjRight(void) { return m_lpobjRight; }
  138. CClusterItemList & LpobjLeft(void) { return m_lpobjLeft; }
  139. protected:
  140. void DuplicateLists(void);
  141. void FillList(IN OUT CListCtrl & rlc, IN const CClusterItemList & rlpobj);
  142. void MoveItems(
  143. IN OUT CListCtrl & rlcDst,
  144. IN OUT CClusterItemList & rlpobjDst,
  145. IN OUT CListCtrl & rlcSrc,
  146. IN OUT CClusterItemList & rlpobjSrc
  147. );
  148. // Column structure and collection.
  149. struct CColumn
  150. {
  151. IDS m_idsText;
  152. int m_nWidth;
  153. };
  154. typedef CArray<CColumn, CColumn&> CColumnArray;
  155. CColumnArray m_aColumns;
  156. // Sort information.
  157. struct SortInfo
  158. {
  159. int m_nDirection;
  160. int m_nColumn;
  161. };
  162. static int CALLBACK CompareItems(LPARAM lparam1, LPARAM lparam2, LPARAM lparamSort);
  163. SortInfo m_siLeft;
  164. SortInfo m_siRight;
  165. SortInfo * m_psiCur;
  166. SortInfo & SiLeft(void) { return m_siLeft; }
  167. SortInfo & SiRight(void) { return m_siRight; }
  168. SortInfo * PsiCur(void) const { return m_psiCur; }
  169. // Generated message map functions
  170. //{{AFX_MSG(CListCtrlPair)
  171. //}}AFX_MSG
  172. public:
  173. virtual BOOL OnInitDialog(void);
  174. virtual BOOL BSaveChanges(void);
  175. protected:
  176. afx_msg BOOL OnContextMenu(CWnd* pWnd, CPoint point);
  177. afx_msg void OnAdd(void);
  178. afx_msg void OnRemove(void);
  179. afx_msg void OnProperties(void);
  180. afx_msg void OnDblClkLeftList(NMHDR* pNMHDR, LRESULT* pResult);
  181. afx_msg void OnDblClkRightList(NMHDR* pNMHDR, LRESULT* pResult);
  182. afx_msg void OnItemChangedLeftList(NMHDR* pNMHDR, LRESULT* pResult);
  183. afx_msg void OnItemChangedRightList(NMHDR* pNMHDR, LRESULT* pResult);
  184. afx_msg void OnColumnClickLeftList(NMHDR* pNMHDR, LRESULT* pResult);
  185. afx_msg void OnColumnClickRightList(NMHDR* pNMHDR, LRESULT* pResult);
  186. DECLARE_MESSAGE_MAP()
  187. }; //*** class CListCtrlPair
  188. /////////////////////////////////////////////////////////////////////////////
  189. #endif // _LCPAIR_H_