Duplicate wxTextCtrl code to wxComboBox because we can no longer derive wxComboBox from wxTextCtrl.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49052 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
#include "wx/hashmap.h"
|
#include "wx/hashmap.h"
|
||||||
#include "wx/cocoa/ObjcAssociate.h"
|
#include "wx/cocoa/ObjcAssociate.h"
|
||||||
|
|
||||||
|
#include "wx/textctrl.h"
|
||||||
|
|
||||||
DECLARE_WXCOCOA_OBJC_CLASS(NSComboBox);
|
DECLARE_WXCOCOA_OBJC_CLASS(NSComboBox);
|
||||||
|
|
||||||
WX_DECLARE_OBJC_HASHMAP(NSComboBox);
|
WX_DECLARE_OBJC_HASHMAP(NSComboBox);
|
||||||
@@ -38,11 +40,12 @@ public:
|
|||||||
// ========================================================================
|
// ========================================================================
|
||||||
// wxComboBox
|
// wxComboBox
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
class WXDLLEXPORT wxComboBox : public wxTextCtrl, public wxComboBoxBase, protected wxCocoaNSComboBox
|
class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase, protected wxCocoaNSComboBox, protected wxCocoaNSTextField
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
WX_DECLARE_COCOA_OWNER(NSComboBox,NSTextField,NSView)
|
WX_DECLARE_COCOA_OWNER(NSComboBox,NSTextField,NSView)
|
||||||
|
WX_DECLARE_COCOA_OWNER(NSTextField,NSControl,NSView)
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// initialization
|
// initialization
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@@ -97,11 +100,12 @@ protected:
|
|||||||
wxArrayPtrVoid m_Datas;
|
wxArrayPtrVoid m_Datas;
|
||||||
virtual void doWxEvent(int nEvent);
|
virtual void doWxEvent(int nEvent);
|
||||||
|
|
||||||
|
virtual void Cocoa_didChangeText()
|
||||||
|
{}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Implementation
|
// Implementation
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
public:
|
public:
|
||||||
// FIXME: Quit deriving from wxTextCtrl
|
|
||||||
void Clear() // HACK
|
void Clear() // HACK
|
||||||
{ wxComboBoxBase::Clear(); }
|
{ wxComboBoxBase::Clear(); }
|
||||||
|
|
||||||
@@ -123,46 +127,28 @@ public:
|
|||||||
virtual void DoSetItemClientData(unsigned int, void*);
|
virtual void DoSetItemClientData(unsigned int, void*);
|
||||||
virtual void* DoGetItemClientData(unsigned int) const;
|
virtual void* DoGetItemClientData(unsigned int) const;
|
||||||
virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
|
virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
|
||||||
// wxComboBoxBase pure virtuals
|
|
||||||
virtual wxString GetValue() const
|
// ------------------------------------------------------------------------
|
||||||
{ return wxTextCtrl::GetValue(); }
|
// wxTextEntryBase virtual implementations:
|
||||||
virtual void SetValue(const wxString& value)
|
// ------------------------------------------------------------------------
|
||||||
{ return wxTextCtrl::SetValue(value); }
|
// FIXME: This needs to be moved to some sort of common code.
|
||||||
virtual void Cut() { wxTextCtrl::Cut(); }
|
virtual void WriteText(const wxString&);
|
||||||
virtual void Copy() { wxTextCtrl::Copy(); }
|
virtual wxString GetValue() const;
|
||||||
virtual void Paste() { wxTextCtrl::Paste(); }
|
virtual void Remove(long, long);
|
||||||
virtual void SetInsertionPoint(long pos)
|
virtual void Cut();
|
||||||
{ wxTextCtrl::SetInsertionPoint(pos); }
|
virtual void Copy();
|
||||||
virtual void SetInsertionPointEnd()
|
virtual void Paste();
|
||||||
{ wxTextCtrl::SetInsertionPointEnd(); }
|
virtual void Undo();
|
||||||
virtual long GetInsertionPoint() const
|
virtual void Redo();
|
||||||
{ return wxTextCtrl::GetInsertionPoint(); }
|
virtual bool CanUndo() const;
|
||||||
virtual wxTextPos GetLastPosition() const
|
virtual bool CanRedo() const;
|
||||||
{ return wxTextCtrl::GetLastPosition(); }
|
virtual void SetInsertionPoint(long pos);
|
||||||
virtual void Replace(long from, long to, const wxString& value)
|
virtual long GetInsertionPoint() const;
|
||||||
{ wxTextCtrl::Replace(from,to,value); }
|
virtual wxTextPos GetLastPosition() const;
|
||||||
virtual void SetSelection(long from, long to)
|
virtual void SetSelection(long from, long to);
|
||||||
{ wxTextCtrl::SetSelection(from,to); }
|
virtual void GetSelection(long *from, long *to) const;
|
||||||
virtual void SetEditable(bool editable)
|
virtual bool IsEditable() const;
|
||||||
{ wxTextCtrl::SetEditable(editable); }
|
virtual void SetEditable(bool editable);
|
||||||
virtual bool IsEditable() const
|
|
||||||
{ return !HasFlag(wxCB_READONLY); }
|
|
||||||
virtual void Undo()
|
|
||||||
{ wxTextCtrl::Undo(); }
|
|
||||||
virtual void Redo()
|
|
||||||
{ wxTextCtrl::Redo(); }
|
|
||||||
virtual void SelectAll()
|
|
||||||
{ wxTextCtrl::SelectAll(); }
|
|
||||||
virtual bool CanCopy() const
|
|
||||||
{ return wxTextCtrl::CanCopy(); }
|
|
||||||
virtual bool CanCut() const
|
|
||||||
{ return wxTextCtrl::CanCut(); }
|
|
||||||
virtual bool CanPaste() const
|
|
||||||
{ return wxTextCtrl::CanPaste(); }
|
|
||||||
virtual bool CanUndo() const
|
|
||||||
{ return wxTextCtrl::CanUndo(); }
|
|
||||||
virtual bool CanRedo() const
|
|
||||||
{ return wxTextCtrl::CanRedo(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __WX_COCOA_COMBOBOX_H__
|
#endif // __WX_COCOA_COMBOBOX_H__
|
||||||
|
@@ -168,10 +168,11 @@ WX_IMPLEMENT_GET_OBJC_CLASS(wxPoserNSComboBox,NSComboBox)
|
|||||||
|
|
||||||
#import <AppKit/NSComboBox.h>
|
#import <AppKit/NSComboBox.h>
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxTextCtrl)
|
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
|
||||||
BEGIN_EVENT_TABLE(wxComboBox, wxTextCtrl)
|
BEGIN_EVENT_TABLE(wxComboBox, wxControl)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
WX_IMPLEMENT_COCOA_OWNER(wxComboBox,NSComboBox,NSTextField,NSView)
|
WX_IMPLEMENT_COCOA_OWNER(wxComboBox,NSComboBox,NSTextField,NSView)
|
||||||
|
WX_IMPLEMENT_COCOA_OWNER(wxComboBox,NSTextField,NSControl,NSView)
|
||||||
|
|
||||||
bool wxComboBox::Create(wxWindow *parent, wxWindowID winid,
|
bool wxComboBox::Create(wxWindow *parent, wxWindowID winid,
|
||||||
const wxString& value,
|
const wxString& value,
|
||||||
@@ -317,4 +318,93 @@ void* wxComboBox::DoGetItemClientData(unsigned int nIndex) const
|
|||||||
return m_Datas[nIndex];
|
return m_Datas[nIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// wxTextEntry virtual implementations:
|
||||||
|
|
||||||
|
void wxComboBox::WriteText(wxString const&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxComboBox::GetValue() const
|
||||||
|
{
|
||||||
|
wxAutoNSAutoreleasePool pool;
|
||||||
|
return wxStringWithNSString([GetNSTextField() stringValue]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::Remove(long, long)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::Cut()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::Copy()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::Paste()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::Undo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::Redo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxComboBox::CanUndo() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxComboBox::CanRedo() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::SetInsertionPoint(long)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
long wxComboBox::GetInsertionPoint() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxTextPos wxComboBox::GetLastPosition() const
|
||||||
|
{
|
||||||
|
// working - returns the size of the wxString
|
||||||
|
return (long)(GetValue().Len());
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::SetSelection(long, long)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::GetSelection(long*, long*) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxComboBox::IsEditable() const
|
||||||
|
{
|
||||||
|
return [GetNSTextField() isEditable];
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxComboBox::SetEditable(bool editable)
|
||||||
|
{
|
||||||
|
// first ensure that the current value is stored (in case the user had not finished editing
|
||||||
|
// before SetEditable(FALSE) was called)
|
||||||
|
DoSetValue(GetValue(),1);
|
||||||
|
|
||||||
|
[GetNSTextField() setEditable: editable];
|
||||||
|
|
||||||
|
// forces the focus on the textctrl to be lost - while focus is still maintained
|
||||||
|
// after SetEditable(FALSE) the user may still edit the control
|
||||||
|
// (might not the best way to do this..)
|
||||||
|
[GetNSTextField() abortEditing];
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_COMBOBOX
|
#endif // wxUSE_COMBOBOX
|
||||||
|
Reference in New Issue
Block a user