From b905d6cc083a38d46ae48712f5221236247a39ce Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 23 Feb 2005 15:46:03 +0000 Subject: [PATCH] adding a peer pointing back to wxWindow git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32315 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/carbon/private.h | 14 ++++++++++---- src/mac/carbon/bmpbuttn.cpp | 2 +- src/mac/carbon/button.cpp | 2 +- src/mac/carbon/checkbox.cpp | 2 +- src/mac/carbon/checklst.cpp | 2 +- src/mac/carbon/choice.cpp | 2 +- src/mac/carbon/combobxc.cpp | 2 +- src/mac/carbon/dc.cpp | 17 ++++++++++------- src/mac/carbon/gauge.cpp | 2 +- src/mac/carbon/listbox.cpp | 2 +- src/mac/carbon/notebmac.cpp | 2 +- src/mac/carbon/radiobut.cpp | 2 +- src/mac/carbon/scrolbar.cpp | 2 +- src/mac/carbon/slider.cpp | 2 +- src/mac/carbon/spinbutt.cpp | 2 +- src/mac/carbon/statbox.cpp | 2 +- src/mac/carbon/statlmac.cpp | 2 +- src/mac/carbon/stattext.cpp | 2 +- src/mac/carbon/tabctrl.cpp | 2 +- src/mac/carbon/tglbtn.cpp | 2 +- 20 files changed, 38 insertions(+), 29 deletions(-) diff --git a/include/wx/mac/carbon/private.h b/include/wx/mac/carbon/private.h index 4fa8f237da..17426052d2 100644 --- a/include/wx/mac/carbon/private.h +++ b/include/wx/mac/carbon/private.h @@ -411,19 +411,23 @@ Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxS class wxMacControl { public : - wxMacControl() + wxMacControl(wxWindow* peer) { + m_peer = peer ; m_controlRef = NULL ; } - wxMacControl( ControlRef control ) + wxMacControl( wxWindow* peer , ControlRef control ) { + m_peer = peer ; m_controlRef = control ; } - wxMacControl( WXWidget control ) + wxMacControl( wxWindow* peer , WXWidget control ) { + m_peer = peer ; m_controlRef = (ControlRef) control ; } + virtual ~wxMacControl() { } @@ -513,9 +517,10 @@ public : // invalidates this control and all children virtual void InvalidateWithChildren() ; virtual void SetDrawingEnabled( bool enable ) ; +#ifdef __WXMAC_OSX__ virtual bool GetNeedsDisplay() const ; virtual void SetNeedsDisplay( bool needsDisplay , RgnHandle where = NULL ) ; - +#endif virtual void ScrollRect( const wxRect &rect , int dx , int dy ) ; virtual void GetRect( Rect *r ) ; @@ -565,6 +570,7 @@ protected : ControlRef m_controlRef ; wxFont m_font ; long m_windowStyle ; + wxWindow* m_peer ; } ; #if wxMAC_USE_CORE_GRAPHICS diff --git a/src/mac/carbon/bmpbuttn.cpp b/src/mac/carbon/bmpbuttn.cpp index 84fb35b64f..727df6679c 100644 --- a/src/mac/carbon/bmpbuttn.cpp +++ b/src/mac/carbon/bmpbuttn.cpp @@ -72,7 +72,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit wxMacCreateBitmapButton( &info , m_bmpNormal ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl( this ) ; verify_noerr ( CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevel : kControlBevelButtonNormalBevel ) , kControlBehaviorOffsetContents , &info , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index 0298236cc3..4402850171 100644 --- a/src/mac/carbon/button.cpp +++ b/src/mac/carbon/button.cpp @@ -44,7 +44,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& lbl, m_label = label ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; if ( id == wxID_HELP ) { ControlButtonContentInfo info ; diff --git a/src/mac/carbon/checkbox.cpp b/src/mac/carbon/checkbox.cpp index b8ad8a5169..68577df5d2 100644 --- a/src/mac/carbon/checkbox.cpp +++ b/src/mac/carbon/checkbox.cpp @@ -45,7 +45,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, maxValue = 2 /* kControlCheckboxMixedValue */; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr( CreateCheckBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds , CFSTR("") , 0 , false , m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/checklst.cpp b/src/mac/carbon/checklst.cpp index 1169800ec4..d56fb61bc9 100644 --- a/src/mac/carbon/checklst.cpp +++ b/src/mac/carbon/checklst.cpp @@ -224,7 +224,7 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, kDataBrowserListView , m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 548eee9e53..abc4a0973d 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -70,7 +70,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr ( CreatePopupButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , -12345 , false /* no variable width */ , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/combobxc.cpp b/src/mac/carbon/combobxc.cpp index 59c2d1db3b..5e88864db4 100644 --- a/src/mac/carbon/combobxc.cpp +++ b/src/mac/carbon/combobxc.cpp @@ -383,7 +383,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, //hiRect.size.height = bounds.bottom - bounds.top; //printf("left = %d, right = %d, top = %d, bottom = %d\n", bounds.left, bounds.right, bounds.top, bounds.bottom); //printf("x = %d, y = %d, width = %d, height = %d\n", hibounds.origin.x, hibounds.origin.y, hibounds.size.width, hibounds.size.height); - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr( HIComboBoxCreate( &hiRect, CFSTR(""), NULL, NULL, kHIComboBoxStandardAttributes, *m_peer ) ); diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index da8c9f138b..d9630ecbb9 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -107,13 +107,16 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) : if ( win ) { - int x = 0 , y = 0; - win->MacWindowToRootWindow( &x,&y ) ; - // get area including focus rect - CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ) ; - if ( !EmptyRgn( m_newClip ) ) - OffsetRgn( m_newClip , x , y ) ; - + // guard against half constructed objects, this just leads to a empty clip + if( win->GetPeer() ) + { + int x = 0 , y = 0; + win->MacWindowToRootWindow( &x,&y ) ; + // get area including focus rect + CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ) ; + if ( !EmptyRgn( m_newClip ) ) + OffsetRgn( m_newClip , x , y ) ; + } SetClip( m_newClip ) ; } } diff --git a/src/mac/carbon/gauge.cpp b/src/mac/carbon/gauge.cpp index 1970134e2f..c10665e402 100644 --- a/src/mac/carbon/gauge.cpp +++ b/src/mac/carbon/gauge.cpp @@ -46,7 +46,7 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, } */ Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr ( CreateProgressBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , GetValue() , 0 , GetRange() , false /* not indeterminate */ , m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index b897ec3b41..a9d1246fae 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -182,7 +182,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, kDataBrowserListView , m_peer->GetControlRefAddr() ) ); DataBrowserSelectionFlags options = kDataBrowserDragSelect ; diff --git a/src/mac/carbon/notebmac.cpp b/src/mac/carbon/notebmac.cpp index f6e54f8522..e382c62449 100644 --- a/src/mac/carbon/notebmac.cpp +++ b/src/mac/carbon/notebmac.cpp @@ -129,7 +129,7 @@ bool wxNotebook::Create(wxWindow *parent, tabsize = kControlSizeSmall; } - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr ( CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , tabsize , tabstyle, 0, NULL, m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/radiobut.cpp b/src/mac/carbon/radiobut.cpp index d3c4187940..a370f1aa6d 100644 --- a/src/mac/carbon/radiobut.cpp +++ b/src/mac/carbon/radiobut.cpp @@ -41,7 +41,7 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr ( CreateRadioButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , 0 , false /* no autotoggle */ , m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/scrolbar.cpp b/src/mac/carbon/scrolbar.cpp index 1b253bad4f..2f77f5e902 100644 --- a/src/mac/carbon/scrolbar.cpp +++ b/src/mac/carbon/scrolbar.cpp @@ -47,7 +47,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr ( CreateScrollBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 0 , 0 , 100 , 1 , true /* liveTracking */ , wxMacLiveScrollbarActionUPP , m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index 6ffd9dd1a5..422fea6b02 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -91,7 +91,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, while (tickMarks > 20) tickMarks /= 5; //keep the number of tickmarks from becoming unwieldly - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr ( CreateSliderControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , value , minValue , maxValue , kControlSliderPointsDownOrRight , tickMarks , true /* liveTracking */ , wxMacLiveScrollbarActionUPP , m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/spinbutt.cpp b/src/mac/carbon/spinbutt.cpp index 35f00904d4..2b432a85a6 100644 --- a/src/mac/carbon/spinbutt.cpp +++ b/src/mac/carbon/spinbutt.cpp @@ -58,7 +58,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr ( CreateLittleArrowsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 0 , m_min , m_max , 1 , m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/statbox.cpp b/src/mac/carbon/statbox.cpp index 23b359dcb2..cc29e9b267 100644 --- a/src/mac/carbon/statbox.cpp +++ b/src/mac/carbon/statbox.cpp @@ -45,7 +45,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , true /*primary*/ , m_peer->GetControlRefAddr() ) ) ; diff --git a/src/mac/carbon/statlmac.cpp b/src/mac/carbon/statlmac.cpp index 92d31f27e2..1b47d345d6 100644 --- a/src/mac/carbon/statlmac.cpp +++ b/src/mac/carbon/statlmac.cpp @@ -56,7 +56,7 @@ bool wxStaticLine::Create( wxWindow *parent, return false; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr(CreateSeparatorControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, m_peer->GetControlRefAddr() ) ) ; MacPostControlCreate(pos,size) ; diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index f01e11f666..f14cd26836 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -51,7 +51,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, str , NULL , m_peer->GetControlRefAddr() ) ) ; diff --git a/src/mac/carbon/tabctrl.cpp b/src/mac/carbon/tabctrl.cpp index 6f4b3006ed..12d52b8801 100644 --- a/src/mac/carbon/tabctrl.cpp +++ b/src/mac/carbon/tabctrl.cpp @@ -59,7 +59,7 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons tabsize = kControlSizeSmall; } - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr ( CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , tabsize , tabstyle, 0, NULL, m_peer->GetControlRefAddr() ) ); diff --git a/src/mac/carbon/tglbtn.cpp b/src/mac/carbon/tglbtn.cpp index 1c3c21b8cd..b13a2d96ab 100644 --- a/src/mac/carbon/tglbtn.cpp +++ b/src/mac/carbon/tglbtn.cpp @@ -65,7 +65,7 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - m_peer = new wxMacControl() ; + m_peer = new wxMacControl(this) ; verify_noerr ( CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , kControlBevelButtonNormalBevel , kControlBehaviorToggles , NULL , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) ); -- 2.45.2