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.

350 lines
9.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1992 **/
  4. /**********************************************************************/
  5. /*
  6. bltmenu.hxx
  7. This file contains the class declarations for the MENU_BASE,
  8. POPUP_MENU, and SYSTEM_MENU classes.
  9. These classes are used to manipulate menus. The classes are
  10. structured as follows:
  11. MENU_BASE
  12. / \
  13. / \
  14. POPUP_MENU SYSTEM_MENU
  15. A POPUP_MENU represents any popup menu. These menus may or may
  16. not actually be attached to a window.
  17. A SYSTEM_MENU represents the system menu of a particular window.
  18. FILE HISTORY:
  19. KeithMo 12-Oct-1992 Created.
  20. */
  21. #ifndef _BLT_HXX_
  22. #error "Don't include this file directly; instead, include it through blt.hxx"
  23. #endif // _BLT_HXX_
  24. #ifndef _BLTMENU_HXX_
  25. #define _BLTMENU_HXX_
  26. #include "base.hxx"
  27. #include "bltidres.hxx" // for IDRESOURCE
  28. #include "bltpwnd.hxx" // for PWND2HWND
  29. /*************************************************************************
  30. NAME: MENU_BASE
  31. SYNOPSIS: This is abstract class is used as a base for POPUP_MENU
  32. and SYSTEM_MENU.
  33. INTERFACE: MENU_BASE - Class constructor (protected).
  34. ~MENU_BASE - Class destructor.
  35. QueryHandle - Get the HMENU for this menu.
  36. QueryItemCount - Returns the number of items in
  37. this menu.
  38. QueryItemState - Returns the state flags for
  39. a particular item.
  40. QueryItemText - Returns the display name of a
  41. particular item.
  42. QuerySubMenu - Returns the HMENU of a submenu.
  43. Append - Append a new item to the menu.
  44. AppendSeparator - Append a separator to the menu.
  45. Delete - Delete an existing menu item.
  46. Insert - Insert a new item into the menu.
  47. InsertSeparator - Insert a separator into the menu.
  48. Modify - Modify the settings of an
  49. existing menu item.
  50. Remove - Removes an existing menu item.
  51. CheckItem - Checks/unchecks an existing item.
  52. EnableItem - Enables/disables an existing item.
  53. IsPopup - Is a given item a popup?
  54. IsSeparator - Is a given item a separator?
  55. PARENT: BASE
  56. HISTORY:
  57. KeithMo 12-Oct-1992 Created.
  58. **************************************************************************/
  59. DLL_CLASS MENU_BASE : public BASE
  60. {
  61. private:
  62. //
  63. // The menu handle.
  64. //
  65. HMENU _hMenu;
  66. protected:
  67. //
  68. // Since this is an abstract class, the
  69. // constructor is protected.
  70. //
  71. MENU_BASE( HMENU hMenu = NULL );
  72. //
  73. // Set the menu handle for this object.
  74. //
  75. VOID SetHandle( HMENU hMenu )
  76. { _hMenu = hMenu; }
  77. //
  78. // These workers perform the "guts" of the
  79. // mutable manipulators.
  80. //
  81. APIERR W_Append( const VOID * pItemData,
  82. UINT_PTR ItemIdOrHmenu,
  83. UINT nFlags ) const;
  84. APIERR W_Insert( const VOID * pItemData,
  85. UINT nPosition,
  86. UINT_PTR ItemIdOrHmenu,
  87. UINT nFlags ) const;
  88. APIERR W_Modify( const VOID * pItemData,
  89. UINT idItem,
  90. UINT_PTR ItemIdOrHmenu,
  91. UINT nFlags ) const;
  92. //
  93. // Worker for QueryItemText variants.
  94. //
  95. INT W_QueryItemText( TCHAR * pszBuffer,
  96. UINT cchBuffer,
  97. UINT nItem,
  98. UINT nFlags ) const;
  99. public:
  100. //
  101. // Class destructor.
  102. //
  103. ~MENU_BASE( VOID );
  104. //
  105. // Accessors.
  106. //
  107. HMENU QueryHandle( VOID ) const
  108. { return _hMenu; }
  109. operator HMENU() const
  110. { return _hMenu; }
  111. INT QueryItemCount( VOID ) const;
  112. UINT QueryItemID( INT nPosition ) const;
  113. UINT QueryItemState( UINT nItem,
  114. UINT nFlags = MF_BYCOMMAND ) const;
  115. APIERR QueryItemText( TCHAR * pszBuffer,
  116. UINT cchBuffer,
  117. UINT nItem,
  118. UINT nFlags = MF_BYCOMMAND ) const;
  119. APIERR QueryItemText( NLS_STR * pnls,
  120. UINT nItem,
  121. UINT nFlags = MF_BYCOMMAND ) const;
  122. HMENU QuerySubMenu( INT nPosition ) const;
  123. //
  124. // Manipulators.
  125. //
  126. APIERR Append( const TCHAR * pszName,
  127. UINT idNewItem,
  128. UINT nFlags = MF_BYCOMMAND ) const;
  129. APIERR Append( const TCHAR * pszName,
  130. HMENU hMenu,
  131. UINT nFlags = MF_BYCOMMAND | MF_POPUP ) const;
  132. APIERR AppendSeparator( VOID ) const;
  133. APIERR Delete( UINT idItem,
  134. UINT nFlags = MF_BYCOMMAND ) const;
  135. APIERR Insert( const TCHAR * pszName,
  136. UINT nPosition,
  137. UINT idNewItem,
  138. UINT nFlags = MF_BYCOMMAND ) const;
  139. APIERR Insert( const TCHAR * pszName,
  140. UINT nPosition,
  141. HMENU hMenu,
  142. UINT nFlags = MF_BYCOMMAND | MF_POPUP ) const;
  143. APIERR InsertSeparator( UINT nPosition,
  144. UINT nFlags = MF_BYCOMMAND ) const;
  145. APIERR Modify( const TCHAR * pszName,
  146. UINT idItem,
  147. UINT idNewItem,
  148. UINT nFlags = MF_BYCOMMAND ) const;
  149. APIERR Modify( const TCHAR * pszName,
  150. UINT idItem,
  151. HMENU hMenu,
  152. UINT nFlags = MF_BYCOMMAND | MF_POPUP ) const;
  153. APIERR Remove( UINT idItem,
  154. UINT nFlags = MF_BYCOMMAND ) const;
  155. UINT CheckItem( UINT idItem,
  156. BOOL fCheck = TRUE,
  157. UINT nFlags = MF_BYCOMMAND ) const;
  158. UINT EnableItem( UINT idItem,
  159. BOOL fEnable = TRUE,
  160. UINT nFlags = MF_BYCOMMAND ) const;
  161. //
  162. // Test functions.
  163. //
  164. BOOL IsPopup( INT nPosition ) const;
  165. BOOL IsSeparator( INT nPosition ) const;
  166. }; // class MENU_BASE
  167. /*************************************************************************
  168. NAME: POPUP_MENU
  169. SYNOPSIS: This class represents a popup menu that may or may not
  170. be attached to an actual window.
  171. INTERFACE: POPUP_MENU - Class constructor.
  172. ~POPUP_MENU - Class destructor.
  173. Destory - Destroys the menu.
  174. Attach - Attach the menu to a given
  175. window.
  176. Track - Tracks a "floating" popup menu.
  177. PARENT: MENU_BASE
  178. HISTORY:
  179. KeithMo 12-Oct-1992 Created.
  180. **************************************************************************/
  181. DLL_CLASS POPUP_MENU : public MENU_BASE
  182. {
  183. private:
  184. //
  185. // Constructor helper.
  186. //
  187. APIERR CtAux( HMENU hMenu );
  188. protected:
  189. public:
  190. //
  191. // Class constructors & destructor.
  192. //
  193. POPUP_MENU( VOID );
  194. POPUP_MENU( IDRESOURCE & id );
  195. POPUP_MENU( HMENU hMenu );
  196. POPUP_MENU( const PWND2HWND & wnd );
  197. ~POPUP_MENU( VOID );
  198. //
  199. // Manipulators.
  200. //
  201. APIERR Destroy( VOID );
  202. APIERR Attach( const PWND2HWND & wnd );
  203. APIERR Track( const PWND2HWND & wnd,
  204. UINT nFlags,
  205. INT x,
  206. INT y,
  207. const RECT * pRect = NULL ) const;
  208. }; // class POPUP_MENU
  209. /*************************************************************************
  210. NAME: SYSTEM_MENU
  211. SYNOPSIS: This class represents the system menu of a particular
  212. window.
  213. INTERFACE: SYSTEM_MENU - Class constructor.
  214. ~SYSTEM_MENU - Class destructor.
  215. PARENT: MENU_BASE
  216. HISTORY:
  217. KeithMo 12-Oct-1992 Created.
  218. **************************************************************************/
  219. DLL_CLASS SYSTEM_MENU : public MENU_BASE
  220. {
  221. private:
  222. protected:
  223. public:
  224. //
  225. // Class constructor & destructor.
  226. //
  227. SYSTEM_MENU( const PWND2HWND & wnd );
  228. ~SYSTEM_MENU( VOID );
  229. }; // class SYSTEM_MENU
  230. #endif // _BLTMENU_HXX_