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 ) : wxToolBarToolBase( pTbar
69 void SetSize(const wxSize
& rSize
)
75 wxCoord
GetWidth(void) const { return m_vWidth
; }
76 wxCoord
GetHeight(void) const { return m_vHeight
; }
82 }; // end of CLASS wxToolBarTool
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
88 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxControl
)
90 BEGIN_EVENT_TABLE(wxToolBar
, wxToolBarBase
)
91 EVT_SIZE(wxToolBar::OnSize
)
92 EVT_PAINT(wxToolBar::OnPaint
)
93 EVT_KILL_FOCUS(wxToolBar::OnKillFocus
)
94 EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent
)
95 EVT_TIMER(-1, wxToolBar::OnTimer
)
98 // ============================================================================
100 // ============================================================================
102 // ----------------------------------------------------------------------------
103 // tool bar tools creation
104 // ----------------------------------------------------------------------------
106 wxToolBarToolBase
* wxToolBar::CreateTool(
108 , const wxString
& rsLabel
109 , const wxBitmap
& rBmpNormal
110 , const wxBitmap
& rBmpDisabled
112 , wxObject
* pClientData
113 , const wxString
& rsShortHelp
114 , const wxString
& rsLongHelp
117 return new wxToolBarTool( this
127 } // end of wxToolBarSimple::CreateTool
129 wxToolBarToolBase
*wxToolBar::CreateTool(
133 return new wxToolBarTool( this
136 } // end of wxToolBarSimple::CreateTool
138 // ----------------------------------------------------------------------------
139 // wxToolBarSimple creation
140 // ----------------------------------------------------------------------------
142 void wxToolBar::Init()
144 m_nCurrentRowsOrColumns
= 0;
146 m_vLastX
= m_vLastY
= 0;
147 m_vMaxWidth
= m_vMaxHeight
= 0;
148 m_nPressedTool
= m_nCurrentTool
= -1;
149 m_vXPos
= m_vYPos
= -1;
150 m_vTextX
= m_vTextY
= 0;
153 m_toolSeparation
= 5;
156 m_defaultHeight
= 15;
159 } // end of wxToolBar::Init
161 wxToolBarToolBase
* wxToolBar::DoAddTool(
163 , const wxString
& rsLabel
164 , const wxBitmap
& rBitmap
165 , const wxBitmap
& rBmpDisabled
167 , const wxString
& rsShortHelp
168 , const wxString
& rsLongHelp
169 , wxObject
* pClientData
175 // Rememeber the position for DoInsertTool()
180 return wxToolBarBase::DoAddTool( vId
191 } // end of wxToolBar::DoAddTool
193 bool wxToolBar::DeleteTool(
197 bool bOk
= wxToolBarBase::DeleteTool(nId
);
204 } // end of wxToolBar::DeleteTool
206 bool wxToolBar::DeleteToolByPos(
210 bool bOk
= wxToolBarBase::DeleteToolByPos(nPos
);
217 } // end of wxToolBar::DeleteTool
219 wxToolBarToolBase
* wxToolBar::InsertControl(
221 , wxControl
* pControl
224 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertControl( nPos
233 } // end of wxToolBar::InsertControl
235 wxToolBarToolBase
* wxToolBar::InsertSeparator(
239 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertSeparator(nPos
);
247 } // end of wxToolBar::InsertSeparator
249 wxToolBarToolBase
* wxToolBar::InsertTool(
252 , const wxString
& rsLabel
253 , const wxBitmap
& rBitmap
254 , const wxBitmap
& rBmpDisabled
256 , const wxString
& rsShortHelp
257 , const wxString
& rsLongHelp
258 , wxObject
* pClientData
261 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertTool( nPos
277 } // end of wxToolBar::InsertTool
279 bool wxToolBar::DoInsertTool( size_t WXUNUSED(nPos
),
280 wxToolBarToolBase
* pToolBase
)
282 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
284 pTool
->m_vX
= m_vXPos
;
285 if (pTool
->m_vX
== -1)
286 pTool
->m_vX
= m_xMargin
;
288 pTool
->m_vY
= m_vYPos
;
289 if (pTool
->m_vY
== -1)
290 pTool
->m_vX
= m_yMargin
;
292 pTool
->SetSize(GetToolSize());
294 if (pTool
->IsButton())
297 // Calculate reasonable max size in case Layout() not called
299 if ((pTool
->m_vX
+ pTool
->GetNormalBitmap().GetWidth() + m_xMargin
) > m_vMaxWidth
)
300 m_vMaxWidth
= (wxCoord
)((pTool
->m_vX
+ pTool
->GetWidth() + m_xMargin
));
302 if ((pTool
->m_vY
+ pTool
->GetNormalBitmap().GetHeight() + m_yMargin
) > m_vMaxHeight
)
303 m_vMaxHeight
= (wxCoord
)((pTool
->m_vY
+ pTool
->GetHeight() + m_yMargin
));
306 } // end of wxToolBar::DoInsertTool
308 bool wxToolBar::DoDeleteTool( size_t WXUNUSED(nPos
),
309 wxToolBarToolBase
* pTool
)
314 } // end of wxToolBar::DoDeleteTool
316 bool wxToolBar::Create( wxWindow
* pParent
,
321 const wxString
& rsName
)
323 if ( !wxWindow::Create( pParent
332 // Set it to grey (or other 3D face colour)
333 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR
));
334 SetFont(*wxSMALL_FONT
);
336 if (GetWindowStyleFlag() & wxTB_VERTICAL
)
341 m_maxRows
= 32000; // a lot
350 m_maxCols
= 32000; // a lot
352 SetCursor(*wxSTANDARD_CURSOR
);
355 // The toolbar's tools, if they have labels and the winTB_TEXT
356 // style is set, then we need to take into account the size of
357 // the text when drawing tool bitmaps and the text
359 if (HasFlag(wxTB_TEXT
))
361 wxClientDC
vDC(this);
363 vDC
.SetFont(GetFont());
364 vDC
.GetTextExtent( wxT("XXXX")
375 int nWidth
= rSize
.x
;
376 int nHeight
= rSize
.y
;
378 if (lStyle
& wxTB_HORIZONTAL
)
382 nWidth
= pParent
->GetClientSize().x
;
386 if (lStyle
& wxTB_TEXT
)
387 nHeight
= m_defaultHeight
+ m_vTextY
;
389 nHeight
= m_defaultHeight
;
396 nHeight
= pParent
->GetClientSize().y
;
400 if (lStyle
& wxTB_TEXT
)
401 nWidth
= m_vTextX
+ (int)(m_vTextX
/2); // a little margin
403 nWidth
= m_defaultWidth
+ (int)(m_defaultWidth
/2); // a little margin
417 } // end of wxToolBar::Create
419 wxToolBar::~wxToolBar()
426 } // end of wxToolBar::~wxToolBar
428 bool wxToolBar::Realize()
430 int nMaxToolWidth
= 0;
431 int nMaxToolHeight
= 0;
433 m_nCurrentRowsOrColumns
= 0;
434 m_vLastX
= m_xMargin
;
435 m_vLastY
= m_yMargin
;
441 // Find the maximum tool width and height
443 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
447 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
449 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
452 // Set the height according to the font and the border size
454 if (pTool
->GetWidth() > m_vTextX
)
455 nMaxToolWidth
= pTool
->GetWidth() + 4;
457 nMaxToolWidth
= m_vTextX
;
458 if (pTool
->GetHeight() + m_vTextY
> nMaxToolHeight
)
459 nMaxToolHeight
= pTool
->GetHeight() + m_vTextY
;
463 if (pTool
->GetWidth() > nMaxToolWidth
)
464 nMaxToolWidth
= pTool
->GetWidth() + 4;
465 if (pTool
->GetHeight() > nMaxToolHeight
)
466 nMaxToolHeight
= pTool
->GetHeight();
468 node
= node
->GetNext();
471 wxCoord vTbWidth
= 0L;
472 wxCoord vTbHeight
= 0L;
477 if (vTbHeight
< nMaxToolHeight
)
484 if (GetParent()->IsKindOf(CLASSINFO(wxFrame
)))
486 wxFrame
* pFrame
= wxDynamicCast(GetParent(), wxFrame
);
489 pFrame
->PositionToolBar();
493 int nSeparatorSize
= m_toolSeparation
;
495 node
= m_tools
.GetFirst();
498 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
500 if (pTool
->IsSeparator())
502 if (GetWindowStyleFlag() & wxTB_HORIZONTAL
)
504 pTool
->m_vX
= m_vLastX
+ nSeparatorSize
;
505 pTool
->m_vHeight
= m_defaultHeight
+ m_vTextY
;
506 if (m_nCurrentRowsOrColumns
>= m_maxCols
)
507 m_vLastY
+= nSeparatorSize
;
509 m_vLastX
+= nSeparatorSize
* 4;
513 pTool
->m_vY
= m_vLastY
+ nSeparatorSize
;
514 pTool
->m_vHeight
= m_defaultHeight
+ m_vTextY
;
515 if (m_nCurrentRowsOrColumns
>= m_maxRows
)
516 m_vLastX
+= nSeparatorSize
;
518 m_vLastY
+= nSeparatorSize
* 4;
521 else if (pTool
->IsButton())
523 if (GetWindowStyleFlag() & wxTB_HORIZONTAL
)
525 if (m_nCurrentRowsOrColumns
>= m_maxCols
)
527 m_nCurrentRowsOrColumns
= 0;
528 m_vLastX
= m_xMargin
;
529 m_vLastY
+= nMaxToolHeight
+ m_toolPacking
;
531 pTool
->m_vX
= m_vLastX
+ (nMaxToolWidth
- ((int)(nMaxToolWidth
/2) + (int)(pTool
->GetWidth()/2)));
532 if (HasFlag(wxTB_TEXT
))
533 pTool
->m_vY
= m_vLastY
+ nSeparatorSize
- 2; // just bit of adjustment
535 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- (int)(pTool
->GetHeight()/2));
536 m_vLastX
+= nMaxToolWidth
+ m_toolPacking
+ m_toolSeparation
;
540 if (m_nCurrentRowsOrColumns
>= m_maxRows
)
542 m_nCurrentRowsOrColumns
= 0;
543 m_vLastX
+= (nMaxToolWidth
+ m_toolPacking
);
544 m_vLastY
= m_yMargin
;
546 pTool
->m_vX
= m_vLastX
+ pTool
->GetWidth();
547 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
548 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- m_vTextY
) + m_toolPacking
;
550 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- (int)(pTool
->GetHeight()/2));
551 m_vLastY
+= nMaxToolHeight
+ m_toolPacking
+ m_toolSeparation
;
553 m_nCurrentRowsOrColumns
++;
557 // TODO: support the controls
560 if (m_vLastX
> m_maxWidth
)
561 m_maxWidth
= m_vLastX
;
562 if (m_vLastY
> m_maxHeight
)
563 m_maxHeight
= m_vLastY
;
565 node
= node
->GetNext();
568 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL
)
569 m_maxWidth
+= nMaxToolWidth
;
571 m_maxHeight
+= nMaxToolHeight
;
573 m_maxWidth
+= m_xMargin
;
574 m_maxHeight
+= m_yMargin
;
575 m_bInitialized
= true;
577 } // end of wxToolBar::Realize
579 // ----------------------------------------------------------------------------
581 // ----------------------------------------------------------------------------
583 void wxToolBar::OnPaint (
584 wxPaintEvent
& WXUNUSED(rEvent
)
591 static int nCount
= 0;
594 // Prevent reentry of OnPaint which would cause wxMemoryDC errors.
600 ::WinFillRect(vDc
.GetHPS(), &vDc
.m_vRclPaint
, GetBackgroundColour().GetPixel());
601 for ( wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
603 node
= node
->GetNext() )
605 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
607 if (pTool
->IsButton() )
608 DrawTool(vDc
, pTool
);
609 if (pTool
->IsSeparator())
611 wxColour
gray85(85, 85, 85);
612 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
618 vDc
.SetPen(vDarkGreyPen
);
619 if (HasFlag(wxTB_TEXT
))
621 if (HasFlag(wxTB_HORIZONTAL
))
624 nY
= pTool
->m_vY
- (m_vTextY
- 6);
625 nHeight
= (m_vTextY
- 2) + pTool
->GetHeight();
629 nX
= pTool
->m_vX
+ m_xMargin
+ 10;
630 nY
= pTool
->m_vY
+ m_vTextY
+ m_toolSeparation
;
631 nWidth
= pTool
->GetWidth() > m_vTextX
? pTool
->GetWidth() : m_vTextX
;
638 if (HasFlag(wxTB_HORIZONTAL
))
639 nHeight
= pTool
->GetHeight() - 2;
642 nX
+= m_xMargin
+ 10;
643 nY
+= m_yMargin
+ m_toolSeparation
;
644 nWidth
= pTool
->GetWidth();
647 vDc
.DrawLine(nX
, nY
, nX
+ nWidth
, nY
+ nHeight
);
651 } // end of wxToolBar::OnPaint
653 void wxToolBar::OnSize (
654 wxSizeEvent
& WXUNUSED(rEvent
)
657 #if wxUSE_CONSTRAINTS
661 } // end of wxToolBar::OnSize
663 void wxToolBar::OnKillFocus(
664 wxFocusEvent
& WXUNUSED(rEvent
)
667 OnMouseEnter(m_nPressedTool
= m_nCurrentTool
= -1);
668 } // end of wxToolBar::OnKillFocus
670 void wxToolBar::OnMouseEvent(
678 HPOINTER hPtr
= ::WinQuerySysPointer(HWND_DESKTOP
, SPTR_ARROW
, FALSE
);
680 ::WinSetPointer(HWND_DESKTOP
, hPtr
);
681 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
682 hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, TRUE
);
683 if (hWnd
!= (HWND
)GetHwnd())
689 rEvent
.GetPosition(&vX
, &vY
);
691 wxToolBarTool
* pTool
= (wxToolBarTool
*)FindToolForPosition( vX
695 if (rEvent
.LeftDown())
707 if (m_nCurrentTool
> -1)
709 if (rEvent
.LeftIsDown())
710 SpringUpButton(m_nCurrentTool
);
711 pTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
712 if (pTool
&& !pTool
->IsToggled())
714 RaiseTool( pTool
, FALSE
);
721 if (!rEvent
.IsButton())
723 if (pTool
->GetId() != m_nCurrentTool
)
726 // If the left button is kept down and moved over buttons,
727 // press those buttons.
729 if (rEvent
.LeftIsDown() && pTool
->IsEnabled())
731 SpringUpButton(m_nCurrentTool
);
732 if (pTool
->CanBeToggled())
738 wxToolBarTool
* pOldTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
740 if (pOldTool
&& !pTool
->IsToggled())
741 RaiseTool( pOldTool
, FALSE
);
742 m_nCurrentTool
= pTool
->GetId();
743 OnMouseEnter(m_nCurrentTool
);
744 if (!pTool
->GetShortHelp().empty())
748 m_pToolTip
= new wxToolTip(pTool
->GetShortHelp());
749 m_vXMouse
= (wxCoord
)vPoint
.x
;
750 m_vYMouse
= (wxCoord
)vPoint
.y
;
751 m_vToolTimer
.Start(1000L, TRUE
);
753 if (!pTool
->IsToggled())
759 // Left button pressed.
760 if (rEvent
.LeftDown() && pTool
->IsEnabled())
762 if (pTool
->CanBeToggled())
768 else if (rEvent
.RightDown())
770 OnRightClick( pTool
->GetId()
777 // Left Button Released. Only this action confirms selection.
778 // If the button is enabled and it is not a toggle tool and it is
779 // in the pressed state, then raise the button and call OnLeftClick.
781 if (rEvent
.LeftUp() && pTool
->IsEnabled() )
784 // Pass the OnLeftClick event to tool
786 if (!OnLeftClick( pTool
->GetId()
787 ,pTool
->IsToggled()) &&
788 pTool
->CanBeToggled())
791 // If it was a toggle, and OnLeftClick says No Toggle allowed,
792 // then change it back
798 } // end of wxToolBar::OnMouseEvent
800 // ----------------------------------------------------------------------------
802 // ----------------------------------------------------------------------------
804 void wxToolBar::DrawTool( wxToolBarToolBase
* pTool
)
806 wxClientDC
vDc(this);
808 DrawTool( vDc
, pTool
);
809 } // end of wxToolBar::DrawTool
811 void wxToolBar::DrawTool( wxDC
& rDc
, wxToolBarToolBase
* pToolBase
)
813 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
814 wxColour
gray85( 85,85,85 );
815 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
816 wxBitmap vBitmap
= pTool
->GetNormalBitmap();
817 bool bUseMask
= false;
818 wxMask
* pMask
= NULL
;
824 if ((pMask
= vBitmap
.GetMask()) != NULL
)
825 if (pMask
->GetMaskBitmap() != NULLHANDLE
)
828 if (!pTool
->IsToggled())
830 LowerTool(pTool
, FALSE
);
831 if (!pTool
->IsEnabled())
833 wxColour
vColor(wxT("GREY"));
835 rDc
.SetTextForeground(vColor
);
836 if (!pTool
->GetDisabledBitmap().Ok())
837 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
838 ,(long)GetBackgroundColour().GetPixel()
840 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
848 rDc
.SetTextForeground(*wxBLACK
);
849 rDc
.DrawBitmap( vBitmap
855 if (m_windowStyle
& wxTB_3DBUTTONS
)
859 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
863 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
865 rDc
.SetFont(GetFont());
866 rDc
.GetTextExtent( pTool
->GetLabel()
870 if (pTool
->GetWidth() > vX
) // large tools
872 vLeft
= pTool
->m_vX
+ (pTool
->GetWidth() - vX
);
874 rDc
.DrawText( pTool
->GetLabel()
881 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
882 rDc
.DrawText( pTool
->GetLabel()
884 ,pTool
->m_vY
+ m_vTextY
+ 4 // a bit of margin
891 wxColour
vColor(wxT("GREY"));
894 rDc
.SetTextForeground(vColor
);
895 if (!pTool
->GetDisabledBitmap().Ok())
896 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
897 ,(long)GetBackgroundColour().GetPixel()
899 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
904 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
908 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
910 rDc
.SetFont(GetFont());
911 rDc
.GetTextExtent( pTool
->GetLabel()
915 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
916 rDc
.DrawText( pTool
->GetLabel()
918 ,pTool
->m_vY
+ m_vTextY
+ 4 // a bit of margin
922 } // end of wxToolBar::DrawTool
924 // ----------------------------------------------------------------------------
926 // ----------------------------------------------------------------------------
928 void wxToolBar::SetRows(
932 wxCHECK_RET( nRows
!= 0, _T("max number of rows must be > 0") );
934 m_maxCols
= (GetToolsCount() + nRows
- 1) / nRows
;
936 } // end of wxToolBar::SetRows
938 wxToolBarToolBase
* wxToolBar::FindToolForPosition(
943 wxCoord vTBarHeight
= 0;
948 vY
= vTBarHeight
- vY
;
949 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
952 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
954 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
956 if ((vX
>= (pTool
->m_vX
- ((wxCoord
)(pTool
->GetWidth()/2) - 2))) &&
957 (vY
>= (pTool
->m_vY
- 2)) &&
958 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
959 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight() + m_vTextY
+ 2)))
966 if ((vX
>= pTool
->m_vX
) &&
967 (vY
>= pTool
->m_vY
) &&
968 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
969 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight())))
974 node
= node
->GetNext();
976 return (wxToolBarToolBase
*)NULL
;
977 } // end of wxToolBar::FindToolForPosition
979 // ----------------------------------------------------------------------------
980 // tool state change handlers
981 // ----------------------------------------------------------------------------
983 void wxToolBar::DoEnableTool(
984 wxToolBarToolBase
* pTool
985 , bool WXUNUSED(bEnable
)
989 } // end of wxToolBar::DoEnableTool
991 void wxToolBar::DoToggleTool(
992 wxToolBarToolBase
* pTool
993 , bool WXUNUSED(bToggle
)
997 } // end of wxToolBar::DoToggleTool
999 void wxToolBar::DoSetToggle(
1000 wxToolBarToolBase
* WXUNUSED(pTool
)
1001 , bool WXUNUSED(bToggle
)
1005 } // end of wxToolBar::DoSetToggle
1008 // Okay, so we've left the tool we're in ... we must check if the tool we're
1009 // leaving was a 'sprung push button' and if so, spring it back to the up
1012 void wxToolBar::SpringUpButton(
1016 wxToolBarToolBase
* pTool
= FindById(vId
);
1018 if (pTool
&& pTool
->CanBeToggled())
1020 if (pTool
->IsToggled())
1025 } // end of wxToolBar::SpringUpButton
1027 // ----------------------------------------------------------------------------
1029 // ----------------------------------------------------------------------------
1031 void wxToolBar::LowerTool ( wxToolBarToolBase
* pToolBase
,
1034 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1039 wxColour
gray85( 85,85,85 );
1040 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
1041 wxPen
vClearPen( GetBackgroundColour(), 1, wxSOLID
);
1042 wxClientDC
vDC(this);
1047 if (pTool
->IsSeparator())
1051 // We only do this for flat toolbars
1053 if (!HasFlag(wxTB_FLAT
))
1056 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
1058 if (pTool
->GetWidth() > m_vTextX
)
1060 vX
= pTool
->m_vX
- 2;
1061 vWidth
= pTool
->GetWidth() + 4;
1065 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1066 vWidth
= m_vTextX
+ 4;
1068 vY
= pTool
->m_vY
- 2;
1069 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1073 vX
= pTool
->m_vX
- 2;
1074 vY
= pTool
->m_vY
- 2;
1075 vWidth
= pTool
->GetWidth() + 4;
1076 vHeight
= pTool
->GetHeight() + 4;
1080 vDC
.SetPen(*wxWHITE_PEN
);
1081 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1082 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1083 vDC
.SetPen(vDarkGreyPen
);
1084 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1085 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1089 vDC
.SetPen(vClearPen
);
1090 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1091 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1092 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1093 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1095 } // end of WinGuiBase_CToolBarTool::LowerTool
1097 void wxToolBar::RaiseTool ( wxToolBarToolBase
* pToolBase
,
1100 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1105 wxColour
gray85( 85,85,85 );
1106 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
1107 wxPen
vClearPen( GetBackgroundColour(), 1, wxSOLID
);
1108 wxClientDC
vDC(this);
1113 if (pTool
->IsSeparator())
1116 if (!pTool
->IsEnabled())
1120 // We only do this for flat toolbars
1122 if (!HasFlag(wxTB_FLAT
))
1125 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
1127 if (pTool
->GetWidth() > m_vTextX
)
1129 vX
= pTool
->m_vX
- 2;
1130 vWidth
= pTool
->GetWidth() + 4;
1134 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1135 vWidth
= m_vTextX
+ 4;
1137 vY
= pTool
->m_vY
- 2;
1138 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1142 vX
= pTool
->m_vX
- 2;
1143 vY
= pTool
->m_vY
- 2;
1144 vWidth
= pTool
->GetWidth() + 4;
1145 vHeight
= pTool
->GetHeight() + 4;
1149 vDC
.SetPen(vDarkGreyPen
);
1150 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1151 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1152 vDC
.SetPen(*wxWHITE_PEN
);
1153 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1154 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1158 vDC
.SetPen(vClearPen
);
1159 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1160 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1161 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1162 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1164 } // end of wxToolBar::RaiseTool
1166 void wxToolBar::OnTimer ( wxTimerEvent
& rEvent
)
1168 if (rEvent
.GetId() == m_vToolTimer
.GetTimerId())
1170 wxPoint
vPos( m_vXMouse
, m_vYMouse
);
1172 m_pToolTip
->DisplayToolTipWindow(vPos
);
1173 m_vToolTimer
.Stop();
1174 m_vToolExpTimer
.Start(4000L, TRUE
);
1176 else if (rEvent
.GetId() == m_vToolExpTimer
.GetTimerId())
1178 m_pToolTip
->HideToolTipWindow();
1179 GetParent()->Refresh();
1180 m_vToolExpTimer
.Stop();
1182 } // end of wxToolBar::OnTimer
1184 #endif // ndef for wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE