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