]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/toolbar.h
Add wxDataViewCtrl::GTKPathToItem() function and use it.
[wxWidgets.git] / include / wx / msw / toolbar.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/msw/tbar95.h
3// Purpose: wxToolBar (Windows 95 toolbar) class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MSW_TBAR95_H_
13#define _WX_MSW_TBAR95_H_
14
15#if wxUSE_TOOLBAR
16
17#include "wx/dynarray.h"
18#include "wx/imaglist.h"
19
20class WXDLLIMPEXP_CORE wxToolBar : public wxToolBarBase
21{
22public:
23 // ctors and dtor
24 wxToolBar() { Init(); }
25
26 wxToolBar(wxWindow *parent,
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();
34
35 Create(parent, id, pos, size, style, name);
36 }
37
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);
44
45 virtual ~wxToolBar();
46
47 // override/implement base class virtuals
48 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
49
50 virtual bool Realize();
51
52 virtual void SetToolBitmapSize(const wxSize& size);
53 virtual wxSize GetToolSize() const;
54
55 virtual void SetRows(int nRows);
56
57 virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
58 virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
59
60 // implementation only from now on
61 // -------------------------------
62
63 virtual void SetWindowStyleFlag(long style);
64
65 virtual bool MSWCommand(WXUINT param, WXWORD id);
66 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
67
68 void OnMouseEvent(wxMouseEvent& event);
69 void OnSysColourChanged(wxSysColourChangedEvent& event);
70
71 void SetFocus() {}
72
73 static WXHBITMAP MapBitmap(WXHBITMAP bitmap, int width, int height);
74
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
80 // returns true if the platform should explicitly apply a theme border
81 virtual bool CanApplyThemeBorder() const { return false; }
82
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
88protected:
89 // common part of all ctors
90 void Init();
91
92 // create the native toolbar control
93 bool MSWCreateToolbar(const wxPoint& pos, const wxSize& size);
94
95 // recreate the control completely
96 void Recreate();
97
98 // implement base class pure virtuals
99 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
100 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
101
102 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
103 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
104 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
105
106 virtual wxToolBarToolBase *CreateTool(int id,
107 const wxString& label,
108 const wxBitmap& bmpNormal,
109 const wxBitmap& bmpDisabled,
110 wxItemKind kind,
111 wxObject *clientData,
112 const wxString& shortHelp,
113 const wxString& longHelp);
114
115 virtual wxToolBarToolBase *CreateTool(wxControl *control,
116 const wxString& label);
117
118 // return the appropriate size and flags for the toolbar control
119 virtual wxSize DoGetBestSize() const;
120
121 // handlers for various events
122 bool HandleSize(WXWPARAM wParam, WXLPARAM lParam);
123#ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK
124 bool HandlePaint(WXWPARAM wParam, WXLPARAM lParam);
125#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK
126 void HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam);
127
128 // should be called whenever the toolbar size changes
129 void UpdateSize();
130
131 // create m_disabledImgList (but doesn't fill it), set it to NULL if it is
132 // unneeded
133 void CreateDisabledImageList();
134
135 // get the Windows toolbar style of this control
136 long GetMSWToolbarStyle() const;
137
138
139 // the big bitmap containing all bitmaps of the toolbar buttons
140 WXHBITMAP m_hBitmap;
141
142 // the image list with disabled images, may be NULL if we use
143 // system-provided versions of them
144 wxImageList *m_disabledImgList;
145
146 // the total number of toolbar elements
147 size_t m_nButtons;
148
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
153 // the tool the cursor is in
154 wxToolBarToolBase *m_pInTool;
155
156private:
157 // makes sure tool bitmap size is sufficient for all tools
158 void AdjustToolBitmapSize();
159
160 // update the sizes of stretchable spacers to consume all extra space we
161 // have
162 void UpdateStretchableSpacersSize();
163
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
174 DECLARE_EVENT_TABLE()
175 DECLARE_DYNAMIC_CLASS(wxToolBar)
176 wxDECLARE_NO_COPY_CLASS(wxToolBar);
177};
178
179#endif // wxUSE_TOOLBAR
180
181#endif // _WX_MSW_TBAR95_H_
182