1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/toolbar.cpp
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
14 #if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE
16 #include "wx/toolbar.h"
19 #include "wx/settings.h"
20 #include "wx/window.h"
23 #include "wx/dcclient.h"
24 #include "wx/dcmemory.h"
27 #include "wx/tooltip.h"
28 #include "wx/os2/dcclient.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()
425 wxDELETE(m_pToolTip
);
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_TOP
| wxTB_BOTTOM
))
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_TOP
| wxTB_BOTTOM
))
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().empty() )
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_TOP
| wxTB_BOTTOM
))
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 wxPMDCImpl
*impl
= (wxPMDCImpl
*) vDc
.GetImpl();
601 ::WinFillRect(impl
->GetHPS(), &impl
->m_vRclPaint
, GetBackgroundColour().GetPixel());
602 for ( wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
604 node
= node
->GetNext() )
606 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
608 if (pTool
->IsButton() )
609 DrawTool(vDc
, pTool
);
610 if (pTool
->IsSeparator())
612 wxColour
gray85(85, 85, 85);
613 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
619 vDc
.SetPen(vDarkGreyPen
);
620 if (HasFlag(wxTB_TEXT
))
622 if (HasFlag(wxTB_TOP
) || HasFlag(wxTB_BOTTOM
))
625 nY
= pTool
->m_vY
- (m_vTextY
- 6);
626 nHeight
= (m_vTextY
- 2) + pTool
->GetHeight();
630 nX
= pTool
->m_vX
+ m_xMargin
+ 10;
631 nY
= pTool
->m_vY
+ m_vTextY
+ m_toolSeparation
;
632 nWidth
= pTool
->GetWidth() > m_vTextX
? pTool
->GetWidth() : m_vTextX
;
639 if (HasFlag(wxTB_TOP
) || HasFlag(wxTB_BOTTOM
))
640 nHeight
= pTool
->GetHeight() - 2;
643 nX
+= m_xMargin
+ 10;
644 nY
+= m_yMargin
+ m_toolSeparation
;
645 nWidth
= pTool
->GetWidth();
648 vDc
.DrawLine(nX
, nY
, nX
+ nWidth
, nY
+ nHeight
);
652 } // end of wxToolBar::OnPaint
654 void wxToolBar::OnSize (
655 wxSizeEvent
& WXUNUSED(rEvent
)
658 #if wxUSE_CONSTRAINTS
662 } // end of wxToolBar::OnSize
664 void wxToolBar::OnKillFocus(
665 wxFocusEvent
& WXUNUSED(rEvent
)
668 OnMouseEnter(m_nPressedTool
= m_nCurrentTool
= -1);
669 } // end of wxToolBar::OnKillFocus
671 void wxToolBar::OnMouseEvent(
679 HPOINTER hPtr
= ::WinQuerySysPointer(HWND_DESKTOP
, SPTR_ARROW
, FALSE
);
681 ::WinSetPointer(HWND_DESKTOP
, hPtr
);
682 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
683 hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, TRUE
);
684 if (hWnd
!= (HWND
)GetHwnd())
690 rEvent
.GetPosition(&vX
, &vY
);
692 wxToolBarTool
* pTool
= (wxToolBarTool
*)FindToolForPosition( vX
696 if (rEvent
.LeftDown())
708 if (m_nCurrentTool
> -1)
710 if (rEvent
.LeftIsDown())
711 SpringUpButton(m_nCurrentTool
);
712 pTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
713 if (pTool
&& !pTool
->IsToggled())
715 RaiseTool( pTool
, FALSE
);
722 if (!rEvent
.IsButton())
724 if (pTool
->GetId() != m_nCurrentTool
)
727 // If the left button is kept down and moved over buttons,
728 // press those buttons.
730 if (rEvent
.LeftIsDown() && pTool
->IsEnabled())
732 SpringUpButton(m_nCurrentTool
);
733 if (pTool
->CanBeToggled())
739 wxToolBarTool
* pOldTool
= (wxToolBarTool
*)FindById(m_nCurrentTool
);
741 if (pOldTool
&& !pTool
->IsToggled())
742 RaiseTool( pOldTool
, FALSE
);
743 m_nCurrentTool
= pTool
->GetId();
744 OnMouseEnter(m_nCurrentTool
);
745 if (!pTool
->GetShortHelp().empty())
749 m_pToolTip
= new wxToolTip(pTool
->GetShortHelp());
750 m_vXMouse
= (wxCoord
)vPoint
.x
;
751 m_vYMouse
= (wxCoord
)vPoint
.y
;
752 m_vToolTimer
.Start(1000L, TRUE
);
754 if (!pTool
->IsToggled())
760 // Left button pressed.
761 if (rEvent
.LeftDown() && pTool
->IsEnabled())
763 if (pTool
->CanBeToggled())
769 else if (rEvent
.RightDown())
771 OnRightClick( pTool
->GetId()
778 // Left Button Released. Only this action confirms selection.
779 // If the button is enabled and it is not a toggle tool and it is
780 // in the pressed state, then raise the button and call OnLeftClick.
782 if (rEvent
.LeftUp() && pTool
->IsEnabled() )
785 // Pass the OnLeftClick event to tool
787 if (!OnLeftClick( pTool
->GetId()
788 ,pTool
->IsToggled()) &&
789 pTool
->CanBeToggled())
792 // If it was a toggle, and OnLeftClick says No Toggle allowed,
793 // then change it back
799 } // end of wxToolBar::OnMouseEvent
801 // ----------------------------------------------------------------------------
803 // ----------------------------------------------------------------------------
805 void wxToolBar::DrawTool( wxToolBarToolBase
* pTool
)
807 wxClientDC
vDc(this);
809 DrawTool( vDc
, pTool
);
810 } // end of wxToolBar::DrawTool
812 void wxToolBar::DrawTool( wxDC
& rDc
, wxToolBarToolBase
* pToolBase
)
814 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
815 wxColour
gray85( 85,85,85 );
816 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
817 wxBitmap vBitmap
= pTool
->GetNormalBitmap();
818 bool bUseMask
= false;
819 wxMask
* pMask
= NULL
;
825 if ((pMask
= vBitmap
.GetMask()) != NULL
)
826 if (pMask
->GetMaskBitmap() != NULLHANDLE
)
829 if (!pTool
->IsToggled())
831 LowerTool(pTool
, FALSE
);
832 if (!pTool
->IsEnabled())
834 wxColour
vColor(wxT("GREY"));
836 rDc
.SetTextForeground(vColor
);
837 if (!pTool
->GetDisabledBitmap().IsOk())
838 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
839 ,(long)GetBackgroundColour().GetPixel()
841 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
849 rDc
.SetTextForeground(*wxBLACK
);
850 rDc
.DrawBitmap( vBitmap
856 if (m_windowStyle
& wxTB_3DBUTTONS
)
860 if ( HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty() )
864 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
866 rDc
.SetFont(GetFont());
867 rDc
.GetTextExtent( pTool
->GetLabel()
871 if (pTool
->GetWidth() > vX
) // large tools
873 vLeft
= pTool
->m_vX
+ (pTool
->GetWidth() - vX
);
875 rDc
.DrawText( pTool
->GetLabel()
882 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
883 rDc
.DrawText( pTool
->GetLabel()
885 ,pTool
->m_vY
+ m_vTextY
- 1 // a bit of margin
892 wxColour
vColor(wxT("GREY"));
895 rDc
.SetTextForeground(vColor
);
896 if (!pTool
->GetDisabledBitmap().IsOk())
897 pTool
->SetDisabledBitmap(wxDisableBitmap( vBitmap
898 ,(long)GetBackgroundColour().GetPixel()
900 rDc
.DrawBitmap( pTool
->GetDisabledBitmap()
905 if ( HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty() )
909 wxCoord vLeft
= pTool
->m_vX
- (int)(pTool
->GetWidth()/2);
911 rDc
.SetFont(GetFont());
912 rDc
.GetTextExtent( pTool
->GetLabel()
916 vLeft
+= (wxCoord
)((m_vTextX
- vX
)/2);
917 rDc
.DrawText( pTool
->GetLabel()
919 ,pTool
->m_vY
+ m_vTextY
- 1 // a bit of margin
923 } // end of wxToolBar::DrawTool
925 // ----------------------------------------------------------------------------
927 // ----------------------------------------------------------------------------
929 void wxToolBar::SetRows(
933 wxCHECK_RET( nRows
!= 0, wxT("max number of rows must be > 0") );
935 m_maxCols
= (GetToolsCount() + nRows
- 1) / nRows
;
937 } // end of wxToolBar::SetRows
939 wxToolBarToolBase
* wxToolBar::FindToolForPosition(
944 wxCoord vTBarHeight
= 0;
949 vY
= vTBarHeight
- vY
;
950 wxToolBarToolsList::compatibility_iterator node
= m_tools
.GetFirst();
953 wxToolBarTool
* pTool
= (wxToolBarTool
*)node
->GetData();
955 if ( HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty() )
957 if ((vX
>= (pTool
->m_vX
- ((wxCoord
)(pTool
->GetWidth()/2) - 2))) &&
958 (vY
>= (pTool
->m_vY
- 2)) &&
959 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
960 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight() + m_vTextY
+ 2)))
967 if ((vX
>= pTool
->m_vX
) &&
968 (vY
>= pTool
->m_vY
) &&
969 (vX
<= (pTool
->m_vX
+ pTool
->GetWidth())) &&
970 (vY
<= (pTool
->m_vY
+ pTool
->GetHeight())))
975 node
= node
->GetNext();
978 } // end of wxToolBar::FindToolForPosition
980 // ----------------------------------------------------------------------------
981 // tool state change handlers
982 // ----------------------------------------------------------------------------
984 void wxToolBar::DoEnableTool(
985 wxToolBarToolBase
* pTool
986 , bool WXUNUSED(bEnable
)
990 } // end of wxToolBar::DoEnableTool
992 void wxToolBar::DoToggleTool(
993 wxToolBarToolBase
* pTool
994 , bool WXUNUSED(bToggle
)
998 } // end of wxToolBar::DoToggleTool
1000 void wxToolBar::DoSetToggle(
1001 wxToolBarToolBase
* WXUNUSED(pTool
)
1002 , bool WXUNUSED(bToggle
)
1006 } // end of wxToolBar::DoSetToggle
1009 // Okay, so we've left the tool we're in ... we must check if the tool we're
1010 // leaving was a 'sprung push button' and if so, spring it back to the up
1013 void wxToolBar::SpringUpButton(
1017 wxToolBarToolBase
* pTool
= FindById(vId
);
1019 if (pTool
&& pTool
->CanBeToggled())
1021 if (pTool
->IsToggled())
1026 } // end of wxToolBar::SpringUpButton
1028 // ----------------------------------------------------------------------------
1030 // ----------------------------------------------------------------------------
1032 void wxToolBar::LowerTool ( wxToolBarToolBase
* pToolBase
,
1035 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1040 wxColour
gray85( 85,85,85 );
1041 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
1042 wxPen
vClearPen( GetBackgroundColour(), 1, wxSOLID
);
1043 wxClientDC
vDC(this);
1048 if (pTool
->IsSeparator())
1052 // We only do this for flat toolbars
1054 if (!HasFlag(wxTB_FLAT
))
1057 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
1059 if (pTool
->GetWidth() > m_vTextX
)
1061 vX
= pTool
->m_vX
- 2;
1062 vWidth
= pTool
->GetWidth() + 4;
1066 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1067 vWidth
= m_vTextX
+ 4;
1069 vY
= pTool
->m_vY
- 2;
1070 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1074 vX
= pTool
->m_vX
- 2;
1075 vY
= pTool
->m_vY
- 2;
1076 vWidth
= pTool
->GetWidth() + 4;
1077 vHeight
= pTool
->GetHeight() + 4;
1081 vDC
.SetPen(*wxWHITE_PEN
);
1082 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1083 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1084 vDC
.SetPen(vDarkGreyPen
);
1085 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1086 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1090 vDC
.SetPen(vClearPen
);
1091 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1092 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1093 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1094 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1096 } // end of WinGuiBase_CToolBarTool::LowerTool
1098 void wxToolBar::RaiseTool ( wxToolBarToolBase
* pToolBase
,
1101 wxToolBarTool
* pTool
= (wxToolBarTool
*)pToolBase
;
1106 wxColour
gray85( 85,85,85 );
1107 wxPen
vDarkGreyPen( gray85
, 1, wxSOLID
);
1108 wxPen
vClearPen( GetBackgroundColour(), 1, wxSOLID
);
1109 wxClientDC
vDC(this);
1114 if (pTool
->IsSeparator())
1117 if (!pTool
->IsEnabled())
1121 // We only do this for flat toolbars
1123 if (!HasFlag(wxTB_FLAT
))
1126 if (HasFlag(wxTB_TEXT
) && !pTool
->GetLabel().empty())
1128 if (pTool
->GetWidth() > m_vTextX
)
1130 vX
= pTool
->m_vX
- 2;
1131 vWidth
= pTool
->GetWidth() + 4;
1135 vX
= pTool
->m_vX
- (wxCoord
)(pTool
->GetWidth()/2);
1136 vWidth
= m_vTextX
+ 4;
1138 vY
= pTool
->m_vY
- 2;
1139 vHeight
= pTool
->GetHeight() + m_vTextY
+ 2;
1143 vX
= pTool
->m_vX
- 2;
1144 vY
= pTool
->m_vY
- 2;
1145 vWidth
= pTool
->GetWidth() + 4;
1146 vHeight
= pTool
->GetHeight() + 4;
1150 vDC
.SetPen(vDarkGreyPen
);
1151 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1152 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1153 vDC
.SetPen(*wxWHITE_PEN
);
1154 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1155 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1159 vDC
.SetPen(vClearPen
);
1160 vDC
.DrawLine(vX
+ vWidth
, vY
+ vHeight
, vX
, vY
+ vHeight
);
1161 vDC
.DrawLine(vX
+ vWidth
, vY
, vX
+ vWidth
, vY
+ vHeight
);
1162 vDC
.DrawLine(vX
, vY
, vX
+ vWidth
, vY
);
1163 vDC
.DrawLine(vX
, vY
+ vHeight
, vX
, vY
);
1165 } // end of wxToolBar::RaiseTool
1167 void wxToolBar::OnTimer ( wxTimerEvent
& rEvent
)
1169 if (rEvent
.GetId() == m_vToolTimer
.GetId())
1171 wxPoint
vPos( m_vXMouse
, m_vYMouse
);
1173 m_pToolTip
->DisplayToolTipWindow(vPos
);
1174 m_vToolTimer
.Stop();
1175 m_vToolExpTimer
.Start(4000L, TRUE
);
1177 else if (rEvent
.GetId() == m_vToolExpTimer
.GetId())
1179 m_pToolTip
->HideToolTipWindow();
1180 GetParent()->Refresh();
1181 m_vToolExpTimer
.Stop();
1183 } // end of wxToolBar::OnTimer
1185 #endif // ndef for wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE