class wxNSTextFieldControl : public wxWidgetCocoaImpl, public wxTextWidgetImpl
{
public :
- wxNSTextFieldControl( wxWindow *wxPeer, WXWidget w );
+ // wxNSTextFieldControl must always be associated with a wxTextEntry. If
+ // it's associated with a wxTextCtrl then we can get the associated entry
+ // from it but otherwise the second ctor should be used to explicitly pass
+ // us the entry.
+ wxNSTextFieldControl( wxTextCtrl *text, WXWidget w );
+ wxNSTextFieldControl( wxWindow *wxPeer, wxTextEntry *entry, WXWidget w );
virtual ~wxNSTextFieldControl();
virtual wxString GetStringValue() const ;
virtual bool HasOwnContextMenu() const { return true; }
virtual void controlAction(WXWidget slf, void* _cmd, void *sender);
+
protected :
NSTextField* m_textField;
long m_selStart;
long m_selEnd;
+
+private:
+ // Common part of both ctors.
+ void Init(WXWidget w);
};
class wxNSTextViewControl : public wxWidgetCocoaImpl, public wxTextWidgetImpl
class wxNSComboBoxControl : public wxNSTextFieldControl, public wxComboWidgetImpl
{
public :
- wxNSComboBoxControl( wxWindow *wxPeer, WXWidget w );
+ wxNSComboBoxControl( wxComboBox *wxPeer, WXWidget w );
virtual ~wxNSComboBoxControl();
virtual int GetSelectedItem() const;
class wxMacControl;
class wxWidgetImpl;
+class wxComboBox;
class wxNotebook;
class wxTextCtrl;
long extraStyle);
#if wxOSX_USE_COCOA
- static wxWidgetImplType* CreateComboBox( wxWindowMac* wxpeer,
+ static wxWidgetImplType* CreateComboBox( wxComboBox* wxpeer,
wxWindowMac* parent,
wxWindowID id,
wxMenu* menu,
//
class WXDLLIMPEXP_FWD_CORE wxTextAttr;
+class WXDLLIMPEXP_FWD_CORE wxTextEntry;
// common interface for all implementations
class WXDLLIMPEXP_CORE wxTextWidgetImpl
{
public :
- wxTextWidgetImpl() {}
+ // Any widgets implementing this interface must be associated with a
+ // wxTextEntry so instead of requiring the derived classes to implement
+ // another (pure) virtual function, just take the pointer to this entry in
+ // our ctor and implement GetTextEntry() ourselves.
+ wxTextWidgetImpl(wxTextEntry *entry) : m_entry(entry) {}
virtual ~wxTextWidgetImpl() {}
+ wxTextEntry *GetTextEntry() const { return m_entry; }
+
virtual bool CanFocus() const { return true; }
virtual wxString GetStringValue() const = 0 ;
virtual void CheckSpelling(bool WXUNUSED(check)) { }
virtual wxSize GetBestSize() const { return wxDefaultSize; }
+
+private:
+ wxTextEntry * const m_entry;
+
+ wxDECLARE_NO_COPY_CLASS(wxTextWidgetImpl);
};
// common interface for all implementations
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacUnicodeTextControlEventHandler )
-wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl *wxPeer ) : wxMacControl( wxPeer )
+wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl *wxPeer )
+ : wxMacControl( wxPeer ),
+ wxTextWidgetImpl( wxPeer )
{
}
const wxString& str,
const wxPoint& pos,
const wxSize& size, long style )
- : wxMacControl( wxPeer )
+ : wxMacControl( wxPeer ),
+ wxTextWidgetImpl( wxPeer )
{
m_font = wxPeer->GetFont() ;
m_windowStyle = style ;
} ;
wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl *peer )
- : wxMacControl( peer )
+ : wxMacControl( peer ),
+ wxTextWidgetImpl( peer )
{
SetNeedsFocusRect( true ) ;
}
}
@end
-wxNSComboBoxControl::wxNSComboBoxControl( wxWindow *wxPeer, WXWidget w ) : wxNSTextFieldControl(wxPeer, w)
+wxNSComboBoxControl::wxNSComboBoxControl( wxComboBox *wxPeer, WXWidget w )
+ : wxNSTextFieldControl(wxPeer, wxPeer, w)
{
m_comboBox = (NSComboBox*)w;
}
return result;
}
-wxWidgetImplType* wxWidgetImpl::CreateComboBox( wxWindowMac* wxpeer,
+wxWidgetImplType* wxWidgetImpl::CreateComboBox( wxComboBox* wxpeer,
wxWindowMac* WXUNUSED(parent),
wxWindowID WXUNUSED(id),
wxMenu* menu,
return wxSize( lbWidth, lbHeight );
}
-#endif // wxUSE_COMBOBOX
\ No newline at end of file
+#endif // wxUSE_COMBOBOX
// wxNSTextViewControl
-wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
+wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w )
+ : wxWidgetCocoaImpl(wxPeer, w),
+ wxTextWidgetImpl(wxPeer)
{
wxNSTextScrollView* sv = (wxNSTextScrollView*) w;
m_scrollView = sv;
// wxNSTextFieldControl
-wxNSTextFieldControl::wxNSTextFieldControl( wxWindow *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
+wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *text, WXWidget w )
+ : wxWidgetCocoaImpl(text, w),
+ wxTextWidgetImpl(text)
+{
+}
+
+wxNSTextFieldControl::wxNSTextFieldControl(wxWindow *wxPeer,
+ wxTextEntry *entry,
+ WXWidget w)
+ : wxWidgetCocoaImpl(wxPeer, w),
+ wxTextWidgetImpl(entry)
+{
+}
+
+void wxNSTextFieldControl::Init(WXWidget w)
{
NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>) *tf = (NSTextField*) w;
m_textField = tf;
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, wxpeer->GetId());
event.SetEventObject( wxpeer );
- event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
+ event.SetString( GetTextEntry()->GetValue() );
wxpeer->HandleWindowEvent( event );
}
}
[v setBezeled:NO];
[v setBordered:NO];
- c = new wxNSTextFieldControl( wxpeer, v );
+ c = new wxNSTextFieldControl( wxpeer, wxpeer, v );
}
return c;