]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/toolbar.h
Allow creating DIBs storing pixels in non-premultiplied format in wxMSW.
[wxWidgets.git] / include / wx / os2 / toolbar.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: toolbar.h
3 // Purpose: wxToolBar class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/17/98
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TOOLBAR_H_
13 #define _WX_TOOLBAR_H_
14
15 #if wxUSE_TOOLBAR
16 #include "wx/timer.h"
17 #include "wx/tbarbase.h"
18
19 #define ID_TOOLTIMER 100
20 #define ID_TOOLEXPTIMER 101
21
22 class WXDLLIMPEXP_CORE wxToolBar: public wxToolBarBase
23 {
24 public:
25 /*
26 * Public interface
27 */
28
29 wxToolBar()
30 : m_vToolTimer(this, ID_TOOLTIMER)
31 , m_vToolExpTimer(this, ID_TOOLEXPTIMER)
32 { Init(); }
33
34 inline wxToolBar( wxWindow* pParent
35 ,wxWindowID vId
36 ,const wxPoint& rPos = wxDefaultPosition
37 ,const wxSize& rSize = wxDefaultSize
38 ,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL
39 ,const wxString& rName = wxToolBarNameStr
40 ) : m_vToolTimer(this, ID_TOOLTIMER)
41 , m_vToolExpTimer(this, ID_TOOLEXPTIMER)
42 {
43 Init();
44 Create( pParent
45 ,vId
46 ,rPos
47 ,rSize
48 ,lStyle
49 ,rName
50 );
51 }
52 virtual ~wxToolBar();
53
54 bool Create( wxWindow* pParent
55 ,wxWindowID vId
56 ,const wxPoint& rPos = wxDefaultPosition
57 ,const wxSize& rSize = wxDefaultSize
58 ,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL
59 ,const wxString& rName = wxToolBarNameStr
60 );
61
62
63 //
64 // Override/implement base class virtuals
65 //
66 virtual wxToolBarToolBase* FindToolForPosition( wxCoord vX
67 ,wxCoord vY
68 ) const;
69 virtual bool Realize(void);
70 virtual void SetRows(int nRows);
71
72 //
73 // Special overrides for OS/2
74 //
75 virtual wxToolBarToolBase* InsertControl( size_t nPos
76 ,wxControl* pControl
77 );
78 virtual wxToolBarToolBase* InsertSeparator(size_t nPos);
79 virtual wxToolBarToolBase* InsertTool( size_t nPos
80 ,int nId
81 ,const wxString& rsLabel
82 ,const wxBitmap& rBitmap
83 ,const wxBitmap& rBmpDisabled = wxNullBitmap
84 ,wxItemKind eKind = wxITEM_NORMAL
85 ,const wxString& rsShortHelp = wxEmptyString
86 ,const wxString& rsLongHelp = wxEmptyString
87 ,wxObject* pClientData = NULL
88 );
89 wxToolBarToolBase* InsertTool( size_t nPos
90 ,int nId
91 ,const wxBitmap& rBitmap
92 ,const wxBitmap& rBmpDisabled = wxNullBitmap
93 ,bool bToggle = FALSE
94 ,wxObject* pClientData = NULL
95 ,const wxString& rsShortHelp = wxEmptyString
96 ,const wxString& rsLongHelp = wxEmptyString
97 )
98 {
99 return InsertTool( nPos
100 ,nId
101 ,wxEmptyString
102 ,rBitmap
103 ,rBmpDisabled
104 ,bToggle ? wxITEM_CHECK : wxITEM_NORMAL
105 ,rsShortHelp
106 ,rsLongHelp
107 ,pClientData
108 );
109 }
110 virtual bool DeleteTool(int nId);
111 virtual bool DeleteToolByPos(size_t nPos);
112
113 //
114 // Event handlers
115 //
116 void OnPaint(wxPaintEvent& event);
117 void OnSize(wxSizeEvent& event);
118 void OnMouseEvent(wxMouseEvent& event);
119 void OnKillFocus(wxFocusEvent& event);
120
121 protected:
122 //
123 // Common part of all ctors
124 //
125 void Init();
126
127 //
128 // Implement base class pure virtuals
129 //
130 virtual wxToolBarToolBase* DoAddTool( int id
131 ,const wxString& label
132 ,const wxBitmap& bitmap
133 ,const wxBitmap& bmpDisabled
134 ,wxItemKind kind
135 ,const wxString& shortHelp = wxEmptyString
136 ,const wxString& longHelp = wxEmptyString
137 ,wxObject *clientData = NULL
138 ,wxCoord xPos = -1
139 ,wxCoord yPos = -1
140 );
141
142 virtual bool DoInsertTool( size_t nPos
143 ,wxToolBarToolBase* pTool
144 );
145 virtual bool DoDeleteTool( size_t nPos
146 , wxToolBarToolBase* pTool
147 );
148
149 virtual void DoEnableTool( wxToolBarToolBase* pTool
150 ,bool bEnable
151 );
152 virtual void DoToggleTool( wxToolBarToolBase* pTool
153 ,bool bToggle
154 );
155 virtual void DoSetToggle( wxToolBarToolBase* pTool
156 ,bool bToggle
157 );
158
159 virtual wxToolBarToolBase* CreateTool( int vId
160 ,const wxString& rsLabel
161 ,const wxBitmap& rBmpNormal
162 ,const wxBitmap& rBmpDisabled
163 ,wxItemKind eKind
164 ,wxObject* pClientData
165 ,const wxString& rsShortHelp
166 ,const wxString& rsLongHelp
167 );
168 virtual wxToolBarToolBase* CreateTool(wxControl* pControl,
169 const wxString& label);
170
171 //
172 // Helpers
173 //
174 void DrawTool(wxToolBarToolBase *tool);
175 virtual void DrawTool( wxDC& rDC
176 ,wxToolBarToolBase* pTool
177 );
178 virtual void SpringUpButton(int nIndex);
179
180 int m_nCurrentRowsOrColumns;
181 int m_nPressedTool;
182 int m_nCurrentTool;
183 wxCoord m_vLastX;
184 wxCoord m_vLastY;
185 wxCoord m_vMaxWidth;
186 wxCoord m_vMaxHeight;
187 wxCoord m_vXPos;
188 wxCoord m_vYPos;
189 wxCoord m_vTextX;
190 wxCoord m_vTextY;
191
192 private:
193 void LowerTool( wxToolBarToolBase* pTool
194 ,bool bLower = TRUE
195 );
196 void RaiseTool( wxToolBarToolBase* pTool
197 ,bool bRaise = TRUE
198 );
199 void OnTimer(wxTimerEvent& rEvent);
200
201 static bool m_bInitialized;
202
203 wxTimer m_vToolTimer;
204 wxTimer m_vToolExpTimer;
205 wxToolTip* m_pToolTip;
206 wxCoord m_vXMouse;
207 wxCoord m_vYMouse;
208
209 //
210 // Virtual function hiding supression
211 virtual wxToolBarToolBase *InsertTool (size_t nPos, wxToolBarToolBase* pTool)
212 {
213 return( wxToolBarBase::InsertTool( nPos
214 ,pTool
215 ));
216 }
217
218 DECLARE_EVENT_TABLE()
219 DECLARE_DYNAMIC_CLASS(wxToolBar)
220 };
221
222 #endif // wxUSE_TOOLBAR
223
224 #endif
225 // _WX_TOOLBAR_H_