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