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.

309 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. **********************************************************************/
  67. DLL_CLASS CONTROL_WINDOW : public WINDOW,
  68. public CONTROL_VALUE,
  69. public FORWARDING_BASE
  70. {
  71. // This class already inherits from vanilla BASE, and so needs
  72. // to override those methods.
  73. //
  74. NEWBASE(FORWARDING_BASE)
  75. // DlgProc needs friendship in order to handle group notification
  76. // upon control activity.
  77. //
  78. friend BOOL DIALOG_WINDOW::DlgProc( HWND hDlg, UINT nMsg,
  79. WPARAM wParam, LPARAM lParam );
  80. // OnCDMessages needs friendship in order to call CD_* members.
  81. //
  82. friend INT OWNER_WINDOW::OnCDMessages( UINT nMsg,
  83. WPARAM wParam, LPARAM lParam );
  84. private:
  85. CID _cid;
  86. protected:
  87. // Virtual methods called on custom drawn (CD) objects
  88. virtual BOOL CD_Draw( DRAWITEMSTRUCT * pdis );
  89. // note, CD_Measure is currently only called for variable size items
  90. virtual BOOL CD_Measure( MEASUREITEMSTRUCT * pmis );
  91. // CD_Char and CD_VKey will only be called for listboxes
  92. virtual INT CD_Char( WCHAR wch, USHORT nLastPos );
  93. virtual INT CD_VKey( USHORT nVKey, USHORT nLastPos );
  94. // Hook for CT's autotest tool
  95. virtual APIERR CD_Guiltt( INT ilb, NLS_STR * pnlsOut );
  96. virtual APIERR OnUserAction( const CONTROL_EVENT & e );
  97. virtual VOID SetTabStop( BOOL fTabStop = TRUE );
  98. // The names "static", "listbox", etc.
  99. static const TCHAR * QueryStaticClassName () ;
  100. static const TCHAR * QueryListboxClassName () ;
  101. static const TCHAR * QueryComboboxClassName () ;
  102. static const TCHAR * QueryEditClassName () ;
  103. #define CW_CLASS_STATIC CONTROL_WINDOW::QueryStaticClassName()
  104. #define CW_CLASS_LISTBOX CONTROL_WINDOW::QueryListboxClassName()
  105. #define CW_CLASS_COMBOBOX CONTROL_WINDOW::QueryComboboxClassName()
  106. #define CW_CLASS_EDIT CONTROL_WINDOW::QueryEditClassName()
  107. public:
  108. CONTROL_WINDOW( OWNER_WINDOW * powin, CID cid );
  109. CONTROL_WINDOW( OWNER_WINDOW * powin, CID cid,
  110. XYPOINT xy, XYDIMENSION dxy,
  111. ULONG flStyle, const TCHAR * pszClassName );
  112. CID QueryCid() const;
  113. VOID ClaimFocus();
  114. HFONT QueryFont() const;
  115. VOID SetFont( HFONT hfont, BOOL fRedraw = FALSE );
  116. VOID SetFont( const FONT & font, BOOL fRedraw = FALSE )
  117. { SetFont(font.QueryHandle(), fRedraw); }
  118. virtual VOID SetControlValueFocus();
  119. /* Tells all parent groups that this CONTROL_WINDOW received the message
  120. * contained in lParam.
  121. * (Should this have another version that doesn't need the event?)
  122. */
  123. APIERR NotifyGroups( const CONTROL_EVENT & e );
  124. // Data-validation functions
  125. virtual APIERR Validate();
  126. virtual VOID IndicateError( APIERR err );
  127. // JonN 8/3/95 This can be used to set the background color of
  128. // controls to other than the default, for example to
  129. // change the default background color for a static text control
  130. // to the same background as for an edit control. The virtual
  131. // redefinition may return non-NULL or it may change *pmsgid.
  132. virtual HBRUSH OnCtlColor( HDC hdc, HWND hwnd, UINT * pmsgid );
  133. };
  134. /*************************************************************************
  135. NAME: ICON_CONTROL
  136. SYNOPSIS: Control for static icon control
  137. INTERFACE: ICON_CONTROL()
  138. powin - pointer to owner window
  139. cid - ID of control
  140. idresIcon - Either a pointer to the name of the icon
  141. resource OR the ordinal of the icon resource.
  142. SetIcon()
  143. SetPredefinedIcon()
  144. PARENT: CONTROL_WINDOW
  145. HISTORY:
  146. JohnL 8-Feb-1991 Created
  147. beng 17-May-1991 Added app-window constructor
  148. beng 04-Oct-1991 Win32 conversion
  149. KeithMo 24-Mar-1992 Now takes IDRESOURCE, added SetPredefinedIcon.
  150. beng 01-Aor-1992 const args fixup
  151. **************************************************************************/
  152. DLL_CLASS ICON_CONTROL : public CONTROL_WINDOW
  153. {
  154. private:
  155. APIERR W_SetIcon( const IDRESOURCE & idresIcon, BOOL fIsPredefined );
  156. public:
  157. ICON_CONTROL( OWNER_WINDOW * powin, CID cid );
  158. ICON_CONTROL( OWNER_WINDOW * powin, CID cid,
  159. const IDRESOURCE & idresIcon );
  160. ICON_CONTROL( OWNER_WINDOW * powin, CID cid,
  161. XYPOINT xy, XYDIMENSION dxy,
  162. ULONG flStyle = WS_CHILD,
  163. const TCHAR * pszClassName = CW_CLASS_STATIC );
  164. ICON_CONTROL( OWNER_WINDOW * powin, CID cid,
  165. XYPOINT xy, XYDIMENSION dxy,
  166. const IDRESOURCE & idresIcon,
  167. ULONG flStyle = WS_CHILD,
  168. const TCHAR * pszClassName = CW_CLASS_STATIC );
  169. APIERR SetIcon( const IDRESOURCE & idresIcon )
  170. { return W_SetIcon( idresIcon, FALSE ); }
  171. APIERR SetPredefinedIcon( const IDRESOURCE & idresIcon )
  172. { return W_SetIcon( idresIcon, TRUE ); }
  173. };
  174. /*************************************************************************
  175. NAME: HIDDEN_CONTROL
  176. SYNOPSIS: This disables control and makes it invisible
  177. INTERFACE: HIDDEN_CONTROL() - constructor
  178. ~HIDDEN_CONTROL() - destructor
  179. PARENT: CONTROL_WINDOW
  180. HISTORY:
  181. o-SimoP 02-Jan-1992 Created
  182. **************************************************************************/
  183. DLL_CLASS HIDDEN_CONTROL: public CONTROL_WINDOW
  184. {
  185. public:
  186. HIDDEN_CONTROL( OWNER_WINDOW * powin, CID cid );
  187. ~HIDDEN_CONTROL()
  188. { ; }
  189. };
  190. /*************************************************************************
  191. NAME: SCROLLBAR
  192. SYNOPSIS: Simple wrapper for creating a scrollbar control
  193. INTERFACE: SCROLLBAR() - ctor
  194. SetPos() - set position within scrolling
  195. SetRange() - set range of values
  196. QueryPos() - query current position
  197. QueryMin() - query current minimum
  198. QueryMax() - query current maximum
  199. PARENT: CONTROL_WINDOW
  200. NOTES:
  201. It would be interesting to make a version of this control
  202. which adopts the embedded scrollbar of another control, e.g.
  203. that of a MLE.
  204. The SetXxx member functions do not redraw the control.
  205. HISTORY:
  206. beng 18-May-1992 Created
  207. beng 29-Jun-1992 Outlined a ctor form
  208. **************************************************************************/
  209. DLL_CLASS SCROLLBAR: public CONTROL_WINDOW
  210. {
  211. private:
  212. static const TCHAR * _pszClassName;
  213. public:
  214. SCROLLBAR( OWNER_WINDOW * pwnd, CID cid )
  215. : CONTROL_WINDOW( pwnd, cid ) { ; }
  216. SCROLLBAR( OWNER_WINDOW * pwnd, CID cid,
  217. XYPOINT xy, XYDIMENSION dxy, ULONG flStyle );
  218. VOID SetPos( UINT nPosition );
  219. VOID SetRange( UINT nMinimum, UINT nMaximum );
  220. UINT QueryPos() const;
  221. UINT QueryMin() const;
  222. UINT QueryMax() const;
  223. };
  224. #endif // _BLTCTRL_HXX_ - end of file