virtual WXWidget GetWXWidget() const { return (WXWidget) m_controlRef; }
- virtual void SetReference( URefCon data );
-
virtual bool IsVisible() const;
virtual void Raise();
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)
// 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
MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()),
&bounds, featureSet, &m_controlRef );
verify_noerr( err );
+ SetControlReference( m_controlRef , (URefCon) wxPeer );
DoCreate();
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 )
// 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
//
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;
long style,
long extraStyle)
{
- NSView* sv = (wxpeer->GetParent()->GetHandle() );
-
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
}
[v setButtonType:NSMomentaryPushInButton];
- [sv addSubview:v];
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
[v setImplementation:c];
return c;
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;
long style,
long extraStyle)
{
- NSView* sv = (wxpeer->GetParent()->GetHandle() );
-
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
if (style & wxCHK_3STATE)
[v setAllowsMixedState:YES];
- [sv addSubview:v];
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
[v setImplementation:c];
return c;
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];
long style,
long extraStyle)
{
- NSView* sv = (wxpeer->GetParent()->GetHandle() );
-
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSProgressIndicator* v = [[wxNSProgressIndicator alloc] initWithFrame:r];
[v setMaxValue: maximum];
[v setIndeterminate:FALSE];
[v setDoubleValue: (double) value];
- [sv addSubview:v];
wxWidgetCocoaImpl* c = new wxOSXGaugeCocoaImpl( wxpeer, v );
[v setImplementation:c];
return c;
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];
long style,
long extraStyle)
{
- NSView* superv = (wxpeer->GetParent()->GetHandle() );
-
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
NSScrollView* scrollview = [[NSScrollView alloc] initWithFrame:r];
[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];
if ( !controller )
controller =[[wxTabViewController alloc] init];
- NSView* sv = (wxpeer->GetParent()->GetHandle() );
-
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
NSTabViewType tabstyle = NSTopTabsBezelBorder;
tabstyle = NSBottomTabsBezelBorder;
wxNSTabView* v = [[wxNSTabView alloc] initWithFrame:r];
- [sv addSubview:v];
[v setTabViewType:tabstyle];
wxWidgetCocoaImpl* c = new wxCocoaTabView( wxpeer, v );
[v setImplementation:c];
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;
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;
long style,
long extraStyle)
{
- NSView* sv = (wxpeer->GetParent()->GetHandle() );
-
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSSlider* v = [[wxNSSlider alloc] initWithFrame:r];
[v setMinValue: minimum];
[v setMaxValue: maximum];
[v setFloatValue: (double) value];
- [sv addSubview:v];
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
[v setImplementation:c];
return c;
long style,
long extraStyle)
{
- NSView* sv = (wxpeer->GetParent()->GetHandle() );
-
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSStepper* v = [[wxNSStepper alloc] initWithFrame:r];
if ( style & wxSP_WRAP )
[v setValueWraps:YES];
- [sv addSubview:v];
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
[v setImplementation:c];
return c;
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];
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;
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;
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];
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 )
{
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;
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;
// TODO
}
+void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
+{
+}
+
//
// Factory methods
//
{
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