The mac toolbar was redrawing buttons when not shown -
making them appear at arbitrary times. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13071 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -25,8 +25,8 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
|
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
|
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
|
||||||
EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
|
EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
|
||||||
EVT_PAINT( wxToolBar::OnPaint )
|
EVT_PAINT( wxToolBar::OnPaint )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
void SetSeparatorsCount(size_t count) { m_nSepCount = count; }
|
void SetSeparatorsCount(size_t count) { m_nSepCount = count; }
|
||||||
size_t GetSeparatorsCount() const { return m_nSepCount; }
|
size_t GetSeparatorsCount() const { return m_nSepCount; }
|
||||||
|
|
||||||
int m_index ;
|
int m_index ;
|
||||||
private:
|
private:
|
||||||
size_t m_nSepCount;
|
size_t m_nSepCount;
|
||||||
};
|
};
|
||||||
@@ -143,13 +143,13 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
|
|||||||
m_windowId = id;
|
m_windowId = id;
|
||||||
|
|
||||||
{
|
{
|
||||||
m_width = size.x ;
|
m_width = size.x ;
|
||||||
m_height = size.y ;
|
m_height = size.y ;
|
||||||
int x = pos.x ;
|
int x = pos.x ;
|
||||||
int y = pos.y ;
|
int y = pos.y ;
|
||||||
AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
|
AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
|
||||||
m_x = x ;
|
m_x = x ;
|
||||||
m_y = y ;
|
m_y = y ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -342,20 +342,20 @@ wxSize wxToolBar::GetToolSize() const
|
|||||||
|
|
||||||
void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
||||||
{
|
{
|
||||||
int index = 0 ;
|
int index = 0 ;
|
||||||
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
||||||
{
|
{
|
||||||
if ( m_macToolHandles[index] == (void*) control )
|
if ( m_macToolHandles[index] == (void*) control )
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)m_tools.Nth( index )->Data();
|
wxToolBarTool *tool = (wxToolBarTool *)m_tools.Nth( index )->Data();
|
||||||
if ( tool->CanBeToggled() )
|
if ( tool->CanBeToggled() )
|
||||||
{
|
{
|
||||||
tool->Toggle( GetControlValue( control ) ) ;
|
tool->Toggle( GetControlValue( control ) ) ;
|
||||||
}
|
}
|
||||||
OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
|
OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::SetRows(int nRows)
|
void wxToolBar::SetRows(int nRows)
|
||||||
@@ -374,24 +374,24 @@ void wxToolBar::MacSuperChangedPosition()
|
|||||||
if (m_tools.Number() > 0)
|
if (m_tools.Number() > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
Point localOrigin ;
|
Point localOrigin ;
|
||||||
Rect clipRect ;
|
Rect clipRect ;
|
||||||
WindowRef window ;
|
WindowRef window ;
|
||||||
wxWindow *win ;
|
wxWindow *win ;
|
||||||
|
|
||||||
GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
|
GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
|
||||||
|
|
||||||
Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
|
Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
|
||||||
m_y + m_height + localOrigin.v , m_x + m_width + localOrigin.h} ;
|
m_y + m_height + localOrigin.v , m_x + m_width + localOrigin.h} ;
|
||||||
ControlFontStyleRec controlstyle ;
|
ControlFontStyleRec controlstyle ;
|
||||||
|
|
||||||
controlstyle.flags = kControlUseFontMask ;
|
controlstyle.flags = kControlUseFontMask ;
|
||||||
controlstyle.font = kControlFontSmallSystemFont ;
|
controlstyle.font = kControlFontSmallSystemFont ;
|
||||||
|
|
||||||
wxNode *node = m_tools.First();
|
wxNode *node = m_tools.First();
|
||||||
int noButtons = 0;
|
int noButtons = 0;
|
||||||
int x = 0 ;
|
int x = 0 ;
|
||||||
wxSize toolSize = GetToolSize() ;
|
wxSize toolSize = GetToolSize() ;
|
||||||
int tw, th;
|
int tw, th;
|
||||||
GetSize(& tw, & th);
|
GetSize(& tw, & th);
|
||||||
|
|
||||||
@@ -399,67 +399,67 @@ void wxToolBar::MacSuperChangedPosition()
|
|||||||
int maxHeight = 0 ;
|
int maxHeight = 0 ;
|
||||||
int toolcount = 0 ;
|
int toolcount = 0 ;
|
||||||
{
|
{
|
||||||
WindowRef rootwindow = GetMacRootWindow() ;
|
WindowRef rootwindow = GetMacRootWindow() ;
|
||||||
wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
|
wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
|
||||||
::SetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ;
|
::SetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
wxMacDrawingHelper focus( wxrootwindow ) ;
|
wxMacDrawingHelper focus( wxrootwindow ) ;
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
|
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
|
||||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ;
|
wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ;
|
||||||
|
|
||||||
if( !tool->IsSeparator() )
|
if( !tool->IsSeparator() )
|
||||||
{
|
{
|
||||||
Rect toolrect = { toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin, toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ;
|
Rect toolrect = { toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin, toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ;
|
||||||
toolrect.right = toolrect.left + toolSize.x ;
|
toolrect.right = toolrect.left + toolSize.x ;
|
||||||
toolrect.bottom = toolrect.top + toolSize.y ;
|
toolrect.bottom = toolrect.top + toolSize.y ;
|
||||||
|
|
||||||
ControlHandle m_macToolHandle = (ControlHandle) m_macToolHandles[toolcount++] ;
|
ControlHandle m_macToolHandle = (ControlHandle) m_macToolHandles[toolcount++] ;
|
||||||
|
|
||||||
{
|
{
|
||||||
Rect contrlRect ;
|
Rect contrlRect ;
|
||||||
GetControlBounds( m_macToolHandle , &contrlRect ) ;
|
GetControlBounds( m_macToolHandle , &contrlRect ) ;
|
||||||
int former_mac_x = contrlRect.left ;
|
int former_mac_x = contrlRect.left ;
|
||||||
int former_mac_y = contrlRect.top ;
|
int former_mac_y = contrlRect.top ;
|
||||||
int mac_x = toolrect.left ;
|
int mac_x = toolrect.left ;
|
||||||
int mac_y = toolrect.top ;
|
int mac_y = toolrect.top ;
|
||||||
|
|
||||||
if ( mac_x != former_mac_x || mac_y != former_mac_y )
|
if ( mac_x != former_mac_x || mac_y != former_mac_y )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Rect inval = { former_mac_y , former_mac_x , former_mac_y + toolSize.y , former_mac_x + toolSize.y } ;
|
Rect inval = { former_mac_y , former_mac_x , former_mac_y + toolSize.y , former_mac_x + toolSize.y } ;
|
||||||
InvalWindowRect( rootwindow , &inval ) ;
|
InvalWindowRect( rootwindow , &inval ) ;
|
||||||
}
|
}
|
||||||
UMAMoveControl( m_macToolHandle , mac_x , mac_y ) ;
|
UMAMoveControl( m_macToolHandle , mac_x , mac_y ) ;
|
||||||
{
|
{
|
||||||
Rect inval = { mac_y , mac_x , mac_y + toolSize.y , mac_x + toolSize.y } ;
|
Rect inval = { mac_y , mac_x , mac_y + toolSize.y , mac_x + toolSize.y } ;
|
||||||
InvalWindowRect( rootwindow , &inval ) ;
|
InvalWindowRect( rootwindow , &inval ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x += (int)toolSize.x;
|
x += (int)toolSize.x;
|
||||||
noButtons ++;
|
noButtons ++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
toolcount++ ;
|
toolcount++ ;
|
||||||
x += (int)toolSize.x / 4;
|
x += (int)toolSize.x / 4;
|
||||||
}
|
}
|
||||||
if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin- m_x - localOrigin.h > maxWidth)
|
if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin- m_x - localOrigin.h > maxWidth)
|
||||||
maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin+ m_xMargin - m_x - localOrigin.h;
|
maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin+ m_xMargin - m_x - localOrigin.h;
|
||||||
if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight)
|
if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight)
|
||||||
maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ;
|
maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ;
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
|
if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
::SetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ;
|
::SetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
|
if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
|
||||||
@@ -469,10 +469,10 @@ void wxToolBar::MacSuperChangedPosition()
|
|||||||
// if not set yet, only one row
|
// if not set yet, only one row
|
||||||
SetRows(1);
|
SetRows(1);
|
||||||
}
|
}
|
||||||
maxWidth = tw ;
|
maxWidth = tw ;
|
||||||
maxHeight += toolSize.y;
|
maxHeight += toolSize.y;
|
||||||
maxHeight += m_yMargin + kwxMacToolBarTopMargin;
|
maxHeight += m_yMargin + kwxMacToolBarTopMargin;
|
||||||
m_maxHeight = maxHeight ;
|
m_maxHeight = maxHeight ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -483,8 +483,8 @@ void wxToolBar::MacSuperChangedPosition()
|
|||||||
}
|
}
|
||||||
maxHeight = th ;
|
maxHeight = th ;
|
||||||
maxWidth += toolSize.x;
|
maxWidth += toolSize.x;
|
||||||
maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
|
maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
|
||||||
m_maxWidth = maxWidth ;
|
m_maxWidth = maxWidth ;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSize(maxWidth, maxHeight);
|
SetSize(maxWidth, maxHeight);
|
||||||
@@ -498,55 +498,61 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
|
|||||||
MacClientToRootWindow( &x , &y ) ;
|
MacClientToRootWindow( &x , &y ) ;
|
||||||
Point pt = { y ,x } ;
|
Point pt = { y ,x } ;
|
||||||
|
|
||||||
int index = 0 ;
|
int index = 0 ;
|
||||||
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
||||||
{
|
{
|
||||||
if ( m_macToolHandles[index] )
|
if ( m_macToolHandles[index] )
|
||||||
{
|
{
|
||||||
Rect bounds ;
|
Rect bounds ;
|
||||||
GetControlBounds((ControlHandle) m_macToolHandles[index], &bounds ) ;
|
GetControlBounds((ControlHandle) m_macToolHandles[index], &bounds ) ;
|
||||||
if ( PtInRect( pt , &bounds ) )
|
if ( PtInRect( pt , &bounds ) )
|
||||||
{
|
{
|
||||||
return (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ;
|
return (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (wxToolBarToolBase *)NULL;
|
return (wxToolBarToolBase *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
|
wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
|
||||||
{
|
{
|
||||||
wxToolBarToolBase* tool = FindToolForPosition( pt.x , pt.y ) ;
|
wxToolBarToolBase* tool = FindToolForPosition( pt.x , pt.y ) ;
|
||||||
if ( tool )
|
if ( tool )
|
||||||
{
|
{
|
||||||
return tool->GetShortHelp() ;
|
return tool->GetShortHelp() ;
|
||||||
}
|
}
|
||||||
return "" ;
|
return "" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
|
void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)t;
|
if (!IsShown())
|
||||||
if ( tool->m_index < 0 )
|
return ;
|
||||||
return ;
|
|
||||||
|
|
||||||
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
wxToolBarTool *tool = (wxToolBarTool *)t;
|
||||||
|
if ( tool->m_index < 0 )
|
||||||
|
return ;
|
||||||
|
|
||||||
if ( enable )
|
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
||||||
UMAActivateControl( control ) ;
|
|
||||||
else
|
if ( enable )
|
||||||
UMADeactivateControl( control ) ;
|
UMAActivateControl( control ) ;
|
||||||
|
else
|
||||||
|
UMADeactivateControl( control ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
|
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)t;
|
if (!IsShown())
|
||||||
if ( tool->m_index < 0 )
|
return ;
|
||||||
return ;
|
|
||||||
|
|
||||||
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
wxToolBarTool *tool = (wxToolBarTool *)t;
|
||||||
::SetControlValue( control , toggle ) ;
|
if ( tool->m_index < 0 )
|
||||||
|
return ;
|
||||||
|
|
||||||
|
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
||||||
|
::SetControlValue( control , toggle ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
||||||
@@ -567,117 +573,117 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase *t, bool toggle)
|
|||||||
|
|
||||||
bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
|
bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
|
||||||
{
|
{
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::OnPaint(wxPaintEvent& event)
|
void wxToolBar::OnPaint(wxPaintEvent& event)
|
||||||
{
|
{
|
||||||
Point localOrigin ;
|
Point localOrigin ;
|
||||||
Rect clipRect ;
|
Rect clipRect ;
|
||||||
WindowRef window ;
|
WindowRef window ;
|
||||||
wxWindow *win ;
|
wxWindow *win ;
|
||||||
|
|
||||||
GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
|
GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
|
||||||
if ( window && win )
|
if ( window && win )
|
||||||
{
|
{
|
||||||
wxMacDrawingHelper help( win ) ;
|
wxMacDrawingHelper help( win ) ;
|
||||||
// the mac control manager always assumes to have the origin at 0,0
|
// the mac control manager always assumes to have the origin at 0,0
|
||||||
SetOrigin( 0 , 0 ) ;
|
SetOrigin( 0 , 0 ) ;
|
||||||
|
|
||||||
bool hasTabBehind = false ;
|
bool hasTabBehind = false ;
|
||||||
wxWindow* parent = GetParent() ;
|
wxWindow* parent = GetParent() ;
|
||||||
while ( parent )
|
while ( parent )
|
||||||
{
|
{
|
||||||
if( parent->MacGetWindowData() )
|
if( parent->MacGetWindowData() )
|
||||||
{
|
{
|
||||||
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
||||||
{
|
{
|
||||||
if ( ((wxControl*)parent)->GetMacControl() )
|
if ( ((wxControl*)parent)->GetMacControl() )
|
||||||
SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
|
SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = parent->GetParent() ;
|
parent = parent->GetParent() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
|
Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
|
||||||
m_y + localOrigin.v + m_height , m_x + localOrigin.h + m_width } ;
|
m_y + localOrigin.v + m_height , m_x + localOrigin.h + m_width } ;
|
||||||
|
|
||||||
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
||||||
{
|
{
|
||||||
int index = 0 ;
|
int index = 0 ;
|
||||||
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
||||||
{
|
{
|
||||||
if ( m_macToolHandles[index] )
|
if ( m_macToolHandles[index] )
|
||||||
{
|
{
|
||||||
UMADrawControl( (ControlHandle) m_macToolHandles[index] ) ;
|
UMADrawControl( (ControlHandle) m_macToolHandles[index] ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::OnMouse( wxMouseEvent &event )
|
void wxToolBar::OnMouse( wxMouseEvent &event )
|
||||||
{
|
{
|
||||||
|
|
||||||
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
||||||
{
|
{
|
||||||
|
|
||||||
int x = event.m_x ;
|
int x = event.m_x ;
|
||||||
int y = event.m_y ;
|
int y = event.m_y ;
|
||||||
|
|
||||||
MacClientToRootWindow( &x , &y ) ;
|
MacClientToRootWindow( &x , &y ) ;
|
||||||
|
|
||||||
ControlHandle control ;
|
ControlHandle control ;
|
||||||
Point localwhere ;
|
Point localwhere ;
|
||||||
GrafPtr port ;
|
GrafPtr port ;
|
||||||
SInt16 controlpart ;
|
SInt16 controlpart ;
|
||||||
WindowRef window = GetMacRootWindow() ;
|
WindowRef window = GetMacRootWindow() ;
|
||||||
|
|
||||||
localwhere.h = x ;
|
localwhere.h = x ;
|
||||||
localwhere.v = y ;
|
localwhere.v = y ;
|
||||||
|
|
||||||
short modifiers = 0;
|
short modifiers = 0;
|
||||||
|
|
||||||
if ( !event.m_leftDown && !event.m_rightDown )
|
if ( !event.m_leftDown && !event.m_rightDown )
|
||||||
modifiers |= btnState ;
|
modifiers |= btnState ;
|
||||||
|
|
||||||
if ( event.m_shiftDown )
|
if ( event.m_shiftDown )
|
||||||
modifiers |= shiftKey ;
|
modifiers |= shiftKey ;
|
||||||
|
|
||||||
if ( event.m_controlDown )
|
if ( event.m_controlDown )
|
||||||
modifiers |= controlKey ;
|
modifiers |= controlKey ;
|
||||||
|
|
||||||
if ( event.m_altDown )
|
if ( event.m_altDown )
|
||||||
modifiers |= optionKey ;
|
modifiers |= optionKey ;
|
||||||
|
|
||||||
if ( event.m_metaDown )
|
if ( event.m_metaDown )
|
||||||
modifiers |= cmdKey ;
|
modifiers |= cmdKey ;
|
||||||
|
|
||||||
controlpart = FindControl( localwhere , window , &control ) ;
|
controlpart = FindControl( localwhere , window , &control ) ;
|
||||||
{
|
{
|
||||||
if ( control && ::IsControlActive( control ) )
|
if ( control && ::IsControlActive( control ) )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() )
|
if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() )
|
||||||
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ;
|
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ;
|
||||||
else
|
else
|
||||||
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
||||||
wxTheApp->s_lastMouseDown = 0 ;
|
wxTheApp->s_lastMouseDown = 0 ;
|
||||||
if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) )
|
if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) )
|
||||||
&& (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice
|
&& (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice
|
||||||
{
|
{
|
||||||
MacHandleControlClick( control , controlpart ) ;
|
MacHandleControlClick( control , controlpart ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
@@ -25,8 +25,8 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
|
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
|
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
|
||||||
EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
|
EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
|
||||||
EVT_PAINT( wxToolBar::OnPaint )
|
EVT_PAINT( wxToolBar::OnPaint )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
void SetSeparatorsCount(size_t count) { m_nSepCount = count; }
|
void SetSeparatorsCount(size_t count) { m_nSepCount = count; }
|
||||||
size_t GetSeparatorsCount() const { return m_nSepCount; }
|
size_t GetSeparatorsCount() const { return m_nSepCount; }
|
||||||
|
|
||||||
int m_index ;
|
int m_index ;
|
||||||
private:
|
private:
|
||||||
size_t m_nSepCount;
|
size_t m_nSepCount;
|
||||||
};
|
};
|
||||||
@@ -143,13 +143,13 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
|
|||||||
m_windowId = id;
|
m_windowId = id;
|
||||||
|
|
||||||
{
|
{
|
||||||
m_width = size.x ;
|
m_width = size.x ;
|
||||||
m_height = size.y ;
|
m_height = size.y ;
|
||||||
int x = pos.x ;
|
int x = pos.x ;
|
||||||
int y = pos.y ;
|
int y = pos.y ;
|
||||||
AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
|
AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
|
||||||
m_x = x ;
|
m_x = x ;
|
||||||
m_y = y ;
|
m_y = y ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -342,20 +342,20 @@ wxSize wxToolBar::GetToolSize() const
|
|||||||
|
|
||||||
void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
||||||
{
|
{
|
||||||
int index = 0 ;
|
int index = 0 ;
|
||||||
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
||||||
{
|
{
|
||||||
if ( m_macToolHandles[index] == (void*) control )
|
if ( m_macToolHandles[index] == (void*) control )
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)m_tools.Nth( index )->Data();
|
wxToolBarTool *tool = (wxToolBarTool *)m_tools.Nth( index )->Data();
|
||||||
if ( tool->CanBeToggled() )
|
if ( tool->CanBeToggled() )
|
||||||
{
|
{
|
||||||
tool->Toggle( GetControlValue( control ) ) ;
|
tool->Toggle( GetControlValue( control ) ) ;
|
||||||
}
|
}
|
||||||
OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
|
OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::SetRows(int nRows)
|
void wxToolBar::SetRows(int nRows)
|
||||||
@@ -374,24 +374,24 @@ void wxToolBar::MacSuperChangedPosition()
|
|||||||
if (m_tools.Number() > 0)
|
if (m_tools.Number() > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
Point localOrigin ;
|
Point localOrigin ;
|
||||||
Rect clipRect ;
|
Rect clipRect ;
|
||||||
WindowRef window ;
|
WindowRef window ;
|
||||||
wxWindow *win ;
|
wxWindow *win ;
|
||||||
|
|
||||||
GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
|
GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
|
||||||
|
|
||||||
Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
|
Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
|
||||||
m_y + m_height + localOrigin.v , m_x + m_width + localOrigin.h} ;
|
m_y + m_height + localOrigin.v , m_x + m_width + localOrigin.h} ;
|
||||||
ControlFontStyleRec controlstyle ;
|
ControlFontStyleRec controlstyle ;
|
||||||
|
|
||||||
controlstyle.flags = kControlUseFontMask ;
|
controlstyle.flags = kControlUseFontMask ;
|
||||||
controlstyle.font = kControlFontSmallSystemFont ;
|
controlstyle.font = kControlFontSmallSystemFont ;
|
||||||
|
|
||||||
wxNode *node = m_tools.First();
|
wxNode *node = m_tools.First();
|
||||||
int noButtons = 0;
|
int noButtons = 0;
|
||||||
int x = 0 ;
|
int x = 0 ;
|
||||||
wxSize toolSize = GetToolSize() ;
|
wxSize toolSize = GetToolSize() ;
|
||||||
int tw, th;
|
int tw, th;
|
||||||
GetSize(& tw, & th);
|
GetSize(& tw, & th);
|
||||||
|
|
||||||
@@ -399,67 +399,67 @@ void wxToolBar::MacSuperChangedPosition()
|
|||||||
int maxHeight = 0 ;
|
int maxHeight = 0 ;
|
||||||
int toolcount = 0 ;
|
int toolcount = 0 ;
|
||||||
{
|
{
|
||||||
WindowRef rootwindow = GetMacRootWindow() ;
|
WindowRef rootwindow = GetMacRootWindow() ;
|
||||||
wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
|
wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
|
||||||
::SetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ;
|
::SetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
wxMacDrawingHelper focus( wxrootwindow ) ;
|
wxMacDrawingHelper focus( wxrootwindow ) ;
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
|
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
|
||||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ;
|
wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ;
|
||||||
|
|
||||||
if( !tool->IsSeparator() )
|
if( !tool->IsSeparator() )
|
||||||
{
|
{
|
||||||
Rect toolrect = { toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin, toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ;
|
Rect toolrect = { toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin, toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ;
|
||||||
toolrect.right = toolrect.left + toolSize.x ;
|
toolrect.right = toolrect.left + toolSize.x ;
|
||||||
toolrect.bottom = toolrect.top + toolSize.y ;
|
toolrect.bottom = toolrect.top + toolSize.y ;
|
||||||
|
|
||||||
ControlHandle m_macToolHandle = (ControlHandle) m_macToolHandles[toolcount++] ;
|
ControlHandle m_macToolHandle = (ControlHandle) m_macToolHandles[toolcount++] ;
|
||||||
|
|
||||||
{
|
{
|
||||||
Rect contrlRect ;
|
Rect contrlRect ;
|
||||||
GetControlBounds( m_macToolHandle , &contrlRect ) ;
|
GetControlBounds( m_macToolHandle , &contrlRect ) ;
|
||||||
int former_mac_x = contrlRect.left ;
|
int former_mac_x = contrlRect.left ;
|
||||||
int former_mac_y = contrlRect.top ;
|
int former_mac_y = contrlRect.top ;
|
||||||
int mac_x = toolrect.left ;
|
int mac_x = toolrect.left ;
|
||||||
int mac_y = toolrect.top ;
|
int mac_y = toolrect.top ;
|
||||||
|
|
||||||
if ( mac_x != former_mac_x || mac_y != former_mac_y )
|
if ( mac_x != former_mac_x || mac_y != former_mac_y )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Rect inval = { former_mac_y , former_mac_x , former_mac_y + toolSize.y , former_mac_x + toolSize.y } ;
|
Rect inval = { former_mac_y , former_mac_x , former_mac_y + toolSize.y , former_mac_x + toolSize.y } ;
|
||||||
InvalWindowRect( rootwindow , &inval ) ;
|
InvalWindowRect( rootwindow , &inval ) ;
|
||||||
}
|
}
|
||||||
UMAMoveControl( m_macToolHandle , mac_x , mac_y ) ;
|
UMAMoveControl( m_macToolHandle , mac_x , mac_y ) ;
|
||||||
{
|
{
|
||||||
Rect inval = { mac_y , mac_x , mac_y + toolSize.y , mac_x + toolSize.y } ;
|
Rect inval = { mac_y , mac_x , mac_y + toolSize.y , mac_x + toolSize.y } ;
|
||||||
InvalWindowRect( rootwindow , &inval ) ;
|
InvalWindowRect( rootwindow , &inval ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x += (int)toolSize.x;
|
x += (int)toolSize.x;
|
||||||
noButtons ++;
|
noButtons ++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
toolcount++ ;
|
toolcount++ ;
|
||||||
x += (int)toolSize.x / 4;
|
x += (int)toolSize.x / 4;
|
||||||
}
|
}
|
||||||
if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin- m_x - localOrigin.h > maxWidth)
|
if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin- m_x - localOrigin.h > maxWidth)
|
||||||
maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin+ m_xMargin - m_x - localOrigin.h;
|
maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin+ m_xMargin - m_x - localOrigin.h;
|
||||||
if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight)
|
if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight)
|
||||||
maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ;
|
maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ;
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
|
if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
::SetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ;
|
::SetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
|
if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
|
||||||
@@ -469,10 +469,10 @@ void wxToolBar::MacSuperChangedPosition()
|
|||||||
// if not set yet, only one row
|
// if not set yet, only one row
|
||||||
SetRows(1);
|
SetRows(1);
|
||||||
}
|
}
|
||||||
maxWidth = tw ;
|
maxWidth = tw ;
|
||||||
maxHeight += toolSize.y;
|
maxHeight += toolSize.y;
|
||||||
maxHeight += m_yMargin + kwxMacToolBarTopMargin;
|
maxHeight += m_yMargin + kwxMacToolBarTopMargin;
|
||||||
m_maxHeight = maxHeight ;
|
m_maxHeight = maxHeight ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -483,8 +483,8 @@ void wxToolBar::MacSuperChangedPosition()
|
|||||||
}
|
}
|
||||||
maxHeight = th ;
|
maxHeight = th ;
|
||||||
maxWidth += toolSize.x;
|
maxWidth += toolSize.x;
|
||||||
maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
|
maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
|
||||||
m_maxWidth = maxWidth ;
|
m_maxWidth = maxWidth ;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSize(maxWidth, maxHeight);
|
SetSize(maxWidth, maxHeight);
|
||||||
@@ -498,55 +498,61 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
|
|||||||
MacClientToRootWindow( &x , &y ) ;
|
MacClientToRootWindow( &x , &y ) ;
|
||||||
Point pt = { y ,x } ;
|
Point pt = { y ,x } ;
|
||||||
|
|
||||||
int index = 0 ;
|
int index = 0 ;
|
||||||
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
||||||
{
|
{
|
||||||
if ( m_macToolHandles[index] )
|
if ( m_macToolHandles[index] )
|
||||||
{
|
{
|
||||||
Rect bounds ;
|
Rect bounds ;
|
||||||
GetControlBounds((ControlHandle) m_macToolHandles[index], &bounds ) ;
|
GetControlBounds((ControlHandle) m_macToolHandles[index], &bounds ) ;
|
||||||
if ( PtInRect( pt , &bounds ) )
|
if ( PtInRect( pt , &bounds ) )
|
||||||
{
|
{
|
||||||
return (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ;
|
return (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (wxToolBarToolBase *)NULL;
|
return (wxToolBarToolBase *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
|
wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
|
||||||
{
|
{
|
||||||
wxToolBarToolBase* tool = FindToolForPosition( pt.x , pt.y ) ;
|
wxToolBarToolBase* tool = FindToolForPosition( pt.x , pt.y ) ;
|
||||||
if ( tool )
|
if ( tool )
|
||||||
{
|
{
|
||||||
return tool->GetShortHelp() ;
|
return tool->GetShortHelp() ;
|
||||||
}
|
}
|
||||||
return "" ;
|
return "" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
|
void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)t;
|
if (!IsShown())
|
||||||
if ( tool->m_index < 0 )
|
return ;
|
||||||
return ;
|
|
||||||
|
|
||||||
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
wxToolBarTool *tool = (wxToolBarTool *)t;
|
||||||
|
if ( tool->m_index < 0 )
|
||||||
|
return ;
|
||||||
|
|
||||||
if ( enable )
|
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
||||||
UMAActivateControl( control ) ;
|
|
||||||
else
|
if ( enable )
|
||||||
UMADeactivateControl( control ) ;
|
UMAActivateControl( control ) ;
|
||||||
|
else
|
||||||
|
UMADeactivateControl( control ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
|
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)t;
|
if (!IsShown())
|
||||||
if ( tool->m_index < 0 )
|
return ;
|
||||||
return ;
|
|
||||||
|
|
||||||
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
wxToolBarTool *tool = (wxToolBarTool *)t;
|
||||||
::SetControlValue( control , toggle ) ;
|
if ( tool->m_index < 0 )
|
||||||
|
return ;
|
||||||
|
|
||||||
|
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
||||||
|
::SetControlValue( control , toggle ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
||||||
@@ -567,117 +573,117 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase *t, bool toggle)
|
|||||||
|
|
||||||
bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
|
bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
|
||||||
{
|
{
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::OnPaint(wxPaintEvent& event)
|
void wxToolBar::OnPaint(wxPaintEvent& event)
|
||||||
{
|
{
|
||||||
Point localOrigin ;
|
Point localOrigin ;
|
||||||
Rect clipRect ;
|
Rect clipRect ;
|
||||||
WindowRef window ;
|
WindowRef window ;
|
||||||
wxWindow *win ;
|
wxWindow *win ;
|
||||||
|
|
||||||
GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
|
GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
|
||||||
if ( window && win )
|
if ( window && win )
|
||||||
{
|
{
|
||||||
wxMacDrawingHelper help( win ) ;
|
wxMacDrawingHelper help( win ) ;
|
||||||
// the mac control manager always assumes to have the origin at 0,0
|
// the mac control manager always assumes to have the origin at 0,0
|
||||||
SetOrigin( 0 , 0 ) ;
|
SetOrigin( 0 , 0 ) ;
|
||||||
|
|
||||||
bool hasTabBehind = false ;
|
bool hasTabBehind = false ;
|
||||||
wxWindow* parent = GetParent() ;
|
wxWindow* parent = GetParent() ;
|
||||||
while ( parent )
|
while ( parent )
|
||||||
{
|
{
|
||||||
if( parent->MacGetWindowData() )
|
if( parent->MacGetWindowData() )
|
||||||
{
|
{
|
||||||
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
||||||
{
|
{
|
||||||
if ( ((wxControl*)parent)->GetMacControl() )
|
if ( ((wxControl*)parent)->GetMacControl() )
|
||||||
SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
|
SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = parent->GetParent() ;
|
parent = parent->GetParent() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
|
Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
|
||||||
m_y + localOrigin.v + m_height , m_x + localOrigin.h + m_width } ;
|
m_y + localOrigin.v + m_height , m_x + localOrigin.h + m_width } ;
|
||||||
|
|
||||||
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
||||||
{
|
{
|
||||||
int index = 0 ;
|
int index = 0 ;
|
||||||
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
|
||||||
{
|
{
|
||||||
if ( m_macToolHandles[index] )
|
if ( m_macToolHandles[index] )
|
||||||
{
|
{
|
||||||
UMADrawControl( (ControlHandle) m_macToolHandles[index] ) ;
|
UMADrawControl( (ControlHandle) m_macToolHandles[index] ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::OnMouse( wxMouseEvent &event )
|
void wxToolBar::OnMouse( wxMouseEvent &event )
|
||||||
{
|
{
|
||||||
|
|
||||||
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
||||||
{
|
{
|
||||||
|
|
||||||
int x = event.m_x ;
|
int x = event.m_x ;
|
||||||
int y = event.m_y ;
|
int y = event.m_y ;
|
||||||
|
|
||||||
MacClientToRootWindow( &x , &y ) ;
|
MacClientToRootWindow( &x , &y ) ;
|
||||||
|
|
||||||
ControlHandle control ;
|
ControlHandle control ;
|
||||||
Point localwhere ;
|
Point localwhere ;
|
||||||
GrafPtr port ;
|
GrafPtr port ;
|
||||||
SInt16 controlpart ;
|
SInt16 controlpart ;
|
||||||
WindowRef window = GetMacRootWindow() ;
|
WindowRef window = GetMacRootWindow() ;
|
||||||
|
|
||||||
localwhere.h = x ;
|
localwhere.h = x ;
|
||||||
localwhere.v = y ;
|
localwhere.v = y ;
|
||||||
|
|
||||||
short modifiers = 0;
|
short modifiers = 0;
|
||||||
|
|
||||||
if ( !event.m_leftDown && !event.m_rightDown )
|
if ( !event.m_leftDown && !event.m_rightDown )
|
||||||
modifiers |= btnState ;
|
modifiers |= btnState ;
|
||||||
|
|
||||||
if ( event.m_shiftDown )
|
if ( event.m_shiftDown )
|
||||||
modifiers |= shiftKey ;
|
modifiers |= shiftKey ;
|
||||||
|
|
||||||
if ( event.m_controlDown )
|
if ( event.m_controlDown )
|
||||||
modifiers |= controlKey ;
|
modifiers |= controlKey ;
|
||||||
|
|
||||||
if ( event.m_altDown )
|
if ( event.m_altDown )
|
||||||
modifiers |= optionKey ;
|
modifiers |= optionKey ;
|
||||||
|
|
||||||
if ( event.m_metaDown )
|
if ( event.m_metaDown )
|
||||||
modifiers |= cmdKey ;
|
modifiers |= cmdKey ;
|
||||||
|
|
||||||
controlpart = FindControl( localwhere , window , &control ) ;
|
controlpart = FindControl( localwhere , window , &control ) ;
|
||||||
{
|
{
|
||||||
if ( control && ::IsControlActive( control ) )
|
if ( control && ::IsControlActive( control ) )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() )
|
if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() )
|
||||||
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ;
|
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ;
|
||||||
else
|
else
|
||||||
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
||||||
wxTheApp->s_lastMouseDown = 0 ;
|
wxTheApp->s_lastMouseDown = 0 ;
|
||||||
if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) )
|
if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) )
|
||||||
&& (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice
|
&& (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice
|
||||||
{
|
{
|
||||||
MacHandleControlClick( control , controlpart ) ;
|
MacHandleControlClick( control , controlpart ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
Reference in New Issue
Block a user