1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/wince/tbarwce.cpp
3 // Purpose: wxToolBar for Windows CE
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "tbarwce.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.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"
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
44 #if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__))
46 #include "wx/toolbar.h"
48 #if !defined(__GNUWIN32__) && !defined(__SALFORDC__)
52 #include "wx/msw/private.h"
59 #if defined(WINCE_WITHOUT_COMMANDBAR)
62 #include "wx/msw/wince/missing.h"
64 #include "wx/msw/winundef.h"
66 #if defined(__MWERKS__) && defined(__WXMSW__)
67 // including <windef.h> for max definition doesn't seem
68 // to work using CodeWarrior 6 Windows. So we define it
69 // here. (Otherwise we get a undefined identifier 'max'
70 // later on in this file.) (Added by dimitri@shortcut.nl)
72 # define max(a,b) (((a) > (b)) ? (a) : (b))
77 // ----------------------------------------------------------------------------
79 // ----------------------------------------------------------------------------
81 // these standard constants are not always defined in compilers headers
85 #define TBSTYLE_LIST 0x1000
86 #define TBSTYLE_FLAT 0x0800
89 #ifndef TBSTYLE_TRANSPARENT
90 #define TBSTYLE_TRANSPARENT 0x8000
93 #ifndef TBSTYLE_TOOLTIPS
94 #define TBSTYLE_TOOLTIPS 0x0100
99 #define TB_SETSTYLE (WM_USER + 56)
100 #define TB_GETSTYLE (WM_USER + 57)
104 #define TB_HITTEST (WM_USER + 69)
107 // these values correspond to those used by comctl32.dll
108 #define DEFAULTBITMAPX 16
109 #define DEFAULTBITMAPY 15
110 #define DEFAULTBUTTONX 24
111 #define DEFAULTBUTTONY 24
112 #define DEFAULTBARHEIGHT 27
114 // ----------------------------------------------------------------------------
116 // ----------------------------------------------------------------------------
118 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxControl
)
120 BEGIN_EVENT_TABLE(wxToolBar
, wxToolBarBase
)
121 EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent
)
122 EVT_SYS_COLOUR_CHANGED(wxToolBar::OnSysColourChanged
)
125 // ----------------------------------------------------------------------------
127 // ----------------------------------------------------------------------------
129 class wxToolBarTool
: public wxToolBarToolBase
132 wxToolBarTool(wxToolBar
*tbar
,
134 const wxString
& label
,
135 const wxBitmap
& bmpNormal
,
136 const wxBitmap
& bmpDisabled
,
138 wxObject
*clientData
,
139 const wxString
& shortHelp
,
140 const wxString
& longHelp
)
141 : wxToolBarToolBase(tbar
, id
, label
, bmpNormal
, bmpDisabled
, kind
,
142 clientData
, shortHelp
, longHelp
)
148 wxToolBarTool(wxToolBar
*tbar
, wxControl
*control
)
149 : wxToolBarToolBase(tbar
, control
)
155 virtual void SetLabel(const wxString
& label
)
157 if ( label
== m_label
)
160 wxToolBarToolBase::SetLabel(label
);
162 // we need to update the label shown in the toolbar because it has a
163 // pointer to the internal buffer of the old label
165 // TODO: use TB_SETBUTTONINFO
168 // set/get the number of separators which we use to cover the space used by
169 // a control in the toolbar
170 void SetSeparatorsCount(size_t count
) { m_nSepCount
= count
; }
171 size_t GetSeparatorsCount() const { return m_nSepCount
; }
173 void SetBitmapIndex(int idx
) { m_bitmapIndex
= idx
; }
174 int GetBitmapIndex() const { return m_bitmapIndex
; }
182 // ============================================================================
184 // ============================================================================
186 // ----------------------------------------------------------------------------
188 // ----------------------------------------------------------------------------
190 wxToolBarToolBase
*wxToolBar::CreateTool(int id
,
191 const wxString
& label
,
192 const wxBitmap
& bmpNormal
,
193 const wxBitmap
& bmpDisabled
,
195 wxObject
*clientData
,
196 const wxString
& shortHelp
,
197 const wxString
& longHelp
)
199 return new wxToolBarTool(this, id
, label
, bmpNormal
, bmpDisabled
, kind
,
200 clientData
, shortHelp
, longHelp
);
203 wxToolBarToolBase
*wxToolBar::CreateTool(wxControl
*control
)
205 return new wxToolBarTool(this, control
);
208 // ----------------------------------------------------------------------------
209 // wxToolBar construction
210 // ----------------------------------------------------------------------------
212 void wxToolBar::Init()
216 m_defaultWidth
= DEFAULTBITMAPX
;
217 m_defaultHeight
= DEFAULTBITMAPY
;
223 bool wxToolBar::Create(wxWindow
*parent
,
228 const wxString
& name
,
231 // common initialisation
232 if ( !CreateControl(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
235 // MSW-specific initialisation
236 if ( !MSWCreateToolbar(pos
, size
, menuBar
) )
239 // set up the colors and fonts
240 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR
));
241 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
246 #ifndef TBSTYLE_NO_DROPDOWN_ARROW
247 #define TBSTYLE_NO_DROPDOWN_ARROW 0x0080
250 bool wxToolBar::MSWCreateToolbar(const wxPoint
& WXUNUSED(pos
), const wxSize
& WXUNUSED(size
), wxMenuBar
* menuBar
)
254 m_menuBar
->SetToolBar(this);
256 // Smartphone doesn't show a toolbar, it uses menu buttons.
258 #if !defined(__SMARTPHONE__)
260 #if defined(WINCE_WITHOUT_COMMANDBAR)
261 // Create the menubar.
264 memset (&mbi
, 0, sizeof (SHMENUBARINFO
));
265 mbi
.cbSize
= sizeof (SHMENUBARINFO
);
266 mbi
.hwndParent
= (HWND
) GetParent()->GetHWND();
267 #ifdef __SMARTPHONE__
268 mbi
.nToolBarId
= 5002;
270 mbi
.nToolBarId
= 5000;
274 mbi
.dwFlags
= 0 ; // SHCMBF_EMPTYBAR;
275 mbi
.hInstRes
= wxGetInstance();
277 if (!SHCreateMenuBar(&mbi
))
279 wxFAIL_MSG( _T("SHCreateMenuBar failed") );
283 SetHWND((WXHWND
) mbi
.hwndMB
);
285 HWND hWnd
= CommandBar_Create(wxGetInstance(), (HWND
) GetParent()->GetHWND(), GetId());
286 SetHWND((WXHWND
) hWnd
);
289 // install wxWidgets window proc for this window
300 void wxToolBar::Recreate()
303 const HWND hwndOld
= GetHwnd();
306 // we haven't been created yet, no need to recreate
310 // get the position and size before unsubclassing the old toolbar
311 const wxPoint pos
= GetPosition();
312 const wxSize size
= GetSize();
316 if ( !MSWCreateToolbar(pos
, size
) )
319 wxFAIL_MSG( _T("recreating the toolbar failed") );
324 // reparent all our children under the new toolbar
325 for ( wxWindowList::compatibility_iterator node
= m_children
.GetFirst();
327 node
= node
->GetNext() )
329 wxWindow
*win
= node
->GetData();
330 if ( !win
->IsTopLevel() )
331 ::SetParent(GetHwndOf(win
), GetHwnd());
334 // only destroy the old toolbar now -- after all the children had been
336 ::DestroyWindow(hwndOld
);
343 wxToolBar::~wxToolBar()
346 GetMenuBar()->SetToolBar(NULL
);
348 // we must refresh the frame size when the toolbar is deleted but the frame
349 // is not - otherwise toolbar leaves a hole in the place it used to occupy
350 wxFrame
*frame
= wxDynamicCast(GetParent(), wxFrame
);
351 if ( frame
&& !frame
->IsBeingDeleted() )
353 frame
->SendSizeEvent();
357 wxSize
wxToolBar::DoGetBestSize() const
359 wxSize sizeBest
= GetToolSize();
360 sizeBest
.x
*= GetToolsCount();
362 // reverse horz and vertical components if necessary
363 return HasFlag(wxTB_VERTICAL
) ? wxSize(sizeBest
.y
, sizeBest
.x
) : sizeBest
;
366 // Return HMENU for the menu associated with the commandbar
367 WXHMENU
wxToolBar::GetHMenu()
369 #if defined(__HANDHELDPC__)
375 return (WXHMENU
) (HMENU
)::SendMessage((HWND
) GetHWND(), SHCMBM_GETMENU
, (WPARAM
)0, (LPARAM
)0);
383 WXDWORD
wxToolBar::MSWGetStyle(long style
, WXDWORD
*exstyle
) const
385 // toolbars never have border, giving one to them results in broken
387 WXDWORD msStyle
= wxControl::MSWGetStyle
389 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
, exstyle
392 // always include this one, it never hurts and setting it later only if we
393 // do have tooltips wouldn't work
394 msStyle
|= TBSTYLE_TOOLTIPS
;
396 if ( style
& (wxTB_FLAT
| wxTB_HORZ_LAYOUT
) )
398 // static as it doesn't change during the program lifetime
399 static int s_verComCtl
= wxTheApp
->GetComCtl32Version();
401 // comctl32.dll 4.00 doesn't support the flat toolbars and using this
402 // style with 6.00 (part of Windows XP) leads to the toolbar with
403 // incorrect background colour - and not using it still results in the
404 // correct (flat) toolbar, so don't use it there
405 if ( s_verComCtl
> 400 && s_verComCtl
< 600 )
407 msStyle
|= TBSTYLE_FLAT
| TBSTYLE_TRANSPARENT
;
410 if ( s_verComCtl
>= 470 && style
& wxTB_HORZ_LAYOUT
)
412 msStyle
|= TBSTYLE_LIST
;
416 if ( style
& wxTB_NODIVIDER
)
417 msStyle
|= CCS_NODIVIDER
;
419 if ( style
& wxTB_NOALIGN
)
420 msStyle
|= CCS_NOPARENTALIGN
;
422 if ( style
& wxTB_VERTICAL
)
428 // ----------------------------------------------------------------------------
429 // adding/removing tools
430 // ----------------------------------------------------------------------------
432 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*tool
)
434 // nothing special to do here - we really create the toolbar buttons in
441 bool wxToolBar::DoDeleteTool(size_t pos
, wxToolBarToolBase
*tool
)
443 // the main difficulty we have here is with the controls in the toolbars:
444 // as we (sometimes) use several separators to cover up the space used by
445 // them, the indices are not the same for us and the toolbar
447 // first determine the position of the first button to delete: it may be
448 // different from pos if we use several separators to cover the space used
450 wxToolBarToolsList::compatibility_iterator node
;
451 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
453 wxToolBarToolBase
*tool2
= node
->GetData();
456 // let node point to the next node in the list
457 node
= node
->GetNext();
462 if ( tool2
->IsControl() )
464 pos
+= ((wxToolBarTool
*)tool2
)->GetSeparatorsCount() - 1;
468 // now determine the number of buttons to delete and the area taken by them
469 size_t nButtonsToDelete
= 1;
471 // get the size of the button we're going to delete
473 if ( !::SendMessage(GetHwnd(), TB_GETITEMRECT
, pos
, (LPARAM
)&r
) )
475 wxLogLastError(_T("TB_GETITEMRECT"));
478 int width
= r
.right
- r
.left
;
480 if ( tool
->IsControl() )
482 nButtonsToDelete
= ((wxToolBarTool
*)tool
)->GetSeparatorsCount();
484 width
*= nButtonsToDelete
;
487 // do delete all buttons
488 m_nButtons
-= nButtonsToDelete
;
489 while ( nButtonsToDelete
-- > 0 )
491 if ( !::SendMessage(GetHwnd(), TB_DELETEBUTTON
, pos
, 0) )
493 wxLogLastError(wxT("TB_DELETEBUTTON"));
501 // and finally reposition all the controls after this button (the toolbar
502 // takes care of all normal items)
503 for ( /* node -> first after deleted */ ; node
; node
= node
->GetNext() )
505 wxToolBarToolBase
*tool2
= node
->GetData();
506 if ( tool2
->IsControl() )
509 wxControl
*control
= tool2
->GetControl();
510 control
->GetPosition(&x
, NULL
);
511 control
->Move(x
- width
, wxDefaultCoord
);
518 bool wxToolBar::Realize()
520 #if defined(__SMARTPHONE__)
523 const size_t nTools
= GetToolsCount();
531 // delete all old buttons, if any
532 for ( size_t pos
= 0; pos
< m_nButtons
; pos
++ )
534 if ( !::SendMessage(GetHwnd(), TB_DELETEBUTTON
, 0, 0) )
536 wxLogDebug(wxT("TB_DELETEBUTTON failed"));
541 bool lastWasRadio
= false;
542 wxToolBarToolsList::Node
* node
;
543 for ( node
= m_tools
.GetFirst(); node
; node
= node
->GetNext() )
545 wxToolBarTool
*tool
= (wxToolBarTool
*) node
->GetData();
547 TBBUTTON buttons
[1] ;
549 TBBUTTON
& button
= buttons
[0];
551 wxZeroMemory(button
);
553 bool isRadio
= false;
554 switch ( tool
->GetStyle() )
556 case wxTOOL_STYLE_CONTROL
:
557 button
.idCommand
= tool
->GetId();
558 // fall through: create just a separator too
560 case wxTOOL_STYLE_SEPARATOR
:
561 button
.fsState
= TBSTATE_ENABLED
;
562 button
.fsStyle
= TBSTYLE_SEP
;
565 case wxTOOL_STYLE_BUTTON
:
567 if ( HasFlag(wxTB_TEXT
) )
569 const wxString
& label
= tool
->GetLabel();
570 if ( !label
.empty() )
572 button
.iString
= (int)label
.c_str();
576 const wxBitmap
& bmp
= tool
->GetNormalBitmap();
578 wxBitmap bmpToUse
= bmp
;
580 if (bmp
.GetWidth() < 16 || bmp
.GetHeight() < 16)
584 memDC
.SelectObject(b
);
585 memDC
.SetBackground(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
)));
587 int x
= (16 - bmp
.GetWidth())/2;
588 int y
= (16 - bmp
.GetHeight())/2;
589 memDC
.DrawBitmap(bmp
, x
, y
, true);
590 memDC
.SelectObject(wxNullBitmap
);
593 tool
->SetNormalBitmap(b
);
599 n
= ::CommandBar_AddBitmap( (HWND
) GetHWND(), NULL
, (int) (HBITMAP
) bmpToUse
.GetHBITMAP(),
603 button
.idCommand
= tool
->GetId();
606 if ( tool
->IsEnabled() )
607 button
.fsState
|= TBSTATE_ENABLED
;
608 if ( tool
->IsToggled() )
609 button
.fsState
|= TBSTATE_CHECKED
;
611 switch ( tool
->GetKind() )
614 button
.fsStyle
= TBSTYLE_CHECKGROUP
;
618 // the first item in the radio group is checked by
619 // default to be consistent with wxGTK and the menu
621 button
.fsState
|= TBSTATE_CHECKED
;
630 button
.fsStyle
= TBSTYLE_CHECK
;
634 wxFAIL_MSG( _T("unexpected toolbar button kind") );
638 button
.fsStyle
= TBSTYLE_BUTTON
;
643 BOOL bRc
= ::CommandBar_AddButtons( (HWND
) GetHWND(), 1, buttons
);
645 wxASSERT_MSG( bRc
, wxT("Could not add toolbar button."));
647 lastWasRadio
= isRadio
;
655 // ----------------------------------------------------------------------------
657 // ----------------------------------------------------------------------------
659 bool wxToolBar::MSWCommand(WXUINT
WXUNUSED(cmd
), WXWORD id
)
661 wxToolBarToolBase
*tool
= FindById((int)id
);
664 wxCommandEvent
event(wxEVT_COMMAND_MENU_SELECTED
);
665 event
.SetEventObject(this);
669 return GetEventHandler()->ProcessEvent(event
);
672 if ( tool
->CanBeToggled() )
674 LRESULT state
= ::SendMessage(GetHwnd(), TB_GETSTATE
, id
, 0);
675 tool
->Toggle((state
& TBSTATE_CHECKED
) != 0);
678 bool toggled
= tool
->IsToggled();
680 // avoid sending the event when a radio button is released, this is not
682 if ( !tool
->CanBeToggled() || tool
->GetKind() != wxITEM_RADIO
|| toggled
)
684 // OnLeftClick() can veto the button state change - for buttons which
685 // may be toggled only, of couse
686 if ( !OnLeftClick((int)id
, toggled
) && tool
->CanBeToggled() )
690 tool
->SetToggle(toggled
);
692 ::SendMessage(GetHwnd(), TB_CHECKBUTTON
, id
, MAKELONG(toggled
, 0));
699 bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl
),
701 WXLPARAM
*WXUNUSED(result
))
704 // First check if this applies to us
705 NMHDR
*hdr
= (NMHDR
*)lParam
;
707 // the tooltips control created by the toolbar is sometimes Unicode, even
708 // in an ANSI application - this seems to be a bug in comctl32.dll v5
709 UINT code
= hdr
->code
;
710 if ( (code
!= (UINT
) TTN_NEEDTEXTA
) && (code
!= (UINT
) TTN_NEEDTEXTW
) )
713 HWND toolTipWnd
= (HWND
)::SendMessage((HWND
)GetHWND(), TB_GETTOOLTIPS
, 0, 0);
714 if ( toolTipWnd
!= hdr
->hwndFrom
)
717 LPTOOLTIPTEXT ttText
= (LPTOOLTIPTEXT
)lParam
;
718 int id
= (int)ttText
->hdr
.idFrom
;
720 wxToolBarToolBase
*tool
= FindById(id
);
724 return HandleTooltipNotify(code
, lParam
, tool
->GetShortHelp());
731 // ----------------------------------------------------------------------------
733 // ----------------------------------------------------------------------------
735 void wxToolBar::SetToolBitmapSize(const wxSize
& size
)
737 wxToolBarBase::SetToolBitmapSize(size
);
739 ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE
, 0, MAKELONG(size
.x
, size
.y
));
742 void wxToolBar::SetRows(int nRows
)
744 if ( nRows
== m_maxRows
)
746 // avoid resizing the frame uselessly
750 // TRUE in wParam means to create at least as many rows, FALSE -
753 ::SendMessage(GetHwnd(), TB_SETROWS
,
754 MAKEWPARAM(nRows
, !(GetWindowStyle() & wxTB_VERTICAL
)),
762 // The button size is bigger than the bitmap size
763 wxSize
wxToolBar::GetToolSize() const
765 // TB_GETBUTTONSIZE is supported from version 4.70
766 #if defined(_WIN32_IE) && (_WIN32_IE >= 0x300 ) \
767 && !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) )
768 if ( wxTheApp
->GetComCtl32Version() >= 470 )
770 DWORD dw
= ::SendMessage(GetHwnd(), TB_GETBUTTONSIZE
, 0, 0);
772 return wxSize(LOWORD(dw
), HIWORD(dw
));
775 #endif // comctl32.dll 4.70+
778 return wxSize(m_defaultWidth
+ 8, m_defaultHeight
+ 7);
783 wxToolBarToolBase
*GetItemSkippingDummySpacers(const wxToolBarToolsList
& tools
,
786 wxToolBarToolsList::compatibility_iterator current
= tools
.GetFirst();
788 for ( ; current
!= 0; current
= current
->GetNext() )
791 return current
->GetData();
793 wxToolBarTool
*tool
= (wxToolBarTool
*)current
->GetData();
794 size_t separators
= tool
->GetSeparatorsCount();
796 // if it is a normal button, sepcount == 0, so skip 1 item (the button)
797 // otherwise, skip as many items as the separator count, plus the
799 index
-= separators
? separators
+ 1 : 1;
805 wxToolBarToolBase
*wxToolBar::FindToolForPosition(wxCoord x
, wxCoord y
) const
810 int index
= (int)::SendMessage(GetHwnd(), TB_HITTEST
, 0, (LPARAM
)&pt
);
811 // MBN: when the point ( x, y ) is close to the toolbar border
812 // TB_HITTEST returns m_nButtons ( not -1 )
813 if ( index
< 0 || (size_t)index
>= m_nButtons
)
815 // it's a separator or there is no tool at all there
816 return (wxToolBarToolBase
*)NULL
;
819 // if comctl32 version < 4.71 wxToolBar95 adds dummy spacers
820 #if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 )
821 if ( wxTheApp
->GetComCtl32Version() >= 471 )
823 return m_tools
.Item((size_t)index
)->GetData();
828 return GetItemSkippingDummySpacers( m_tools
, (size_t) index
);
832 void wxToolBar::UpdateSize()
834 // the toolbar size changed
835 ::SendMessage(GetHwnd(), TB_AUTOSIZE
, 0, 0);
837 // we must also refresh the frame after the toolbar size (possibly) changed
838 wxFrame
*frame
= wxDynamicCast(GetParent(), wxFrame
);
841 frame
->SendSizeEvent();
845 // ----------------------------------------------------------------------------
847 // ---------------------------------------------------------------------------
849 void wxToolBar::SetWindowStyleFlag(long style
)
851 // the style bits whose changes force us to recreate the toolbar
852 static const long MASK_NEEDS_RECREATE
= wxTB_TEXT
| wxTB_NOICONS
;
854 const long styleOld
= GetWindowStyle();
856 wxToolBarBase::SetWindowStyleFlag(style
);
858 // don't recreate an empty toolbar: not only this is unnecessary, but it is
859 // also fatal as we'd then try to recreate the toolbar when it's just being
861 if ( GetToolsCount() &&
862 (style
& MASK_NEEDS_RECREATE
) != (styleOld
& MASK_NEEDS_RECREATE
) )
864 // to remove the text labels, simply re-realizing the toolbar is enough
865 // but I don't know of any way to add the text to an existing toolbar
866 // other than by recreating it entirely
871 // ----------------------------------------------------------------------------
873 // ----------------------------------------------------------------------------
875 void wxToolBar::DoEnableTool(wxToolBarToolBase
*tool
, bool enable
)
877 ::SendMessage(GetHwnd(), TB_ENABLEBUTTON
,
878 (WPARAM
)tool
->GetId(), (LPARAM
)MAKELONG(enable
, 0));
881 void wxToolBar::DoToggleTool(wxToolBarToolBase
*tool
, bool toggle
)
883 ::SendMessage(GetHwnd(), TB_CHECKBUTTON
,
884 (WPARAM
)tool
->GetId(), (LPARAM
)MAKELONG(toggle
, 0));
887 void wxToolBar::DoSetToggle(wxToolBarToolBase
*WXUNUSED(tool
), bool WXUNUSED(toggle
))
889 // VZ: AFAIK, the button has to be created either with TBSTYLE_CHECK or
890 // without, so we really need to delete the button and recreate it here
891 wxFAIL_MSG( _T("not implemented") );
894 // ----------------------------------------------------------------------------
896 // ----------------------------------------------------------------------------
898 // Responds to colour changes, and passes event on to children.
899 void wxToolBar::OnSysColourChanged(wxSysColourChangedEvent
& event
)
901 wxRGBToColour(m_backgroundColour
, ::GetSysColor(COLOR_BTNFACE
));
906 // Relayout the toolbar
907 int nrows
= m_maxRows
;
908 m_maxRows
= 0; // otherwise SetRows() wouldn't do anything
913 // let the event propagate further
917 void wxToolBar::OnMouseEvent(wxMouseEvent
& event
)
919 if (event
.Leaving() && m_pInTool
)
926 if (event
.RightDown())
928 // For now, we don't have an id. Later we could
929 // try finding the tool.
930 OnRightClick((int)-1, event
.GetX(), event
.GetY());
938 void wxToolBar::HandleMouseMove(WXWPARAM
WXUNUSED(wParam
), WXLPARAM lParam
)
940 wxCoord x
= GET_X_LPARAM(lParam
),
941 y
= GET_Y_LPARAM(lParam
);
942 wxToolBarToolBase
* tool
= FindToolForPosition( x
, y
);
944 // cursor left current tool
945 if( tool
!= m_pInTool
&& !tool
)
951 // cursor entered a tool
952 if( tool
!= m_pInTool
&& tool
)
955 OnMouseEnter( tool
->GetId() );
959 WXLRESULT
wxToolBar::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
965 if ( HandleSize(wParam
, lParam
) )
970 // we don't handle mouse moves, so always pass the message to
971 // wxControl::MSWWindowProc
972 HandleMouseMove(wParam
, lParam
);
976 return wxControl::MSWWindowProc(nMsg
, wParam
, lParam
);
979 #endif // wxUSE_TOOLBAR && Win95