1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/toolbar.cpp
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE
17 #include "wx/toolbar.h"
20 #include "wx/settings.h"
21 #include "wx/window.h"
24 #include "wx/dcclient.h"
25 #include "wx/dcmemory.h"
28 #include "wx/tooltip.h"
30 bool wxToolBar::m_bInitialized
= false;
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 class wxToolBarTool
: public wxToolBarToolBase
39 inline wxToolBarTool( wxToolBar
* pTbar
41 ,const wxString
& rsLabel
42 ,const wxBitmap
& rBitmap1
43 ,const wxBitmap
& rBitmap2
45 ,wxObject
* pClientData
46 ,const wxString
& rsShortHelpString
47 ,const wxString
& rsLongHelpString
48 ) : wxToolBarToolBase( pTbar
61 inline wxToolBarTool( wxToolBar
* pTbar
63 ,const wxString
& label
64 ) : wxToolBarToolBase( pTbar
71 void SetSize(const wxSize
& rSize
)
77 wxCoord
GetWidth(void) const { return m_vWidth
; }
78 wxCoord
GetHeight(void) const { return m_vHeight
; }
84 }; // end of CLASS wxToolBarTool
86 // ----------------------------------------------------------------------------
88 // ----------------------------------------------------------------------------
90 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxControl
)
92 BEGIN_EVENT_TABLE(wxToolBar
, wxToolBarBase
)
93 EVT_SIZE(wxToolBar::OnSize
)
94 EVT_PAINT(wxToolBar::OnPaint
)
95 EVT_KILL_FOCUS(wxToolBar::OnKillFocus
)
96 EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent
)
97 EVT_TIMER(-1, wxToolBar::OnTimer
)
100 // ============================================================================
102 // ============================================================================
104 // ----------------------------------------------------------------------------
105 // tool bar tools creation
106 // ----------------------------------------------------------------------------
108 wxToolBarToolBase
* wxToolBar::CreateTool(
110 , const wxString
& rsLabel
111 , const wxBitmap
& rBmpNormal
112 , const wxBitmap
& rBmpDisabled
114 , wxObject
* pClientData
115 , const wxString
& rsShortHelp
116 , const wxString
& rsLongHelp
119 return new wxToolBarTool( this
129 } // end of wxToolBarSimple::CreateTool
131 wxToolBarToolBase
*wxToolBar::CreateTool(
133 , const wxString
& label
136 return new wxToolBarTool( this
140 } // end of wxToolBarSimple::CreateTool
142 // ----------------------------------------------------------------------------
143 // wxToolBarSimple creation
144 // ----------------------------------------------------------------------------
146 void wxToolBar::Init()
148 m_nCurrentRowsOrColumns
= 0;
150 m_vLastX
= m_vLastY
= 0;
151 m_vMaxWidth
= m_vMaxHeight
= 0;
152 m_nPressedTool
= m_nCurrentTool
= -1;
153 m_vXPos
= m_vYPos
= -1;
154 m_vTextX
= m_vTextY
= 0;
157 m_toolSeparation
= 5;
160 m_defaultHeight
= 15;
163 } // end of wxToolBar::Init
165 wxToolBarToolBase
* wxToolBar::DoAddTool(
167 , const wxString
& rsLabel
168 , const wxBitmap
& rBitmap
169 , const wxBitmap
& rBmpDisabled
171 , const wxString
& rsShortHelp
172 , const wxString
& rsLongHelp
173 , wxObject
* pClientData
179 // Rememeber the position for DoInsertTool()
184 return wxToolBarBase::DoAddTool( vId
195 } // end of wxToolBar::DoAddTool
197 bool wxToolBar::DeleteTool(
201 bool bOk
= wxToolBarBase::DeleteTool(nId
);
208 } // end of wxToolBar::DeleteTool
210 bool wxToolBar::DeleteToolByPos(
214 bool bOk
= wxToolBarBase::DeleteToolByPos(nPos
);
221 } // end of wxToolBar::DeleteTool
223 wxToolBarToolBase
* wxToolBar::InsertControl(
225 , wxControl
* pControl
228 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertControl( nPos
237 } // end of wxToolBar::InsertControl
239 wxToolBarToolBase
* wxToolBar::InsertSeparator(
243 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertSeparator(nPos
);
251 } // end of wxToolBar::InsertSeparator
253 wxToolBarToolBase
* wxToolBar::InsertTool(
256 , const wxString
& rsLabel
257 , const wxBitmap
& rBitmap
258 , const wxBitmap
& rBmpDisabled
260 , const wxString
& rsShortHelp
261 , const wxString
& rsLongHelp
262 , wxObject
* pClientData
265 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertTool( nPos
281 } // end of wxToolBar::InsertTool
283 bool wxToolBar::DoInsertTool( size_t WXUNUSED(nPos
),
284 wxToolBarToolBase
* pToolBase
)
286 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
288 pTool
->m_vX
= m_vXPos
;
289 if (pTool
->m_vX
== -1)
290 pTool
->m_vX
= m_xMargin
;
292 pTool
->m_vY
= m_vYPos
;
293 if (pTool
->m_vY
== -1)
294 pTool
->m_vX
= m_yMargin
;
296 pTool
->SetSize(GetToolSize());
298 if (pTool
->IsButton())
301 // Calculate reasonable max size in case Layout() not called
303 if ((pTool
->m_vX
+ pTool
->GetNormalBitmap().GetWidth() + m_xMargin
) > m_vMaxWidth
)
304 m_vMaxWidth
= (wxCoord
)((pTool
->m_vX
+ pTool
->GetWidth() + m_xMargin
));
306 if ((pTool
->m_vY
+ pTool
->GetNormalBitmap().GetHeight() + m_yMargin
) > m_vMaxHeight
)
307 m_vMaxHeight
= (wxCoord
)((pTool
->m_vY
+ pTool
->GetHeight() + m_yMargin
));
310 } // end of wxToolBar::DoInsertTool
312 bool wxToolBar::DoDeleteTool( size_t WXUNUSED(nPos
),
313 wxToolBarToolBase
* pTool
)
318 } // end of wxToolBar::DoDeleteTool
320 bool wxToolBar::Create( wxWindow
* pParent
,
325 const wxString
& rsName
)
327 if ( !wxWindow::Create( pParent
336 // Set it to grey (or other 3D face colour)
337 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR
));
338 SetFont(*wxSMALL_FONT
);
340 if (GetWindowStyleFlag() & (wxTB_LEFT
| wxTB_RIGHT
))
345 m_maxRows
= 32000; // a lot
354 m_maxCols
= 32000; // a lot
356 SetCursor(*wxSTANDARD_CURSOR
);
359 // The toolbar's tools, if they have labels and the winTB_TEXT
360 // style is set, then we need to take into account the size of
361 // the text when drawing tool bitmaps and the text
363 if (HasFlag(wxTB_TEXT
))
365 wxClientDC
vDC(this);
367 vDC
.SetFont(GetFont());
368 vDC
.GetTextExtent( wxT("XXXX")
379 int nWidth
= rSize
.x
;
380 int nHeight
= rSize
.y
;
382 if (lStyle
& (wxTB_TOP
| wxTB_BOTTOM
))
386 nWidth
= pParent
->GetClientSize().x
;
390 if (lStyle
& wxTB_TEXT
)
391 nHeight
= m_defaultHeight
+ m_vTextY
;
393 nHeight
= m_defaultHeight
;
400 nHeight
= pParent
->GetClientSize().y
;
404 if (lStyle
& wxTB_TEXT
)
405 nWidth
= m_vTextX
+ (int)(m_vTextX
/2); // a little margin
407 nWidth
= m_defaultWidth
+ (int)(m_defaultWidth
/2); // a little margin
421 } // end of wxToolBar::Create
423 wxToolBar::~wxToolBar()
430 } // end of wxToolBar::~wxToolBar
432 bool wxToolBar::Realize()
434 int nMaxToolWidth
= 0;
435 int nMaxToolHeight
= 0;
437 m_nCurrentRowsOrColumns
= 0;
438 m_vLastX
= m_xMargin
;
439 m_vLastY
= m_yMargin
;
445 // Find the maximum tool width and height
447 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
451 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
453 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
456 // Set the height according to the font and the border size
458 if (pTool
->GetWidth() > m_vTextX
)
459 nMaxToolWidth
= pTool
->GetWidth() + 4;
461 nMaxToolWidth
= m_vTextX
;
462 if (pTool
->GetHeight() + m_vTextY
> nMaxToolHeight
)
463 nMaxToolHeight
= pTool
->GetHeight() + m_vTextY
;
467 if (pTool
->GetWidth() > nMaxToolWidth
)
468 nMaxToolWidth
= pTool
->GetWidth() + 4;
469 if (pTool
->GetHeight() > nMaxToolHeight
)
470 nMaxToolHeight
= pTool
->GetHeight();
472 node
= node
->GetNext();
475 wxCoord vTbWidth
= 0L;
476 wxCoord vTbHeight
= 0L;
481 if (vTbHeight
< nMaxToolHeight
)
488 if (GetParent()->IsKindOf(CLASSINFO(wxFrame
)))
490 wxFrame
* pFrame
= wxDynamicCast(GetParent(), wxFrame
);
493 pFrame
->PositionToolBar();
497 int nSeparatorSize
= m_toolSeparation
;
499 node
= m_tools
.GetFirst();
502 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
504 if (pTool
->IsSeparator())
506 if (GetWindowStyleFlag() & (wxTB_TOP
| wxTB_BOTTOM
))
508 pTool
->m_vX
= m_vLastX
+ nSeparatorSize
;
509 pTool
->m_vHeight
= m_defaultHeight
+ m_vTextY
;
510 if (m_nCurrentRowsOrColumns
>= m_maxCols
)
511 m_vLastY
+= nSeparatorSize
;
513 m_vLastX
+= nSeparatorSize
* 4;
517 pTool
->m_vY
= m_vLastY
+ nSeparatorSize
;
518 pTool
->m_vHeight
= m_defaultHeight
+ m_vTextY
;
519 if (m_nCurrentRowsOrColumns
>= m_maxRows
)
520 m_vLastX
+= nSeparatorSize
;
522 m_vLastY
+= nSeparatorSize
* 4;
525 else if (pTool
->IsButton())
527 if (GetWindowStyleFlag() & (wxTB_TOP
| wxTB_BOTTOM
))
529 if (m_nCurrentRowsOrColumns
>= m_maxCols
)
531 m_nCurrentRowsOrColumns
= 0;
532 m_vLastX
= m_xMargin
;
533 m_vLastY
+= nMaxToolHeight
+ m_toolPacking
;
535 pTool
->m_vX
= m_vLastX
+ (nMaxToolWidth
- ((int)(nMaxToolWidth
/2) + (int)(pTool
->GetWidth()/2)));
536 if (HasFlag(wxTB_TEXT
))
537 pTool
->m_vY
= m_vLastY
+ nSeparatorSize
- 2; // just bit of adjustment
539 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- (int)(pTool
->GetHeight()/2));
540 m_vLastX
+= nMaxToolWidth
+ m_toolPacking
+ m_toolSeparation
;
544 if (m_nCurrentRowsOrColumns
>= m_maxRows
)
546 m_nCurrentRowsOrColumns
= 0;
547 m_vLastX
+= (nMaxToolWidth
+ m_toolPacking
);
548 m_vLastY
= m_yMargin
;
550 pTool
->m_vX
= m_vLastX
+ pTool
->GetWidth();
551 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
552 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- m_vTextY
) + m_toolPacking
;
554 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- (int)(pTool
->GetHeight()/2));
555 m_vLastY
+= nMaxToolHeight
+ m_toolPacking
+ m_toolSeparation
;
557 m_nCurrentRowsOrColumns
++;
561 // TODO: support the controls
564 if (m_vLastX
> m_maxWidth
)
565 m_maxWidth
= m_vLastX
;
566 if (m_vLastY
> m_maxHeight
)
567 m_maxHeight
= m_vLastY
;
569 node
= node
->GetNext();
572 if (GetWindowStyleFlag() & (wxTB_TOP
| wxTB_BOTTOM
))
573 m_maxWidth
+= nMaxToolWidth
;
575 m_maxHeight
+= nMaxToolHeight
;
577 m_maxWidth
+= m_xMargin
;
578 m_maxHeight
+= m_yMargin
;
579 m_bInitialized
= true;
581 } // end of wxToolBar::Realize
583 // ----------------------------------------------------------------------------
585 // ----------------------------------------------------------------------------
587 void wxToolBar::OnPaint (
588 wxPaintEvent
& WXUNUSED(rEvent
)
595 static int nCount
= 0;
598 // Prevent reentry of OnPaint which would cause wxMemoryDC errors.
604 ::WinFillRect(vDc
.GetHPS(), &vDc
.m_vRclPaint
, GetBackgroundColour().GetPixel());
605 for ( wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
607 node
= node
->GetNext() )
609 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
611 if (pTool
->IsButton() )
612 DrawTool(vDc
, pTool
);
613 if (pTool
->IsSeparator())
615 wxColour
gray85(85, 85, 85);
616 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
622 vDc
.SetPen(vDarkGreyPen
);
623 if (HasFlag(wxTB_TEXT
))
625 if (HasFlag(wxTB_TOP
) || HasFlag(wxTB_BOTTOM
))
628 nY
= pTool
->m_vY
- (m_vTextY
- 6);
629 nHeight
= (m_vTextY
- 2) + pTool
->GetHeight();
633 nX
= pTool
->m_vX
+ m_xMargin
+ 10;
634 nY
= pTool
->m_vY
+ m_vTextY
+ m_toolSeparation
;
635 nWidth
= pTool
->GetWidth() > m_vTextX
? pTool
->GetWidth() : m_vTextX
;
642 if (HasFlag(wxTB_TOP
) || HasFlag(wxTB_BOTTOM
))
643 nHeight
= pTool
->GetHeight() - 2;
646 nX
+= m_xMargin
+ 10;
647 nY
+= m_yMargin
+ m_toolSeparation
;
648 nWidth
= pTool
->GetWidth();
651 vDc
.DrawLine(nX
, nY
, nX
+ nWidth
, nY
+ nHeight
);
655 } // end of wxToolBar::OnPaint
657 void wxToolBar::OnSize (
658 wxSizeEvent
& WXUNUSED(rEvent
)
661 #if wxUSE_CONSTRAINTS
665 } // end of wxToolBar::OnSize
667 void wxToolBar::OnKillFocus(
668 wxFocusEvent
& WXUNUSED(rEvent
)
671 OnMouseEnter(m_nPressedTool
= m_nCurrentTool
= -1);
672 } // end of wxToolBar::OnKillFocus
674 void wxToolBar::OnMouseEvent(
682 HPOINTER hPtr
= ::WinQuerySysPointer(HWND_DESKTOP
, SPTR_ARROW
, FALSE
);
684 ::WinSetPointer(HWND_DESKTOP
, hPtr
);
685 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
686 hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, TRUE
);
687 if (hWnd
!= (HWND
)GetHwnd())
693 rEvent
.GetPosition(&vX
, &vY
);
695 wxToolBarTool
* pTool
= (wxToolBarTool
*)FindToolForPosition( vX
699 if (rEvent
.LeftDown())
711 if (m_nCurrentTool
> -1)
713 if (rEvent
.LeftIsDown())
714 SpringUpButton(m_nCurrentTool
);
715 pTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
716 if (pTool
&& !pTool
->IsToggled())
718 RaiseTool( pTool
, FALSE
);
725 if (!rEvent
.IsButton())
727 if (pTool
->GetId() != m_nCurrentTool
)
730 // If the left button is kept down and moved over buttons,
731 // press those buttons.
733 if (rEvent
.LeftIsDown() && pTool
->IsEnabled())
735 SpringUpButton(m_nCurrentTool
);
736 if (pTool
->CanBeToggled())
742 wxToolBarTool
* pOldTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
744 if (pOldTool
&& !pTool
->IsToggled())
745 RaiseTool( pOldTool
, FALSE
);
746 m_nCurrentTool
= pTool
->GetId();
747 OnMouseEnter(m_nCurrentTool
);
748 if (!pTool
->GetShortHelp().empty())
752 m_pToolTip
= new wxToolTip(pTool
->GetShortHelp());
753 m_vXMouse
= (wxCoord
)vPoint
.x
;
754 m_vYMouse
= (wxCoord
)vPoint
.y
;
755 m_vToolTimer
.Start(1000L, TRUE
);
757 if (!pTool
->IsToggled())
763 // Left button pressed.
764 if (rEvent
.LeftDown() && pTool
->IsEnabled())
766 if (pTool
->CanBeToggled())
772 else if (rEvent
.RightDown())
774 OnRightClick( pTool
->GetId()
781 // Left Button Released. Only this action confirms selection.
782 // If the button is enabled and it is not a toggle tool and it is
783 // in the pressed state, then raise the button and call OnLeftClick.
785 if (rEvent
.LeftUp() && pTool
->IsEnabled() )
788 // Pass the OnLeftClick event to tool
790 if (!OnLeftClick( pTool
->GetId()
791 ,pTool
->IsToggled()) &&
792 pTool
->CanBeToggled())
795 // If it was a toggle, and OnLeftClick says No Toggle allowed,
796 // then change it back
802 } // end of wxToolBar::OnMouseEvent
804 // ----------------------------------------------------------------------------
806 // ----------------------------------------------------------------------------
808 void wxToolBar::DrawTool( wxToolBarToolBase
* pTool
)
810 wxClientDC
vDc(this);
812 DrawTool( vDc
, pTool
);
813 } // end of wxToolBar::DrawTool
815 void wxToolBar::DrawTool( wxDC
& rDc
, wxToolBarToolBase
* pToolBase
)
817 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
818 wxColour
gray85( 85,85,85 );
819 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
820 wxBitmap vBitmap
= pTool
->GetNormalBitmap();
821 bool bUseMask
= false;
822 wxMask
* pMask
= NULL
;
828 if ((pMask
= vBitmap
.GetMask()) != NULL
)
829 if (pMask
->GetMaskBitmap() != NULLHANDLE
)
832 if (!pTool
->IsToggled())
834 LowerTool(pTool
, FALSE
);
835 if (!pTool
->IsEnabled())
837 wxColour
vColor(wxT("GREY"));
839 rDc
.SetTextForeground(vColor
);
840 if (!pTool
->GetDisabledBitmap().Ok())
841 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
842 ,(long)GetBackgroundColour().GetPixel()
844 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
852 rDc
.SetTextForeground(*wxBLACK
);
853 rDc
.DrawBitmap( vBitmap
859 if (m_windowStyle
& wxTB_3DBUTTONS
)
863 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
867 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
869 rDc
.SetFont(GetFont());
870 rDc
.GetTextExtent( pTool
->GetLabel()
874 if (pTool
->GetWidth() > vX
) // large tools
876 vLeft
= pTool
->m_vX
+ (pTool
->GetWidth() - vX
);
878 rDc
.DrawText( pTool
->GetLabel()
885 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
886 rDc
.DrawText( pTool
->GetLabel()
888 ,pTool
->m_vY
+ m_vTextY
- 1 // a bit of margin
895 wxColour
vColor(wxT("GREY"));
898 rDc
.SetTextForeground(vColor
);
899 if (!pTool
->GetDisabledBitmap().Ok())
900 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
901 ,(long)GetBackgroundColour().GetPixel()
903 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
908 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
912 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
914 rDc
.SetFont(GetFont());
915 rDc
.GetTextExtent( pTool
->GetLabel()
919 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
920 rDc
.DrawText( pTool
->GetLabel()
922 ,pTool
->m_vY
+ m_vTextY
- 1 // a bit of margin
926 } // end of wxToolBar::DrawTool
928 // ----------------------------------------------------------------------------
930 // ----------------------------------------------------------------------------
932 void wxToolBar::SetRows(
936 wxCHECK_RET( nRows
!= 0, _T("max number of rows must be > 0") );
938 m_maxCols
= (GetToolsCount() + nRows
- 1) / nRows
;
940 } // end of wxToolBar::SetRows
942 wxToolBarToolBase
* wxToolBar::FindToolForPosition(
947 wxCoord vTBarHeight
= 0;
952 vY
= vTBarHeight
- vY
;
953 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
956 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
958 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
960 if ((vX
>= (pTool
->m_vX
- ((wxCoord
)(pTool
->GetWidth()/2) - 2))) &&
961 (vY
>= (pTool
->m_vY
- 2)) &&
962 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
963 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight() + m_vTextY
+ 2)))
970 if ((vX
>= pTool
->m_vX
) &&
971 (vY
>= pTool
->m_vY
) &&
972 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
973 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight())))
978 node
= node
->GetNext();
980 return (wxToolBarToolBase
*)NULL
;
981 } // end of wxToolBar::FindToolForPosition
983 // ----------------------------------------------------------------------------
984 // tool state change handlers
985 // ----------------------------------------------------------------------------
987 void wxToolBar::DoEnableTool(
988 wxToolBarToolBase
* pTool
989 , bool WXUNUSED(bEnable
)
993 } // end of wxToolBar::DoEnableTool
995 void wxToolBar::DoToggleTool(
996 wxToolBarToolBase
* pTool
997 , bool WXUNUSED(bToggle
)
1001 } // end of wxToolBar::DoToggleTool
1003 void wxToolBar::DoSetToggle(
1004 wxToolBarToolBase
* WXUNUSED(pTool
)
1005 , bool WXUNUSED(bToggle
)
1009 } // end of wxToolBar::DoSetToggle
1012 // Okay, so we've left the tool we're in ... we must check if the tool we're
1013 // leaving was a 'sprung push button' and if so, spring it back to the up
1016 void wxToolBar::SpringUpButton(
1020 wxToolBarToolBase
* pTool
= FindById(vId
);
1022 if (pTool
&& pTool
->CanBeToggled())
1024 if (pTool
->IsToggled())
1029 } // end of wxToolBar::SpringUpButton
1031 // ----------------------------------------------------------------------------
1033 // ----------------------------------------------------------------------------
1035 void wxToolBar::LowerTool ( wxToolBarToolBase
* pToolBase
,
1038 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1043 wxColour
gray85( 85,85,85 );
1044 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
1045 wxPen
vClearPen( GetBackgroundColour(), 1, wxSOLID
);
1046 wxClientDC
vDC(this);
1051 if (pTool
->IsSeparator())
1055 // We only do this for flat toolbars
1057 if (!HasFlag(wxTB_FLAT
))
1060 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
1062 if (pTool
->GetWidth() > m_vTextX
)
1064 vX
= pTool
->m_vX
- 2;
1065 vWidth
= pTool
->GetWidth() + 4;
1069 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1070 vWidth
= m_vTextX
+ 4;
1072 vY
= pTool
->m_vY
- 2;
1073 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1077 vX
= pTool
->m_vX
- 2;
1078 vY
= pTool
->m_vY
- 2;
1079 vWidth
= pTool
->GetWidth() + 4;
1080 vHeight
= pTool
->GetHeight() + 4;
1084 vDC
.SetPen(*wxWHITE_PEN
);
1085 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1086 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1087 vDC
.SetPen(vDarkGreyPen
);
1088 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1089 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1093 vDC
.SetPen(vClearPen
);
1094 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1095 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1096 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1097 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1099 } // end of WinGuiBase_CToolBarTool::LowerTool
1101 void wxToolBar::RaiseTool ( wxToolBarToolBase
* pToolBase
,
1104 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1109 wxColour
gray85( 85,85,85 );
1110 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
1111 wxPen
vClearPen( GetBackgroundColour(), 1, wxSOLID
);
1112 wxClientDC
vDC(this);
1117 if (pTool
->IsSeparator())
1120 if (!pTool
->IsEnabled())
1124 // We only do this for flat toolbars
1126 if (!HasFlag(wxTB_FLAT
))
1129 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
1131 if (pTool
->GetWidth() > m_vTextX
)
1133 vX
= pTool
->m_vX
- 2;
1134 vWidth
= pTool
->GetWidth() + 4;
1138 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1139 vWidth
= m_vTextX
+ 4;
1141 vY
= pTool
->m_vY
- 2;
1142 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1146 vX
= pTool
->m_vX
- 2;
1147 vY
= pTool
->m_vY
- 2;
1148 vWidth
= pTool
->GetWidth() + 4;
1149 vHeight
= pTool
->GetHeight() + 4;
1153 vDC
.SetPen(vDarkGreyPen
);
1154 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1155 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1156 vDC
.SetPen(*wxWHITE_PEN
);
1157 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1158 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1162 vDC
.SetPen(vClearPen
);
1163 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1164 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1165 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1166 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1168 } // end of wxToolBar::RaiseTool
1170 void wxToolBar::OnTimer ( wxTimerEvent
& rEvent
)
1172 if (rEvent
.GetId() == m_vToolTimer
.GetTimerId())
1174 wxPoint
vPos( m_vXMouse
, m_vYMouse
);
1176 m_pToolTip
->DisplayToolTipWindow(vPos
);
1177 m_vToolTimer
.Stop();
1178 m_vToolExpTimer
.Start(4000L, TRUE
);
1180 else if (rEvent
.GetId() == m_vToolExpTimer
.GetTimerId())
1182 m_pToolTip
->HideToolTipWindow();
1183 GetParent()->Refresh();
1184 m_vToolExpTimer
.Stop();
1186 } // end of wxToolBar::OnTimer
1188 #endif // ndef for wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE