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.

201 lines
6.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. bltsetbx.hxx
  7. Header file for set control ( a linked pair of control windows )
  8. FILE HISTORY:
  9. terryk 01-Jul-91 Created
  10. terryk 12-Aug-91 Add Bitmap parameter to the constrcutor
  11. terryk 16-Aug-91 Code review. Attended by: rustanl
  12. davidhov davidbul terryk
  13. jonn 09-Sep-93 Modified to allow SET_CONTROL listboxes
  14. to be lazy
  15. */
  16. #ifndef _BLTSETBX_HXX_
  17. #define _BLTSETBX_HXX_
  18. #include "bltctrl.hxx"
  19. #include "bltbutn.hxx"
  20. #include "bltlc.hxx"
  21. #include "bltlb.hxx"
  22. #include "bltgroup.hxx"
  23. /* Forward references */
  24. DLL_CLASS SET_CONTROL;
  25. DLL_CLASS BLT_SET_CONTROL;
  26. /*********************************************************************
  27. NAME: SET_CONTROL (setctrl)
  28. SYNOPSIS: Set Control - This control consists of 2
  29. list boxes and 2 push buttons. The first
  30. listbox consists of all the orginial strings and
  31. the second listbox consists of all the strings
  32. which transfer from the orginial listbox.
  33. The 2 push buttons are: Add and Delete.
  34. Add will add the current selected items from
  35. the orginial listbox to the new listbox
  36. Delete will move the selected item from the
  37. new listbox to the orginial listbox
  38. INTERFACE:
  39. SET_CONTROL() - constructor
  40. ~SET_CONTROL() - destructor
  41. DoAdd() - add items from the orginial listbox to the new
  42. listbox
  43. DoRemove() - move item from the new listbox to the
  44. original listbox
  45. EnableMoves() - enable and disable the set control's add and
  46. delete buttons.
  47. MoveItems() - redefine to move items from one listbox to another.
  48. Use BLTMoveItems or subclass BLT_SET_CONTROL
  49. for ordinary sorted BLT_LISTBOXes.
  50. HandleOnLMouseButtonDown() The listboxes must redirect these events
  51. HandleOnLMouseButtonUp() - to the corresponding SET_CONTROL. This
  52. HandleOnMouseMove() implies that the listboxes must multiply
  53. derive from CUSTOM_CONTROL.
  54. PARENT: CONTROL_GROUP
  55. NOTES: Drag and drop will not work unless you manage listbox events
  56. properly. See the Handle* methods above for details.
  57. HISTORY:
  58. terryk 02-Jul-91 Created
  59. terryk 12-Aug-91 Add bitmap name parameter to the
  60. constructor
  61. terryk 16-Aug-91 Add DoAdd(), DoRemove() and
  62. EnableMoves()
  63. Code review by rustanl, davidhov,
  64. davidbul, terryk
  65. beng 08-Oct-1991 Win32 conversion
  66. beng 27-May-1992 Direct manipulation delta
  67. jonn 09-Sep-93 Modified to allow SET_CONTROL listboxes
  68. to be lazy
  69. **********************************************************************/
  70. DLL_CLASS SET_CONTROL: public CONTROL_GROUP
  71. {
  72. private:
  73. LISTBOX * _plbOrigBox;
  74. LISTBOX * _plbNewBox;
  75. UINT _dxIconColumn;
  76. PUSH_BUTTON _butAdd;
  77. PUSH_BUTTON _butDelete;
  78. HCURSOR _hcurNoDrop;
  79. HCURSOR _hcurSingle;
  80. HCURSOR _hcurMultiple;
  81. HCURSOR _hcurSave;
  82. HCURSOR _hcurUse;
  83. BOOL _fEnableMove;
  84. BOOL _fInDrag;
  85. BOOL _fInFakeClick;
  86. BOOL _fAlreadyFakedClick;
  87. MOUSE_EVENT _eMouseDownSave;
  88. APIERR DoAddOrRemove( LISTBOX *plbFrom,
  89. LISTBOX *plbTo );
  90. // Worker fcns
  91. HCURSOR CalcAppropriateCursor( LISTBOX * plbThis, LISTBOX * plbOther, const XYPOINT & xy ) const;
  92. BOOL IsWithinHitZone( LISTBOX * plbThis, LISTBOX * plbOther, const XYPOINT & xy ) const;
  93. BOOL IsOnSelectedItem( LISTBOX * plbThis, LISTBOX * plbOther, const XYPOINT & xy ) const;
  94. BOOL IsOnDragStart( LISTBOX * plbThis, LISTBOX * plbOther, const XYPOINT & xy ) const;
  95. BOOL IsOverTarget( LISTBOX * plbThis, LISTBOX * plbOther, const XYPOINT & xy ) const;
  96. LISTBOX * OtherListbox( LISTBOX * plb ) const;
  97. protected:
  98. virtual APIERR OnUserAction( CONTROL_WINDOW *, const CONTROL_EVENT & );
  99. virtual APIERR MoveItems( LISTBOX *plbFrom,
  100. LISTBOX *plbTo ) = 0; // must redefine
  101. virtual APIERR BLTMoveItems( BLT_LISTBOX *plbFrom,
  102. BLT_LISTBOX *plbTo );
  103. VOID EnableButtons();
  104. public:
  105. SET_CONTROL( OWNER_WINDOW * powin, CID cidAdd, CID cidRemove,
  106. HCURSOR hcurSingle, HCURSOR hcurMultiple,
  107. LISTBOX *plbOrigBox,
  108. LISTBOX *plbNewBox,
  109. UINT dxIconColumn );
  110. ~SET_CONTROL();
  111. // Hooks for the dialog
  112. virtual APIERR DoAdd();
  113. virtual APIERR DoRemove();
  114. VOID EnableMoves( BOOL fEnable );
  115. // Listboxes should redefine corresponding methods to call through to these
  116. BOOL HandleOnLMouseButtonDown( LISTBOX * plb,
  117. CUSTOM_CONTROL * pcc,
  118. const MOUSE_EVENT & e );
  119. BOOL HandleOnLMouseButtonUp( LISTBOX * plb,
  120. CUSTOM_CONTROL * pcc,
  121. const MOUSE_EVENT & e );
  122. BOOL HandleOnMouseMove( LISTBOX * plb, const MOUSE_EVENT & e );
  123. };
  124. /*********************************************************************
  125. NAME: BLT_SET_CONTROL (bltsetctrl)
  126. SYNOPSIS: This is a SET_CONTROL with a MoveItems virtual which is
  127. appropriate for sorted BLT_LISTBOXes.
  128. PARENT: SET_CONTROL
  129. HISTORY:
  130. JonN 09-Sep-93 Created
  131. **********************************************************************/
  132. class BLT_SET_CONTROL: public SET_CONTROL
  133. {
  134. protected:
  135. virtual APIERR MoveItems( LISTBOX *plbFrom, LISTBOX *plbTo );
  136. public:
  137. BLT_SET_CONTROL( OWNER_WINDOW * powin,
  138. CID cidAdd, CID cidRemove,
  139. HCURSOR hcurSingle, HCURSOR hcurMultiple,
  140. LISTBOX *plbOrigBox,
  141. LISTBOX *plbNewBox,
  142. UINT dxIconColumn )
  143. : SET_CONTROL( powin, cidAdd, cidRemove, hcurSingle, hcurMultiple,
  144. plbOrigBox, plbNewBox, dxIconColumn )
  145. {}
  146. ~BLT_SET_CONTROL()
  147. {}
  148. };
  149. #endif // _BLTSETBX_HXX_