moving embedding to common API
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56218 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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();
|
||||
|
@@ -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)
|
||||
|
@@ -236,6 +236,8 @@ public :
|
||||
// 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
|
||||
|
||||
static wxWidgetImpl*
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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
|
||||
//
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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];
|
||||
|
@@ -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;
|
||||
|
@@ -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];
|
||||
|
||||
|
@@ -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];
|
||||
|
@@ -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];
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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];
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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];
|
||||
|
@@ -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 )
|
||||
{
|
||||
|
@@ -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;
|
||||
|
@@ -718,6 +718,10 @@ void wxWidgetCocoaImpl::SetFont(wxFont const&, wxColour const&, long, bool)
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Factory methods
|
||||
//
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user