Add association between wxOSX wxTextWidgetImpl and wxTextEntry.
This allows to always find the correct wxTextEntry to use in the implementation of text-related widgets without using any casts. Notably, the wrong up-cast of wxWindow to wxTextCtrl in wxNSTextFieldControl::controlAction() which resulted in a crash when the window was actually a wxComboBox can now be fixed. Closes #12284. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65129 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -103,6 +103,7 @@ class wxNonOwnedWindow;
|
||||
|
||||
class wxMacControl;
|
||||
class wxWidgetImpl;
|
||||
class wxComboBox;
|
||||
class wxNotebook;
|
||||
class wxTextCtrl;
|
||||
|
||||
@@ -480,7 +481,7 @@ public :
|
||||
long extraStyle);
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
static wxWidgetImplType* CreateComboBox( wxWindowMac* wxpeer,
|
||||
static wxWidgetImplType* CreateComboBox( wxComboBox* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
wxMenu* menu,
|
||||
@@ -572,16 +573,23 @@ public:
|
||||
//
|
||||
|
||||
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 ;
|
||||
@@ -622,6 +630,11 @@ public :
|
||||
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
|
||||
|
Reference in New Issue
Block a user