NGenericToolBar.h
上传用户:libwxy
上传日期:2007-01-02
资源大小:200k
文件大小:5k
源码类别:

工具条

开发平台:

Visual C++

  1. // NGenericToolBar.h: interface for the CNGenericToolBar class.
  2. //
  3. /*
  4. Copyright (C) 1998 Tony Hoyle (tmh@netfusion.co.uk)
  5. Copyright (C) 1998 George H. Stahl (GStahl@VipMail.Com)
  6. - Added GenericToolBarModifyStyle
  7. This program is free software; you can redistribute it and/or modify it under the terms
  8. of the GNU General Public License as published by the Free Software Foundation; either
  9. version 2 of the License, or (at your option) any later version.
  10. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  11. without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. See the GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License along with this program;
  14. if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. //////////////////////////////////////////////////////////////////////
  17. #if !defined(AFX_NGENERICTOOLBAR_H__DE1A2044_A20C_11D1_87DF_00A0C94457BF__INCLUDED_)
  18. #define AFX_NGENERICTOOLBAR_H__DE1A2044_A20C_11D1_87DF_00A0C94457BF__INCLUDED_
  19. #if _MSC_VER >= 1000
  20. #pragma once
  21. #endif // _MSC_VER >= 1000
  22. #pragma message ("Include "__FILE__)
  23. #ifndef NGTB_PROJECT
  24. #define NGTB_EXPORT __declspec(dllimport)
  25. #else
  26. #define NGTB_EXPORT __declspec(dllexport)
  27. #endif
  28. #undef AFX_DATA
  29. #define AFX_DATA NGTB_EXPORT
  30. // Command IDs.  These should really be in resource.h
  31. #define IDM_BUTTONSONLY                 52700
  32. #define IDM_BUTTONSANDTEXT              52701
  33. #define IDM_TEXTONLY                    52702
  34. #define IDM_RECALCSIZE                  52703
  35. #define NGTB_NO_SYSMENU 0x0002L
  36. class CNGenericToolBar : public CToolBar  
  37. {
  38. friend class CNMDIMenuFrameWnd;
  39. friend class CNSDIMenuFrameWnd;
  40. friend class CNGenericPopup;
  41. DECLARE_DYNAMIC(CNGenericToolBar)
  42. public:
  43. NGTB_EXPORT CNGenericToolBar();
  44. NGTB_EXPORT virtual ~CNGenericToolBar();
  45. // Compatibility with CToolBar
  46. NGTB_EXPORT BOOL Create( CWnd* pParentWnd, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP,
  47. UINT nID = AFX_IDW_TOOLBAR ) { return CreateEx(pParentWnd,TBSTYLE_FLAT|TBSTYLE_TRANSPARENT,dwStyle|CBRS_SIZE_DYNAMIC,nID); }
  48. // Our stuff
  49. NGTB_EXPORT BOOL CreateEx(CWnd* pParentWnd, DWORD dwExStyle = TBSTYLE_FLAT | TBSTYLE_TRANSPARENT,
  50. DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_SIZE_DYNAMIC,
  51. UINT nID = AFX_IDW_TOOLBAR, LPCTSTR szTitle = NULL);
  52. NGTB_EXPORT static void SetVisualState(BOOL bButtons, BOOL bText);
  53. NGTB_EXPORT BOOL GetVisualState(BOOL bText);
  54. // CToolBar implementation changes
  55. NGTB_EXPORT BOOL LoadToolBar(LPCTSTR lpszResourceName);
  56. NGTB_EXPORT BOOL LoadToolBar(UINT nIDResource) { return LoadToolBar(MAKEINTRESOURCE(nIDResource)); }
  57. NGTB_EXPORT BOOL SetButtonText(int nIndex, LPCTSTR lpszText);
  58. NGTB_EXPORT BOOL GenericToolBarModifyStyle(DWORD dwRemove, DWORD dwAdd);
  59. NGTB_EXPORT DWORD GetGenericToolBarStyle(){return m_dwGenericToolBarStyle;}
  60. protected:
  61. // Styles
  62. DWORD m_dwGenericToolBarStyle;
  63. struct Accel { UINT nKey; UINT nId; };
  64. CMenu m_pop;
  65. BOOL m_bHasText,m_bHasBitmaps,m_bForceText;
  66. CArray<int,int> m_TextIds;
  67. CArray<Accel,Accel&> m_accelList;
  68. CWnd* m_pParent;
  69. static BOOL m_bButtons;
  70. static BOOL m_bText;
  71. BOOL m_bSysMenuIcon; // Used by menu to draw icon
  72. HICON m_hSysMenuIcon; // Icon to draw for above
  73. CRect m_rectSysMenu; // Where we drew it
  74. static CArray<CNGenericToolBar*,CNGenericToolBar*> m_ToolbarList;
  75. virtual void SettingChange();
  76. BOOL RecalcSize();
  77. static void SendToAllToolbars(UINT uMsg, WPARAM wParam = NULL, LPARAM lParam = NULL);
  78. void _SetButton(int nIndex, TBBUTTON* pButton);
  79. void DrawGripper(CWindowDC *pDC, CRect& rectWindow);
  80. void DrawSysMenuIcon(CWindowDC* pDC, CRect& rectWindow);
  81. void EraseNonClient(BOOL bRaised);
  82. void DrawBorders(CDC* pDC, CRect& rect);
  83. void RepaintBackground();
  84. void DrawSeparators();
  85. void DrawSeparators(CClientDC* pDC);
  86. virtual BOOL TranslateMenuChar(UINT nChar);
  87. virtual BOOL KeyboardFilter(UINT nChar, UINT nRepCnt, UINT nFlags);
  88. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  89. virtual void OnOverSysMenu() { };
  90. protected:
  91. //{{AFX_MSG(CNGenericToolBar)
  92. afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
  93. afx_msg void OnDestroy();
  94. afx_msg UINT OnNcHitTest(CPoint point);
  95. //}}AFX_MSG
  96. DECLARE_MESSAGE_MAP()
  97. afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
  98. afx_msg void OnButtonsOnly();
  99. afx_msg void OnTextOnly();
  100. afx_msg void OnTextAndButtons();
  101. afx_msg void OnRecalcSize();
  102. afx_msg void OnNcPaint();
  103. afx_msg void OnWindowPosChanging(LPWINDOWPOS lpWndPos);
  104. afx_msg void OnPaint();
  105. };
  106. #undef AFX_DATA
  107. #define AFX_DATA
  108. #endif // !defined(AFX_NGENERICTOOLBAR_H__DE1A2044_A20C_11D1_87DF_00A0C94457BF__INCLUDED_)