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"
29 #include "wx/os2/dcclient.h"
31 bool wxToolBar::m_bInitialized
= false;
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 class wxToolBarTool
: public wxToolBarToolBase
40 inline wxToolBarTool( wxToolBar
* pTbar
42 ,const wxString
& rsLabel
43 ,const wxBitmap
& rBitmap1
44 ,const wxBitmap
& rBitmap2
46 ,wxObject
* pClientData
47 ,const wxString
& rsShortHelpString
48 ,const wxString
& rsLongHelpString
49 ) : wxToolBarToolBase( pTbar
62 inline wxToolBarTool( wxToolBar
* pTbar
64 ,const wxString
& label
65 ) : wxToolBarToolBase( pTbar
72 void SetSize(const wxSize
& rSize
)
78 wxCoord
GetWidth(void) const { return m_vWidth
; }
79 wxCoord
GetHeight(void) const { return m_vHeight
; }
85 }; // end of CLASS wxToolBarTool
87 // ----------------------------------------------------------------------------
89 // ----------------------------------------------------------------------------
91 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxControl
)
93 BEGIN_EVENT_TABLE(wxToolBar
, wxToolBarBase
)
94 EVT_SIZE(wxToolBar::OnSize
)
95 EVT_PAINT(wxToolBar::OnPaint
)
96 EVT_KILL_FOCUS(wxToolBar::OnKillFocus
)
97 EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent
)
98 EVT_TIMER(-1, wxToolBar::OnTimer
)
101 // ============================================================================
103 // ============================================================================
105 // ----------------------------------------------------------------------------
106 // tool bar tools creation
107 // ----------------------------------------------------------------------------
109 wxToolBarToolBase
* wxToolBar::CreateTool(
111 , const wxString
& rsLabel
112 , const wxBitmap
& rBmpNormal
113 , const wxBitmap
& rBmpDisabled
115 , wxObject
* pClientData
116 , const wxString
& rsShortHelp
117 , const wxString
& rsLongHelp
120 return new wxToolBarTool( this
130 } // end of wxToolBarSimple::CreateTool
132 wxToolBarToolBase
*wxToolBar::CreateTool(
134 , const wxString
& label
137 return new wxToolBarTool( this
141 } // end of wxToolBarSimple::CreateTool
143 // ----------------------------------------------------------------------------
144 // wxToolBarSimple creation
145 // ----------------------------------------------------------------------------
147 void wxToolBar::Init()
149 m_nCurrentRowsOrColumns
= 0;
151 m_vLastX
= m_vLastY
= 0;
152 m_vMaxWidth
= m_vMaxHeight
= 0;
153 m_nPressedTool
= m_nCurrentTool
= -1;
154 m_vXPos
= m_vYPos
= -1;
155 m_vTextX
= m_vTextY
= 0;
158 m_toolSeparation
= 5;
161 m_defaultHeight
= 15;
164 } // end of wxToolBar::Init
166 wxToolBarToolBase
* wxToolBar::DoAddTool(
168 , const wxString
& rsLabel
169 , const wxBitmap
& rBitmap
170 , const wxBitmap
& rBmpDisabled
172 , const wxString
& rsShortHelp
173 , const wxString
& rsLongHelp
174 , wxObject
* pClientData
180 // Rememeber the position for DoInsertTool()
185 return wxToolBarBase::DoAddTool( vId
196 } // end of wxToolBar::DoAddTool
198 bool wxToolBar::DeleteTool(
202 bool bOk
= wxToolBarBase::DeleteTool(nId
);
209 } // end of wxToolBar::DeleteTool
211 bool wxToolBar::DeleteToolByPos(
215 bool bOk
= wxToolBarBase::DeleteToolByPos(nPos
);
222 } // end of wxToolBar::DeleteTool
224 wxToolBarToolBase
* wxToolBar::InsertControl(
226 , wxControl
* pControl
229 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertControl( nPos
238 } // end of wxToolBar::InsertControl
240 wxToolBarToolBase
* wxToolBar::InsertSeparator(
244 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertSeparator(nPos
);
252 } // end of wxToolBar::InsertSeparator
254 wxToolBarToolBase
* wxToolBar::InsertTool(
257 , const wxString
& rsLabel
258 , const wxBitmap
& rBitmap
259 , const wxBitmap
& rBmpDisabled
261 , const wxString
& rsShortHelp
262 , const wxString
& rsLongHelp
263 , wxObject
* pClientData
266 wxToolBarToolBase
* pTool
= wxToolBarBase::InsertTool( nPos
282 } // end of wxToolBar::InsertTool
284 bool wxToolBar::DoInsertTool( size_t WXUNUSED(nPos
),
285 wxToolBarToolBase
* pToolBase
)
287 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
289 pTool
->m_vX
= m_vXPos
;
290 if (pTool
->m_vX
== -1)
291 pTool
->m_vX
= m_xMargin
;
293 pTool
->m_vY
= m_vYPos
;
294 if (pTool
->m_vY
== -1)
295 pTool
->m_vX
= m_yMargin
;
297 pTool
->SetSize(GetToolSize());
299 if (pTool
->IsButton())
302 // Calculate reasonable max size in case Layout() not called
304 if ((pTool
->m_vX
+ pTool
->GetNormalBitmap().GetWidth() + m_xMargin
) > m_vMaxWidth
)
305 m_vMaxWidth
= (wxCoord
)((pTool
->m_vX
+ pTool
->GetWidth() + m_xMargin
));
307 if ((pTool
->m_vY
+ pTool
->GetNormalBitmap().GetHeight() + m_yMargin
) > m_vMaxHeight
)
308 m_vMaxHeight
= (wxCoord
)((pTool
->m_vY
+ pTool
->GetHeight() + m_yMargin
));
311 } // end of wxToolBar::DoInsertTool
313 bool wxToolBar::DoDeleteTool( size_t WXUNUSED(nPos
),
314 wxToolBarToolBase
* pTool
)
319 } // end of wxToolBar::DoDeleteTool
321 bool wxToolBar::Create( wxWindow
* pParent
,
326 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_LEFT
| wxTB_RIGHT
))
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( wxT("XXXX")
380 int nWidth
= rSize
.x
;
381 int nHeight
= rSize
.y
;
383 if (lStyle
& (wxTB_TOP
| wxTB_BOTTOM
))
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::compatibility_iterator node
= m_tools
.GetFirst();
452 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
454 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
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 node
= node
->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 node
= m_tools
.GetFirst();
503 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
505 if (pTool
->IsSeparator())
507 if (GetWindowStyleFlag() & (wxTB_TOP
| wxTB_BOTTOM
))
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_TOP
| wxTB_BOTTOM
))
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 node
= node
->GetNext();
573 if (GetWindowStyleFlag() & (wxTB_TOP
| wxTB_BOTTOM
))
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 wxPMDCImpl
*impl
= (wxPMDCImpl
*) vDc
.GetImpl();
606 ::WinFillRect(impl
->GetHPS(), &impl
->m_vRclPaint
, GetBackgroundColour().GetPixel());
607 for ( wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
609 node
= node
->GetNext() )
611 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
613 if (pTool
->IsButton() )
614 DrawTool(vDc
, pTool
);
615 if (pTool
->IsSeparator())
617 wxColour
gray85(85, 85, 85);
618 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
624 vDc
.SetPen(vDarkGreyPen
);
625 if (HasFlag(wxTB_TEXT
))
627 if (HasFlag(wxTB_TOP
) || HasFlag(wxTB_BOTTOM
))
630 nY
= pTool
->m_vY
- (m_vTextY
- 6);
631 nHeight
= (m_vTextY
- 2) + pTool
->GetHeight();
635 nX
= pTool
->m_vX
+ m_xMargin
+ 10;
636 nY
= pTool
->m_vY
+ m_vTextY
+ m_toolSeparation
;
637 nWidth
= pTool
->GetWidth() > m_vTextX
? pTool
->GetWidth() : m_vTextX
;
644 if (HasFlag(wxTB_TOP
) || HasFlag(wxTB_BOTTOM
))
645 nHeight
= pTool
->GetHeight() - 2;
648 nX
+= m_xMargin
+ 10;
649 nY
+= m_yMargin
+ m_toolSeparation
;
650 nWidth
= pTool
->GetWidth();
653 vDc
.DrawLine(nX
, nY
, nX
+ nWidth
, nY
+ nHeight
);
657 } // end of wxToolBar::OnPaint
659 void wxToolBar::OnSize (
660 wxSizeEvent
& WXUNUSED(rEvent
)
663 #if wxUSE_CONSTRAINTS
667 } // end of wxToolBar::OnSize
669 void wxToolBar::OnKillFocus(
670 wxFocusEvent
& WXUNUSED(rEvent
)
673 OnMouseEnter(m_nPressedTool
= m_nCurrentTool
= -1);
674 } // end of wxToolBar::OnKillFocus
676 void wxToolBar::OnMouseEvent(
684 HPOINTER hPtr
= ::WinQuerySysPointer(HWND_DESKTOP
, SPTR_ARROW
, FALSE
);
686 ::WinSetPointer(HWND_DESKTOP
, hPtr
);
687 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
688 hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, TRUE
);
689 if (hWnd
!= (HWND
)GetHwnd())
695 rEvent
.GetPosition(&vX
, &vY
);
697 wxToolBarTool
* pTool
= (wxToolBarTool
*)FindToolForPosition( vX
701 if (rEvent
.LeftDown())
713 if (m_nCurrentTool
> -1)
715 if (rEvent
.LeftIsDown())
716 SpringUpButton(m_nCurrentTool
);
717 pTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
718 if (pTool
&& !pTool
->IsToggled())
720 RaiseTool( pTool
, FALSE
);
727 if (!rEvent
.IsButton())
729 if (pTool
->GetId() != m_nCurrentTool
)
732 // If the left button is kept down and moved over buttons,
733 // press those buttons.
735 if (rEvent
.LeftIsDown() && pTool
->IsEnabled())
737 SpringUpButton(m_nCurrentTool
);
738 if (pTool
->CanBeToggled())
744 wxToolBarTool
* pOldTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
746 if (pOldTool
&& !pTool
->IsToggled())
747 RaiseTool( pOldTool
, FALSE
);
748 m_nCurrentTool
= pTool
->GetId();
749 OnMouseEnter(m_nCurrentTool
);
750 if (!pTool
->GetShortHelp().empty())
754 m_pToolTip
= new wxToolTip(pTool
->GetShortHelp());
755 m_vXMouse
= (wxCoord
)vPoint
.x
;
756 m_vYMouse
= (wxCoord
)vPoint
.y
;
757 m_vToolTimer
.Start(1000L, TRUE
);
759 if (!pTool
->IsToggled())
765 // Left button pressed.
766 if (rEvent
.LeftDown() && pTool
->IsEnabled())
768 if (pTool
->CanBeToggled())
774 else if (rEvent
.RightDown())
776 OnRightClick( pTool
->GetId()
783 // Left Button Released. Only this action confirms selection.
784 // If the button is enabled and it is not a toggle tool and it is
785 // in the pressed state, then raise the button and call OnLeftClick.
787 if (rEvent
.LeftUp() && pTool
->IsEnabled() )
790 // Pass the OnLeftClick event to tool
792 if (!OnLeftClick( pTool
->GetId()
793 ,pTool
->IsToggled()) &&
794 pTool
->CanBeToggled())
797 // If it was a toggle, and OnLeftClick says No Toggle allowed,
798 // then change it back
804 } // end of wxToolBar::OnMouseEvent
806 // ----------------------------------------------------------------------------
808 // ----------------------------------------------------------------------------
810 void wxToolBar::DrawTool( wxToolBarToolBase
* pTool
)
812 wxClientDC
vDc(this);
814 DrawTool( vDc
, pTool
);
815 } // end of wxToolBar::DrawTool
817 void wxToolBar::DrawTool( wxDC
& rDc
, wxToolBarToolBase
* pToolBase
)
819 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
820 wxColour
gray85( 85,85,85 );
821 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
822 wxBitmap vBitmap
= pTool
->GetNormalBitmap();
823 bool bUseMask
= false;
824 wxMask
* pMask
= NULL
;
830 if ((pMask
= vBitmap
.GetMask()) != NULL
)
831 if (pMask
->GetMaskBitmap() != NULLHANDLE
)
834 if (!pTool
->IsToggled())
836 LowerTool(pTool
, FALSE
);
837 if (!pTool
->IsEnabled())
839 wxColour
vColor(wxT("GREY"));
841 rDc
.SetTextForeground(vColor
);
842 if (!pTool
->GetDisabledBitmap().Ok())
843 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
844 ,(long)GetBackgroundColour().GetPixel()
846 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
854 rDc
.SetTextForeground(*wxBLACK
);
855 rDc
.DrawBitmap( vBitmap
861 if (m_windowStyle
& wxTB_3DBUTTONS
)
865 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
869 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
871 rDc
.SetFont(GetFont());
872 rDc
.GetTextExtent( pTool
->GetLabel()
876 if (pTool
->GetWidth() > vX
) // large tools
878 vLeft
= pTool
->m_vX
+ (pTool
->GetWidth() - vX
);
880 rDc
.DrawText( pTool
->GetLabel()
887 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
888 rDc
.DrawText( pTool
->GetLabel()
890 ,pTool
->m_vY
+ m_vTextY
- 1 // a bit of margin
897 wxColour
vColor(wxT("GREY"));
900 rDc
.SetTextForeground(vColor
);
901 if (!pTool
->GetDisabledBitmap().Ok())
902 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
903 ,(long)GetBackgroundColour().GetPixel()
905 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
910 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
914 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
916 rDc
.SetFont(GetFont());
917 rDc
.GetTextExtent( pTool
->GetLabel()
921 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
922 rDc
.DrawText( pTool
->GetLabel()
924 ,pTool
->m_vY
+ m_vTextY
- 1 // a bit of margin
928 } // end of wxToolBar::DrawTool
930 // ----------------------------------------------------------------------------
932 // ----------------------------------------------------------------------------
934 void wxToolBar::SetRows(
938 wxCHECK_RET( nRows
!= 0, _T("max number of rows must be > 0") );
940 m_maxCols
= (GetToolsCount() + nRows
- 1) / nRows
;
942 } // end of wxToolBar::SetRows
944 wxToolBarToolBase
* wxToolBar::FindToolForPosition(
949 wxCoord vTBarHeight
= 0;
954 vY
= vTBarHeight
- vY
;
955 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
958 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
960 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().IsNull())
962 if ((vX
>= (pTool
->m_vX
- ((wxCoord
)(pTool
->GetWidth()/2) - 2))) &&
963 (vY
>= (pTool
->m_vY
- 2)) &&
964 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
965 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight() + m_vTextY
+ 2)))
972 if ((vX
>= pTool
->m_vX
) &&
973 (vY
>= pTool
->m_vY
) &&
974 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
975 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight())))
980 node
= node
->GetNext();
982 return (wxToolBarToolBase
*)NULL
;
983 } // end of wxToolBar::FindToolForPosition
985 // ----------------------------------------------------------------------------
986 // tool state change handlers
987 // ----------------------------------------------------------------------------
989 void wxToolBar::DoEnableTool(
990 wxToolBarToolBase
* pTool
991 , bool WXUNUSED(bEnable
)
995 } // end of wxToolBar::DoEnableTool
997 void wxToolBar::DoToggleTool(
998 wxToolBarToolBase
* pTool
999 , bool WXUNUSED(bToggle
)
1003 } // end of wxToolBar::DoToggleTool
1005 void wxToolBar::DoSetToggle(
1006 wxToolBarToolBase
* WXUNUSED(pTool
)
1007 , bool WXUNUSED(bToggle
)
1011 } // end of wxToolBar::DoSetToggle
1014 // Okay, so we've left the tool we're in ... we must check if the tool we're
1015 // leaving was a 'sprung push button' and if so, spring it back to the up
1018 void wxToolBar::SpringUpButton(
1022 wxToolBarToolBase
* pTool
= FindById(vId
);
1024 if (pTool
&& pTool
->CanBeToggled())
1026 if (pTool
->IsToggled())
1031 } // end of wxToolBar::SpringUpButton
1033 // ----------------------------------------------------------------------------
1035 // ----------------------------------------------------------------------------
1037 void wxToolBar::LowerTool ( wxToolBarToolBase
* pToolBase
,
1040 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1045 wxColour
gray85( 85,85,85 );
1046 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
1047 wxPen
vClearPen( GetBackgroundColour(), 1, wxSOLID
);
1048 wxClientDC
vDC(this);
1053 if (pTool
->IsSeparator())
1057 // We only do this for flat toolbars
1059 if (!HasFlag(wxTB_FLAT
))
1062 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
1064 if (pTool
->GetWidth() > m_vTextX
)
1066 vX
= pTool
->m_vX
- 2;
1067 vWidth
= pTool
->GetWidth() + 4;
1071 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1072 vWidth
= m_vTextX
+ 4;
1074 vY
= pTool
->m_vY
- 2;
1075 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1079 vX
= pTool
->m_vX
- 2;
1080 vY
= pTool
->m_vY
- 2;
1081 vWidth
= pTool
->GetWidth() + 4;
1082 vHeight
= pTool
->GetHeight() + 4;
1086 vDC
.SetPen(*wxWHITE_PEN
);
1087 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1088 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1089 vDC
.SetPen(vDarkGreyPen
);
1090 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1091 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1095 vDC
.SetPen(vClearPen
);
1096 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1097 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1098 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1099 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1101 } // end of WinGuiBase_CToolBarTool::LowerTool
1103 void wxToolBar::RaiseTool ( wxToolBarToolBase
* pToolBase
,
1106 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1111 wxColour
gray85( 85,85,85 );
1112 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
1113 wxPen
vClearPen( GetBackgroundColour(), 1, wxSOLID
);
1114 wxClientDC
vDC(this);
1119 if (pTool
->IsSeparator())
1122 if (!pTool
->IsEnabled())
1126 // We only do this for flat toolbars
1128 if (!HasFlag(wxTB_FLAT
))
1131 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
1133 if (pTool
->GetWidth() > m_vTextX
)
1135 vX
= pTool
->m_vX
- 2;
1136 vWidth
= pTool
->GetWidth() + 4;
1140 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1141 vWidth
= m_vTextX
+ 4;
1143 vY
= pTool
->m_vY
- 2;
1144 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1148 vX
= pTool
->m_vX
- 2;
1149 vY
= pTool
->m_vY
- 2;
1150 vWidth
= pTool
->GetWidth() + 4;
1151 vHeight
= pTool
->GetHeight() + 4;
1155 vDC
.SetPen(vDarkGreyPen
);
1156 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1157 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1158 vDC
.SetPen(*wxWHITE_PEN
);
1159 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1160 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1164 vDC
.SetPen(vClearPen
);
1165 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1166 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1167 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1168 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1170 } // end of wxToolBar::RaiseTool
1172 void wxToolBar::OnTimer ( wxTimerEvent
& rEvent
)
1174 if (rEvent
.GetId() == m_vToolTimer
.GetId())
1176 wxPoint
vPos( m_vXMouse
, m_vYMouse
);
1178 m_pToolTip
->DisplayToolTipWindow(vPos
);
1179 m_vToolTimer
.Stop();
1180 m_vToolExpTimer
.Start(4000L, TRUE
);
1182 else if (rEvent
.GetId() == m_vToolExpTimer
.GetId())
1184 m_pToolTip
->HideToolTipWindow();
1185 GetParent()->Refresh();
1186 m_vToolExpTimer
.Stop();
1188 } // end of wxToolBar::OnTimer
1190 #endif // ndef for wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE