]> git.saurik.com Git - wxWidgets.git/commitdiff
moving embedding to common API
authorStefan Csomor <csomor@advancedconcepts.ch>
Fri, 10 Oct 2008 19:01:32 +0000 (19:01 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Fri, 10 Oct 2008 19:01:32 +0000 (19:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56218 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

25 files changed:
include/wx/osx/carbon/private.h
include/wx/osx/cocoa/private.h
include/wx/osx/core/private.h
src/osx/carbon/textctrl.cpp
src/osx/carbon/window.cpp
src/osx/cocoa/bmpbuttn.mm
src/osx/cocoa/button.mm
src/osx/cocoa/checkbox.mm
src/osx/cocoa/choice.mm
src/osx/cocoa/gauge.mm
src/osx/cocoa/glcanvas.mm
src/osx/cocoa/listbox.mm
src/osx/cocoa/notebook.mm
src/osx/cocoa/radiobut.mm
src/osx/cocoa/scrolbar.mm
src/osx/cocoa/slider.mm
src/osx/cocoa/spinbutt.mm
src/osx/cocoa/srchctrl.mm
src/osx/cocoa/statbox.mm
src/osx/cocoa/statline.mm
src/osx/cocoa/stattext.mm
src/osx/cocoa/textctrl.mm
src/osx/cocoa/tglbtn.mm
src/osx/cocoa/window.mm
src/osx/window_osx.cpp

index 2e5d38c20ba215b958f11c060923e8bd1c05e9dd..3e35afa471611133f4b941c3e767956ca27ff3a4 100644 (file)
@@ -299,8 +299,6 @@ public :
 
     virtual WXWidget GetWXWidget() const { return (WXWidget) m_controlRef; }
 
-    virtual void SetReference( URefCon data );
-    
     virtual bool        IsVisible() const;
 
     virtual void        Raise();
index fa8075efe560b0e0a6371cae07350239f44548a6..f46aeafa2fe690706768605401b286171d0b5585 100644 (file)
@@ -160,6 +160,7 @@ public :
 
     void                SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
 
+    void                InstallEventHandler( WXWidget control = NULL );
 protected:
     WXWidget m_osxView;
     DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
index 15e0f81736d96f7a8701eef60e2ca5af5e65c721..dec77345e54cce44486a94e8cb39ca0d56558098 100644 (file)
@@ -235,6 +235,8 @@ public :
     // is the clicked event sent AFTER the state already changed, so no additional
     // state changing logic is required from the outside
     virtual bool        ButtonClickDidStateChange() = 0;
+    
+    virtual void        InstallEventHandler( WXWidget control = NULL ) = 0;
 
     // static methods for associating native controls and their implementations
 
index 55fb6f4178a28303e0e712227e3a90f152c4e911..f385f45e0666e815f0648b61c98bce2e8792a9f7 100644 (file)
@@ -1907,6 +1907,7 @@ wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl *wxPeer,
         MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()),
         &bounds, featureSet, &m_controlRef );
     verify_noerr( err );
+    SetControlReference( m_controlRef , (URefCon) wxPeer );
 
     DoCreate();
 
index 21e9c4174a56316a237157191a12417d1b7d7b5a..2a2db6407cfe57b051ffc97026cc39d931a6f3f8 100644 (file)
@@ -841,22 +841,15 @@ void wxMacControl::Init()
     m_macControlEventHandler = NULL;
 }
 
-void wxMacControl::SetReference( URefCon data )
-{
-    SetControlReference( m_controlRef , data );
-}
-
 void wxMacControl::RemoveFromParent()
 {
     // nothing to do here for carbon
+    HIViewRemoveFromSuperview(m_controlRef);
 }
 
 void wxMacControl::Embed( wxWidgetImpl *parent )
 {
-    // copied from MacPostControlCreate
-    ControlRef container = (ControlRef) parent->GetWXWidget() ;
-    wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
-    ::EmbedControl( m_controlRef , container ) ;
+    HIViewAddSubview(parent->GetWXWidget(), m_controlRef);
 }
 
 void wxMacControl::SetNeedsDisplay( const wxRect* rect )
@@ -1388,6 +1381,13 @@ void wxMacControl::SetScrollThumb( wxInt32 WXUNUSED(pos), wxInt32 WXUNUSED(views
     // implemented in respective subclass
 }
 
+void wxMacControl::AddSubWidget( wxWidgetImpl* widget )
+{
+    ControlRef container = (ControlRef) GetWXWidget() ;
+    wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
+    ::EmbedControl( (ControlRef) widget->GetWXWidget() , container ) ;
+}
+
 //
 // Tab Control
 //
index 3de4eafe5facd3f22a76f3a6e58df12c80382898..0c1f471a3ea87a7d70b14c7dfef0354c9e8c96b9 100644 (file)
@@ -31,15 +31,12 @@ wxWidgetImplType* wxWidgetImpl::CreateBitmapButton( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle) 
 {
-    NSView* sv = static_cast<NSView*>(wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
     
     [v setBezelStyle:NSRegularSquareBezelStyle];
     [v setImage:bitmap.GetNSImage() ];
     [v setButtonType:NSMomentaryPushInButton];
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index ec396993247ea9a991e6e718f16e77b925a43feb..bbf249361fd37c04b6e01e050378f3cd05ef3511 100644 (file)
@@ -198,8 +198,6 @@ wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle) 
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
     
@@ -213,7 +211,6 @@ wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
     }
     
     [v setButtonType:NSMomentaryPushInButton];
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
@@ -287,15 +284,12 @@ wxWidgetImplType* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle) 
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
     [v setBezelStyle:NSDisclosureBezelStyle];
     [v setButtonType:NSOnOffButton];
     [v setTitle:wxCFStringRef( label).AsNSString()];
     [v setImagePosition:NSImageRight];
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index 0bca191ba836a67aac4c1b2856f617962e154fc5..8e79189ed1eef16421a4a733b0553bfad09dbe80 100644 (file)
@@ -25,8 +25,6 @@ wxWidgetImplType* wxWidgetImpl::CreateCheckBox( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle) 
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
 
@@ -34,7 +32,6 @@ wxWidgetImplType* wxWidgetImpl::CreateCheckBox( wxWindowMac* wxpeer,
     if (style & wxCHK_3STATE)
         [v setAllowsMixedState:YES];
         
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index 50d1bac3321a4a0332edeefb52e9afe9c45b4553..cf583d5fee7bc6e8efd68f70e26bd7e267d12624 100644 (file)
@@ -91,11 +91,8 @@ wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStylew)
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSPopUpButton* v = [[wxNSPopUpButton alloc] initWithFrame:r pullsDown:NO];
-    [sv addSubview:v];
     [v setMenu: menu->GetHMenu()];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
index 80ed675dc876d76471216f240e06cb257ca34624..71b9043b0a4055e0e0f77b16dc3feefb6de70e87 100644 (file)
@@ -105,8 +105,6 @@ wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle)
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSProgressIndicator* v = [[wxNSProgressIndicator alloc] initWithFrame:r];
 
@@ -114,7 +112,6 @@ wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
     [v setMaxValue: maximum];
     [v setIndeterminate:FALSE];
     [v setDoubleValue: (double) value];
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxOSXGaugeCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index df3bb0e424a5585e222be804f9d19ebd71a3c9b0..0952fc18f3477cd9de4d72aeaa9b9615143b34a6 100644 (file)
@@ -291,11 +291,8 @@ bool wxGLCanvas::Create(wxWindow *parent,
         return false;
 
 /*
-    NSView* sv = (parent->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( this, pos , size ) ;
     wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r];
-    [sv addSubview:v];
     m_peer = new wxWidgetCocoaImpl( this, v );
     [v setImplementation:m_peer];
 
index 2d43f9827f261a1b63f059360e68827063cb9d6e..5297c16508d2b24a21fadc1cc278e0bbdeb172e8 100644 (file)
@@ -473,8 +473,6 @@ wxWidgetImplType* wxWidgetImpl::CreateListBox( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle)
 {
-    NSView* superv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     NSScrollView* scrollview = [[NSScrollView alloc] initWithFrame:r];
     
@@ -503,7 +501,6 @@ wxWidgetImplType* wxWidgetImpl::CreateListBox( wxWindowMac* wxpeer,
     [tableview setColumnAutoresizingStyle:NSTableViewLastColumnOnlyAutoresizingStyle];
     wxNSTableDataSource* ds = [[ wxNSTableDataSource alloc] init];
     [tableview setDataSource:ds];
-    [superv addSubview:scrollview];
     wxListWidgetCocoaImpl* c = new wxListWidgetCocoaImpl( wxpeer, scrollview, tableview, ds );
     [tableview setImplementation:c];
     [ds setImplementation:c];
index e085d76899d84eab834f18f03302459301902fe2..d4acf6b3200614d15227663cbed8f7d85781798f 100644 (file)
@@ -246,8 +246,6 @@ wxWidgetImplType* wxWidgetImpl::CreateTabView( wxWindowMac* wxpeer,
     if ( !controller )
         controller =[[wxTabViewController alloc] init];
 
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     
     NSTabViewType tabstyle = NSTopTabsBezelBorder;
@@ -259,7 +257,6 @@ wxWidgetImplType* wxWidgetImpl::CreateTabView( wxWindowMac* wxpeer,
         tabstyle = NSBottomTabsBezelBorder;
     
     wxNSTabView* v = [[wxNSTabView alloc] initWithFrame:r];
-    [sv addSubview:v];
     [v setTabViewType:tabstyle];
     wxWidgetCocoaImpl* c = new wxCocoaTabView( wxpeer, v );
     [v setImplementation:c];
index 6ade4cba1ce06b9c0ad4258301f3868bb9966784..681f6cf9c9f9faa4fb3a8cd6e55b1df4ac7e28d7 100644 (file)
@@ -25,14 +25,11 @@ wxWidgetImplType* wxWidgetImpl::CreateRadioButton( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle) 
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
 
     [v setButtonType:NSRadioButton];    
         
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index 5571d10c954d03d06ef636320c8a9796d1d4f2fb..c3e7b73b6d418598f530edee675e7f114d163abc 100644 (file)
@@ -111,12 +111,9 @@ wxWidgetImplType* wxWidgetImpl::CreateScrollBar( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle)
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSScroller* v = [[wxNSScroller alloc] initWithFrame:r];
 
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxOSXScrollBarCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index a80fb434d6a7eff9aa8ec7c26786a5baca4d359e..8fc664c26c5798226e57245d02b37c0994fd4318 100644 (file)
@@ -77,8 +77,6 @@ wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle)
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSSlider* v = [[wxNSSlider alloc] initWithFrame:r];
 
@@ -99,7 +97,6 @@ wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer,
     [v setMinValue: minimum];
     [v setMaxValue: maximum];
     [v setFloatValue: (double) value];
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index 9fbce04a936122eebb7bea0961a5c5c991081d69..436576b8b37416c3d2be3925ae6e093b07c81a69 100644 (file)
@@ -77,8 +77,6 @@ wxWidgetImplType* wxWidgetImpl::CreateSpinButton( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle)
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSStepper* v = [[wxNSStepper alloc] initWithFrame:r];
 
@@ -89,7 +87,6 @@ wxWidgetImplType* wxWidgetImpl::CreateSpinButton( wxWindowMac* wxpeer,
     if ( style & wxSP_WRAP )
         [v setValueWraps:YES];
     
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index 0c33e9859943fb46c37892f1b5ddc60622387443..6cda0bfab594529a29d2b9d24d9c5abbdb1bc505 100644 (file)
@@ -171,11 +171,8 @@ wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxTextCtrl* wxpeer,
                                     long style, 
                                     long extraStyle)
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSSearchField* v = [[wxNSSearchField alloc] initWithFrame:r];
-    [sv addSubview:v];
     [[v cell] setSendsWholeSearchString:YES];
     // per wx default cancel is not shown
     [[v cell] setCancelButtonCell:nil];
index f1e60f923c9ba3922cdf4ce72a2eec128990ae04..3eca187518acd3745df68faac2750ff6fc2d155c 100644 (file)
@@ -44,11 +44,8 @@ wxWidgetImplType* wxWidgetImpl::CreateGroupBox( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle)
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSBox* v = [[wxNSBox alloc] initWithFrame:r];
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index 6fc86cc2e212e476e891ad8e0c36b41b3e563644..f57c1bb28fb0f13ae55e563937c6a5b9b0c11d82 100644 (file)
@@ -41,11 +41,8 @@ wxWidgetImplType* wxWidgetImpl::CreateStaticLine( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle) 
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSBox* v = [[wxNSBox alloc] initWithFrame:r];
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index a30082c99010e6cb8422b77da00cc188b652cff6..973a7b2e9fb47127faf355036cd662b1fcbf19f4 100644 (file)
@@ -101,11 +101,8 @@ wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle) 
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSTextField* v = [[wxNSTextField alloc] initWithFrame:r];
-    [sv addSubview:v];
 
     [v setBezeled:NO];
     [v setEditable:NO];
index b5c896241eaf590a0caee82d4954eb8fd45db5fb..6a2b2946dea08400885860c223a79fd543f84a0c 100644 (file)
@@ -136,11 +136,8 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
                                     long style, 
                                     long extraStyle)
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSTextField* v = [[wxNSTextField alloc] initWithFrame:r];
-    [sv addSubview:v];
     
     if ( style & wxNO_BORDER )
     {
index de93bd3bf022dea458d3b9fcc38d28ed3779d994..5db9b8e456099aa374f9bcb4f6feef201d23d13f 100644 (file)
@@ -34,14 +34,11 @@ wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle)
 {
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
     
     [v setBezelStyle:NSRoundedBezelStyle];    
     [v setButtonType:NSOnOffButton];
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
@@ -56,14 +53,11 @@ wxWidgetImplType* wxWidgetImpl::CreateBitmapToggleButton( wxWindowMac* wxpeer,
                                     long style, 
                                     long extraStyle)
 {    
-    NSView* sv = (wxpeer->GetParent()->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
     
     [v setBezelStyle:NSRegularSquareBezelStyle];
     [v setButtonType:NSOnOffButton];
-    [sv addSubview:v];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
     [v setImplementation:c];
     return c;
index cc9a21066a621143d78e0f20cebe011ae4d09f27..4594a4931da1e3aea95e38e5319baa305a1c93fb 100644 (file)
@@ -718,6 +718,10 @@ void wxWidgetCocoaImpl::SetFont(wxFont const&, wxColour const&, long, bool)
     // TODO
 }
 
+void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
+{
+}
+
 //
 // Factory methods
 //
index b5baf1f0098567c366d503261044d9f7a02c6404..3ad07ae4d2c168047fb2bd121fdaaf34e4133f40 100644 (file)
@@ -274,19 +274,11 @@ void wxWindowMac::MacPostControlCreate(const wxPoint& WXUNUSED(pos), const wxSiz
 {
     wxASSERT_MSG( m_peer != NULL && m_peer->IsOk() , wxT("No valid mac control") ) ;
 
-#if wxOSX_USE_CARBON
-    m_peer->SetReference( (URefCon) this ) ;
-#endif
-
     GetParent()->AddChild( this );
 
-#if wxOSX_USE_CARBON
     m_peer->InstallEventHandler();
+    m_peer->Embed(GetParent()->GetPeer());
 
-    ControlRef container = (ControlRef) GetParent()->GetHandle() ;
-    wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
-    ::EmbedControl( m_peer->GetControlRef() , container ) ;
-#endif
     GetParent()->MacChildAdded() ;
 
     // adjust font, controlsize etc