]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/toolbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
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
18 #include "wx/settings.h"
19 #include "wx/window.h"
22 #include "wx/dcclient.h"
23 #include "wx/dcmemory.h"
26 #include "wx/tooltip.h"
27 #include "wx/toolbar.h"
29 bool wxToolBar::m_bInitialized
= FALSE
;
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 class wxToolBarTool
: public wxToolBarToolBase
38 inline wxToolBarTool( wxToolBar
* pTbar
40 ,const wxString
& rsLabel
41 ,const wxBitmap
& rBitmap1
42 ,const wxBitmap
& rBitmap2
44 ,wxObject
* pClientData
45 ,const wxString
& rsShortHelpString
46 ,const wxString
& rsLongHelpString
47 ) : wxToolBarToolBase( pTbar
60 inline wxToolBarTool( wxToolBar
* pTbar
62 ) : wxToolBarToolBase( pTbar
68 void SetSize(const wxSize
& rSize
)
74 wxCoord
GetWidth(void) const { return m_vWidth
; }
75 wxCoord
GetHeight(void) const { return m_vHeight
; }
81 }; // end of CLASS wxToolBarTool
83 // ----------------------------------------------------------------------------
85 // ----------------------------------------------------------------------------
87 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxControl
)
89 BEGIN_EVENT_TABLE(wxToolBar
, wxToolBarBase
)
90 EVT_SIZE(wxToolBar::OnSize
)
91 EVT_PAINT(wxToolBar::OnPaint
)
92 EVT_KILL_FOCUS(wxToolBar::OnKillFocus
)
93 EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent
)
94 EVT_TIMER(-1, wxToolBar::OnTimer
)
97 // ============================================================================
99 // ============================================================================
101 // ----------------------------------------------------------------------------
102 // tool bar tools creation
103 // ----------------------------------------------------------------------------
105 wxToolBarToolBase
* wxToolBar::CreateTool(
107 , const wxString
& rsLabel
108 , const wxBitmap
& rBmpNormal
109 , const wxBitmap
& rBmpDisabled
111 , wxObject
* pClientData
112 , const wxString
& rsShortHelp
113 , const wxString
& rsLongHelp
116 return new wxToolBarTool( this
126 } // end of wxToolBarSimple::CreateTool
128 wxToolBarToolBase
*wxToolBar::CreateTool(
132 return new wxToolBarTool( this
135 } // end of wxToolBarSimple::CreateTool
137 // ----------------------------------------------------------------------------
138 // wxToolBarSimple creation
139 // ----------------------------------------------------------------------------
141 void wxToolBar::Init()
143 m_nCurrentRowsOrColumns
= 0;
145 m_vLastX
= m_vLastY
= 0;
146 m_vMaxWidth
= m_vMaxHeight
= 0;
147 m_nPressedTool
= m_nCurrentTool
= -1;
148 m_vXPos
= m_vYPos
= -1;
149 m_vTextX
= m_vTextY
= 0;
152 m_toolSeparation
= 5;
155 m_defaultHeight
= 15;
158 } // end of wxToolBar::Init
160 wxToolBarToolBase
* wxToolBar::DoAddTool(
162 , const wxString
& rsLabel
163 , const wxBitmap
& rBitmap
164 , const wxBitmap
& rBmpDisabled
166 , const wxString
& rsShortHelp
167 , const wxString
& rsLongHelp
168 , wxObject
* pClientData
174 // Rememeber the position for DoInsertTool()
179 return wxToolBarBase::DoAddTool( vId
190 } // end of wxToolBar::DoAddTool
192 bool wxToolBar::DeleteTool(
196 bool bOk
= wxToolBarBase::DeleteTool(nId
);
203 } // end of wxToolBar::DeleteTool
205 bool wxToolBar::DeleteToolByPos(
209 bool bOk
= wxToolBarBase::DeleteToolByPos(nPos
);
216 } // end of wxToolBar::DeleteTool
218 wxToolBarToolBase
* wxToolBar::InsertControl(
220 , wxControl
* pControl
223 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertControl( nPos
232 } // end of wxToolBar::InsertControl
234 wxToolBarToolBase
* wxToolBar::InsertSeparator(
238 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertSeparator(nPos
);
246 } // end of wxToolBar::InsertSeparator
248 wxToolBarToolBase
* wxToolBar::InsertTool(
251 , const wxString
& rsLabel
252 , const wxBitmap
& rBitmap
253 , const wxBitmap
& rBmpDisabled
255 , const wxString
& rsShortHelp
256 , const wxString
& rsLongHelp
257 , wxObject
* pClientData
260 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertTool( nPos
276 } // end of wxToolBar::InsertTool
278 bool wxToolBar::DoInsertTool(
279 size_t WXUNUSED(nPos
)
280 , wxToolBarToolBase
* pToolBase
283 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
285 pTool
->m_vX
= m_vXPos
;
286 if (pTool
->m_vX
== -1)
287 pTool
->m_vX
= m_xMargin
;
289 pTool
->m_vY
= m_vYPos
;
290 if (pTool
->m_vY
== -1)
291 pTool
->m_vX
= m_yMargin
;
293 pTool
->SetSize(GetToolSize());
295 if (pTool
->IsButton())
298 // Calculate reasonable max size in case Layout() not called
300 if ((pTool
->m_vX
+ pTool
->GetNormalBitmap().GetWidth() + m_xMargin
) > m_vMaxWidth
)
301 m_vMaxWidth
= (wxCoord
)((pTool
->m_vX
+ pTool
->GetWidth() + m_xMargin
));
303 if ((pTool
->m_vY
+ pTool
->GetNormalBitmap().GetHeight() + m_yMargin
) > m_vMaxHeight
)
304 m_vMaxHeight
= (wxCoord
)((pTool
->m_vY
+ pTool
->GetHeight() + m_yMargin
));
307 } // end of wxToolBar::DoInsertTool
309 bool wxToolBar::DoDeleteTool(
310 size_t WXUNUSED(nPos
)
311 , wxToolBarToolBase
* pTool
317 } // end of wxToolBar::DoDeleteTool
319 bool wxToolBar::Create(
322 , const wxPoint
& rPos
323 , const wxSize
& rSize
325 , const wxString
& rsName
328 if ( !wxWindow::Create( pParent
337 // Set it to grey (or other 3D face colour)
338 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR
));
339 SetFont(*wxSMALL_FONT
);
341 if (GetWindowStyleFlag() & wxTB_VERTICAL
)
346 m_maxRows
= 32000; // a lot
355 m_maxCols
= 32000; // a lot
357 SetCursor(*wxSTANDARD_CURSOR
);
360 // The toolbar's tools, if they have labels and the winTB_TEXT
361 // style is set, then we need to take into account the size of
362 // the text when drawing tool bitmaps and the text
364 if (HasFlag(wxTB_TEXT
))
366 wxClientDC
vDC(this);
368 vDC
.SetFont(GetFont());
369 vDC
.GetTextExtent( "XXXX"
380 int nWidth
= rSize
.x
;
381 int nHeight
= rSize
.y
;
383 if (lStyle
& wxTB_HORIZONTAL
)
387 nWidth
= pParent
->GetClientSize().x
;
391 if (lStyle
& wxTB_TEXT
)
392 nHeight
= m_defaultHeight
+ m_vTextY
;
394 nHeight
= m_defaultHeight
;
401 nHeight
= pParent
->GetClientSize().y
;
405 if (lStyle
& wxTB_TEXT
)
406 nWidth
= m_vTextX
+ (int)(m_vTextX
/2); // a little margin
408 nWidth
= m_defaultWidth
+ (int)(m_defaultWidth
/2); // a little margin
422 } // end of wxToolBar::Create
424 wxToolBar::~wxToolBar()
431 } // end of wxToolBar::~wxToolBar
433 bool wxToolBar::Realize()
435 int nMaxToolWidth
= 0;
436 int nMaxToolHeight
= 0;
438 m_nCurrentRowsOrColumns
= 0;
439 m_vLastX
= m_xMargin
;
440 m_vLastY
= m_yMargin
;
446 // Find the maximum tool width and height
448 wxToolBarToolsList::Node
* pNode
= m_tools
.GetFirst();
452 wxToolBarTool
* pTool
= (wxToolBarTool
*)pNode
->GetData();
454 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsEmpty())
457 // Set the height according to the font and the border size
459 if (pTool
->GetWidth() > m_vTextX
)
460 nMaxToolWidth
= pTool
->GetWidth() + 4;
462 nMaxToolWidth
= m_vTextX
;
463 if (pTool
->GetHeight() + m_vTextY
> nMaxToolHeight
)
464 nMaxToolHeight
= pTool
->GetHeight() + m_vTextY
;
468 if (pTool
->GetWidth() > nMaxToolWidth
)
469 nMaxToolWidth
= pTool
->GetWidth() + 4;
470 if (pTool
->GetHeight() > nMaxToolHeight
)
471 nMaxToolHeight
= pTool
->GetHeight();
473 pNode
= pNode
->GetNext();
476 wxCoord vTbWidth
= 0L;
477 wxCoord vTbHeight
= 0L;
482 if (vTbHeight
< nMaxToolHeight
)
489 if (GetParent()->IsKindOf(CLASSINFO(wxFrame
)))
491 wxFrame
* pFrame
= wxDynamicCast(GetParent(), wxFrame
);
494 pFrame
->PositionToolBar();
498 int nSeparatorSize
= m_toolSeparation
;
500 pNode
= m_tools
.GetFirst();
503 wxToolBarTool
* pTool
= (wxToolBarTool
*)pNode
->GetData();
505 if (pTool
->IsSeparator())
507 if (GetWindowStyleFlag() & wxTB_HORIZONTAL
)
509 pTool
->m_vX
= m_vLastX
+ nSeparatorSize
;
510 pTool
->m_vHeight
= m_defaultHeight
+ m_vTextY
;
511 if (m_nCurrentRowsOrColumns
>= m_maxCols
)
512 m_vLastY
+= nSeparatorSize
;
514 m_vLastX
+= nSeparatorSize
* 4;
518 pTool
->m_vY
= m_vLastY
+ nSeparatorSize
;
519 pTool
->m_vHeight
= m_defaultHeight
+ m_vTextY
;
520 if (m_nCurrentRowsOrColumns
>= m_maxRows
)
521 m_vLastX
+= nSeparatorSize
;
523 m_vLastY
+= nSeparatorSize
* 4;
526 else if (pTool
->IsButton())
528 if (GetWindowStyleFlag() & wxTB_HORIZONTAL
)
530 if (m_nCurrentRowsOrColumns
>= m_maxCols
)
532 m_nCurrentRowsOrColumns
= 0;
533 m_vLastX
= m_xMargin
;
534 m_vLastY
+= nMaxToolHeight
+ m_toolPacking
;
536 pTool
->m_vX
= m_vLastX
+ (nMaxToolWidth
- ((int)(nMaxToolWidth
/2) + (int)(pTool
->GetWidth()/2)));
537 if (HasFlag(wxTB_TEXT
))
538 pTool
->m_vY
= m_vLastY
+ nSeparatorSize
- 2; // just bit of adjustment
540 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- (int)(pTool
->GetHeight()/2));
541 m_vLastX
+= nMaxToolWidth
+ m_toolPacking
+ m_toolSeparation
;
545 if (m_nCurrentRowsOrColumns
>= m_maxRows
)
547 m_nCurrentRowsOrColumns
= 0;
548 m_vLastX
+= (nMaxToolWidth
+ m_toolPacking
);
549 m_vLastY
= m_yMargin
;
551 pTool
->m_vX
= m_vLastX
+ pTool
->GetWidth();
552 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
553 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- m_vTextY
) + m_toolPacking
;
555 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- (int)(pTool
->GetHeight()/2));
556 m_vLastY
+= nMaxToolHeight
+ m_toolPacking
+ m_toolSeparation
;
558 m_nCurrentRowsOrColumns
++;
562 // TODO: support the controls
565 if (m_vLastX
> m_maxWidth
)
566 m_maxWidth
= m_vLastX
;
567 if (m_vLastY
> m_maxHeight
)
568 m_maxHeight
= m_vLastY
;
570 pNode
= pNode
->GetNext();
573 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL
)
574 m_maxWidth
+= nMaxToolWidth
;
576 m_maxHeight
+= nMaxToolHeight
;
578 m_maxWidth
+= m_xMargin
;
579 m_maxHeight
+= m_yMargin
;
580 m_bInitialized
= TRUE
;
582 } // end of wxToolBar::Realize
584 // ----------------------------------------------------------------------------
586 // ----------------------------------------------------------------------------
588 void wxToolBar::OnPaint (
589 wxPaintEvent
& WXUNUSED(rEvent
)
596 static int nCount
= 0;
599 // Prevent reentry of OnPaint which would cause wxMemoryDC errors.
605 ::WinFillRect(vDc
.GetHPS(), &vDc
.m_vRclPaint
, GetBackgroundColour().GetPixel());
606 for ( wxToolBarToolsList::Node
* pNode
= m_tools
.GetFirst();
608 pNode
= pNode
->GetNext() )
610 wxToolBarTool
* pTool
= (wxToolBarTool
*)pNode
->GetData();
612 if (pTool
->IsButton() )
613 DrawTool(vDc
, pTool
);
614 if (pTool
->IsSeparator())
616 wxPen
vDarkGreyPen( wxColour(85, 85, 85)
625 vDc
.SetPen(vDarkGreyPen
);
626 if (HasFlag(wxTB_TEXT
))
628 if (HasFlag(wxTB_HORIZONTAL
))
631 nY
= pTool
->m_vY
- (m_vTextY
- 6);
632 nHeight
= (m_vTextY
- 2) + pTool
->GetHeight();
636 nX
= pTool
->m_vX
+ m_xMargin
+ 10;
637 nY
= pTool
->m_vY
+ m_vTextY
+ m_toolSeparation
;
638 nWidth
= pTool
->GetWidth() > m_vTextX
? pTool
->GetWidth() : m_vTextX
;
645 if (HasFlag(wxTB_HORIZONTAL
))
646 nHeight
= pTool
->GetHeight() - 2;
649 nX
+= m_xMargin
+ 10;
650 nY
+= m_yMargin
+ m_toolSeparation
;
651 nWidth
= pTool
->GetWidth();
654 vDc
.DrawLine(nX
, nY
, nX
+ nWidth
, nY
+ nHeight
);
658 } // end of wxToolBar::OnPaint
660 void wxToolBar::OnSize (
661 wxSizeEvent
& WXUNUSED(rEvent
)
664 #if wxUSE_CONSTRAINTS
668 } // end of wxToolBar::OnSize
670 void wxToolBar::OnKillFocus(
671 wxFocusEvent
& WXUNUSED(rEvent
)
674 OnMouseEnter(m_nPressedTool
= m_nCurrentTool
= -1);
675 } // end of wxToolBar::OnKillFocus
677 void wxToolBar::OnMouseEvent(
685 HPOINTER hPtr
= ::WinQuerySysPointer(HWND_DESKTOP
, SPTR_ARROW
, FALSE
);
687 ::WinSetPointer(HWND_DESKTOP
, hPtr
);
688 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
689 hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, TRUE
);
690 if (hWnd
!= (HWND
)GetHwnd())
696 rEvent
.GetPosition(&vX
, &vY
);
698 wxToolBarTool
* pTool
= (wxToolBarTool
*)FindToolForPosition( vX
702 if (rEvent
.LeftDown())
714 if (m_nCurrentTool
> -1)
716 if (rEvent
.LeftIsDown())
717 SpringUpButton(m_nCurrentTool
);
718 pTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
719 if (pTool
&& !pTool
->IsToggled())
730 if (!rEvent
.IsButton())
732 if (pTool
->GetId() != m_nCurrentTool
)
735 // If the left button is kept down and moved over buttons,
736 // press those buttons.
738 if (rEvent
.LeftIsDown() && pTool
->IsEnabled())
740 SpringUpButton(m_nCurrentTool
);
741 if (pTool
->CanBeToggled())
747 wxToolBarTool
* pOldTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
749 if (pOldTool
&& !pTool
->IsToggled())
753 m_nCurrentTool
= pTool
->GetId();
754 OnMouseEnter(m_nCurrentTool
);
755 if (!pTool
->GetShortHelp().IsEmpty())
759 m_pToolTip
= new wxToolTip(pTool
->GetShortHelp());
760 m_vXMouse
= (wxCoord
)vPoint
.x
;
761 m_vYMouse
= (wxCoord
)vPoint
.y
;
762 m_vToolTimer
.Start(1000L, TRUE
);
764 if (!pTool
->IsToggled())
770 // Left button pressed.
771 if (rEvent
.LeftDown() && pTool
->IsEnabled())
773 if (pTool
->CanBeToggled())
779 else if (rEvent
.RightDown())
781 OnRightClick( pTool
->GetId()
788 // Left Button Released. Only this action confirms selection.
789 // If the button is enabled and it is not a toggle tool and it is
790 // in the pressed state, then raise the button and call OnLeftClick.
792 if (rEvent
.LeftUp() && pTool
->IsEnabled() )
795 // Pass the OnLeftClick event to tool
797 if (!OnLeftClick( pTool
->GetId()
798 ,pTool
->IsToggled()) &&
799 pTool
->CanBeToggled())
802 // If it was a toggle, and OnLeftClick says No Toggle allowed,
803 // then change it back
809 } // end of wxToolBar::OnMouseEvent
811 // ----------------------------------------------------------------------------
813 // ----------------------------------------------------------------------------
815 void wxToolBar::DrawTool(
816 wxToolBarToolBase
* pTool
819 wxClientDC
vDc(this);
824 } // end of wxToolBar::DrawTool
826 void wxToolBar::DrawTool(
828 , wxToolBarToolBase
* pToolBase
831 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
832 wxPen
vDarkGreyPen( wxColour( 85,85,85 )
836 wxPen
vWhitePen( wxT("WHITE")
840 wxPen
vBlackPen( wxT("BLACK")
844 wxBitmap vBitmap
= pTool
->GetNormalBitmap();
845 bool bUseMask
= FALSE
;
846 wxMask
* pMask
= NULL
;
852 if ((pMask
= vBitmap
.GetMask()) != NULL
)
853 if (pMask
->GetMaskBitmap() != NULLHANDLE
)
856 if (!pTool
->IsToggled())
858 LowerTool(pTool
, FALSE
);
859 if (!pTool
->IsEnabled())
861 wxColour
vColor("GREY");
863 rDc
.SetTextForeground(vColor
);
864 if (!pTool
->GetDisabledBitmap().Ok())
865 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
866 ,(long)GetBackgroundColour().GetPixel()
868 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
876 wxColour
vColor("BLACK");
878 rDc
.SetTextForeground(vColor
);
879 rDc
.DrawBitmap( vBitmap
885 if (m_windowStyle
& wxTB_3DBUTTONS
)
889 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
893 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
895 rDc
.SetFont(GetFont());
896 rDc
.GetTextExtent( pTool
->GetLabel()
900 if (pTool
->GetWidth() > vX
) // large tools
902 vLeft
= pTool
->m_vX
+ (pTool
->GetWidth() - vX
);
904 rDc
.DrawText( pTool
->GetLabel()
911 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
912 rDc
.DrawText( pTool
->GetLabel()
914 ,pTool
->m_vY
+ m_vTextY
+ 4 // a bit of margin
921 wxColour
vColor("GREY");
924 rDc
.SetTextForeground(vColor
);
925 if (!pTool
->GetDisabledBitmap().Ok())
926 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
927 ,(long)GetBackgroundColour().GetPixel()
929 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
934 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
938 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
940 rDc
.SetFont(GetFont());
941 rDc
.GetTextExtent( pTool
->GetLabel()
945 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
946 rDc
.DrawText( pTool
->GetLabel()
948 ,pTool
->m_vY
+ m_vTextY
+ 4 // a bit of margin
952 } // end of wxToolBar::DrawTool
954 // ----------------------------------------------------------------------------
956 // ----------------------------------------------------------------------------
958 void wxToolBar::SetRows(
962 wxCHECK_RET( nRows
!= 0, _T("max number of rows must be > 0") );
964 m_maxCols
= (GetToolsCount() + nRows
- 1) / nRows
;
966 } // end of wxToolBar::SetRows
968 wxToolBarToolBase
* wxToolBar::FindToolForPosition(
973 wxCoord vTBarHeight
= 0;
978 vY
= vTBarHeight
- vY
;
979 wxToolBarToolsList::Node
* pNode
= m_tools
.GetFirst();
982 wxToolBarTool
* pTool
= (wxToolBarTool
*)pNode
->GetData();
984 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
986 if ((vX
>= (pTool
->m_vX
- ((wxCoord
)(pTool
->GetWidth()/2) - 2))) &&
987 (vY
>= (pTool
->m_vY
- 2)) &&
988 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
989 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight() + m_vTextY
+ 2)))
996 if ((vX
>= pTool
->m_vX
) &&
997 (vY
>= pTool
->m_vY
) &&
998 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
999 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight())))
1004 pNode
= pNode
->GetNext();
1006 return (wxToolBarToolBase
*)NULL
;
1007 } // end of wxToolBar::FindToolForPosition
1009 // ----------------------------------------------------------------------------
1010 // tool state change handlers
1011 // ----------------------------------------------------------------------------
1013 void wxToolBar::DoEnableTool(
1014 wxToolBarToolBase
* pTool
1015 , bool WXUNUSED(bEnable
)
1019 } // end of wxToolBar::DoEnableTool
1021 void wxToolBar::DoToggleTool(
1022 wxToolBarToolBase
* pTool
1023 , bool WXUNUSED(bToggle
)
1027 } // end of wxToolBar::DoToggleTool
1029 void wxToolBar::DoSetToggle(
1030 wxToolBarToolBase
* WXUNUSED(pTool
)
1031 , bool WXUNUSED(bToggle
)
1035 } // end of wxToolBar::DoSetToggle
1038 // Okay, so we've left the tool we're in ... we must check if the tool we're
1039 // leaving was a 'sprung push button' and if so, spring it back to the up
1042 void wxToolBar::SpringUpButton(
1046 wxToolBarToolBase
* pTool
= FindById(vId
);
1048 if (pTool
&& pTool
->CanBeToggled())
1050 if (pTool
->IsToggled())
1055 } // end of wxToolBar::SpringUpButton
1057 // ----------------------------------------------------------------------------
1059 // ----------------------------------------------------------------------------
1061 void wxToolBar::LowerTool (
1062 wxToolBarToolBase
* pToolBase
1066 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1071 wxPen
vDarkGreyPen( wxColour(85, 85, 85)
1075 wxPen
vWhitePen( "WHITE"
1079 wxPen
vClearPen( GetBackgroundColour()
1083 wxClientDC
vDC(this);
1088 if (pTool
->IsSeparator())
1092 // We only do this for flat toolbars
1094 if (!HasFlag(wxTB_FLAT
))
1097 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsEmpty())
1099 if (pTool
->GetWidth() > m_vTextX
)
1101 vX
= pTool
->m_vX
- 2;
1102 vWidth
= pTool
->GetWidth() + 4;
1106 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1107 vWidth
= m_vTextX
+ 4;
1109 vY
= pTool
->m_vY
- 2;
1110 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1114 vX
= pTool
->m_vX
- 2;
1115 vY
= pTool
->m_vY
- 2;
1116 vWidth
= pTool
->GetWidth() + 4;
1117 vHeight
= pTool
->GetHeight() + 4;
1121 vDC
.SetPen(vWhitePen
);
1122 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1123 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1124 vDC
.SetPen(vDarkGreyPen
);
1125 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1126 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1130 vDC
.SetPen(vClearPen
);
1131 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1132 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1133 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1134 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1136 } // end of WinGuiBase_CToolBarTool::LowerTool
1138 void wxToolBar::RaiseTool (
1139 wxToolBarToolBase
* pToolBase
1143 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1148 wxPen
vDarkGreyPen( wxColour(85, 85, 85)
1152 wxPen
vWhitePen( "WHITE"
1156 wxPen
vClearPen( GetBackgroundColour()
1160 wxClientDC
vDC(this);
1165 if (pTool
->IsSeparator())
1168 if (!pTool
->IsEnabled())
1172 // We only do this for flat toolbars
1174 if (!HasFlag(wxTB_FLAT
))
1177 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsEmpty())
1179 if (pTool
->GetWidth() > m_vTextX
)
1181 vX
= pTool
->m_vX
- 2;
1182 vWidth
= pTool
->GetWidth() + 4;
1186 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1187 vWidth
= m_vTextX
+ 4;
1189 vY
= pTool
->m_vY
- 2;
1190 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1194 vX
= pTool
->m_vX
- 2;
1195 vY
= pTool
->m_vY
- 2;
1196 vWidth
= pTool
->GetWidth() + 4;
1197 vHeight
= pTool
->GetHeight() + 4;
1201 vDC
.SetPen(vDarkGreyPen
);
1202 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1203 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1204 vDC
.SetPen(vWhitePen
);
1205 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1206 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1210 vDC
.SetPen(vClearPen
);
1211 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1212 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1213 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1214 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1216 } // end of wxToolBar::RaiseTool
1218 void wxToolBar::OnTimer (
1219 wxTimerEvent
& rEvent
1222 if (rEvent
.GetId() == m_vToolTimer
.GetTimerId())
1224 wxPoint
vPos( m_vXMouse
1228 m_pToolTip
->DisplayToolTipWindow(vPos
);
1229 m_vToolTimer
.Stop();
1230 m_vToolExpTimer
.Start(4000L, TRUE
);
1232 else if (rEvent
.GetId() == m_vToolExpTimer
.GetTimerId())
1234 m_pToolTip
->HideToolTipWindow();
1235 GetParent()->Refresh();
1236 m_vToolExpTimer
.Stop();
1238 } // end of wxToolBar::OnTimer
1240 #endif // ndef for wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE