]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/msw/toolbar.h |
8a0681f9 | 3 | // Purpose: wxToolBar (Windows 95 toolbar) class |
2bda0e17 KB |
4 | // Author: Julian Smart |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
8d0a7b56 VZ |
12 | #ifndef _WX_MSW_TBAR95_H_ |
13 | #define _WX_MSW_TBAR95_H_ | |
2bda0e17 | 14 | |
d427503c | 15 | #if wxUSE_TOOLBAR |
2bda0e17 | 16 | |
bdc72a22 | 17 | #include "wx/dynarray.h" |
8d0a7b56 | 18 | #include "wx/imaglist.h" |
bdc72a22 | 19 | |
53a2db12 | 20 | class WXDLLIMPEXP_CORE wxToolBar : public wxToolBarBase |
2bda0e17 | 21 | { |
1c383dba | 22 | public: |
8a0681f9 VZ |
23 | // ctors and dtor |
24 | wxToolBar() { Init(); } | |
2bda0e17 | 25 | |
8a0681f9 | 26 | wxToolBar(wxWindow *parent, |
1c383dba VZ |
27 | wxWindowID id, |
28 | const wxPoint& pos = wxDefaultPosition, | |
29 | const wxSize& size = wxDefaultSize, | |
30 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
31 | const wxString& name = wxToolBarNameStr) | |
32 | { | |
33 | Init(); | |
2bda0e17 | 34 | |
1c383dba VZ |
35 | Create(parent, id, pos, size, style, name); |
36 | } | |
2bda0e17 | 37 | |
1c383dba VZ |
38 | bool Create(wxWindow *parent, |
39 | wxWindowID id, | |
40 | const wxPoint& pos = wxDefaultPosition, | |
41 | const wxSize& size = wxDefaultSize, | |
42 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
43 | const wxString& name = wxToolBarNameStr); | |
2bda0e17 | 44 | |
8a0681f9 | 45 | virtual ~wxToolBar(); |
2bda0e17 | 46 | |
8a0681f9 VZ |
47 | // override/implement base class virtuals |
48 | virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const; | |
2bda0e17 | 49 | |
8a0681f9 | 50 | virtual bool Realize(); |
4fabb575 | 51 | |
1c383dba VZ |
52 | virtual void SetToolBitmapSize(const wxSize& size); |
53 | virtual wxSize GetToolSize() const; | |
14b72bf5 | 54 | |
1c383dba | 55 | virtual void SetRows(int nRows); |
81d66cf3 | 56 | |
bbd321ff RD |
57 | virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap); |
58 | virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap); | |
cdb11cb9 | 59 | |
8a0681f9 VZ |
60 | // implementation only from now on |
61 | // ------------------------------- | |
62 | ||
c631abda VZ |
63 | virtual void SetWindowStyleFlag(long style); |
64 | ||
1c383dba VZ |
65 | virtual bool MSWCommand(WXUINT param, WXWORD id); |
66 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); | |
2bda0e17 | 67 | |
1c383dba VZ |
68 | void OnMouseEvent(wxMouseEvent& event); |
69 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
ae580de3 | 70 | void OnEraseBackground(wxEraseEvent& event); |
2bda0e17 | 71 | |
8a328874 RR |
72 | void SetFocus() {} |
73 | ||
566fb299 VZ |
74 | static WXHBITMAP MapBitmap(WXHBITMAP bitmap, int width, int height); |
75 | ||
6f02a879 VZ |
76 | // override WndProc mainly to process WM_SIZE |
77 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
78 | ||
79 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; | |
80 | ||
4c0d2cd3 JS |
81 | // returns true if the platform should explicitly apply a theme border |
82 | virtual bool CanApplyThemeBorder() const { return false; } | |
83 | ||
bec9bf3e VZ |
84 | #ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK |
85 | virtual bool MSWEraseBgHook(WXHDC hDC); | |
86 | virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child); | |
87 | #endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK | |
88 | ||
f2b6dd8c RD |
89 | virtual wxToolBarToolBase *CreateTool(int id, |
90 | const wxString& label, | |
91 | const wxBitmap& bmpNormal, | |
92 | const wxBitmap& bmpDisabled = wxNullBitmap, | |
93 | wxItemKind kind = wxITEM_NORMAL, | |
94 | wxObject *clientData = NULL, | |
95 | const wxString& shortHelp = wxEmptyString, | |
96 | const wxString& longHelp = wxEmptyString); | |
97 | ||
98 | virtual wxToolBarToolBase *CreateTool(wxControl *control, | |
99 | const wxString& label); | |
2bda0e17 | 100 | protected: |
1c383dba VZ |
101 | // common part of all ctors |
102 | void Init(); | |
103 | ||
278c927d VZ |
104 | // create the native toolbar control |
105 | bool MSWCreateToolbar(const wxPoint& pos, const wxSize& size); | |
24998710 VZ |
106 | |
107 | // recreate the control completely | |
108 | void Recreate(); | |
109 | ||
8a0681f9 VZ |
110 | // implement base class pure virtuals |
111 | virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); | |
112 | virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); | |
bdc72a22 | 113 | |
8a0681f9 VZ |
114 | virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable); |
115 | virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); | |
116 | virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); | |
bdc72a22 | 117 | |
24998710 VZ |
118 | // return the appropriate size and flags for the toolbar control |
119 | virtual wxSize DoGetBestSize() const; | |
24998710 | 120 | |
7509fa8c VZ |
121 | // handlers for various events |
122 | bool HandleSize(WXWPARAM wParam, WXLPARAM lParam); | |
bec9bf3e | 123 | #ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK |
7509fa8c | 124 | bool HandlePaint(WXWPARAM wParam, WXLPARAM lParam); |
bec9bf3e | 125 | #endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK |
7509fa8c VZ |
126 | void HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam); |
127 | ||
24998710 VZ |
128 | // should be called whenever the toolbar size changes |
129 | void UpdateSize(); | |
130 | ||
8d0a7b56 VZ |
131 | // create m_disabledImgList (but doesn't fill it), set it to NULL if it is |
132 | // unneeded | |
133 | void CreateDisabledImageList(); | |
134 | ||
2588b9c4 VZ |
135 | // get the Windows toolbar style of this control |
136 | long GetMSWToolbarStyle() const; | |
137 | ||
8d0a7b56 | 138 | |
8a0681f9 VZ |
139 | // the big bitmap containing all bitmaps of the toolbar buttons |
140 | WXHBITMAP m_hBitmap; | |
141 | ||
8d0a7b56 VZ |
142 | // the image list with disabled images, may be NULL if we use |
143 | // system-provided versions of them | |
144 | wxImageList *m_disabledImgList; | |
145 | ||
8a0681f9 VZ |
146 | // the total number of toolbar elements |
147 | size_t m_nButtons; | |
7c0ea335 | 148 | |
cc260109 VZ |
149 | // the sum of the sizes of the fixed items (i.e. excluding stretchable |
150 | // spaces) in the toolbar direction | |
151 | int m_totalFixedSize; | |
152 | ||
a8945eef MB |
153 | // the tool the cursor is in |
154 | wxToolBarToolBase *m_pInTool; | |
155 | ||
7c0ea335 | 156 | private: |
26dd7154 VS |
157 | // makes sure tool bitmap size is sufficient for all tools |
158 | void AdjustToolBitmapSize(); | |
159 | ||
cc260109 VZ |
160 | // update the sizes of stretchable spacers to consume all extra space we |
161 | // have | |
162 | void UpdateStretchableSpacersSize(); | |
163 | ||
bec9bf3e VZ |
164 | #ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK |
165 | // do erase the toolbar background, always do it for the entire control as | |
166 | // the caller sets the clipping region correctly to exclude parts which | |
167 | // should not be erased | |
168 | void MSWDoEraseBackground(WXHDC hDC); | |
169 | ||
170 | // return the brush to use for erasing the toolbar background | |
171 | WXHBRUSH MSWGetToolbarBgBrush(); | |
172 | #endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK | |
173 | ||
8a0681f9 | 174 | DECLARE_EVENT_TABLE() |
7c0ea335 | 175 | DECLARE_DYNAMIC_CLASS(wxToolBar) |
c0c133e1 | 176 | wxDECLARE_NO_COPY_CLASS(wxToolBar); |
2bda0e17 KB |
177 | }; |
178 | ||
d427503c VZ |
179 | #endif // wxUSE_TOOLBAR |
180 | ||
8d0a7b56 VZ |
181 | #endif // _WX_MSW_TBAR95_H_ |
182 |