mnbase.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 7k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #ifndef MNBASE
  2. #define MNBASE
  3. // Characters for _DrawMenuGlyph
  4. #define CH_MENUARROWA    '8'
  5. #define CH_MENUARROW     TEXT(CH_MENUARROWA)
  6. #define CH_MENUCHECKA    'a'
  7. #define CH_MENUCHEVRONA  187
  8. class CMenuBand;    // Forward Declare
  9. class CMenuBandMetrics;
  10. #define LIST_GAP 8      // from Observation
  11. class CMenuToolbarBase: public IWinEventHandler, public IObjectWithSite
  12. {
  13. public:
  14.     // *** IUnknown ***
  15.     virtual STDMETHODIMP_(ULONG) AddRef(void);
  16.     virtual STDMETHODIMP_(ULONG) Release(void);
  17.     virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppvObj);
  18.     // *** IObjectWithSite methods ***
  19.     virtual STDMETHODIMP SetSite(IUnknown* punkSite);
  20.     virtual STDMETHODIMP GetSite(REFIID riid, void ** ppvSite);
  21.     // *** IWinEventHandler methods ***
  22.     virtual STDMETHODIMP IsWindowOwner(HWND hwnd) PURE;
  23.     virtual STDMETHODIMP OnWinEvent(HWND hwnd, UINT dwMsg, WPARAM wParam, LPARAM lParam, LRESULT *plres);
  24.     // Other public methods
  25.     CMenuToolbarBase(CMenuBand* pmb, DWORD dwFlags);
  26.     // Returns the HWND and Converts the pt to child.
  27.     virtual void v_ForwardMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  28.     virtual void v_SendMenuNotification(UINT idCmd, BOOL fClear) PURE;
  29.     virtual BOOL v_TrackingSubContextMenu() PURE;
  30.     virtual void v_Show(BOOL fShow, BOOL fForceUpdate);
  31.     virtual BOOL v_UpdateIconSize(UINT uIconSize, BOOL fUpdateButtons) PURE;
  32.     virtual void v_UpdateButtons(BOOL fNegotiateSize) PURE;
  33.     virtual HRESULT v_GetSubMenu(int iCmd, const GUID* pguidService, REFIID riid, void** pObj) PURE;
  34.     virtual HRESULT v_CallCBItem(int idtCmd, UINT uMsg, WPARAM wParam, LPARAM lParam) PURE;
  35.     virtual HRESULT v_GetState(int idtCmd, LPSMDATA psmd) PURE;
  36.     virtual HRESULT v_ExecItem(int iCmd) PURE;
  37.     virtual DWORD v_GetFlags(int iCmd) PURE;
  38.     virtual void v_Refresh() PURE;
  39.     virtual void v_Close();
  40.     virtual void v_OnEmptyToolbar();
  41.     virtual void v_OnDeleteButton(LPVOID pData) {};
  42.     virtual HRESULT v_InvalidateItem(LPSMDATA psmd, DWORD dwFlags) 
  43.         { return E_NOTIMPL; };
  44.     virtual void NegotiateSize();
  45.     virtual void SetWindowPos(LPSIZE psize, LPRECT prc, DWORD dwFlags);
  46.     virtual void GetSize(SIZE*);
  47.     virtual void CreateToolbar(HWND hwndParent);
  48.     virtual void SetParent(HWND hwndParent);
  49.     virtual HRESULT GetShellFolder(LPITEMIDLIST* ppidl, REFIID riid, void** ppvObj) {return E_FAIL;};
  50.     virtual HRESULT GetMenu(HMENU* phmenu, HWND* phwnd, DWORD* pdwFlags) { return E_FAIL; };
  51.     virtual HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags) { return E_FAIL;};
  52.     virtual void Expand(BOOL fExpand) {};
  53.     HRESULT GetSubMenu(int idCmd, GUID* pguidService, REFIID riid, void** ppvObj);
  54.     HRESULT PositionSubmenu(int idCmd);
  55.     void Activate(BOOL fActivate);
  56.     void SetMenuBandMetrics(CMenuBandMetrics* pmbm);
  57.     void PostPopup(int idCmd, BOOL bSetItem, BOOL bInitialSelect);
  58.     void PopupClose(void);
  59.     HRESULT PopupOpen(int nCmd);
  60.     void PopupHelper(int idCmd, BOOL bInitialSelect);
  61.     void KillPopupTimer();
  62.     void SetToTop(BOOL bToTop);
  63.     void EmptyToolbar();        // override
  64.     DWORD GetFlags(void)          { return _dwFlags; };
  65.     BOOL DontShowEmpty()           { return _fDontShowEmpty; };
  66.     void DontShowEmpty(BOOL fDontShowEmpty) { _fDontShowEmpty = BOOLIFY(fDontShowEmpty); };
  67.     BOOL GetChevronID()               { return _idCmdChevron;  };
  68.     int GetValidHotItem(int iDir, int iIndex, int iCount, DWORD dwFlags);
  69.     BOOL SetHotItem(int iDir, int iIndex, int iCount, DWORD dwFlags);
  70.     void SetKeyboardCue();
  71.     virtual ~CMenuToolbarBase() {};
  72.     BOOL IsEmpty()      { return _fEmpty; };
  73.     HWND        _hwndMB;
  74.    
  75. protected:
  76.     static void s_FadeCallback(DWORD dwStep, LPVOID pvParam);
  77.     virtual void v_CalcWidth(int* pcxMin, int* pcxMax);
  78.     virtual int  v_GetDragOverButton() PURE;
  79.     virtual HRESULT v_GetInfoTip(int iCmd, LPTSTR psz, UINT cch) PURE;
  80.     virtual HRESULT v_CreateTrackPopup(int idCmd, REFIID riid, void** ppvObj) PURE;
  81.     
  82.     // Window Proc Overrides
  83.     LRESULT _DropDownOrExec(UINT idCmd, BOOL bKeyboard);
  84.     LRESULT _OnCustomDraw(NMCUSTOMDRAW * pnmcd);
  85.     void    _PaintButton(HDC hdc, int idCmd, LPRECT prc, DWORD dwMBIF);
  86.     LRESULT _OnWrapHotItem(NMTBWRAPHOTITEM* pnmwh);
  87.     LRESULT _OnWrapAccelerator(NMTBWRAPACCELERATOR* pnmwa);
  88.     LRESULT _OnDupAccelerator(NMTBDUPACCELERATOR* pnmda);
  89.     virtual LRESULT _OnHotItemChange(NMTBHOTITEM * pnmhot);
  90.     virtual LRESULT _OnNotify(LPNMHDR pnm);
  91.     virtual LRESULT _OnDropDown(LPNMTOOLBAR pnmtb);
  92.     virtual LRESULT _OnTimer( WPARAM wParam );
  93.     virtual void _FlashChevron();
  94.     virtual LRESULT _DefWindowProcMB(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  95.     BOOL    _OnKey(BOOL bDown, UINT vk, UINT uFlags);
  96.     void    _OnSelectArrow(int iDir);
  97.     void    _FireEvent(BYTE bEvent);
  98.     // Utility Functions
  99.     void    _DoPopup(int idCmd, BOOL bInitialSelect);
  100.     virtual void    _SetFontMetrics();
  101.     virtual void    _SetToolbarState();
  102.     void    _PressBtn(int idBtn, BOOL bDown);
  103.     HRESULT _SetMenuBand(IShellMenu* psm);
  104.     BOOL    _SetTimer(int nTimer);
  105.     void    _DrawMenuArrowGlyph( HDC hdc, RECT * prc, COLORREF rgbText );
  106.     void    _DrawMenuGlyph( HDC hdc, HFONT hFont, RECT * prc, 
  107.                                CHAR ch, COLORREF rgbText,
  108.                                LPSIZE psize);
  109.     int     _CalcChevronSize();
  110.     void    _DrawChevron(HDC hdc, LPRECT prect, BOOL fFocus, BOOL fSelected);
  111.     BOOL    _HandleObscuredItem(int idCmd);
  112.     CMenuBand*  _pcmb;
  113.     DEBUG_CODE (int _cRef);     // To debug references to the sub objects.
  114.     DWORD       _dwFlags;           // SMSET_* flags
  115.     UINT        _uIconSizeMB;
  116.     UINT        _nItemTimer;
  117.     int         _idCmdChevron;     // -1 if no chevron exists
  118.     int         _cPromotedItems;    // Number of promoted items.
  119.     BYTE        _cFlashCount;
  120.     int         _idCmdLastClicked;
  121.     int         _iLastClickedTime;
  122.     int         _idCmdDragging;        
  123.     BITBOOL     _fHasDemotedItems: 1;
  124.     BITBOOL     _fVerticalMB: 1;
  125.     BITBOOL     _fTopLevel: 1;
  126.     BITBOOL     _fEmpty : 1;
  127.     BITBOOL     _fHasSubMenu: 1;
  128.     BITBOOL     _fEditMode : 1;
  129.     BITBOOL     _fClickHandled: 1;
  130.     BITBOOL     _fProcessingWrapHotItem: 1;
  131.     BITBOOL     _fEmptyingToolbar : 1;
  132.     BITBOOL     _fMulticolumnMB : 1;
  133.     BITBOOL     _fExpandTimer: 1;   // There is an expand timer.
  134.     BITBOOL     _fIgnoreHotItemChange: 1;
  135.     BITBOOL     _fShowMB: 1;
  136.     BITBOOL     _fFirstTime: 1;
  137.     BITBOOL     _fHasDrop: 1;
  138.     BITBOOL     _fRefreshInfo: 1;
  139.     BITBOOL     _fDontShowEmpty: 1;
  140.     BITBOOL     _fSuppressUserMonitor: 1;
  141.     BITBOOL     _fHorizInVerticalMB: 1;     // TRUE: Don't set EX_Vertical on the Toolbar
  142. };
  143. int     GetButtonCmd(HWND hwndTB, int iPos);
  144. void*   ItemDataFromPos(HWND hwndTB, int iPos);
  145. BOOL    SetHotItem(HWND hwnd, int iDir, int iIndex, int iCount, DWORD dwFlags);
  146. long    GetIndexFromChild(BOOL fTop, int iIndex);
  147. // UEM Parameters
  148. #define UEM_TIMEOUT         0
  149. #define UEM_HOT_ITEM        1
  150. #define UEM_HOT_FOLDER      2
  151. #define UEM_RESET           -1
  152. #endif  // MNBASE