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.

310 lines
10 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. bltctrl.hxx
  7. BLT control hierarchy declarations
  8. (Enormous hierarchy comment deleted for the greater good of all mankind.)
  9. FILE HISTORY
  10. RustanL 20-Nov-1990 Created
  11. beng 14-May-1991 Hacked for separate compilation
  12. terryk 18-Jul-1991 Change the GRAPHICAL_BUTTON and GRAPHICAL_
  13. BUTTON_WITH_DISABLE classes
  14. terryk 26-Aug-1991 Add QuerySelected to GBWD
  15. beng 17-Sep-1991 Broke apart bltbutn, bltedit
  16. o-SimoP 02-Jan-1992 Added HIDDEN_CONTROL
  17. beng 18-May-1992 Added SCROLLBAR
  18. beng 30-May-1992 Changed GUILTT support
  19. */
  20. #ifndef _BLT_HXX_
  21. #error "Don't include this file directly; instead, include it through blt.hxx"
  22. #endif // _BLT_HXX_
  23. #ifndef _BLTCTRL_HXX_
  24. #define _BLTCTRL_HXX_
  25. #include "bltdlg.hxx"
  26. #include "bltdc.hxx"
  27. #include "bltfont.hxx"
  28. #include "bltidres.hxx"
  29. #include "string.hxx"
  30. // N.b. This file depends on bltcons.h and bltwin.hxx.
  31. /**********************************************************************
  32. NAME: CONTROL_WINDOW
  33. SYNOPSIS: Control window class
  34. INTERFACE:
  35. CONTROL_WINDOW() - constructor.
  36. QueryCid() - return the CID private member.
  37. ClaimFocus() - focus the current window
  38. QueryFont() - return the current font handle
  39. SetFont() - sets the current font, optionally redrawing
  40. the control. Takes either a font handle or
  41. a logical font object
  42. SetControlValueFocus()
  43. Redefines the CONTROL_VALUE::SetControlValueFocus to simply call
  44. ClaimFocus.
  45. Validate() - checks the control's contents for validity.
  46. IndicateError() - indicates erroneous user input
  47. PARENT: WINDOW, CONTROL_VALUE, FORWARDING_BASE
  48. USES: CID, FONT
  49. NOTES:
  50. At its construction, each control checks its owning window
  51. (to which it forwards all error reports and queries) to see
  52. if it failed.
  53. HISTORY:
  54. rustanl 20-Nov-90 Creation
  55. gregj 01-May-91 Added GUILTT custom-draw support
  56. beng 14-May-1991 Changed friend
  57. beng 21-May-1991 CD_* members made protected;
  58. changed friends
  59. beng 31-Jul-1991 Error reporting changed
  60. beng 21-Aug-1991 Added SetFont member
  61. Johnl 17-Sep-1991 Made NotifyGroups Public
  62. beng 05-Oct-1991 Win32 conversion
  63. beng 31-Oct-1991 Added dialog validation
  64. beng 01-Jun-1992 Changed GUILTT support
  65. jonn 05-Sep-1995 Added OnCtlColor
  66. DavePr 03-Jun-2002 Fixing DLGPROC for Win64
  67. **********************************************************************/
  68. DLL_CLASS CONTROL_WINDOW : public WINDOW,
  69. public CONTROL_VALUE,
  70. public FORWARDING_BASE
  71. {
  72. // This class already inherits from vanilla BASE, and so needs
  73. // to override those methods.
  74. //
  75. NEWBASE(FORWARDING_BASE)
  76. // DlgProc needs friendship in order to handle group notification
  77. // upon control activity.
  78. //
  79. friend INT_PTR CALLBACK DIALOG_WINDOW::DlgProc( HWND hDlg, UINT nMsg,
  80. WPARAM wParam, LPARAM lParam );
  81. // OnCDMessages needs friendship in order to call CD_* members.
  82. //
  83. friend INT OWNER_WINDOW::OnCDMessages( UINT nMsg,
  84. WPARAM wParam, LPARAM lParam );
  85. private:
  86. CID _cid;
  87. protected:
  88. // Virtual methods called on custom drawn (CD) objects
  89. virtual BOOL CD_Draw( DRAWITEMSTRUCT * pdis );
  90. // note, CD_Measure is currently only called for variable size items
  91. virtual BOOL CD_Measure( MEASUREITEMSTRUCT * pmis );
  92. // CD_Char and CD_VKey will only be called for listboxes
  93. virtual INT CD_Char( WCHAR wch, USHORT nLastPos );
  94. virtual INT CD_VKey( USHORT nVKey, USHORT nLastPos );
  95. // Hook for CT's autotest tool
  96. virtual APIERR CD_Guiltt( INT ilb, NLS_STR * pnlsOut );
  97. virtual APIERR OnUserAction( const CONTROL_EVENT & e );
  98. virtual VOID SetTabStop( BOOL fTabStop = TRUE );
  99. // The names "static", "listbox", etc.
  100. static const TCHAR * QueryStaticClassName () ;
  101. static const TCHAR * QueryListboxClassName () ;
  102. static const TCHAR * QueryComboboxClassName () ;
  103. static const TCHAR * QueryEditClassName () ;
  104. #define CW_CLASS_STATIC CONTROL_WINDOW::QueryStaticClassName()
  105. #define CW_CLASS_LISTBOX CONTROL_WINDOW::QueryListboxClassName()
  106. #define CW_CLASS_COMBOBOX CONTROL_WINDOW::QueryComboboxClassName()
  107. #define CW_CLASS_EDIT CONTROL_WINDOW::QueryEditClassName()
  108. public:
  109. CONTROL_WINDOW( OWNER_WINDOW * powin, CID cid );
  110. CONTROL_WINDOW( OWNER_WINDOW * powin, CID cid,
  111. XYPOINT xy, XYDIMENSION dxy,
  112. ULONG flStyle, const TCHAR * pszClassName );
  113. CID QueryCid() const;
  114. VOID ClaimFocus();
  115. HFONT QueryFont() const;
  116. VOID SetFont( HFONT hfont, BOOL fRedraw = FALSE );
  117. VOID SetFont( const FONT & font, BOOL fRedraw = FALSE )
  118. { SetFont(font.QueryHandle(), fRedraw); }
  119. virtual VOID SetControlValueFocus();
  120. /* Tells all parent groups that this CONTROL_WINDOW received the message
  121. * contained in lParam.
  122. * (Should this have another version that doesn't need the event?)
  123. */
  124. APIERR NotifyGroups( const CONTROL_EVENT & e );
  125. // Data-validation functions
  126. virtual APIERR Validate();
  127. virtual VOID IndicateError( APIERR err );
  128. // JonN 8/3/95 This can be used to set the background color of
  129. // controls to other than the default, for example to
  130. // change the default background color for a static text control
  131. // to the same background as for an edit control. The virtual
  132. // redefinition may return non-NULL or it may change *pmsgid.
  133. virtual HBRUSH OnCtlColor( HDC hdc, HWND hwnd, UINT * pmsgid );
  134. };
  135. /*************************************************************************
  136. NAME: ICON_CONTROL
  137. SYNOPSIS: Control for static icon control
  138. INTERFACE: ICON_CONTROL()
  139. powin - pointer to owner window
  140. cid - ID of control
  141. idresIcon - Either a pointer to the name of the icon
  142. resource OR the ordinal of the icon resource.
  143. SetIcon()
  144. SetPredefinedIcon()
  145. PARENT: CONTROL_WINDOW
  146. HISTORY:
  147. JohnL 8-Feb-1991 Created
  148. beng 17-May-1991 Added app-window constructor
  149. beng 04-Oct-1991 Win32 conversion
  150. KeithMo 24-Mar-1992 Now takes IDRESOURCE, added SetPredefinedIcon.
  151. beng 01-Aor-1992 const args fixup
  152. **************************************************************************/
  153. DLL_CLASS ICON_CONTROL : public CONTROL_WINDOW
  154. {
  155. private:
  156. APIERR W_SetIcon( const IDRESOURCE & idresIcon, BOOL fIsPredefined );
  157. public:
  158. ICON_CONTROL( OWNER_WINDOW * powin, CID cid );
  159. ICON_CONTROL( OWNER_WINDOW * powin, CID cid,
  160. const IDRESOURCE & idresIcon );
  161. ICON_CONTROL( OWNER_WINDOW * powin, CID cid,
  162. XYPOINT xy, XYDIMENSION dxy,
  163. ULONG flStyle = WS_CHILD,
  164. const TCHAR * pszClassName = CW_CLASS_STATIC );
  165. ICON_CONTROL( OWNER_WINDOW * powin, CID cid,
  166. XYPOINT xy, XYDIMENSION dxy,
  167. const IDRESOURCE & idresIcon,
  168. ULONG flStyle = WS_CHILD,
  169. const TCHAR * pszClassName = CW_CLASS_STATIC );
  170. APIERR SetIcon( const IDRESOURCE & idresIcon )
  171. { return W_SetIcon( idresIcon, FALSE ); }
  172. APIERR SetPredefinedIcon( const IDRESOURCE & idresIcon )
  173. { return W_SetIcon( idresIcon, TRUE ); }
  174. };
  175. /*************************************************************************
  176. NAME: HIDDEN_CONTROL
  177. SYNOPSIS: This disables control and makes it invisible
  178. INTERFACE: HIDDEN_CONTROL() - constructor
  179. ~HIDDEN_CONTROL() - destructor
  180. PARENT: CONTROL_WINDOW
  181. HISTORY:
  182. o-SimoP 02-Jan-1992 Created
  183. **************************************************************************/
  184. DLL_CLASS HIDDEN_CONTROL: public CONTROL_WINDOW
  185. {
  186. public:
  187. HIDDEN_CONTROL( OWNER_WINDOW * powin, CID cid );
  188. ~HIDDEN_CONTROL()
  189. { ; }
  190. };
  191. /*************************************************************************
  192. NAME: SCROLLBAR
  193. SYNOPSIS: Simple wrapper for creating a scrollbar control
  194. INTERFACE: SCROLLBAR() - ctor
  195. SetPos() - set position within scrolling
  196. SetRange() - set range of values
  197. QueryPos() - query current position
  198. QueryMin() - query current minimum
  199. QueryMax() - query current maximum
  200. PARENT: CONTROL_WINDOW
  201. NOTES:
  202. It would be interesting to make a version of this control
  203. which adopts the embedded scrollbar of another control, e.g.
  204. that of a MLE.
  205. The SetXxx member functions do not redraw the control.
  206. HISTORY:
  207. beng 18-May-1992 Created
  208. beng 29-Jun-1992 Outlined a ctor form
  209. **************************************************************************/
  210. DLL_CLASS SCROLLBAR: public CONTROL_WINDOW
  211. {
  212. private:
  213. static const TCHAR * _pszClassName;
  214. public:
  215. SCROLLBAR( OWNER_WINDOW * pwnd, CID cid )
  216. : CONTROL_WINDOW( pwnd, cid ) { ; }
  217. SCROLLBAR( OWNER_WINDOW * pwnd, CID cid,
  218. XYPOINT xy, XYDIMENSION dxy, ULONG flStyle );
  219. VOID SetPos( UINT nPosition );
  220. VOID SetRange( UINT nMinimum, UINT nMaximum );
  221. UINT QueryPos() const;
  222. UINT QueryMin() const;
  223. UINT QueryMax() const;
  224. };
  225. #endif // _BLTCTRL_HXX_ - end of file