cleanup - reformatting
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37614 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
b26ed94e4f
commit
3b6a117962
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: toolbar.cpp
|
// Name: src/mac/carbon/toolbar.cpp
|
||||||
// Purpose: wxToolBar
|
// Purpose: wxToolBar
|
||||||
// Author: Stefan Csomor
|
// Author: Stefan Csomor
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@ -208,10 +208,8 @@ static const EventTypeSpec eventList[] =
|
|||||||
static pascal OSStatus wxMacToolBarToolControlEventHandler( EventHandlerCallRef handler, EventRef event, void *data )
|
static pascal OSStatus wxMacToolBarToolControlEventHandler( EventHandlerCallRef handler, EventRef event, void *data )
|
||||||
{
|
{
|
||||||
OSStatus result = eventNotHandledErr;
|
OSStatus result = eventNotHandledErr;
|
||||||
|
|
||||||
wxMacCarbonEvent cEvent( event ) ;
|
|
||||||
|
|
||||||
ControlRef controlRef;
|
ControlRef controlRef;
|
||||||
|
wxMacCarbonEvent cEvent( event );
|
||||||
|
|
||||||
cEvent.GetParameter( kEventParamDirectObject, &controlRef );
|
cEvent.GetParameter( kEventParamDirectObject, &controlRef );
|
||||||
|
|
||||||
@ -489,13 +487,13 @@ void wxToolBarTool::UpdateToggleImage( bool toggle )
|
|||||||
{
|
{
|
||||||
ControlButtonContentInfo info;
|
ControlButtonContentInfo info;
|
||||||
wxMacCreateBitmapButton( &info, m_bmpNormal );
|
wxMacCreateBitmapButton( &info, m_bmpNormal );
|
||||||
SetControlData( m_controlHandle , 0, kControlIconContentTag,
|
SetControlData( m_controlHandle, 0, kControlIconContentTag, sizeof( info ), (Ptr)&info );
|
||||||
sizeof( info ), (Ptr)&info );
|
|
||||||
wxMacReleaseBitmapButton( &info );
|
wxMacReleaseBitmapButton( &info );
|
||||||
}
|
}
|
||||||
|
|
||||||
IconTransformType transform = toggle ? kTransformSelected : kTransformNone;
|
IconTransformType transform = toggle ? kTransformSelected : kTransformNone;
|
||||||
SetControlData( m_controlHandle, 0, kControlIconTransformTag,
|
SetControlData(
|
||||||
|
m_controlHandle, 0, kControlIconTransformTag,
|
||||||
sizeof( transform ), (Ptr)&transform );
|
sizeof( transform ), (Ptr)&transform );
|
||||||
HIViewSetNeedsDisplay( m_controlHandle, true );
|
HIViewSetNeedsDisplay( m_controlHandle, true );
|
||||||
|
|
||||||
@ -504,7 +502,8 @@ void wxToolBarTool::UpdateToggleImage( bool toggle )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
|
wxToolBarTool::wxToolBarTool(
|
||||||
|
wxToolBar *tbar,
|
||||||
int id,
|
int id,
|
||||||
const wxString& label,
|
const wxString& label,
|
||||||
const wxBitmap& bmpNormal,
|
const wxBitmap& bmpNormal,
|
||||||
@ -513,7 +512,9 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
|
|||||||
wxObject *clientData,
|
wxObject *clientData,
|
||||||
const wxString& shortHelp,
|
const wxString& shortHelp,
|
||||||
const wxString& longHelp )
|
const wxString& longHelp )
|
||||||
: wxToolBarToolBase(tbar, id, label, bmpNormal, bmpDisabled, kind,
|
:
|
||||||
|
wxToolBarToolBase(
|
||||||
|
tbar, id, label, bmpNormal, bmpDisabled, kind,
|
||||||
clientData, shortHelp, longHelp )
|
clientData, shortHelp, longHelp )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
@ -522,7 +523,8 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Toolbar Implementation
|
#pragma mark Toolbar Implementation
|
||||||
|
|
||||||
wxToolBarToolBase *wxToolBar::CreateTool(int id,
|
wxToolBarToolBase *wxToolBar::CreateTool(
|
||||||
|
int id,
|
||||||
const wxString& label,
|
const wxString& label,
|
||||||
const wxBitmap& bmpNormal,
|
const wxBitmap& bmpNormal,
|
||||||
const wxBitmap& bmpDisabled,
|
const wxBitmap& bmpDisabled,
|
||||||
@ -531,7 +533,8 @@ wxToolBarToolBase *wxToolBar::CreateTool(int id,
|
|||||||
const wxString& shortHelp,
|
const wxString& shortHelp,
|
||||||
const wxString& longHelp )
|
const wxString& longHelp )
|
||||||
{
|
{
|
||||||
return new wxToolBarTool(this, id, label, bmpNormal, bmpDisabled, kind,
|
return new wxToolBarTool(
|
||||||
|
this, id, label, bmpNormal, bmpDisabled, kind,
|
||||||
clientData, shortHelp, longHelp );
|
clientData, shortHelp, longHelp );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,7 +559,8 @@ void wxToolBar::Init()
|
|||||||
// also for the toolbar we have the dual implementation:
|
// also for the toolbar we have the dual implementation:
|
||||||
// only when MacInstallNativeToolbar is called is the native toolbar set as the window toolbar
|
// only when MacInstallNativeToolbar is called is the native toolbar set as the window toolbar
|
||||||
//
|
//
|
||||||
bool wxToolBar::Create(wxWindow *parent,
|
bool wxToolBar::Create(
|
||||||
|
wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
@ -570,7 +574,8 @@ bool wxToolBar::Create(wxWindow *parent,
|
|||||||
|
|
||||||
#if wxMAC_USE_NATIVE_TOOLBAR
|
#if wxMAC_USE_NATIVE_TOOLBAR
|
||||||
wxString labelStr = wxString::Format( wxT("%xd"), (int)this );
|
wxString labelStr = wxString::Format( wxT("%xd"), (int)this );
|
||||||
err = HIToolbarCreate( wxMacCFStringHolder(labelStr, wxFont::GetDefaultEncoding() ) , 0 ,
|
err = HIToolbarCreate(
|
||||||
|
wxMacCFStringHolder( labelStr, wxFont::GetDefaultEncoding() ), 0,
|
||||||
(HIToolbarRef*) &m_macHIToolbarRef );
|
(HIToolbarRef*) &m_macHIToolbarRef );
|
||||||
|
|
||||||
if (m_macHIToolbarRef != NULL)
|
if (m_macHIToolbarRef != NULL)
|
||||||
@ -1101,8 +1106,7 @@ void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
|
|||||||
tool->UpdateToggleImage( toggle );
|
tool->UpdateToggleImage( toggle );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase)
|
||||||
wxToolBarToolBase *toolBase)
|
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = wx_static_cast( wxToolBarTool*, toolBase );
|
wxToolBarTool *tool = wx_static_cast( wxToolBarTool*, toolBase );
|
||||||
if (tool == NULL)
|
if (tool == NULL)
|
||||||
@ -1151,13 +1155,15 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
|||||||
wxMacCreateBitmapButton( &info, tool->GetNormalBitmap(), kControlContentIconRef );
|
wxMacCreateBitmapButton( &info, tool->GetNormalBitmap(), kControlContentIconRef );
|
||||||
|
|
||||||
if ( UMAGetSystemVersion() >= 0x1000)
|
if ( UMAGetSystemVersion() >= 0x1000)
|
||||||
|
{
|
||||||
CreateIconControl( window, &toolrect, &info, false, &controlHandle );
|
CreateIconControl( window, &toolrect, &info, false, &controlHandle );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SInt16 behaviour = kControlBehaviorOffsetContents;
|
SInt16 behaviour = kControlBehaviorOffsetContents;
|
||||||
if ( tool->CanBeToggled() )
|
if ( tool->CanBeToggled() )
|
||||||
behaviour |= kControlBehaviorToggles;
|
behaviour |= kControlBehaviorToggles;
|
||||||
CreateBevelButtonControl( window ,
|
err = CreateBevelButtonControl( window,
|
||||||
&toolrect, CFSTR(""), kControlBevelButtonNormalBevel,
|
&toolrect, CFSTR(""), kControlBevelButtonNormalBevel,
|
||||||
behaviour, &info, 0, 0, 0, &controlHandle );
|
behaviour, &info, 0, 0, 0, &controlHandle );
|
||||||
}
|
}
|
||||||
@ -1185,7 +1191,8 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
|||||||
UMASetControlTitle( m_controlHandle, label, wxFont::GetDefaultEncoding() );
|
UMASetControlTitle( m_controlHandle, label, wxFont::GetDefaultEncoding() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
InstallControlEventHandler( (ControlRef) controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
|
InstallControlEventHandler(
|
||||||
|
(ControlRef) controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
|
||||||
GetEventTypeCount(eventList), eventList, tool, NULL );
|
GetEventTypeCount(eventList), eventList, tool, NULL );
|
||||||
|
|
||||||
tool->SetControlHandle( controlHandle );
|
tool->SetControlHandle( controlHandle );
|
||||||
@ -1194,15 +1201,17 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
|||||||
|
|
||||||
case wxTOOL_STYLE_CONTROL:
|
case wxTOOL_STYLE_CONTROL:
|
||||||
wxASSERT( tool->GetControl() != NULL );
|
wxASSERT( tool->GetControl() != NULL );
|
||||||
|
|
||||||
#if 0 // wxMAC_USE_NATIVE_TOOLBAR
|
#if 0 // wxMAC_USE_NATIVE_TOOLBAR
|
||||||
// FIXME: doesn't work yet...
|
// FIXME: doesn't work yet...
|
||||||
{
|
{
|
||||||
HIToolbarItemRef item;
|
HIToolbarItemRef item;
|
||||||
wxString labelStr = wxString::Format( wxT("%xd"), (int)tool );
|
wxString labelStr = wxString::Format( wxT("%xd"), (int)tool );
|
||||||
result = HIToolbarItemCreate( wxMacCFStringHolder(labelStr, wxFont::GetDefaultEncoding()),
|
result = HIToolbarItemCreate(
|
||||||
|
wxMacCFStringHolder( labelStr, wxFont::GetDefaultEncoding() ),
|
||||||
kHIToolbarItemCantBeRemoved | kHIToolbarItemAnchoredLeft | kHIToolbarItemAllowDuplicates,
|
kHIToolbarItemCantBeRemoved | kHIToolbarItemAnchoredLeft | kHIToolbarItemAllowDuplicates,
|
||||||
&item );
|
&item );
|
||||||
if ( result == 0 )
|
if ( result == noErr )
|
||||||
{
|
{
|
||||||
HIToolbarItemSetLabel( item, wxMacCFStringHolder( tool->GetLabel(), m_font.GetEncoding() ) );
|
HIToolbarItemSetLabel( item, wxMacCFStringHolder( tool->GetLabel(), m_font.GetEncoding() ) );
|
||||||
HIToolbarItemSetCommandID( item, tool->GetId() );
|
HIToolbarItemSetCommandID( item, tool->GetId() );
|
||||||
@ -1216,7 +1225,8 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
|||||||
UMAMoveControl( controlHandle, -toolrect.left, -toolrect.top );
|
UMAMoveControl( controlHandle, -toolrect.left, -toolrect.top );
|
||||||
|
|
||||||
// FIXME: is this necessary ??
|
// FIXME: is this necessary ??
|
||||||
InstallControlEventHandler( controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
|
InstallControlEventHandler(
|
||||||
|
controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
|
||||||
GetEventTypeCount(eventList), eventList, tool, NULL );
|
GetEventTypeCount(eventList), eventList, tool, NULL );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1235,7 +1245,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
|||||||
if ( controlHandle )
|
if ( controlHandle )
|
||||||
{
|
{
|
||||||
ControlRef container = (ControlRef) GetHandle();
|
ControlRef container = (ControlRef) GetHandle();
|
||||||
wxASSERT_MSG( container != NULL, wxT("No valid mac container control") );
|
wxASSERT_MSG( container != NULL, wxT("No valid Mac container control") );
|
||||||
|
|
||||||
UMAShowControl( controlHandle );
|
UMAShowControl( controlHandle );
|
||||||
::EmbedControl( controlHandle, container );
|
::EmbedControl( controlHandle, container );
|
||||||
@ -1259,7 +1269,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
|
|||||||
|
|
||||||
void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle))
|
void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle))
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( _T("not implemented") );
|
wxFAIL_MSG( wxT("not implemented") );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolbase)
|
bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolbase)
|
||||||
@ -1430,4 +1440,3 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user