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.

209 lines
5.5 KiB

  1. //
  2. // cuimenu.h
  3. //
  4. #ifndef CUIMENU_H
  5. #define CUIMENU_H
  6. #include "cuiwnd.h"
  7. #define CUI_MENU_UNSELECTED (UINT)(-1)
  8. class CUIFMenu;
  9. #define UIMENUITEM_NONSELECTEDITEM 0x0001
  10. #define UIMENUITEM_MULTICOLUMNITEM 0x0002
  11. //-----------------------------------------------------------------------------
  12. //
  13. // CUIFMenuItem
  14. //
  15. //-----------------------------------------------------------------------------
  16. class CUIFMenuItem : public CUIFObject
  17. {
  18. public:
  19. CUIFMenuItem(CUIFMenu *pMenu, DWORD dwFlags = 0);
  20. virtual ~CUIFMenuItem(void);
  21. BOOL Init(UINT uId, WCHAR *psz);
  22. void SetBitmap(HBITMAP hbmp);
  23. void SetBitmapMask( HBITMAP hBmp );
  24. void Check(BOOL bChecked);
  25. void RadioCheck(BOOL bChecked);
  26. void Gray(BOOL bGrayed);
  27. BOOL IsGrayed() {return _bGrayed;}
  28. virtual void InitMenuExtent();
  29. void SetSub(CUIFMenu *pMenu);
  30. CUIFMenu *GetSub() {return _pSubMenu;}
  31. CUIFMenu *GetMenu() {return _pMenu;}
  32. void ShowSubPopup();
  33. virtual void OnLButtonUp(POINT pt);
  34. virtual void OnMouseIn(POINT pt);
  35. virtual void OnMouseOut(POINT pt);
  36. virtual void OnPaint(HDC hdc);
  37. virtual void OnPaintDef(HDC hdc);
  38. virtual void OnPaintO10(HDC hdc);
  39. virtual void OnTimer();
  40. virtual BOOL IsSeparator() {return FALSE;}
  41. BOOL IsNonSelectedItem() {return _bNonSelectedItem;}
  42. UINT GetId() {return _uId;}
  43. UINT GetVKey() {return _uShortcutkey;}
  44. BOOL IsCheck() {return (_bChecked || _bRadioChecked) ? TRUE : FALSE;}
  45. BOOL IsBmp() {return (_hbmp) ? TRUE : FALSE;}
  46. BOOL IsStr() {return (_psz) ? TRUE : FALSE;}
  47. BOOL GetMenuExtent(SIZE *psize)
  48. {
  49. *psize = _size;
  50. return TRUE;
  51. }
  52. int GetTabTextLength() {return _sizeTab.cx;}
  53. protected:
  54. void DrawUnderline(HDC hDC, int x, int y, HBRUSH hbr);
  55. void DrawCheck(HDC hDC, int x, int y);
  56. void DrawArrow(HDC hDC, int x, int y);
  57. void DrawBitmapProc( HDC hDC, int x, int y);
  58. UINT _uId;
  59. WCHAR *_psz;
  60. UINT _cch;
  61. WCHAR *_pszTab;
  62. UINT _cchTab;
  63. UINT _uShortcutkey;
  64. UINT _uUnderLine;
  65. HBITMAP _hbmp;
  66. HBITMAP _hbmpMask;
  67. BOOL _bChecked;
  68. BOOL _bRadioChecked;
  69. BOOL _bGrayed;
  70. BOOL _bNonSelectedItem;
  71. CUIFMenu *_pMenu;
  72. CUIFMenu *_pSubMenu;
  73. SIZE _size;
  74. SIZE _sizeTab;
  75. };
  76. //-----------------------------------------------------------------------------
  77. //
  78. // CUIFMenuItemSeparator
  79. //
  80. //-----------------------------------------------------------------------------
  81. class CUIFMenuItemSeparator : public CUIFMenuItem
  82. {
  83. public:
  84. CUIFMenuItemSeparator(CUIFMenu *pMenu) : CUIFMenuItem(pMenu, UIMENUITEM_NONSELECTEDITEM)
  85. {
  86. _uId = (UINT)-1;
  87. }
  88. virtual ~CUIFMenuItemSeparator(void) {}
  89. virtual void InitMenuExtent();
  90. virtual void OnPaint(HDC hDC);
  91. virtual void OnPaintDef(HDC hdc);
  92. virtual void OnPaintO10(HDC hdc);
  93. virtual BOOL IsSeparator() {return TRUE;}
  94. };
  95. //-----------------------------------------------------------------------------
  96. //
  97. // CUIFMenu
  98. //
  99. //-----------------------------------------------------------------------------
  100. #define UIMENU_MULTICOLUMN 0x00000001
  101. class CUIFMenu : public CUIFWindow
  102. {
  103. public:
  104. CUIFMenu(HINSTANCE hInst, DWORD dwWndStyle, DWORD dwMenuStyle);
  105. virtual ~CUIFMenu(void);
  106. BOOL InsertItem(CUIFMenuItem *pItem);
  107. BOOL InsertSeparator();
  108. UINT ShowModalPopup(CUIFWindow *pcuiWndParent, const RECT *prc, BOOL fVertical);
  109. void ModalMouseNotify( UINT uMsg, POINT pt);
  110. void ShowSubPopup(CUIFMenu *pcuiParentMenu, const RECT *prc, BOOL fVertical);
  111. void HandleMouseMsg( UINT uMsg, POINT pt );
  112. HFONT GetMarlettFont() {return _hfontMarlett;}
  113. void CancelMenu();
  114. void PostKey(BOOL fUp, WPARAM wParam, LPARAM lParam);
  115. void SetSelectedId(UINT uId);
  116. void OnKeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam);
  117. void OnKeyUp(HWND hwnd, WPARAM wParam, LPARAM lParam);
  118. void CancelSubMenu()
  119. {
  120. if (_pCurrentSubMenu)
  121. _pCurrentSubMenu->CancelMenu();
  122. }
  123. CUIFMenu *GetCurrentSubMenu()
  124. {
  125. return _pCurrentSubMenu;
  126. }
  127. void SetSelectedItem(CUIFMenuItem *pItem)
  128. {
  129. if (_pSelectedItem == pItem)
  130. return;
  131. CUIFMenuItem *pOldItem = _pSelectedItem;
  132. _pSelectedItem = pItem;
  133. if (pOldItem)
  134. pOldItem->CallOnPaint();
  135. if (_pSelectedItem)
  136. _pSelectedItem->CallOnPaint();
  137. }
  138. BOOL IsSelectedItem(CUIFMenuItem *pItem)
  139. {
  140. return (_pSelectedItem == pItem) ? TRUE : FALSE;
  141. }
  142. BOOL IsBmpCheckItem() {return _fIsBmpCheckItem;}
  143. BOOL IsO10Menu() {return FHasStyle( UIWINDOW_OFC10MENU ) ? TRUE : FALSE;}
  144. int GetMenuCheckWidth() {return _cxMenuCheck;}
  145. int GetMaxTabTextLength() {return _cxMaxTab;}
  146. protected:
  147. virtual void ModalMessageLoop( void );
  148. virtual BOOL InitShow(CUIFWindow *pcuiWndParent, const RECT *prc, BOOL fVertical, BOOL fAnimate);
  149. virtual BOOL UninitShow();
  150. CUIFMenu *GetTopSubMenu();
  151. CUIFMenuItem *GetNextItem(CUIFMenuItem *pItem);
  152. CUIFMenuItem *GetPrevItem(CUIFMenuItem *pItem);
  153. void SetMenuFont();
  154. void ClearMenuFont();
  155. CUIFMenu *_pcuiParentMenu;
  156. CUIFMenu *_pCurrentSubMenu;
  157. CUIFMenuItem *_pSelectedItem;
  158. UINT _uIdSelect;
  159. CUIFObjectArray<CUIFMenuItem> _rgItems;
  160. HFONT _hfontMarlett;
  161. BOOL _fInModal;
  162. BOOL _fIsBmpCheckItem;
  163. DWORD _dwMenuStyle;
  164. int _cxMenuCheck;
  165. int _cxMaxTab;
  166. };
  167. #endif // CUIMENU_H