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