]>
Commit | Line | Data |
---|---|---|
39d2f9a7 | 1 | ///////////////////////////////////////////////////////////////////////////// |
a71d815b | 2 | // Name: src/msw/wince/tbarwce.cpp |
39d2f9a7 JS |
3 | // Purpose: wxToolBar for Windows CE |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 2003-07-12 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
65571936 | 9 | // Licence: wxWindows licence |
39d2f9a7 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
39d2f9a7 JS |
20 | // For compilers that support precompilation, includes "wx.h". |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
ad9835c9 WS |
27 | // Use the WinCE-specific toolbar only if we're either compiling |
28 | // with a WinCE earlier than 4, or we wish to emulate a PocketPC-style UI | |
29 | #if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) | |
30 | ||
39d2f9a7 | 31 | #ifndef WX_PRECOMP |
ad9835c9 | 32 | #include "wx/dynarray.h" |
39d2f9a7 JS |
33 | #include "wx/frame.h" |
34 | #include "wx/log.h" | |
35 | #include "wx/intl.h" | |
39d2f9a7 JS |
36 | #include "wx/settings.h" |
37 | #include "wx/bitmap.h" | |
38 | #include "wx/dcmemory.h" | |
39 | #include "wx/control.h" | |
40 | #endif | |
41 | ||
39d2f9a7 JS |
42 | #include "wx/toolbar.h" |
43 | ||
44 | #if !defined(__GNUWIN32__) && !defined(__SALFORDC__) | |
45 | #include "malloc.h" | |
46 | #endif | |
47 | ||
48 | #include "wx/msw/private.h" | |
49 | #include <windows.h> | |
50 | #include <windowsx.h> | |
51 | #include <tchar.h> | |
52 | #include <ole2.h> | |
eae4425d | 53 | #include <shellapi.h> |
39d2f9a7 | 54 | #include <commctrl.h> |
3d487566 | 55 | #if defined(WINCE_WITHOUT_COMMANDBAR) |
2d36b3d8 JS |
56 | #include <aygshell.h> |
57 | #endif | |
58 | #include "wx/msw/wince/missing.h" | |
39d2f9a7 JS |
59 | |
60 | #include "wx/msw/winundef.h" | |
61 | ||
a9102b36 | 62 | #if !defined(__SMARTPHONE__) |
39d2f9a7 | 63 | |
a9102b36 JS |
64 | ///////////// This implementation is for PocketPC. |
65 | ///////////// See later for the Smartphone dummy toolbar class. | |
39d2f9a7 JS |
66 | |
67 | // ---------------------------------------------------------------------------- | |
a9102b36 | 68 | // Event table |
39d2f9a7 JS |
69 | // ---------------------------------------------------------------------------- |
70 | ||
a9102b36 | 71 | IMPLEMENT_DYNAMIC_CLASS(wxToolMenuBar, wxToolBar) |
39d2f9a7 | 72 | |
a9102b36 | 73 | BEGIN_EVENT_TABLE(wxToolMenuBar, wxToolBar) |
39d2f9a7 JS |
74 | END_EVENT_TABLE() |
75 | ||
76 | // ---------------------------------------------------------------------------- | |
77 | // private classes | |
78 | // ---------------------------------------------------------------------------- | |
79 | ||
a9102b36 | 80 | class wxToolMenuBarTool : public wxToolBarToolBase |
39d2f9a7 JS |
81 | { |
82 | public: | |
a9102b36 | 83 | wxToolMenuBarTool(wxToolBar *tbar, |
39d2f9a7 JS |
84 | int id, |
85 | const wxString& label, | |
86 | const wxBitmap& bmpNormal, | |
87 | const wxBitmap& bmpDisabled, | |
88 | wxItemKind kind, | |
89 | wxObject *clientData, | |
90 | const wxString& shortHelp, | |
91 | const wxString& longHelp) | |
92 | : wxToolBarToolBase(tbar, id, label, bmpNormal, bmpDisabled, kind, | |
93 | clientData, shortHelp, longHelp) | |
94 | { | |
95 | m_nSepCount = 0; | |
ac1f013c | 96 | m_bitmapIndex = -1; |
39d2f9a7 JS |
97 | } |
98 | ||
a9102b36 | 99 | wxToolMenuBarTool(wxToolBar *tbar, wxControl *control) |
39d2f9a7 JS |
100 | : wxToolBarToolBase(tbar, control) |
101 | { | |
102 | m_nSepCount = 1; | |
ac1f013c | 103 | m_bitmapIndex = -1; |
39d2f9a7 JS |
104 | } |
105 | ||
106 | virtual void SetLabel(const wxString& label) | |
107 | { | |
108 | if ( label == m_label ) | |
109 | return; | |
110 | ||
111 | wxToolBarToolBase::SetLabel(label); | |
112 | ||
113 | // we need to update the label shown in the toolbar because it has a | |
114 | // pointer to the internal buffer of the old label | |
115 | // | |
116 | // TODO: use TB_SETBUTTONINFO | |
117 | } | |
118 | ||
119 | // set/get the number of separators which we use to cover the space used by | |
120 | // a control in the toolbar | |
121 | void SetSeparatorsCount(size_t count) { m_nSepCount = count; } | |
122 | size_t GetSeparatorsCount() const { return m_nSepCount; } | |
a71d815b | 123 | |
ac1f013c JS |
124 | void SetBitmapIndex(int idx) { m_bitmapIndex = idx; } |
125 | int GetBitmapIndex() const { return m_bitmapIndex; } | |
39d2f9a7 JS |
126 | |
127 | private: | |
128 | size_t m_nSepCount; | |
ac1f013c | 129 | int m_bitmapIndex; |
39d2f9a7 JS |
130 | }; |
131 | ||
132 | ||
133 | // ============================================================================ | |
134 | // implementation | |
135 | // ============================================================================ | |
136 | ||
137 | // ---------------------------------------------------------------------------- | |
138 | // wxToolBarTool | |
139 | // ---------------------------------------------------------------------------- | |
140 | ||
a9102b36 | 141 | wxToolBarToolBase *wxToolMenuBar::CreateTool(int id, |
39d2f9a7 JS |
142 | const wxString& label, |
143 | const wxBitmap& bmpNormal, | |
144 | const wxBitmap& bmpDisabled, | |
145 | wxItemKind kind, | |
146 | wxObject *clientData, | |
147 | const wxString& shortHelp, | |
148 | const wxString& longHelp) | |
149 | { | |
a9102b36 | 150 | return new wxToolMenuBarTool(this, id, label, bmpNormal, bmpDisabled, kind, |
39d2f9a7 JS |
151 | clientData, shortHelp, longHelp); |
152 | } | |
153 | ||
a9102b36 | 154 | wxToolBarToolBase *wxToolMenuBar::CreateTool(wxControl *control) |
39d2f9a7 | 155 | { |
a9102b36 | 156 | return new wxToolMenuBarTool(this, control); |
39d2f9a7 JS |
157 | } |
158 | ||
159 | // ---------------------------------------------------------------------------- | |
160 | // wxToolBar construction | |
161 | // ---------------------------------------------------------------------------- | |
162 | ||
a9102b36 | 163 | void wxToolMenuBar::Init() |
39d2f9a7 | 164 | { |
a9102b36 | 165 | wxToolBar::Init(); |
a71d815b WS |
166 | |
167 | m_nButtons = 0; | |
39d2f9a7 JS |
168 | m_menuBar = NULL; |
169 | } | |
170 | ||
a9102b36 | 171 | bool wxToolMenuBar::Create(wxWindow *parent, |
39d2f9a7 JS |
172 | wxWindowID id, |
173 | const wxPoint& pos, | |
174 | const wxSize& size, | |
175 | long style, | |
176 | const wxString& name, | |
177 | wxMenuBar* menuBar) | |
178 | { | |
179 | // common initialisation | |
180 | if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) | |
16640ba2 | 181 | return false; |
39d2f9a7 JS |
182 | |
183 | // MSW-specific initialisation | |
184 | if ( !MSWCreateToolbar(pos, size, menuBar) ) | |
16640ba2 | 185 | return false; |
39d2f9a7 JS |
186 | |
187 | // set up the colors and fonts | |
188 | SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR)); | |
189 | SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); | |
190 | ||
39fc096d | 191 | return true; |
39d2f9a7 JS |
192 | } |
193 | ||
a9102b36 | 194 | bool wxToolMenuBar::MSWCreateToolbar(const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), wxMenuBar* menuBar) |
39d2f9a7 JS |
195 | { |
196 | SetMenuBar(menuBar); | |
197 | if (m_menuBar) | |
198 | m_menuBar->SetToolBar(this); | |
199 | ||
3d487566 | 200 | #if defined(WINCE_WITHOUT_COMMANDBAR) |
39d2f9a7 JS |
201 | // Create the menubar. |
202 | SHMENUBARINFO mbi; | |
39fc096d | 203 | |
39d2f9a7 JS |
204 | memset (&mbi, 0, sizeof (SHMENUBARINFO)); |
205 | mbi.cbSize = sizeof (SHMENUBARINFO); | |
206 | mbi.hwndParent = (HWND) GetParent()->GetHWND(); | |
d7da7f13 | 207 | #ifdef __SMARTPHONE__ |
74d0b78c JS |
208 | mbi.nToolBarId = 5002; |
209 | #else | |
39d2f9a7 | 210 | mbi.nToolBarId = 5000; |
74d0b78c | 211 | #endif |
39d2f9a7 JS |
212 | mbi.nBmpId = 0; |
213 | mbi.cBmpImages = 0; | |
214 | mbi.dwFlags = 0 ; // SHCMBF_EMPTYBAR; | |
215 | mbi.hInstRes = wxGetInstance(); | |
39fc096d | 216 | |
39d2f9a7 JS |
217 | if (!SHCreateMenuBar(&mbi)) |
218 | { | |
219 | wxFAIL_MSG( _T("SHCreateMenuBar failed") ); | |
16640ba2 | 220 | return false; |
39d2f9a7 | 221 | } |
39fc096d | 222 | |
39d2f9a7 | 223 | SetHWND((WXHWND) mbi.hwndMB); |
960b193e JS |
224 | #else |
225 | HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND) GetParent()->GetHWND(), GetId()); | |
226 | SetHWND((WXHWND) hWnd); | |
2d36b3d8 JS |
227 | #endif |
228 | ||
77ffb593 | 229 | // install wxWidgets window proc for this window |
39d2f9a7 JS |
230 | SubclassWin(m_hWnd); |
231 | ||
232 | if (menuBar) | |
233 | menuBar->Create(); | |
39fc096d WS |
234 | |
235 | return true; | |
39d2f9a7 JS |
236 | } |
237 | ||
a9102b36 | 238 | void wxToolMenuBar::Recreate() |
39d2f9a7 | 239 | { |
a9102b36 | 240 | // TODO |
39d2f9a7 JS |
241 | } |
242 | ||
a9102b36 | 243 | wxToolMenuBar::~wxToolMenuBar() |
39d2f9a7 | 244 | { |
bf95a04f JS |
245 | if (GetMenuBar()) |
246 | GetMenuBar()->SetToolBar(NULL); | |
39d2f9a7 JS |
247 | } |
248 | ||
249 | // Return HMENU for the menu associated with the commandbar | |
a9102b36 | 250 | WXHMENU wxToolMenuBar::GetHMenu() |
39d2f9a7 | 251 | { |
781a24e8 | 252 | #if defined(__HANDHELDPC__) |
781a24e8 RR |
253 | return 0; |
254 | #else | |
39d2f9a7 JS |
255 | if (GetHWND()) |
256 | { | |
257 | return (WXHMENU) (HMENU)::SendMessage((HWND) GetHWND(), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0); | |
258 | } | |
259 | else | |
260 | return 0; | |
781a24e8 | 261 | #endif |
39d2f9a7 JS |
262 | } |
263 | ||
39d2f9a7 JS |
264 | // ---------------------------------------------------------------------------- |
265 | // adding/removing tools | |
266 | // ---------------------------------------------------------------------------- | |
267 | ||
a9102b36 | 268 | bool wxToolMenuBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) |
39d2f9a7 JS |
269 | { |
270 | // nothing special to do here - we really create the toolbar buttons in | |
271 | // Realize() later | |
272 | tool->Attach(this); | |
273 | ||
39fc096d | 274 | return true; |
39d2f9a7 JS |
275 | } |
276 | ||
a9102b36 | 277 | bool wxToolMenuBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) |
39d2f9a7 JS |
278 | { |
279 | // the main difficulty we have here is with the controls in the toolbars: | |
280 | // as we (sometimes) use several separators to cover up the space used by | |
281 | // them, the indices are not the same for us and the toolbar | |
282 | ||
283 | // first determine the position of the first button to delete: it may be | |
284 | // different from pos if we use several separators to cover the space used | |
285 | // by a control | |
286 | wxToolBarToolsList::compatibility_iterator node; | |
287 | for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) | |
288 | { | |
289 | wxToolBarToolBase *tool2 = node->GetData(); | |
290 | if ( tool2 == tool ) | |
291 | { | |
292 | // let node point to the next node in the list | |
293 | node = node->GetNext(); | |
294 | ||
295 | break; | |
296 | } | |
297 | ||
298 | if ( tool2->IsControl() ) | |
299 | { | |
a9102b36 | 300 | pos += ((wxToolMenuBarTool *)tool2)->GetSeparatorsCount() - 1; |
39d2f9a7 JS |
301 | } |
302 | } | |
303 | ||
304 | // now determine the number of buttons to delete and the area taken by them | |
305 | size_t nButtonsToDelete = 1; | |
306 | ||
307 | // get the size of the button we're going to delete | |
308 | RECT r; | |
309 | if ( !::SendMessage(GetHwnd(), TB_GETITEMRECT, pos, (LPARAM)&r) ) | |
310 | { | |
311 | wxLogLastError(_T("TB_GETITEMRECT")); | |
312 | } | |
313 | ||
314 | int width = r.right - r.left; | |
315 | ||
316 | if ( tool->IsControl() ) | |
317 | { | |
a9102b36 | 318 | nButtonsToDelete = ((wxToolMenuBarTool *)tool)->GetSeparatorsCount(); |
39d2f9a7 JS |
319 | |
320 | width *= nButtonsToDelete; | |
321 | } | |
322 | ||
323 | // do delete all buttons | |
324 | m_nButtons -= nButtonsToDelete; | |
325 | while ( nButtonsToDelete-- > 0 ) | |
326 | { | |
327 | if ( !::SendMessage(GetHwnd(), TB_DELETEBUTTON, pos, 0) ) | |
328 | { | |
329 | wxLogLastError(wxT("TB_DELETEBUTTON")); | |
330 | ||
16640ba2 | 331 | return false; |
39d2f9a7 JS |
332 | } |
333 | } | |
334 | ||
335 | tool->Detach(); | |
336 | ||
337 | // and finally reposition all the controls after this button (the toolbar | |
338 | // takes care of all normal items) | |
339 | for ( /* node -> first after deleted */ ; node; node = node->GetNext() ) | |
340 | { | |
341 | wxToolBarToolBase *tool2 = node->GetData(); | |
342 | if ( tool2->IsControl() ) | |
343 | { | |
344 | int x; | |
345 | wxControl *control = tool2->GetControl(); | |
346 | control->GetPosition(&x, NULL); | |
39fc096d | 347 | control->Move(x - width, wxDefaultCoord); |
39d2f9a7 JS |
348 | } |
349 | } | |
350 | ||
39fc096d | 351 | return true; |
39d2f9a7 JS |
352 | } |
353 | ||
4012b958 | 354 | bool wxToolMenuBar::Realize() |
39d2f9a7 JS |
355 | { |
356 | const size_t nTools = GetToolsCount(); | |
357 | if ( nTools == 0 ) | |
358 | { | |
359 | // nothing to do | |
39fc096d | 360 | return true; |
39d2f9a7 JS |
361 | } |
362 | ||
39d2f9a7 JS |
363 | #if 0 |
364 | // delete all old buttons, if any | |
365 | for ( size_t pos = 0; pos < m_nButtons; pos++ ) | |
366 | { | |
367 | if ( !::SendMessage(GetHwnd(), TB_DELETEBUTTON, 0, 0) ) | |
368 | { | |
369 | wxLogDebug(wxT("TB_DELETEBUTTON failed")); | |
370 | } | |
371 | } | |
7010702f | 372 | #endif // 0 |
39d2f9a7 | 373 | |
16640ba2 | 374 | bool lastWasRadio = false; |
39d2f9a7 JS |
375 | wxToolBarToolsList::Node* node; |
376 | for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) | |
377 | { | |
a9102b36 | 378 | wxToolMenuBarTool *tool = (wxToolMenuBarTool*) node->GetData(); |
39d2f9a7 | 379 | |
ac1f013c | 380 | TBBUTTON buttons[1] ; |
bf95a04f | 381 | |
ac1f013c | 382 | TBBUTTON& button = buttons[0]; |
39d2f9a7 JS |
383 | |
384 | wxZeroMemory(button); | |
385 | ||
16640ba2 | 386 | bool isRadio = false; |
39d2f9a7 JS |
387 | switch ( tool->GetStyle() ) |
388 | { | |
389 | case wxTOOL_STYLE_CONTROL: | |
390 | button.idCommand = tool->GetId(); | |
391 | // fall through: create just a separator too | |
4012b958 | 392 | // TODO: controls are not yet supported on wxToolMenuBar. |
39d2f9a7 JS |
393 | |
394 | case wxTOOL_STYLE_SEPARATOR: | |
395 | button.fsState = TBSTATE_ENABLED; | |
396 | button.fsStyle = TBSTYLE_SEP; | |
397 | break; | |
398 | ||
399 | case wxTOOL_STYLE_BUTTON: | |
a71d815b | 400 | |
39d2f9a7 JS |
401 | if ( HasFlag(wxTB_TEXT) ) |
402 | { | |
403 | const wxString& label = tool->GetLabel(); | |
404 | if ( !label.empty() ) | |
405 | { | |
406 | button.iString = (int)label.c_str(); | |
407 | } | |
408 | } | |
409 | ||
ac1f013c JS |
410 | const wxBitmap& bmp = tool->GetNormalBitmap(); |
411 | ||
412 | wxBitmap bmpToUse = bmp; | |
413 | ||
ec5f0c24 | 414 | if (bmp.GetWidth() < 16 || bmp.GetHeight() < 16 || bmp.GetMask() != NULL) |
ac1f013c JS |
415 | { |
416 | wxMemoryDC memDC; | |
417 | wxBitmap b(16,16); | |
418 | memDC.SelectObject(b); | |
4012b958 JS |
419 | wxColour col = wxColour(192,192,192); |
420 | memDC.SetBackground(wxBrush(col)); | |
ac1f013c JS |
421 | memDC.Clear(); |
422 | int x = (16 - bmp.GetWidth())/2; | |
423 | int y = (16 - bmp.GetHeight())/2; | |
424 | memDC.DrawBitmap(bmp, x, y, true); | |
425 | memDC.SelectObject(wxNullBitmap); | |
426 | ||
427 | bmpToUse = b; | |
428 | tool->SetNormalBitmap(b); | |
429 | } | |
430 | ||
431 | int n = 0; | |
432 | if ( bmpToUse.Ok() ) | |
bf95a04f | 433 | { |
ac1f013c JS |
434 | n = ::CommandBar_AddBitmap( (HWND) GetHWND(), NULL, (int) (HBITMAP) bmpToUse.GetHBITMAP(), |
435 | 1, 16, 16 ); | |
bf95a04f | 436 | } |
ac1f013c JS |
437 | |
438 | button.idCommand = tool->GetId(); | |
439 | button.iBitmap = n; | |
39d2f9a7 JS |
440 | |
441 | if ( tool->IsEnabled() ) | |
442 | button.fsState |= TBSTATE_ENABLED; | |
443 | if ( tool->IsToggled() ) | |
444 | button.fsState |= TBSTATE_CHECKED; | |
445 | ||
446 | switch ( tool->GetKind() ) | |
447 | { | |
448 | case wxITEM_RADIO: | |
449 | button.fsStyle = TBSTYLE_CHECKGROUP; | |
450 | ||
451 | if ( !lastWasRadio ) | |
452 | { | |
453 | // the first item in the radio group is checked by | |
454 | // default to be consistent with wxGTK and the menu | |
455 | // radio items | |
456 | button.fsState |= TBSTATE_CHECKED; | |
457 | ||
39fc096d | 458 | tool->Toggle(true); |
39d2f9a7 JS |
459 | } |
460 | ||
39fc096d | 461 | isRadio = true; |
39d2f9a7 JS |
462 | break; |
463 | ||
464 | case wxITEM_CHECK: | |
465 | button.fsStyle = TBSTYLE_CHECK; | |
466 | break; | |
467 | ||
468 | default: | |
469 | wxFAIL_MSG( _T("unexpected toolbar button kind") ); | |
470 | // fall through | |
471 | ||
472 | case wxITEM_NORMAL: | |
473 | button.fsStyle = TBSTYLE_BUTTON; | |
474 | } | |
39d2f9a7 JS |
475 | break; |
476 | } | |
477 | ||
30b9db02 VZ |
478 | if ( !::CommandBar_AddButtons( (HWND) GetHWND(), 1, buttons ) ) |
479 | { | |
480 | wxFAIL_MSG( wxT("Could not add toolbar button.")); | |
481 | } | |
7010702f | 482 | |
ac1f013c | 483 | lastWasRadio = isRadio; |
39d2f9a7 | 484 | } |
39d2f9a7 | 485 | |
7010702f | 486 | return true; |
39d2f9a7 JS |
487 | } |
488 | ||
a9102b36 | 489 | bool wxToolMenuBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id) |
39d2f9a7 JS |
490 | { |
491 | wxToolBarToolBase *tool = FindById((int)id); | |
492 | if ( !tool ) | |
493 | { | |
c616c2e8 WS |
494 | if (m_menuBar) |
495 | { | |
496 | wxMenuItem *item = m_menuBar->FindItem(id); | |
497 | if (item && item->IsCheckable()) | |
498 | { | |
499 | item->Toggle(); | |
500 | } | |
501 | } | |
502 | ||
39d2f9a7 JS |
503 | wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED); |
504 | event.SetEventObject(this); | |
505 | event.SetId(id); | |
506 | event.SetInt(id); | |
507 | ||
508 | return GetEventHandler()->ProcessEvent(event); | |
509 | } | |
510 | ||
511 | if ( tool->CanBeToggled() ) | |
512 | { | |
513 | LRESULT state = ::SendMessage(GetHwnd(), TB_GETSTATE, id, 0); | |
514 | tool->Toggle((state & TBSTATE_CHECKED) != 0); | |
515 | } | |
516 | ||
517 | bool toggled = tool->IsToggled(); | |
518 | ||
519 | // avoid sending the event when a radio button is released, this is not | |
520 | // interesting | |
521 | if ( !tool->CanBeToggled() || tool->GetKind() != wxITEM_RADIO || toggled ) | |
522 | { | |
523 | // OnLeftClick() can veto the button state change - for buttons which | |
524 | // may be toggled only, of couse | |
525 | if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() ) | |
526 | { | |
527 | // revert back | |
528 | toggled = !toggled; | |
529 | tool->SetToggle(toggled); | |
530 | ||
531 | ::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0)); | |
532 | } | |
533 | } | |
534 | ||
39fc096d | 535 | return true; |
39d2f9a7 JS |
536 | } |
537 | ||
ea9aa80e JS |
538 | WXLRESULT wxToolMenuBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) |
539 | { | |
540 | switch ( nMsg ) | |
541 | { | |
542 | case WM_SIZE: | |
543 | break; | |
544 | ||
545 | case WM_MOUSEMOVE: | |
546 | // we don't handle mouse moves, so always pass the message to | |
547 | // wxControl::MSWWindowProc | |
548 | HandleMouseMove(wParam, lParam); | |
549 | break; | |
550 | ||
551 | case WM_PAINT: | |
552 | break; | |
553 | } | |
554 | ||
625b3cf1 | 555 | return MSWDefWindowProc(nMsg, wParam, lParam); |
ea9aa80e JS |
556 | } |
557 | ||
558 | ||
39d2f9a7 | 559 | #else |
a9102b36 JS |
560 | |
561 | ////////////// For Smartphone | |
39d2f9a7 JS |
562 | |
563 | // ---------------------------------------------------------------------------- | |
a9102b36 | 564 | // Event table |
39d2f9a7 JS |
565 | // ---------------------------------------------------------------------------- |
566 | ||
a9102b36 | 567 | IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase) |
39d2f9a7 | 568 | |
a9102b36 JS |
569 | BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase) |
570 | END_EVENT_TABLE() | |
39d2f9a7 | 571 | |
a9102b36 JS |
572 | wxToolBarToolBase *wxToolBar::CreateTool(int id, |
573 | const wxString& label, | |
574 | const wxBitmap& bmpNormal, | |
575 | const wxBitmap& bmpDisabled, | |
576 | wxItemKind kind, | |
577 | wxObject *clientData, | |
578 | const wxString& shortHelp, | |
579 | const wxString& longHelp) | |
39d2f9a7 | 580 | { |
a9102b36 JS |
581 | return new wxToolBarToolBase(this, id, label, bmpNormal, bmpDisabled, kind, |
582 | clientData, shortHelp, longHelp); | |
39d2f9a7 JS |
583 | } |
584 | ||
a9102b36 | 585 | wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control) |
39d2f9a7 | 586 | { |
a9102b36 | 587 | return new wxToolBarToolBase(this, control); |
39d2f9a7 JS |
588 | } |
589 | ||
a9102b36 JS |
590 | bool wxToolBar::Create(wxWindow *parent, |
591 | wxWindowID WXUNUSED(id), | |
592 | const wxPoint& WXUNUSED(pos), | |
593 | const wxSize& WXUNUSED(size), | |
594 | long style, | |
595 | const wxString& name) | |
39d2f9a7 | 596 | { |
a9102b36 JS |
597 | // TODO: we may need to make this a dummy hidden window to |
598 | // satisfy other parts of wxWidgets. | |
39d2f9a7 | 599 | |
a9102b36 | 600 | parent->AddChild(this); |
a71d815b | 601 | |
a9102b36 JS |
602 | SetWindowStyle(style); |
603 | SetName(name); | |
a71d815b | 604 | |
a9102b36 | 605 | return true; |
39d2f9a7 JS |
606 | } |
607 | ||
a9102b36 JS |
608 | // ---------------------------------------------------------------------------- |
609 | // adding/removing tools | |
610 | // ---------------------------------------------------------------------------- | |
39d2f9a7 | 611 | |
a9102b36 JS |
612 | bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) |
613 | { | |
614 | tool->Attach(this); | |
615 | return true; | |
39d2f9a7 JS |
616 | } |
617 | ||
a9102b36 | 618 | bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) |
39d2f9a7 | 619 | { |
a9102b36 JS |
620 | tool->Detach(); |
621 | return true; | |
39d2f9a7 JS |
622 | } |
623 | ||
a9102b36 | 624 | wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) const |
39d2f9a7 | 625 | { |
a9102b36 | 626 | return NULL; |
39d2f9a7 JS |
627 | } |
628 | ||
629 | // ---------------------------------------------------------------------------- | |
630 | // tool state | |
631 | // ---------------------------------------------------------------------------- | |
632 | ||
a9102b36 | 633 | void wxToolBar::DoEnableTool(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(enable)) |
39d2f9a7 | 634 | { |
39d2f9a7 JS |
635 | } |
636 | ||
a9102b36 | 637 | void wxToolBar::DoToggleTool(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle)) |
39d2f9a7 | 638 | { |
39d2f9a7 JS |
639 | } |
640 | ||
641 | void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle)) | |
642 | { | |
39d2f9a7 JS |
643 | wxFAIL_MSG( _T("not implemented") ); |
644 | } | |
645 | ||
a9102b36 JS |
646 | #endif |
647 | // !__SMARTPHONE__ | |
39d2f9a7 | 648 | |
a71d815b | 649 | #endif // wxUSE_TOOLBAR |