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