]>
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
, wxToolBarBase
)
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
;
382 wxFrame
* pFrame
= wxDynamicCast(GetParent(), wxFrame
);
384 if (lStyle
& wxTB_HORIZONTAL
)
388 nWidth
= pParent
->GetClientSize().x
;
392 if (lStyle
& wxTB_TEXT
)
393 nHeight
= m_defaultHeight
+ m_vTextY
;
395 nHeight
= m_defaultHeight
;
402 nHeight
= pParent
->GetClientSize().y
;
406 if (lStyle
& wxTB_TEXT
)
407 nWidth
= m_vTextX
+ (int)(m_vTextX
/2); // a little margin
409 nWidth
= m_defaultWidth
+ (int)(m_defaultWidth
/2); // a little margin
423 } // end of wxToolBar::Create
425 wxToolBar::~wxToolBar()
432 } // end of wxToolBar::~wxToolBar
434 bool wxToolBar::Realize()
436 int nMaxToolWidth
= 0;
437 int nMaxToolHeight
= 0;
441 m_nCurrentRowsOrColumns
= 0;
442 m_vLastX
= m_xMargin
;
443 m_vLastY
= m_yMargin
;
449 // Find the maximum tool width and height
451 wxToolBarToolsList::Node
* pNode
= m_tools
.GetFirst();
455 wxToolBarTool
* pTool
= (wxToolBarTool
*)pNode
->GetData();
457 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsEmpty())
460 // Set the height according to the font and the border size
462 if (pTool
->GetWidth() > m_vTextX
)
463 nMaxToolWidth
= pTool
->GetWidth() + 4;
465 nMaxToolWidth
= m_vTextX
;
466 if (pTool
->GetHeight() + m_vTextY
> nMaxToolHeight
)
467 nMaxToolHeight
= pTool
->GetHeight() + m_vTextY
;
471 if (pTool
->GetWidth() > nMaxToolWidth
)
472 nMaxToolWidth
= pTool
->GetWidth() + 4;
473 if (pTool
->GetHeight() > nMaxToolHeight
)
474 nMaxToolHeight
= pTool
->GetHeight();
476 pNode
= pNode
->GetNext();
479 wxCoord vTbWidth
= 0L;
480 wxCoord vTbHeight
= 0L;
485 if (vTbHeight
< nMaxToolHeight
)
492 if (GetParent()->IsKindOf(CLASSINFO(wxFrame
)))
494 wxFrame
* pFrame
= wxDynamicCast(GetParent(), wxFrame
);
497 pFrame
->PositionToolBar();
501 int nSeparatorSize
= m_toolSeparation
;
503 pNode
= m_tools
.GetFirst();
506 wxToolBarTool
* pTool
= (wxToolBarTool
*)pNode
->GetData();
508 if (pTool
->IsSeparator())
510 if (GetWindowStyleFlag() & wxTB_HORIZONTAL
)
512 pTool
->m_vX
= m_vLastX
+ nSeparatorSize
;
513 pTool
->m_vHeight
= m_defaultHeight
+ m_vTextY
;
514 if (m_nCurrentRowsOrColumns
>= m_maxCols
)
515 m_vLastY
+= nSeparatorSize
;
517 m_vLastX
+= nSeparatorSize
* 4;
521 pTool
->m_vY
= m_vLastY
+ nSeparatorSize
;
522 pTool
->m_vHeight
= m_defaultHeight
+ m_vTextY
;
523 if (m_nCurrentRowsOrColumns
>= m_maxRows
)
524 m_vLastX
+= nSeparatorSize
;
526 m_vLastY
+= nSeparatorSize
* 4;
529 else if (pTool
->IsButton())
531 if (GetWindowStyleFlag() & wxTB_HORIZONTAL
)
533 if (m_nCurrentRowsOrColumns
>= m_maxCols
)
535 m_nCurrentRowsOrColumns
= 0;
536 m_vLastX
= m_xMargin
;
537 m_vLastY
+= nMaxToolHeight
+ m_toolPacking
;
539 pTool
->m_vX
= m_vLastX
+ (nMaxToolWidth
- ((int)(nMaxToolWidth
/2) + (int)(pTool
->GetWidth()/2)));
540 if (HasFlag(wxTB_TEXT
))
541 pTool
->m_vY
= m_vLastY
+ nSeparatorSize
- 2; // just bit of adjustment
543 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- (int)(pTool
->GetHeight()/2));
544 m_vLastX
+= nMaxToolWidth
+ m_toolPacking
+ m_toolSeparation
;
548 if (m_nCurrentRowsOrColumns
>= m_maxRows
)
550 m_nCurrentRowsOrColumns
= 0;
551 m_vLastX
+= (nMaxToolWidth
+ m_toolPacking
);
552 m_vLastY
= m_yMargin
;
554 pTool
->m_vX
= m_vLastX
+ pTool
->GetWidth();
555 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
556 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- m_vTextY
) + m_toolPacking
;
558 pTool
->m_vY
= m_vLastY
+ (nMaxToolHeight
- (int)(pTool
->GetHeight()/2));
559 m_vLastY
+= nMaxToolHeight
+ m_toolPacking
+ m_toolSeparation
;
561 m_nCurrentRowsOrColumns
++;
565 // TODO: support the controls
568 if (m_vLastX
> m_maxWidth
)
569 m_maxWidth
= m_vLastX
;
570 if (m_vLastY
> m_maxHeight
)
571 m_maxHeight
= m_vLastY
;
573 pNode
= pNode
->GetNext();
576 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL
)
577 m_maxWidth
+= nMaxToolWidth
;
579 m_maxHeight
+= nMaxToolHeight
;
581 m_maxWidth
+= m_xMargin
;
582 m_maxHeight
+= m_yMargin
;
583 m_bInitialized
= TRUE
;
585 } // end of wxToolBar::Realize
587 // ----------------------------------------------------------------------------
589 // ----------------------------------------------------------------------------
591 void wxToolBar::OnPaint (
592 wxPaintEvent
& WXUNUSED(rEvent
)
599 static int nCount
= 0;
602 // Prevent reentry of OnPaint which would cause wxMemoryDC errors.
608 ::WinFillRect(vDc
.GetHPS(), &vDc
.m_vRclPaint
, GetBackgroundColour().GetPixel());
609 for ( wxToolBarToolsList::Node
* pNode
= m_tools
.GetFirst();
611 pNode
= pNode
->GetNext() )
613 wxToolBarTool
* pTool
= (wxToolBarTool
*)pNode
->GetData();
615 if (pTool
->IsButton() )
616 DrawTool(vDc
, pTool
);
617 if (pTool
->IsSeparator())
619 wxPen
vDarkGreyPen( wxColour(85, 85, 85)
628 vDc
.SetPen(vDarkGreyPen
);
629 if (HasFlag(wxTB_TEXT
))
631 if (HasFlag(wxTB_HORIZONTAL
))
634 nY
= pTool
->m_vY
- (m_vTextY
- 6);
635 nHeight
= (m_vTextY
- 2) + pTool
->GetHeight();
639 nX
= pTool
->m_vX
+ m_xMargin
+ 10;
640 nY
= pTool
->m_vY
+ m_vTextY
+ m_toolSeparation
;
641 nWidth
= pTool
->GetWidth() > m_vTextX
? pTool
->GetWidth() : m_vTextX
;
648 if (HasFlag(wxTB_HORIZONTAL
))
649 nHeight
= pTool
->GetHeight() - 2;
652 nX
+= m_xMargin
+ 10;
653 nY
+= m_yMargin
+ m_toolSeparation
;
654 nWidth
= pTool
->GetWidth();
657 vDc
.DrawLine(nX
, nY
, nX
+ nWidth
, nY
+ nHeight
);
661 } // end of wxToolBar::OnPaint
663 void wxToolBar::OnSize (
664 wxSizeEvent
& WXUNUSED(rEvent
)
667 #if wxUSE_CONSTRAINTS
671 } // end of wxToolBar::OnSize
673 void wxToolBar::OnKillFocus(
674 wxFocusEvent
& WXUNUSED(rEvent
)
677 OnMouseEnter(m_nPressedTool
= m_nCurrentTool
= -1);
678 } // end of wxToolBar::OnKillFocus
680 void wxToolBar::OnMouseEvent(
688 HPOINTER hPtr
= ::WinQuerySysPointer(HWND_DESKTOP
, SPTR_ARROW
, FALSE
);
690 ::WinSetPointer(HWND_DESKTOP
, hPtr
);
691 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
692 hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, TRUE
);
693 if (hWnd
!= (HWND
)GetHwnd())
699 rEvent
.GetPosition(&vX
, &vY
);
701 wxToolBarTool
* pTool
= (wxToolBarTool
*)FindToolForPosition( vX
705 if (rEvent
.LeftDown())
717 if (m_nCurrentTool
> -1)
719 if (rEvent
.LeftIsDown())
720 SpringUpButton(m_nCurrentTool
);
721 pTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
722 if (pTool
&& !pTool
->IsToggled())
733 if (!rEvent
.IsButton())
735 if (pTool
->GetId() != m_nCurrentTool
)
738 // If the left button is kept down and moved over buttons,
739 // press those buttons.
741 if (rEvent
.LeftIsDown() && pTool
->IsEnabled())
743 SpringUpButton(m_nCurrentTool
);
744 if (pTool
->CanBeToggled())
750 wxToolBarTool
* pOldTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
752 if (pOldTool
&& !pTool
->IsToggled())
756 m_nCurrentTool
= pTool
->GetId();
757 OnMouseEnter(m_nCurrentTool
);
758 if (!pTool
->GetShortHelp().IsEmpty())
762 m_pToolTip
= new wxToolTip(pTool
->GetShortHelp());
763 m_vXMouse
= (wxCoord
)vPoint
.x
;
764 m_vYMouse
= (wxCoord
)vPoint
.y
;
765 m_vToolTimer
.Start(1000L, TRUE
);
767 if (!pTool
->IsToggled())
773 // Left button pressed.
774 if (rEvent
.LeftDown() && pTool
->IsEnabled())
776 if (pTool
->CanBeToggled())
782 else if (rEvent
.RightDown())
784 OnRightClick( pTool
->GetId()
791 // Left Button Released. Only this action confirms selection.
792 // If the button is enabled and it is not a toggle tool and it is
793 // in the pressed state, then raise the button and call OnLeftClick.
795 if (rEvent
.LeftUp() && pTool
->IsEnabled() )
798 // Pass the OnLeftClick event to tool
800 if (!OnLeftClick( pTool
->GetId()
801 ,pTool
->IsToggled()) &&
802 pTool
->CanBeToggled())
805 // If it was a toggle, and OnLeftClick says No Toggle allowed,
806 // then change it back
812 } // end of wxToolBar::OnMouseEvent
814 // ----------------------------------------------------------------------------
816 // ----------------------------------------------------------------------------
818 void wxToolBar::DrawTool(
819 wxToolBarToolBase
* pTool
822 wxClientDC
vDc(this);
827 } // end of wxToolBar::DrawTool
829 void wxToolBar::DrawTool(
831 , wxToolBarToolBase
* pToolBase
834 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
835 wxPen
vDarkGreyPen( wxColour( 85,85,85 )
839 wxPen
vWhitePen( wxT("WHITE")
843 wxPen
vBlackPen( wxT("BLACK")
847 wxBitmap vBitmap
= pTool
->GetNormalBitmap();
848 bool bUseMask
= FALSE
;
849 wxMask
* pMask
= NULL
;
856 if ((pMask
= vBitmap
.GetMask()) != NULL
)
857 if (pMask
->GetMaskBitmap() != NULLHANDLE
)
860 if (!pTool
->IsToggled())
862 LowerTool(pTool
, FALSE
);
863 if (!pTool
->IsEnabled())
865 wxColour
vColor("GREY");
867 rDc
.SetTextForeground(vColor
);
868 if (!pTool
->GetDisabledBitmap().Ok())
869 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
870 ,(long)GetBackgroundColour().GetPixel()
872 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
880 wxColour
vColor("BLACK");
882 rDc
.SetTextForeground(vColor
);
883 rDc
.DrawBitmap( vBitmap
889 if (m_windowStyle
& wxTB_3DBUTTONS
)
893 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
897 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
899 rDc
.SetFont(GetFont());
900 rDc
.GetTextExtent( pTool
->GetLabel()
904 if (pTool
->GetWidth() > vX
) // large tools
906 vLeft
= pTool
->m_vX
+ (pTool
->GetWidth() - vX
);
908 rDc
.DrawText( 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
925 wxColour
vColor("GREY");
928 rDc
.SetTextForeground(vColor
);
929 if (!pTool
->GetDisabledBitmap().Ok())
930 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
931 ,(long)GetBackgroundColour().GetPixel()
933 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
938 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
942 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
944 rDc
.SetFont(GetFont());
945 rDc
.GetTextExtent( pTool
->GetLabel()
949 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
950 rDc
.DrawText( pTool
->GetLabel()
952 ,pTool
->m_vY
+ m_vTextY
+ 4 // a bit of margin
956 } // end of wxToolBar::DrawTool
958 // ----------------------------------------------------------------------------
960 // ----------------------------------------------------------------------------
962 void wxToolBar::SetRows(
966 wxCHECK_RET( nRows
!= 0, _T("max number of rows must be > 0") );
968 m_maxCols
= (GetToolsCount() + nRows
- 1) / nRows
;
970 } // end of wxToolBar::SetRows
972 wxToolBarToolBase
* wxToolBar::FindToolForPosition(
979 wxCoord vTBarHeight
= 0;
984 vY
= vTBarHeight
- vY
;
985 wxToolBarToolsList::Node
* pNode
= m_tools
.GetFirst();
988 wxToolBarTool
* pTool
= (wxToolBarTool
*)pNode
->GetData();
990 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
992 if ((vX
>= (pTool
->m_vX
- ((wxCoord
)(pTool
->GetWidth()/2) - 2))) &&
993 (vY
>= (pTool
->m_vY
- 2)) &&
994 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
995 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight() + m_vTextY
+ 2)))
1002 if ((vX
>= pTool
->m_vX
) &&
1003 (vY
>= pTool
->m_vY
) &&
1004 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
1005 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight())))
1010 pNode
= pNode
->GetNext();
1012 return (wxToolBarToolBase
*)NULL
;
1013 } // end of wxToolBar::FindToolForPosition
1015 // ----------------------------------------------------------------------------
1016 // tool state change handlers
1017 // ----------------------------------------------------------------------------
1019 void wxToolBar::DoEnableTool(
1020 wxToolBarToolBase
* pTool
1021 , bool WXUNUSED(bEnable
)
1025 } // end of wxToolBar::DoEnableTool
1027 void wxToolBar::DoToggleTool(
1028 wxToolBarToolBase
* pTool
1029 , bool WXUNUSED(bToggle
)
1033 } // end of wxToolBar::DoToggleTool
1035 void wxToolBar::DoSetToggle(
1036 wxToolBarToolBase
* WXUNUSED(pTool
)
1037 , bool WXUNUSED(bToggle
)
1041 } // end of wxToolBar::DoSetToggle
1044 // Okay, so we've left the tool we're in ... we must check if the tool we're
1045 // leaving was a 'sprung push button' and if so, spring it back to the up
1048 void wxToolBar::SpringUpButton(
1052 wxToolBarToolBase
* pTool
= FindById(vId
);
1054 if (pTool
&& pTool
->CanBeToggled())
1056 if (pTool
->IsToggled())
1061 } // end of wxToolBar::SpringUpButton
1063 // ----------------------------------------------------------------------------
1065 // ----------------------------------------------------------------------------
1067 void wxToolBar::LowerTool (
1068 wxToolBarToolBase
* pToolBase
1072 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1077 wxPen
vDarkGreyPen( wxColour(85, 85, 85)
1081 wxPen
vWhitePen( "WHITE"
1085 wxPen
vClearPen( GetBackgroundColour()
1089 wxClientDC
vDC(this);
1094 if (pTool
->IsSeparator())
1098 // We only do this for flat toolbars
1100 if (!HasFlag(wxTB_FLAT
))
1103 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsEmpty())
1105 if (pTool
->GetWidth() > m_vTextX
)
1107 vX
= pTool
->m_vX
- 2;
1108 vWidth
= pTool
->GetWidth() + 4;
1112 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1113 vWidth
= m_vTextX
+ 4;
1115 vY
= pTool
->m_vY
- 2;
1116 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1120 vX
= pTool
->m_vX
- 2;
1121 vY
= pTool
->m_vY
- 2;
1122 vWidth
= pTool
->GetWidth() + 4;
1123 vHeight
= pTool
->GetHeight() + 4;
1127 vDC
.SetPen(vWhitePen
);
1128 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1129 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1130 vDC
.SetPen(vDarkGreyPen
);
1131 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1132 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1136 vDC
.SetPen(vClearPen
);
1137 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1138 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1139 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1140 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1142 } // end of WinGuiBase_CToolBarTool::LowerTool
1144 void wxToolBar::RaiseTool (
1145 wxToolBarToolBase
* pToolBase
1149 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1154 wxPen
vDarkGreyPen( wxColour(85, 85, 85)
1158 wxPen
vWhitePen( "WHITE"
1162 wxPen
vClearPen( GetBackgroundColour()
1166 wxClientDC
vDC(this);
1171 if (pTool
->IsSeparator())
1174 if (!pTool
->IsEnabled())
1178 // We only do this for flat toolbars
1180 if (!HasFlag(wxTB_FLAT
))
1183 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsEmpty())
1185 if (pTool
->GetWidth() > m_vTextX
)
1187 vX
= pTool
->m_vX
- 2;
1188 vWidth
= pTool
->GetWidth() + 4;
1192 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1193 vWidth
= m_vTextX
+ 4;
1195 vY
= pTool
->m_vY
- 2;
1196 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1200 vX
= pTool
->m_vX
- 2;
1201 vY
= pTool
->m_vY
- 2;
1202 vWidth
= pTool
->GetWidth() + 4;
1203 vHeight
= pTool
->GetHeight() + 4;
1207 vDC
.SetPen(vDarkGreyPen
);
1208 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1209 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1210 vDC
.SetPen(vWhitePen
);
1211 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1212 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1216 vDC
.SetPen(vClearPen
);
1217 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1218 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1219 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1220 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1222 } // end of wxToolBar::RaiseTool
1224 void wxToolBar::OnTimer (
1225 wxTimerEvent
& rEvent
1228 if (rEvent
.GetId() == m_vToolTimer
.GetTimerId())
1230 wxPoint
vPos( m_vXMouse
1234 m_pToolTip
->DisplayToolTipWindow(vPos
);
1235 m_vToolTimer
.Stop();
1236 m_vToolExpTimer
.Start(4000L, TRUE
);
1238 else if (rEvent
.GetId() == m_vToolExpTimer
.GetTimerId())
1240 m_pToolTip
->HideToolTipWindow();
1241 GetParent()->Refresh();
1242 m_vToolExpTimer
.Stop();
1244 } // end of wxToolBar::OnTimer
1246 #endif // ndef for wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE