going private for m_peer to give a foundation for better encapsulation

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67230 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2011-03-18 14:20:12 +00:00
parent 37204b5d30
commit 2275632282
36 changed files with 152 additions and 144 deletions

View File

@@ -247,6 +247,7 @@ public:
// the 'true' OS level control for this wxWindow
wxOSXWidgetImpl* GetPeer() const { return m_peer ; }
void SetPeer(wxOSXWidgetImpl* peer);
#if wxOSX_USE_COCOA_OR_IPHONE
// the NSView or NSWindow of this window: can be used for both child and
@@ -274,7 +275,6 @@ protected:
wxList m_subControls;
// the peer object, allowing for cleaner API support
wxOSXWidgetImpl * m_peer ;
void * m_cgContextRef ;
@@ -365,6 +365,7 @@ protected:
unsigned timeout);
private:
wxOSXWidgetImpl * m_peer ;
// common part of all ctors
void Init();

View File

@@ -448,28 +448,28 @@ bool wxWebKitCtrl::Create(wxWindow *parent,
m_macIsUserPane = false;
wxControl::Create(parent, winID, pos, size, style , validator , name);
#if wxOSX_USE_CARBON
m_peer = new wxMacControl(this);
SetPeer(new wxMacControl(this));
WebInitForCarbon();
HIWebViewCreate( m_peer->GetControlRefAddr() );
HIWebViewCreate( GetPeer()->GetControlRefAddr() );
m_webView = (WebView*) HIWebViewGetWebView( m_peer->GetControlRef() );
m_webView = (WebView*) HIWebViewGetWebView( GetPeer()->GetControlRef() );
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
if ( UMAGetSystemVersion() >= 0x1030 )
HIViewChangeFeatures( m_peer->GetControlRef() , kHIViewIsOpaque , 0 ) ;
HIViewChangeFeatures( GetPeer()->GetControlRef() , kHIViewIsOpaque , 0 ) ;
#endif
InstallControlEventHandler( m_peer->GetControlRef() , GetwxWebKitCtrlEventHandlerUPP(),
InstallControlEventHandler( GetPeer()->GetControlRef() , GetwxWebKitCtrlEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, this,
(EventHandlerRef *)&m_webKitCtrlEventHandler);
#else
NSRect r = wxOSXGetFrameForControl( this, pos , size ) ;
m_webView = [[WebView alloc] initWithFrame:r frameName:@"webkitFrame" groupName:@"webkitGroup"];
m_peer = new wxWidgetCocoaImpl( this, m_webView );
SetPeer(new wxWidgetCocoaImpl( this, m_webView ));
#endif
MacPostControlCreate(pos, size);
#if wxOSX_USE_CARBON
HIViewSetVisible( m_peer->GetControlRef(), true );
HIViewSetVisible( GetPeer()->GetControlRef(), true );
#endif
[m_webView setHidden:false];
@@ -742,7 +742,7 @@ void wxWebKitCtrl::OnSize(wxSizeEvent &event){
// and this tripped me up at first. But in fact, what we want is the root view, because we need to
// make the y origin relative to the very top of the window, not its contents, since we later flip
// the y coordinate for Cocoa.
HIViewConvertRect (&rect, m_peer->GetControlRef(),
HIViewConvertRect (&rect, GetPeer()->GetControlRef(),
HIViewGetRoot( (WindowRef) MacGetTopLevelWindowRef() ) );
x = (int)rect.origin.x;
@@ -773,7 +773,7 @@ void wxWebKitCtrl::OnSize(wxSizeEvent &event){
void wxWebKitCtrl::MacVisibilityChanged(){
#if defined(__WXMAC__) && wxOSX_USE_CARBON
bool isHidden = !IsControlVisible( m_peer->GetControlRef());
bool isHidden = !IsControlVisible( GetPeer()->GetControlRef());
if (!isHidden)
[(WebView*)m_webView display];

View File

@@ -52,7 +52,7 @@ bool wxBitmapButton::Create( wxWindow *parent,
m_bitmaps[State_Normal] = bitmap;
m_peer = wxWidgetImpl::CreateBitmapButton( this, parent, id, bitmap, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateBitmapButton( this, parent, id, bitmap, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );

View File

@@ -89,7 +89,7 @@ bool wxButton::Create(wxWindow *parent,
m_labelOrig =
m_label = label ;
m_peer = wxWidgetImpl::CreateButton( this, parent, id, label, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateButton( this, parent, id, label, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -126,10 +126,10 @@ void wxButton::DoSetBitmap(const wxBitmap& bitmap, State which)
m_bitmaps[which] = bitmap;
if ( which == State_Normal )
m_peer->SetBitmap(bitmap);
GetPeer()->SetBitmap(bitmap);
else if ( which == State_Pressed )
{
wxButtonImpl* bi = dynamic_cast<wxButtonImpl*> (m_peer);
wxButtonImpl* bi = dynamic_cast<wxButtonImpl*> (GetPeer());
if ( bi )
bi->SetPressedBitmap(bitmap);
}
@@ -138,7 +138,7 @@ void wxButton::DoSetBitmap(const wxBitmap& bitmap, State which)
void wxButton::DoSetBitmapPosition(wxDirection dir)
{
m_peer->SetBitmapPosition(dir);
GetPeer()->SetBitmapPosition(dir);
InvalidateBestSize();
}
@@ -149,7 +149,7 @@ bool wxButton::DoSetLabelMarkup(const wxString& markup)
if ( !wxButtonBase::DoSetLabelMarkup(markup) )
return false;
m_peer->SetLabelMarkup(markup);
GetPeer()->SetLabelMarkup(markup);
return true;
}
@@ -165,27 +165,27 @@ wxWindow *wxButton::SetDefault()
btnOldDefault->GetPeer()->SetDefaultButton( false );
}
m_peer->SetDefaultButton( true );
GetPeer()->SetDefaultButton( true );
return btnOldDefault;
}
void wxButton::Command (wxCommandEvent & WXUNUSED(event))
{
m_peer->PerformClick() ;
GetPeer()->PerformClick() ;
// ProcessCommand(event);
}
void wxButton::OnEnterWindow( wxMouseEvent& WXUNUSED(event))
{
if ( DoGetBitmap( State_Current ).IsOk() )
m_peer->SetBitmap( DoGetBitmap( State_Current ) );
GetPeer()->SetBitmap( DoGetBitmap( State_Current ) );
}
void wxButton::OnLeaveWindow( wxMouseEvent& WXUNUSED(event))
{
if ( DoGetBitmap( State_Current ).IsOk() )
m_peer->SetBitmap( DoGetBitmap( State_Normal ) );
GetPeer()->SetBitmap( DoGetBitmap( State_Normal ) );
}
bool wxButton::OSXHandleClicked( double WXUNUSED(timestampsec) )
@@ -208,7 +208,7 @@ bool wxDisclosureTriangle::Create(wxWindow *parent, wxWindowID id, const wxStrin
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
m_peer = wxWidgetImpl::CreateDisclosureTriangle(this, parent, id, label, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateDisclosureTriangle(this, parent, id, label, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
// passing the text in the param doesn't seem to work, so lets do it again
@@ -219,12 +219,12 @@ bool wxDisclosureTriangle::Create(wxWindow *parent, wxWindowID id, const wxStrin
void wxDisclosureTriangle::SetOpen( bool open )
{
m_peer->SetValue( open ? 1 : 0 );
GetPeer()->SetValue( open ? 1 : 0 );
}
bool wxDisclosureTriangle::IsOpen() const
{
return m_peer->GetValue() == 1;
return GetPeer()->GetValue() == 1;
}
bool wxDisclosureTriangle::OSXHandleClicked( double WXUNUSED(timestampsec) )

View File

@@ -55,7 +55,7 @@ wxSize wxButton::DoGetBestSize() const
#if wxOSX_USE_CARBON
Rect bestsize = { 0 , 0 , 0 , 0 } ;
m_peer->GetBestRect( &bestsize ) ;
GetPeer()->GetBestRect( &bestsize ) ;
int wBtn;
if ( EmptyRect( &bestsize ) || ( GetWindowStyle() & wxBU_EXACTFIT) )
@@ -63,7 +63,7 @@ wxSize wxButton::DoGetBestSize() const
Point bounds;
ControlFontStyleRec controlFont;
OSStatus err = m_peer->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
OSStatus err = GetPeer()->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
verify_noerr( err );
// GetThemeTextDimensions will cache strings and the documentation

View File

@@ -73,7 +73,7 @@ bool wxControl::ProcessCommand( wxCommandEvent &event )
void wxControl::OnKeyDown( wxKeyEvent &WXUNUSED(event) )
{
if ( m_peer == NULL || !m_peer->IsOk() )
if ( GetPeer() == NULL || !GetPeer()->IsOk() )
return;
#if wxOSX_USE_CARBON
@@ -84,7 +84,7 @@ void wxControl::OnKeyDown( wxKeyEvent &WXUNUSED(event) )
GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode );
GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
m_peer->HandleKey( keyCode, charCode, modifiers );
GetPeer()->HandleKey( keyCode, charCode, modifiers );
#else
// TODO
#endif

View File

@@ -337,8 +337,8 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxWindow *peer, const
err = SetHasScrollBars( (style & wxHSCROLL) != 0 , true );
#if 0
// shouldn't be necessary anymore under 10.2
m_peer->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean)false );
m_peer->SetNeedsFocusRect( true );
GetPeer()->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean)false );
GetPeer()->SetNeedsFocusRect( true );
#endif
}

View File

@@ -678,11 +678,11 @@ bool wxListCtrl::Create(wxWindow *parent,
if ( !wxWindow::Create(parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), name) )
return false;
m_dbImpl = new wxMacDataBrowserListCtrlControl( this, pos, size, style );
m_peer = m_dbImpl;
SetPeer(m_dbImpl);
MacPostControlCreate( pos, size );
InstallControlEventHandler( m_peer->GetControlRef() , GetwxMacListCtrlEventHandlerUPP(),
InstallControlEventHandler( GetPeer()->GetControlRef() , GetwxMacListCtrlEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, this,
(EventHandlerRef *)&m_macListCtrlEventHandler);

View File

@@ -97,32 +97,32 @@ int wxNotebook::HitTest(const wxPoint& pt, long * flags) const
HIPoint hipoint= { adjustedPt.x , adjustedPt.y } ;
HIViewPartCode outPart = 0 ;
OSStatus err = HIViewGetPartHit( m_peer->GetControlRef(), &hipoint, &outPart );
OSStatus err = HIViewGetPartHit( GetPeer()->GetControlRef(), &hipoint, &outPart );
int max = m_peer->GetMaximum() ;
int max = GetPeer()->GetMaximum() ;
if ( outPart == 0 && max > 0 )
{
// this is a hack, as unfortunately a hit on an already selected tab returns 0,
// so we have to go some extra miles to make sure we select something different
// and try again ..
int val = m_peer->GetValue() ;
int val = GetPeer()->GetValue() ;
int maxval = max ;
if ( max == 1 )
{
m_peer->SetMaximum( 2 ) ;
GetPeer()->SetMaximum( 2 ) ;
maxval = 2 ;
}
if ( val == 1 )
m_peer->SetValue( maxval ) ;
GetPeer()->SetValue( maxval ) ;
else
m_peer->SetValue( 1 ) ;
GetPeer()->SetValue( 1 ) ;
err = HIViewGetPartHit( m_peer->GetControlRef(), &hipoint, &outPart );
err = HIViewGetPartHit( GetPeer()->GetControlRef(), &hipoint, &outPart );
m_peer->SetValue( val ) ;
GetPeer()->SetValue( val ) ;
if ( max == 1 )
m_peer->SetMaximum( 1 ) ;
GetPeer()->SetMaximum( 1 ) ;
}
if ( outPart >= 1 && outPart <= countPages )

View File

@@ -48,10 +48,10 @@ wxSize wxStaticText::DoGetBestSize() const
Rect bestsize = { 0 , 0 , 0 , 0 } ;
// try the built-in best size if available
Boolean former = m_peer->GetData<Boolean>( kControlStaticTextIsMultilineTag);
m_peer->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 );
m_peer->GetBestRect( &bestsize ) ;
m_peer->SetData( kControlStaticTextIsMultilineTag, former );
Boolean former = GetPeer()->GetData<Boolean>( kControlStaticTextIsMultilineTag);
GetPeer()->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 );
GetPeer()->GetBestRect( &bestsize ) ;
GetPeer()->SetData( kControlStaticTextIsMultilineTag, former );
if ( !EmptyRect( &bestsize ) )
{
bounds.h = bestsize.right - bestsize.left ;
@@ -62,7 +62,7 @@ wxSize wxStaticText::DoGetBestSize() const
{
#if wxOSX_USE_CARBON
ControlFontStyleRec controlFont;
OSStatus err = m_peer->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
OSStatus err = GetPeer()->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
verify_noerr( err );
#if wxOSX_USE_ATSU_TEXT

View File

@@ -1118,9 +1118,9 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative)
SetAutomaticControlDragTrackingEnabledForWindow( tlw, true );
m_peer->Move(0,0,0,0 );
GetPeer()->Move(0,0,0,0 );
SetSize( wxSIZE_AUTO_WIDTH, 0 );
m_peer->SetVisibility( false );
GetPeer()->SetVisibility( false );
wxToolBarBase::Show( false );
}
}
@@ -1135,7 +1135,7 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative)
ChangeWindowAttributes( tlw, 0, kWindowToolbarButtonAttribute );
MacUninstallNativeToolbar();
m_peer->SetVisibility( true );
GetPeer()->SetVisibility( true );
}
}

View File

@@ -36,7 +36,7 @@ bool wxCheckBox::Create(wxWindow *parent,
m_labelOrig = m_label = label ;
WXValidateStyle( &style );
m_peer = wxWidgetImpl::CreateCheckBox( this, parent, id, label, pos, size, style, GetExtraStyle() ) ;
SetPeer(wxWidgetImpl::CreateCheckBox( this, parent, id, label, pos, size, style, GetExtraStyle() )) ;
MacPostControlCreate(pos, size) ;
@@ -72,12 +72,12 @@ void wxCheckBox::Command(wxCommandEvent & event)
wxCheckBoxState wxCheckBox::DoGet3StateValue() const
{
return (wxCheckBoxState)m_peer->GetValue() ;
return (wxCheckBoxState)GetPeer()->GetValue() ;
}
void wxCheckBox::DoSet3StateValue(wxCheckBoxState val)
{
m_peer->SetValue( val ) ;
GetPeer()->SetValue( val ) ;
}
bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec) )
@@ -85,7 +85,7 @@ bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec) )
bool sendEvent = true;
wxCheckBoxState newState = Get3StateValue();
if ( !m_peer->ButtonClickDidStateChange() )
if ( !GetPeer()->ButtonClickDidStateChange() )
{
wxCheckBoxState origState ;

View File

@@ -74,7 +74,7 @@ bool wxChoice::Create(wxWindow *parent,
m_popUpMenu = new wxMenu();
m_popUpMenu->SetNoEventsMode(true);
m_peer = wxWidgetImpl::CreateChoice( this, parent, id, m_popUpMenu, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateChoice( this, parent, id, m_popUpMenu, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -132,7 +132,7 @@ int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
AssignNewItemClientData(idx, clientData, i, type);
}
m_peer->SetMaximum( GetCount() );
GetPeer()->SetMaximum( GetCount() );
return pos - 1;
}
@@ -148,7 +148,7 @@ void wxChoice::DoDeleteOneItem(unsigned int n)
m_strings.RemoveAt( n ) ;
m_datas.RemoveAt( n ) ;
m_peer->SetMaximum( GetCount() ) ;
GetPeer()->SetMaximum( GetCount() ) ;
}
@@ -162,7 +162,7 @@ void wxChoice::DoClear()
m_strings.Empty() ;
m_datas.Empty() ;
m_peer->SetMaximum( 0 ) ;
GetPeer()->SetMaximum( 0 ) ;
}
// ----------------------------------------------------------------------------
@@ -170,12 +170,12 @@ void wxChoice::DoClear()
// ----------------------------------------------------------------------------
int wxChoice::GetSelection() const
{
return m_peer->GetValue();
return GetPeer()->GetValue();
}
void wxChoice::SetSelection( int n )
{
m_peer->SetValue( n );
GetPeer()->SetValue( n );
}
// ----------------------------------------------------------------------------

View File

@@ -32,7 +32,7 @@ wxSize wxButton::DoGetBestSize() const
return wxSize( 23 , 23 ) ;
wxRect r ;
m_peer->GetBestRect(&r);
GetPeer()->GetBestRect(&r);
wxSize sz = r.GetSize();
sz.x = sz.x + MacGetLeftBorderSize() +

View File

@@ -221,7 +221,7 @@ public:
m_peer = new wxMacControl( this );
OSStatus err = CreateTabsControl(
MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds,
tabsize, tabstyle, 0, NULL, m_peer->GetControlRefAddr() );
tabsize, tabstyle, 0, NULL, GetPeer()->GetControlRefAddr() );
verify_noerr( err );
#endif
*/

View File

@@ -841,9 +841,9 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative)
[tlw setToolbar:(NSToolbar*) m_macToolbar];
[(NSToolbar*) m_macToolbar setVisible:YES];
m_peer->Move(0,0,0,0 );
GetPeer()->Move(0,0,0,0 );
SetSize( wxSIZE_AUTO_WIDTH, 0 );
m_peer->SetVisibility( false );
GetPeer()->SetVisibility( false );
wxToolBarBase::Show( false );
}
}
@@ -855,7 +855,7 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative)
bResult = true;
[(NSToolbar*) m_macToolbar setVisible:NO];
MacUninstallNativeToolbar();
m_peer->SetVisibility( true );
GetPeer()->SetVisibility( true );
}
}

View File

@@ -64,7 +64,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
wxASSERT_MSG( !(style & wxCB_SORT),
"wxCB_SORT not currently supported by wxOSX/Cocoa");
m_peer = wxWidgetImpl::CreateComboBox( this, parent, id, NULL, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateComboBox( this, parent, id, NULL, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -110,7 +110,7 @@ int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
AssignNewItemClientData(idx, clientData, i, type);
}
m_peer->SetMaximum( GetCount() );
GetPeer()->SetMaximum( GetCount() );
return pos - 1;
}
@@ -216,7 +216,7 @@ bool wxComboBox::OSXHandleClicked( double WXUNUSED(timestampsec) )
wxComboWidgetImpl* wxComboBox::GetComboPeer() const
{
return dynamic_cast<wxComboWidgetImpl*> (m_peer);
return dynamic_cast<wxComboWidgetImpl*> (GetPeer());
}
#endif // wxUSE_COMBOBOX && wxOSX_USE_COCOA

View File

@@ -365,7 +365,7 @@ bool wxDataViewCtrl::Create(wxWindow *parent,
{
if (!(wxControl::Create(parent,id,pos,size,style,validator,name)))
return false;
m_peer = ::CreateDataView(this,parent,id,pos,size,style,GetExtraStyle());
SetPeer(::CreateDataView(this,parent,id,pos,size,style,GetExtraStyle()));
MacPostControlCreate(pos,size);

View File

@@ -33,7 +33,7 @@ bool wxGauge::Create( wxWindow *parent,
wxSize size = s;
m_peer = wxWidgetImpl::CreateGauge( this, parent, id, GetValue() , 0, GetRange(), pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateGauge( this, parent, id, GetValue() , 0, GetRange(), pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -45,8 +45,8 @@ void wxGauge::SetRange(int r)
// we are going via the base class in case there is
// some change behind the values by it
wxGaugeBase::SetRange( r ) ;
if ( m_peer )
m_peer->SetMaximum( GetRange() ) ;
if ( GetPeer() )
GetPeer()->SetMaximum( GetRange() ) ;
}
void wxGauge::SetValue(int pos)
@@ -55,8 +55,8 @@ void wxGauge::SetValue(int pos)
// some change behind the values by it
wxGaugeBase::SetValue( pos ) ;
if ( m_peer )
m_peer->SetValue( GetValue() ) ;
if ( GetPeer() )
GetPeer()->SetValue( GetValue() ) ;
}
int wxGauge::GetValue() const
@@ -66,7 +66,7 @@ int wxGauge::GetValue() const
void wxGauge::Pulse()
{
m_peer->PulseGauge();
GetPeer()->PulseGauge();
}
#endif // wxUSE_GAUGE

View File

@@ -85,7 +85,7 @@ bool wxListBox::Create(
else
m_strings.unsorted = new wxArrayString;
m_peer = wxWidgetImpl::CreateListBox( this, parent, id, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateListBox( this, parent, id, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -106,7 +106,7 @@ wxListBox::~wxListBox()
m_blockEvents = false;
// make sure no native events get sent to a object in destruction
wxDELETE(m_peer);
SetPeer(NULL);
if ( IsSorted() )
delete m_strings.sorted;

View File

@@ -111,7 +111,7 @@ void wxMenu::SetNoEventsMode( bool noEvents )
bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
{
wxASSERT_MSG( pItem != NULL, wxT("can't append NULL item to the menu") );
m_peer->InsertOrAppend( pItem, pos );
GetPeer()->InsertOrAppend( pItem, pos );
if ( pItem->IsSeparator() )
{
@@ -228,7 +228,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
wxOSXMenuRemoveItem(m_hMenu , pos );
*/
m_peer->Remove( item );
GetPeer()->Remove( item );
// and from internal data structures
return wxMenuBase::DoRemove(item);
}
@@ -236,7 +236,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
void wxMenu::SetTitle(const wxString& label)
{
m_title = label ;
m_peer->SetTitle( wxStripMenuCodes( label ) );
GetPeer()->SetTitle( wxStripMenuCodes( label ) );
}
bool wxMenu::ProcessCommand(wxCommandEvent & event)

View File

@@ -177,7 +177,7 @@ void wxMenuItem::UpdateItemBitmap()
if ( m_bitmap.Ok() )
{
m_peer->SetBitmap( m_bitmap );
GetPeer()->SetBitmap( m_bitmap );
}
}
@@ -190,11 +190,11 @@ void wxMenuItem::UpdateItemStatus()
return ;
if ( IsCheckable() && IsChecked() )
m_peer->Check( true );
GetPeer()->Check( true );
else
m_peer->Check( false );
GetPeer()->Check( false );
m_peer->Enable( IsEnabled() );
GetPeer()->Enable( IsEnabled() );
}
void wxMenuItem::UpdateItemText()
@@ -210,7 +210,7 @@ void wxMenuItem::UpdateItemText()
}
wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ;
m_peer->SetLabel( text, entry );
GetPeer()->SetLabel( text, entry );
delete entry ;
}

View File

@@ -144,7 +144,7 @@ bool wxNonOwnedWindow::Create(wxWindow *parent,
name
);
wxNonOwnedWindowImpl::Associate( m_nowpeer->GetWXWindow() , m_nowpeer ) ;
m_peer = wxWidgetImpl::CreateContentView(this);
SetPeer(wxWidgetImpl::CreateContentView(this));
DoSetWindowVariant( m_windowVariant ) ;
@@ -177,7 +177,7 @@ void wxNonOwnedWindow::SubclassWin(WXWindow nativeWindow)
m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow(this, GetParent(), nativeWindow );
m_isNativeWindowWrapper = true;
wxNonOwnedWindowImpl::Associate( m_nowpeer->GetWXWindow() , m_nowpeer ) ;
m_peer = wxWidgetImpl::CreateContentView(this);
SetPeer(wxWidgetImpl::CreateContentView(this));
}
void wxNonOwnedWindow::UnsubclassWin()
@@ -189,7 +189,7 @@ void wxNonOwnedWindow::UnsubclassWin()
wxNonOwnedWindowImpl::RemoveAssociations(m_nowpeer) ;
wxDELETE(m_nowpeer);
wxDELETE(m_peer);
SetPeer(NULL);
m_isNativeWindowWrapper = false;
}
@@ -471,7 +471,7 @@ void wxNonOwnedWindow::DoGetClientSize( int *width, int *height ) const
// inner area, while the content area extends under the translucent
// status bar, therefore we use the content view's area
#ifdef __WXOSX_IPHONE__
m_peer->GetContentArea(left, top, w, h);
GetPeer()->GetContentArea(left, top, w, h);
#else
m_nowpeer->GetContentArea(left, top, w, h);
#endif

View File

@@ -53,7 +53,7 @@ bool wxNotebook::Create( wxWindow *parent,
if ( !wxNotebookBase::Create( parent, id, pos, size, style, name ) )
return false;
m_peer = wxWidgetImpl::CreateTabView(this,parent, id, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateTabView(this,parent, id, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -235,7 +235,7 @@ bool wxNotebook::InsertPage(size_t nPage,
m_selection++;
// while this still is the same page showing, we need to update the tabs
m_peer->SetValue( m_selection + 1 ) ;
GetPeer()->SetValue( m_selection + 1 ) ;
}
DoSetSelectionAfterInsertion(nPage, bSelect);
@@ -259,32 +259,32 @@ int wxNotebook::HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(flags)) con
HIPoint hipoint= { adjustedPt.x , adjustedPt.y } ;
HIViewPartCode outPart = 0 ;
OSStatus err = HIViewGetPartHit( m_peer->GetControlRef(), &hipoint, &outPart );
OSStatus err = HIViewGetPartHit( GetPeer()->GetControlRef(), &hipoint, &outPart );
int max = m_peer->GetMaximum() ;
int max = GetPeer()->GetMaximum() ;
if ( outPart == 0 && max > 0 )
{
// this is a hack, as unfortunately a hit on an already selected tab returns 0,
// so we have to go some extra miles to make sure we select something different
// and try again ..
int val = m_peer->GetValue() ;
int val = GetPeer()->GetValue() ;
int maxval = max ;
if ( max == 1 )
{
m_peer->SetMaximum( 2 ) ;
GetPeer()->SetMaximum( 2 ) ;
maxval = 2 ;
}
if ( val == 1 )
m_peer->SetValue( maxval ) ;
GetPeer()->SetValue( maxval ) ;
else
m_peer->SetValue( 1 ) ;
GetPeer()->SetValue( 1 ) ;
err = HIViewGetPartHit( m_peer->GetControlRef(), &hipoint, &outPart );
err = HIViewGetPartHit( GetPeer()->GetControlRef(), &hipoint, &outPart );
m_peer->SetValue( val ) ;
GetPeer()->SetValue( val ) ;
if ( max == 1 )
m_peer->SetMaximum( 1 ) ;
GetPeer()->SetMaximum( 1 ) ;
}
if ( outPart >= 1 && outPart <= countPages )
@@ -311,7 +311,7 @@ int wxNotebook::HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(flags)) con
//
void wxNotebook::MacSetupTabs()
{
m_peer->SetupTabs(*this);
GetPeer()->SetupTabs(*this);
Refresh();
}
@@ -494,14 +494,14 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
}
m_selection = nSel;
m_peer->SetValue( m_selection + 1 ) ;
GetPeer()->SetValue( m_selection + 1 ) ;
}
bool wxNotebook::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
bool status = false ;
SInt32 newSel = m_peer->GetValue() - 1 ;
SInt32 newSel = GetPeer()->GetValue() - 1 ;
if ( newSel != m_selection )
{
wxBookCtrlEvent changing(
@@ -520,7 +520,7 @@ bool wxNotebook::OSXHandleClicked( double WXUNUSED(timestampsec) )
}
else
{
m_peer->SetValue( m_selection + 1 ) ;
GetPeer()->SetValue( m_selection + 1 ) ;
}
status = true ;

View File

@@ -113,7 +113,7 @@ bool wxRadioBox::Create( wxWindow *parent,
m_labelOrig = m_label = label;
m_peer = wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() ));
for (i = 0; i < n; i++)
{

View File

@@ -32,7 +32,7 @@ bool wxRadioButton::Create( wxWindow *parent,
m_labelOrig = m_label = label;
m_peer = wxWidgetImpl::CreateRadioButton( this, parent, id, label, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateRadioButton( this, parent, id, label, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -74,10 +74,10 @@ wxRadioButton::~wxRadioButton()
void wxRadioButton::SetValue(bool val)
{
wxRadioButton *cycle;
if (m_peer->GetValue() == val)
if (GetPeer()->GetValue() == val)
return;
m_peer->SetValue( val );
GetPeer()->SetValue( val );
if (val)
{
cycle = this->NextInCycle();
@@ -94,7 +94,7 @@ void wxRadioButton::SetValue(bool val)
bool wxRadioButton::GetValue() const
{
return m_peer->GetValue() != 0;
return GetPeer()->GetValue() != 0;
}
void wxRadioButton::Command(wxCommandEvent& event)
@@ -105,7 +105,7 @@ void wxRadioButton::Command(wxCommandEvent& event)
bool wxRadioButton::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
if ( !m_peer->ButtonClickDidStateChange() )
if ( !GetPeer()->ButtonClickDidStateChange() )
{
// if already set -> no action
if (GetValue())

View File

@@ -40,7 +40,7 @@ bool wxScrollBar::Create( wxWindow *parent,
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
return false;
m_peer = wxWidgetImpl::CreateScrollBar( this, parent, id, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateScrollBar( this, parent, id, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -53,12 +53,12 @@ wxScrollBar::~wxScrollBar()
void wxScrollBar::SetThumbPosition( int viewStart )
{
m_peer->SetScrollThumb( viewStart, m_viewSize );
GetPeer()->SetScrollThumb( viewStart, m_viewSize );
}
int wxScrollBar::GetThumbPosition() const
{
return m_peer->GetValue();
return GetPeer()->GetValue();
}
void wxScrollBar::SetScrollbar( int position,
@@ -73,8 +73,8 @@ void wxScrollBar::SetScrollbar( int position,
int range1 = wxMax( (m_objectSize - m_viewSize), 0 );
m_peer->SetMaximum( range1 );
m_peer->SetScrollThumb( position, m_viewSize );
GetPeer()->SetMaximum( range1 );
GetPeer()->SetScrollThumb( position, m_viewSize );
}
void wxScrollBar::Command( wxCommandEvent& event )
@@ -85,7 +85,7 @@ void wxScrollBar::Command( wxCommandEvent& event )
bool wxScrollBar::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
int new_pos = m_peer->GetValue();
int new_pos = GetPeer()->GetValue();
wxScrollEvent event( wxEVT_SCROLL_THUMBRELEASE, m_windowId );
if ( m_windowStyle & wxHORIZONTAL )
@@ -127,9 +127,9 @@ wxSize wxScrollBar::DoGetBestSize() const
void wxScrollBar::TriggerScrollEvent( wxEventType scrollEvent )
{
int position = m_peer->GetValue();
int position = GetPeer()->GetValue();
int minPos = 0 ;
int maxPos = m_peer->GetMaximum();
int maxPos = GetPeer()->GetMaximum();
int nScrollInc = 0;
if ( scrollEvent == wxEVT_SCROLL_LINEUP )

View File

@@ -103,7 +103,7 @@ bool wxSlider::Create(wxWindow *parent,
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
m_peer = wxWidgetImpl::CreateSlider( this, parent, id, value, minValue, maxValue, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateSlider( this, parent, id, value, minValue, maxValue, pos, size, style, GetExtraStyle() ));
if (style & wxSL_VERTICAL)
// Forces SetSize to use the proper width
@@ -146,7 +146,7 @@ wxSlider::~wxSlider()
int wxSlider::GetValue() const
{
// We may need to invert the value returned by the widget
return ValueInvertOrNot( m_peer->GetValue() ) ;
return ValueInvertOrNot( GetPeer()->GetValue() ) ;
}
void wxSlider::SetValue(int value)
@@ -159,7 +159,7 @@ void wxSlider::SetValue(int value)
}
// We only invert for the setting of the actual native widget
m_peer->SetValue( ValueInvertOrNot( value ) );
GetPeer()->SetValue( ValueInvertOrNot( value ) );
}
void wxSlider::SetRange(int minValue, int maxValue)
@@ -175,8 +175,8 @@ void wxSlider::SetRange(int minValue, int maxValue)
m_rangeMin = minValue;
m_rangeMax = maxValue;
m_peer->SetMinimum( m_rangeMin );
m_peer->SetMaximum( m_rangeMax );
GetPeer()->SetMinimum( m_rangeMin );
GetPeer()->SetMaximum( m_rangeMax );
if (m_macMinimumStatic)
{
@@ -288,7 +288,7 @@ void wxSlider::TriggerScrollEvent( wxEventType scrollEvent)
{
// Whatever the native value is, we may need to invert it for calling
// SetValue and putting the possibly inverted value in the event
int value = ValueInvertOrNot( m_peer->GetValue() );
int value = ValueInvertOrNot( GetPeer()->GetValue() );
SetValue( value );
@@ -436,7 +436,7 @@ void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags)
if (GetWindowStyle() & wxSL_VERTICAL)
// If vertical, use current value
text.Printf(wxT("%d"), (int)m_peer->GetValue());
text.Printf(wxT("%d"), (int)GetPeer()->GetValue());
else
// Use max so that the current value doesn't drift as centering would need to change
text.Printf(wxT("%d"), m_rangeMax);

View File

@@ -37,8 +37,8 @@ bool wxSpinButton::Create( wxWindow *parent,
if (!parent)
return false;
m_peer = wxWidgetImpl::CreateSpinButton( this , parent, id, 0, m_min, m_max, pos, size,
style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateSpinButton( this , parent, id, 0, m_min, m_max, pos, size,
style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -51,20 +51,20 @@ wxSpinButton::~wxSpinButton()
void wxSpinButton::SetValue( int val )
{
m_peer->SetValue( val );
GetPeer()->SetValue( val );
}
int wxSpinButton::GetValue() const
{
return m_peer->GetValue();
return GetPeer()->GetValue();
}
void wxSpinButton::SetRange(int minVal, int maxVal)
{
m_min = minVal;
m_max = maxVal;
m_peer->SetMaximum( maxVal );
m_peer->SetMinimum( minVal );
GetPeer()->SetMaximum( maxVal );
GetPeer()->SetMinimum( minVal );
}
void wxSpinButton::SendThumbTrackEvent()
@@ -143,7 +143,7 @@ void wxSpinButton::TriggerScrollEvent(wxEventType scrollEvent)
newValue = oldValue;
}
m_peer->SetValue( newValue );
GetPeer()->SetValue( newValue );
// always send a thumbtrack event
SendThumbTrackEvent() ;

View File

@@ -68,7 +68,7 @@ void wxSearchCtrl::Init()
wxSearchWidgetImpl* wxSearchCtrl::GetSearchPeer() const
{
return dynamic_cast<wxSearchWidgetImpl*> (m_peer);
return dynamic_cast<wxSearchWidgetImpl*> (GetPeer());
}
wxSearchCtrl::~wxSearchCtrl()
@@ -185,7 +185,7 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
}
m_peer = wxWidgetImpl::CreateSearchControl( this, GetParent(), GetId(), value, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateSearchControl( this, GetParent(), GetId(), value, pos, size, style, GetExtraStyle() ));
MacPostControlCreate(pos, size) ;

View File

@@ -31,7 +31,7 @@ bool wxStaticBox::Create( wxWindow *parent,
m_labelOrig = m_label = label;
m_peer = wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );

View File

@@ -54,7 +54,7 @@ bool wxStaticLine::Create( wxWindow *parent,
style, wxDefaultValidator, name) )
return false;
m_peer = wxWidgetImpl::CreateStaticLine( this, parent, id, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateStaticLine( this, parent, id, pos, size, style, GetExtraStyle() ));
MacPostControlCreate(pos,size) ;

View File

@@ -41,7 +41,7 @@ bool wxStaticText::Create( wxWindow *parent,
if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
return false;
m_peer = wxWidgetImpl::CreateStaticText( this, parent, id, label, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateStaticText( this, parent, id, label, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
@@ -101,7 +101,7 @@ bool wxStaticText::SetFont(const wxFont& font)
void wxStaticText::DoSetLabel(const wxString& label)
{
m_label = RemoveMnemonics(label);
m_peer->SetLabel(m_label , GetFont().GetEncoding() );
GetPeer()->SetLabel(m_label , GetFont().GetEncoding() );
}
#if wxUSE_MARKUP && wxOSX_USE_COCOA
@@ -111,7 +111,7 @@ bool wxStaticText::DoSetLabelMarkup(const wxString& markup)
if ( !wxStaticTextBase::DoSetLabelMarkup(markup) )
return false;
m_peer->SetLabelMarkup(markup);
GetPeer()->SetLabelMarkup(markup);
return true;
}

View File

@@ -112,7 +112,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
}
m_peer = wxWidgetImpl::CreateTextControl( this, GetParent(), GetId(), str, pos, size, style, GetExtraStyle() );
SetPeer(wxWidgetImpl::CreateTextControl( this, GetParent(), GetId(), str, pos, size, style, GetExtraStyle() ));
MacPostControlCreate(pos, size) ;

View File

@@ -54,7 +54,7 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
m_labelOrig = m_label = label ;
m_peer = wxWidgetImpl::CreateToggleButton( this, parent, id, label, pos, size, style, GetExtraStyle() ) ;
SetPeer(wxWidgetImpl::CreateToggleButton( this, parent, id, label, pos, size, style, GetExtraStyle() )) ;
MacPostControlCreate(pos,size) ;
@@ -75,12 +75,12 @@ wxSize wxToggleButton::DoGetBestSize() const
void wxToggleButton::SetValue(bool val)
{
m_peer->SetValue( val ) ;
GetPeer()->SetValue( val ) ;
}
bool wxToggleButton::GetValue() const
{
return m_peer->GetValue() ;
return GetPeer()->GetValue() ;
}
void wxToggleButton::Command(wxCommandEvent & event)
@@ -121,7 +121,7 @@ bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id,
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
m_peer = wxWidgetImpl::CreateBitmapToggleButton( this, parent, id, label, pos, size, style, GetExtraStyle() ) ;
SetPeer(wxWidgetImpl::CreateBitmapToggleButton( this, parent, id, label, pos, size, style, GetExtraStyle() ));
MacPostControlCreate(pos,size) ;
@@ -142,12 +142,12 @@ wxSize wxBitmapToggleButton::DoGetBestSize() const
void wxBitmapToggleButton::SetValue(bool val)
{
m_peer->SetValue( val ) ;
GetPeer()->SetValue( val ) ;
}
bool wxBitmapToggleButton::GetValue() const
{
return m_peer->GetValue() ;
return GetPeer()->GetValue() ;
}
void wxBitmapToggleButton::Command(wxCommandEvent & event)

View File

@@ -268,6 +268,13 @@ WXWidget wxWindowMac::GetHandle() const
return NULL;
}
void wxWindowMac::SetPeer(wxOSXWidgetImpl* peer)
{
wxDELETE(m_peer);
// todo event check handlers
m_peer = peer;
}
// ---------------------------------------------------------------------------
// Utility Routines to move between different coordinate systems
// ---------------------------------------------------------------------------