From 80645074d8bcb64ecf4b3608d71cfd73a3d2a50c Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 28 Feb 2001 14:29:53 +0000 Subject: [PATCH] toolbars are now possible in any window git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9444 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/toolbar.cpp | 62 ++++++++++++++++++++++++++++++++++++-- src/mac/toolbar.cpp | 62 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 120 insertions(+), 4 deletions(-) diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 752f71a8cc..9e69e73a60 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -262,9 +262,17 @@ bool wxToolBar::Realize() if (m_tools.Number() == 0) return FALSE; - Rect toolbarrect = { m_y , m_x , m_y + m_height , m_x + m_width } ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *win ; + + MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ; + + Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h , + m_y + m_height + localOrigin.v , m_x + m_width + localOrigin.h} ; ControlFontStyleRec controlstyle ; - WindowPtr window = GetMacRootWindow() ; + controlstyle.flags = kControlUseFontMask ; controlstyle.font = kControlFontSmallSystemFont ; @@ -493,6 +501,55 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) void wxToolBar::OnPaint(wxPaintEvent& event) { + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *win ; + + MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ; + if ( window && win ) + { + wxMacDrawingHelper help( win ) ; + // the mac control manager always assumes to have the origin at 0,0 + SetOrigin( 0 , 0 ) ; + + bool hasTabBehind = false ; + wxWindow* parent = GetParent() ; + while ( parent ) + { + if( parent->MacGetWindowData() ) + { + UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ; + break ; + } + + if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) )) + { + if ( ((wxControl*)parent)->GetMacControl() ) + SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ; + break ; + } + + parent = parent->GetParent() ; + } + Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h , + m_y + localOrigin.v + m_height , m_x + localOrigin.h + m_width } ; + + UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; + { + int index = 0 ; + for ( index = 0 ; index < m_macToolHandles.Count() ; ++index ) + { + if ( m_macToolHandles[index] ) + { + UMADrawControl( (ControlHandle) m_macToolHandles[index] ) ; + } + } + } + UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ; + wxDC::MacInvalidateSetup() ; + } + /* WindowRef window = GetMacRootWindow() ; if ( window ) { @@ -539,6 +596,7 @@ void wxToolBar::OnPaint(wxPaintEvent& event) wxDC::MacInvalidateSetup() ; } } + */ } void wxToolBar::OnMouse( wxMouseEvent &event ) { diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 752f71a8cc..9e69e73a60 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -262,9 +262,17 @@ bool wxToolBar::Realize() if (m_tools.Number() == 0) return FALSE; - Rect toolbarrect = { m_y , m_x , m_y + m_height , m_x + m_width } ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *win ; + + MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ; + + Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h , + m_y + m_height + localOrigin.v , m_x + m_width + localOrigin.h} ; ControlFontStyleRec controlstyle ; - WindowPtr window = GetMacRootWindow() ; + controlstyle.flags = kControlUseFontMask ; controlstyle.font = kControlFontSmallSystemFont ; @@ -493,6 +501,55 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) void wxToolBar::OnPaint(wxPaintEvent& event) { + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *win ; + + MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ; + if ( window && win ) + { + wxMacDrawingHelper help( win ) ; + // the mac control manager always assumes to have the origin at 0,0 + SetOrigin( 0 , 0 ) ; + + bool hasTabBehind = false ; + wxWindow* parent = GetParent() ; + while ( parent ) + { + if( parent->MacGetWindowData() ) + { + UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ; + break ; + } + + if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) )) + { + if ( ((wxControl*)parent)->GetMacControl() ) + SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ; + break ; + } + + parent = parent->GetParent() ; + } + Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h , + m_y + localOrigin.v + m_height , m_x + localOrigin.h + m_width } ; + + UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; + { + int index = 0 ; + for ( index = 0 ; index < m_macToolHandles.Count() ; ++index ) + { + if ( m_macToolHandles[index] ) + { + UMADrawControl( (ControlHandle) m_macToolHandles[index] ) ; + } + } + } + UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ; + wxDC::MacInvalidateSetup() ; + } + /* WindowRef window = GetMacRootWindow() ; if ( window ) { @@ -539,6 +596,7 @@ void wxToolBar::OnPaint(wxPaintEvent& event) wxDC::MacInvalidateSetup() ; } } + */ } void wxToolBar::OnMouse( wxMouseEvent &event ) { -- 2.47.2