]> git.saurik.com Git - wxWidgets.git/commitdiff
adding a peer pointing back to wxWindow
authorStefan Csomor <csomor@advancedconcepts.ch>
Wed, 23 Feb 2005 15:46:03 +0000 (15:46 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Wed, 23 Feb 2005 15:46:03 +0000 (15:46 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32315 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

20 files changed:
include/wx/mac/carbon/private.h
src/mac/carbon/bmpbuttn.cpp
src/mac/carbon/button.cpp
src/mac/carbon/checkbox.cpp
src/mac/carbon/checklst.cpp
src/mac/carbon/choice.cpp
src/mac/carbon/combobxc.cpp
src/mac/carbon/dc.cpp
src/mac/carbon/gauge.cpp
src/mac/carbon/listbox.cpp
src/mac/carbon/notebmac.cpp
src/mac/carbon/radiobut.cpp
src/mac/carbon/scrolbar.cpp
src/mac/carbon/slider.cpp
src/mac/carbon/spinbutt.cpp
src/mac/carbon/statbox.cpp
src/mac/carbon/statlmac.cpp
src/mac/carbon/stattext.cpp
src/mac/carbon/tabctrl.cpp
src/mac/carbon/tglbtn.cpp

index 4fa8f237dac7fefb85f27e8b69af1d89bb646341..17426052d28b38464390b47fdaecc8739140cc77 100644 (file)
@@ -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
index 84fb35b64ff542115e4f442731e010a4fc8a0a74..727df6679cab0aa67e1d8b9782adbbb0ae0bd0bf 100644 (file)
@@ -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() ) );
index 0298236cc3b4b4d28f47052dcdc0fa5839857155..4402850171d85bad6e6470ed2530a38f4714c17c 100644 (file)
@@ -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 ;
index b8ad8a5169b26c3c7f55d4f04bd1a11f82748694..68577df5d259babd7cd0911b87262b1dc82ce444 100644 (file)
@@ -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() ) );
     
index 1169800ec4c663bb2c403de0766b1996211179fe..d56fb61bc94e70765b05f00b825b4727e5518cc9 100644 (file)
@@ -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() ) );
     
 
index 548eee9e53d915b12769cbcb69f876c8afda9acd..abc4a0973d9b6e18fcb84fea1dccc73c6183ca7a 100644 (file)
@@ -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() ) );
 
index 59c2d1db3bd7020c628d5b263a08043f2b63ea30..5e88864db49af78d3c1c171d097fb99c95f337a4 100644 (file)
@@ -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 ) );
 
 
index da8c9f138bdf35f7ec7ca3a87d620ad76218f94a..d9630ecbb9916fa48eb4d3465437582c81a40631 100644 (file)
@@ -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 ) ;
     }
 }
index 1970134e2f28440b72dd6b0af58b0a8bde27d0c2..c10665e40242a286ed494e5b1b31ed83f45218c0 100644 (file)
@@ -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() ) );
 
index b897ec3b41b4d74b3837efbfe51130e8aada2209..a9d1246fae208c7b237d7eeee5590f944e7945ee 100644 (file)
@@ -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 ;
index f6e54f85228c0b9828cb7e795ecd3a609f1d657b..e382c62449e24335a4dc926d343ecaf1b2e2b24f 100644 (file)
@@ -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() ) );
     
index d3c41879403ca8349293597cbf8b535a21eec909..a370f1aa6de3a3dab7e6843cf56743ce376bddaf 100644 (file)
@@ -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() ) );
     
index 1b253bad4f477a8c1ad05e9bb3aa3fd6a42da21a..2f77f5e9029e88688ce6825bfb9b53869ddcf9f6 100644 (file)
@@ -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() ) );
     
index 6ffd9dd1a5fe6acbf03f6e9931453a1fcfdf6ddd..422fea6b02b6bb3438f988b6d675298c34661231 100644 (file)
@@ -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() ) );
index 35f00904d4c7a757feeceba15ae19196cf20f989..2b432a85a677be49609c05e89c62d3223cd262fb 100644 (file)
@@ -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() ) );
 
index 23b359dcb223a55ef200137d48a9be1e1411be77..cc29e9b2675a79bb0a32b98546e3e18586fad3d5 100644 (file)
@@ -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() ) ) ;  
 
index 92d31f27e27f168036cc36d5d9463b952802d3aa..1b47d345d67e39e0bfb15d2a54868a8052ff9195 100644 (file)
@@ -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) ;
index f01e11f66652f8a4b79cbacfbb78325dfb8cd1d1..f14cd26836d3a73cc699cb015c99995c05bb4372 100644 (file)
@@ -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() ) ) ;  
 
index 6f4b3006ed2096c03542caeb514fd2591809374e..12d52b880167457d65bec478b712d02d43584387 100644 (file)
@@ -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() ) );
     
index 1c3c21b8cd7337d539c426f25bd39958355393d7..b13a2d96ab322071d6fc8c59955e10ff8fbee2ce 100644 (file)
@@ -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() ) );