src/osx/statbox_osx.cpp
src/osx/statline_osx.cpp
src/osx/stattext_osx.cpp
+ src/osx/textentry_osx.cpp
src/osx/textctrl_osx.cpp
src/osx/tglbtn_osx.cpp
src/osx/toolbar_osx.cpp
#ifndef _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
#define _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
+#include "wx/combobox.h"
#include "wx/osx/private.h"
// implementation exposed, so that search control can pull it
class wxNSTextFieldControl : public wxWidgetCocoaImpl, public wxTextWidgetImpl
{
public :
- wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w );
+ wxNSTextFieldControl( wxWindow *wxPeer, WXWidget w );
virtual ~wxNSTextFieldControl();
virtual wxString GetStringValue() const ;
NSTextView* m_textView;
};
+class wxNSComboBoxControl : public wxNSTextFieldControl, public wxComboWidgetImpl
+{
+public :
+ wxNSComboBoxControl( wxWindow *wxPeer, WXWidget w );
+ virtual ~wxNSComboBoxControl();
+
+ virtual int GetSelectedItem() const;
+ virtual void SetSelectedItem(int item);
+
+ virtual int GetNumberOfItems() const;
+
+ virtual void InsertItem(int pos, const wxString& item);
+ virtual void RemoveItem(int pos);
+
+ virtual void Clear();
+
+ virtual wxString GetStringAtIndex(int pos) const;
+
+ virtual int FindString(const wxString& text) const;
+private:
+ NSComboBox* m_comboBox;
+};
+
#endif // _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/carbon/combobox.h
+// Name: wx/osx/combobox.h
// Purpose: wxComboBox class
// Author: Stefan Csomor
// Modified by:
#include "wx/containr.h"
#include "wx/choice.h"
+#include "wx/textctrl.h"
WXDLLIMPEXP_DATA_CORE(extern const char) wxComboBoxNameStr[];
+WX_DEFINE_ARRAY( char * , wxComboBoxDataArray ) ;
+
// forward declaration of private implementation classes
class wxComboBoxText;
class wxComboBoxChoice;
+class wxComboWidgetImpl;
// Combobox item
class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase
public:
virtual ~wxComboBox();
-#ifndef wxOSX_USE_NATIVE_COMBOBOX
+#if wxOSX_USE_CARBON
// forward these functions to all subcontrols
virtual bool Enable(bool enable = true);
virtual bool Show(bool show = true);
const wxString& name = wxComboBoxNameStr);
virtual int GetSelection() const;
+ virtual void GetSelection(long *from, long *to) const;
virtual void SetSelection(int n);
+ virtual void SetSelection(long from, long to);
virtual int FindString(const wxString& s, bool bCase = false) const;
virtual wxString GetString(unsigned int n) const;
virtual wxString GetStringSelection() const;
virtual void SetString(unsigned int n, const wxString& s);
+ virtual unsigned int GetCount() const;
+
+// these methods are provided by wxTextEntry for the native impl.
+#if wxOSX_USE_CARBON
// Text field functions
virtual void SetValue(const wxString& value);
virtual wxString GetValue() const;
virtual void WriteText(const wxString& text);
- virtual void GetSelection(long *from, long *to) const;
// Clipboard operations
virtual void Copy();
virtual wxTextPos GetLastPosition() const;
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
- virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
virtual bool IsEditable() const;
- virtual unsigned int GetCount() const;
-
virtual void Undo();
virtual void Redo();
virtual void SelectAll();
virtual bool CanRedo() const;
virtual wxClientDataType GetClientDataType() const;
+#endif
+
+
// osx specific event handling common for all osx-ports
virtual bool OSXHandleClicked( double timestampsec );
-#ifndef wxOSX_USE_NATIVE_COMBOBOX
+#if wxOSX_USE_CARBON
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
WX_DECLARE_CONTROL_CONTAINER();
#endif
+ // only used by the native Cocoa combobox, but we must define it everywhere
+ // to maintain the wxTextEntry abstraction.
+ virtual wxTextWidgetImpl * GetTextPeer() const;
+
+#if wxOSX_USE_COCOA
+ wxComboWidgetImpl* GetComboPeer() const;
+#endif
protected:
// common part of all ctors
void Init();
virtual void DoClear();
// wxTextEntry functions
+#if wxOSX_USE_CARBON
virtual wxString DoGetValue() const;
+#endif
virtual wxWindow *GetEditableWindow() { return this; }
-#ifndef wxOSX_USE_NATIVE_COMBOBOX
+#if wxOSX_USE_CARBON
// override the base class virtuals involved in geometry calculations
virtual wxSize DoGetBestSize() const;
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoSetItemClientData(unsigned int n, void* clientData);
virtual void * DoGetItemClientData(unsigned int n) const;
+#if wxOSX_USE_CARBON
virtual void SetClientDataType(wxClientDataType clientDataItemsType);
+#endif
virtual void EnableTextChangedEvents(bool enable);
wxComboBoxText* m_text;
wxComboBoxChoice* m_choice;
-#ifndef wxOSX_USE_NATIVE_COMBOBOX
+ wxComboBoxDataArray m_datas;
+
+#if wxOSX_USE_CARBON
DECLARE_EVENT_TABLE()
#endif
};
long style,
long extraStyle);
-#ifdef wxOSX_USE_NATIVE_COMBOBOX
+#if wxOSX_USE_COCOA
static wxWidgetImplType* CreateComboBox( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
virtual wxSize GetBestSize() const { return wxDefaultSize; }
};
+// common interface for all implementations
+class WXDLLIMPEXP_CORE wxComboWidgetImpl
+
+{
+public :
+ wxComboWidgetImpl() {}
+
+ virtual ~wxComboWidgetImpl() {}
+
+ virtual int GetSelectedItem() const { return -1; };
+ virtual void SetSelectedItem(int WXUNUSED(item)) {};
+
+ virtual int GetNumberOfItems() const { return -1; };
+
+ virtual void InsertItem(int WXUNUSED(pos), const wxString& WXUNUSED(item)) {}
+
+ virtual void RemoveItem(int WXUNUSED(pos)) {}
+
+ virtual void Clear() {}
+
+ virtual wxString GetStringAtIndex(int WXUNUSED(pos)) const { return wxEmptyString; }
+
+ virtual int FindString(const wxString& WXUNUSED(text)) const { return -1; }
+};
+
//
// common interface for buttons
//
virtual int GetNumberOfLines() const;
virtual bool IsModified() const;
- virtual bool IsEditable() const;
-
- // If the return values from and to are the same, there is no selection.
- virtual void GetSelection(long* from, long* to) const;
// operations
// ----------
- // editing
- virtual void Clear();
- virtual void Remove(long from, long to);
// sets/clears the dirty flag
virtual void MarkDirty();
virtual bool SetStyle(long start, long end, const wxTextAttr& style);
virtual bool SetDefaultStyle(const wxTextAttr& style);
- // writing text inserts it at the current position;
- // appending always inserts it at the end
- virtual void WriteText(const wxString& text);
-
// translate between the position (which is just an index into the textctrl
// considering all its contents as a single strings) and (x, y) coordinates
// which represent column and line.
virtual void ShowPosition(long pos);
- // Clipboard operations
- virtual void Copy();
+ // overrides so that we can send text updated events
virtual void Cut();
virtual void Paste();
-
- virtual bool CanCopy() const;
- virtual bool CanCut() const;
- virtual bool CanPaste() const;
-
- // Undo/redo
- virtual void Undo();
- virtual void Redo();
-
- virtual bool CanUndo() const;
- virtual bool CanRedo() const;
-
- // Insertion point
- virtual void SetInsertionPoint(long pos);
- virtual void SetInsertionPointEnd();
- virtual long GetInsertionPoint() const;
- virtual wxTextPos GetLastPosition() const;
-
- virtual void SetSelection(long from, long to);
- virtual void SetEditable(bool editable);
+
+ virtual void WriteText(const wxString& text);
+ virtual void Clear();
+ virtual void Remove(long from, long to);
// Implementation
// --------------
virtual void MacSuperChangedPosition();
virtual void MacCheckSpelling(bool check);
- wxTextWidgetImpl * GetTextPeer() const;
+ virtual wxTextWidgetImpl * GetTextPeer() const;
protected:
// common part of all ctors
void Init();
virtual wxSize DoGetBestSize() const;
- virtual wxString DoGetValue() const;
-
bool m_editable;
// flag is set to true when the user edits the controls contents
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: wx/osx/textentry.h
+// Purpose: wxTextEntry class
+// Author: Stefan Csomor
+// Modified by: Kevin Ollivier
+// Created: 1998-01-01
+// RCS-ID: $Id: textctrl.h 62531 2009-11-01 00:58:04Z KO $
+// Copyright: (c) Stefan Csomor
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_OSX_TEXTENTRY_H_
+#define _WX_OSX_TEXTENTRY_H_
+
+#if wxUSE_SYSTEM_OPTIONS
+ // set this to 'true' if you want to use the 'classic' MLTE-based implementation
+ // instead of the HIView-based implementation in 10.3 and upwards, the former
+ // has more features (backgrounds etc.), but may show redraw artefacts and other
+ // problems depending on your usage; hence, the default is 'false'.
+ #define wxMAC_TEXTCONTROL_USE_MLTE wxT("mac.textcontrol-use-mlte")
+ // set this to 'true' if you want editable text controls to have spell checking turned
+ // on by default, you can change this setting individually on a control using MacCheckSpelling
+ #define wxMAC_TEXTCONTROL_USE_SPELL_CHECKER wxT("mac.textcontrol-use-spell-checker")
+#endif
+
+#include "wx/control.h"
+
+// forward decl for wxListWidgetImpl implementation type.
+class WXDLLIMPEXP_FWD_CORE wxTextWidgetImpl;
+
+class WXDLLIMPEXP_CORE wxTextEntry: public wxTextEntryBase
+{
+
+public:
+ wxTextEntry()
+ { }
+
+ virtual ~wxTextEntry() {};
+
+ virtual bool IsEditable() const;
+
+ // If the return values from and to are the same, there is no selection.
+ virtual void GetSelection(long* from, long* to) const;
+
+ // operations
+ // ----------
+
+ // editing
+ virtual void Clear();
+ virtual void Remove(long from, long to);
+
+ // set the max number of characters which may be entered
+ // in a single line text control
+ virtual void SetMaxLength(unsigned long len);
+
+ // writing text inserts it at the current position;
+ // appending always inserts it at the end
+ virtual void WriteText(const wxString& text);
+
+ // Clipboard operations
+ virtual void Copy();
+ virtual void Cut();
+ virtual void Paste();
+
+ virtual bool CanCopy() const;
+ virtual bool CanCut() const;
+ virtual bool CanPaste() const;
+
+ // Undo/redo
+ virtual void Undo();
+ virtual void Redo();
+
+ virtual bool CanUndo() const;
+ virtual bool CanRedo() const;
+
+ // Insertion point
+ virtual void SetInsertionPoint(long pos);
+ virtual void SetInsertionPointEnd();
+ virtual long GetInsertionPoint() const;
+ virtual wxTextPos GetLastPosition() const;
+
+ virtual void SetSelection(long from, long to);
+ virtual void SetEditable(bool editable);
+
+ // Implementation
+ // --------------
+
+ virtual wxTextWidgetImpl * GetTextPeer() const;
+protected:
+
+ virtual wxString DoGetValue() const;
+
+ bool m_editable;
+
+ // need to make this public because of the current implementation via callbacks
+ unsigned long m_maxLength;
+
+ virtual void EnableTextChangedEvents(bool enable)
+ {
+ m_triggerUpdateEvents = enable;
+ }
+
+ bool m_triggerUpdateEvents ;
+
+};
+
+#endif // _WX_OSX_TEXTENTRY_H_
};
#elif defined(__WXGTK20__)
#include "wx/gtk/textentry.h"
+#elif defined(__WXMAC__)
+ #include "wx/osx/textentry.h"
#elif defined(__WXMSW__)
#include "wx/msw/textentry.h"
#elif defined(__WXMOTIF__)
#include "wx/wxprec.h"
-#if wxUSE_COMBOBOX && !defined(wxOSX_USE_NATIVE_COMBOBOX)
+#if wxUSE_COMBOBOX && wxOSX_USE_CARBON
#include "wx/combobox.h"
return true ;
}
-#endif // wxUSE_COMBOBOX && !defined(wxOSX_USE_NATIVE_COMBOBOX)
+wxTextWidgetImpl* wxComboBox::GetTextPeer() const
+{
+ if (m_text)
+ return m_text->GetTextPeer();
+
+ return NULL;
+}
+
+#endif // wxUSE_COMBOBOX && wxOSX_USE_CARBON
#include "wx/wxprec.h"
-#if wxUSE_COMBOBOX && defined(wxOSX_USE_NATIVE_COMBOBOX)
+#if wxUSE_COMBOBOX
#include "wx/combobox.h"
#include "wx/dcclient.h"
#endif
-#include "wx/osx/private.h"
+#include "wx/osx/cocoa/private/textimpl.h"
// work in progress
}
}
-- (int) intValue
+- (void)controlTextDidChange:(NSNotification *)aNotification
{
- return [self indexOfSelectedItem];
+ wxUnusedVar(aNotification);
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if ( wxpeer ) {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetString( static_cast<wxComboBox*>(wxpeer)->GetValue() );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
}
-- (void) setIntValue: (int) v
+- (void)comboBoxSelectionDidChange:(NSNotification *)notification
{
- [self selectItemAtIndex:v];
+ wxUnusedVar(notification);
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if ( wxpeer ) {
+ wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetInt( static_cast<wxComboBox*>(wxpeer)->GetSelection() );
+ // For some reason, wxComboBox::GetValue will not return the newly selected item
+ // while we're inside this callback, so use AddPendingEvent to make sure
+ // GetValue() returns the right value.
+ wxpeer->GetEventHandler()->AddPendingEvent( event );
+ }
+ }
}
-
@end
+wxNSComboBoxControl::wxNSComboBoxControl( wxWindow *wxPeer, WXWidget w ) : wxNSTextFieldControl(wxPeer, w)
+{
+ m_comboBox = (NSComboBox*)w;
+}
+
+wxNSComboBoxControl::~wxNSComboBoxControl()
+{
+}
+
+int wxNSComboBoxControl::GetSelectedItem() const
+{
+ return [m_comboBox indexOfSelectedItem];
+}
+
+void wxNSComboBoxControl::SetSelectedItem(int item)
+{
+ [m_comboBox selectItemAtIndex: item];
+}
+
+int wxNSComboBoxControl::GetNumberOfItems() const
+{
+ return [m_comboBox numberOfItems];
+}
+
+void wxNSComboBoxControl::InsertItem(int pos, const wxString& item)
+{
+ [m_comboBox insertItemWithObjectValue:wxCFStringRef( item , m_wxPeer->GetFont().GetEncoding() ).AsNSString() atIndex:pos];
+}
+
+void wxNSComboBoxControl::RemoveItem(int pos)
+{
+ [m_comboBox removeItemAtIndex:pos];
+}
+
+void wxNSComboBoxControl::Clear()
+{
+ [m_comboBox removeAllItems];
+}
+
+wxString wxNSComboBoxControl::GetStringAtIndex(int pos) const
+{
+ return wxCFStringRef::AsString([m_comboBox itemObjectValueAtIndex:pos], m_wxPeer->GetFont().GetEncoding());
+}
+
+int wxNSComboBoxControl::FindString(const wxString& text) const
+{
+ return [m_comboBox indexOfItemWithObjectValue:wxCFStringRef( text , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
+}
+
wxWidgetImplType* wxWidgetImpl::CreateComboBox( wxWindowMac* wxpeer,
wxWindowMac* WXUNUSED(parent),
wxWindowID WXUNUSED(id),
{
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSComboBox* v = [[wxNSComboBox alloc] initWithFrame:r];
- wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
+ wxNSComboBoxControl* c = new wxNSComboBoxControl( wxpeer, v );
return c;
}
-#endif // wxUSE_COMBOBOX && defined(wxOSX_USE_NATIVE_COMBOBOX)
+#endif // wxUSE_COMBOBOX
\ No newline at end of file
// wxNSTextFieldControl
-wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
+wxNSTextFieldControl::wxNSTextFieldControl( wxWindow *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
{
m_textField = (NSTextField*) w;
[m_textField setDelegate: w];
#include "wx/wxprec.h"
-#if wxUSE_COMBOBOX && defined(wxOSX_USE_NATIVE_COMBOBOX)
+#if wxUSE_COMBOBOX && wxOSX_USE_COCOA
#include "wx/combobox.h"
#include "wx/osx/private.h"
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
return false;
+ if (style & wxCB_READONLY)
+ wxLogWarning("wxCB_READONLY style not supported by OS X Cocoa. Use wxChoice instead.");
+
+ if (style & wxCB_SORT)
+ wxLogWarning("wxCB_SORT style not currently supported by OS X Cocoa.");
+
m_peer = wxWidgetImpl::CreateComboBox( this, parent, id, NULL, pos, size, style, GetExtraStyle() );
MacPostControlCreate( pos, size );
SetStringSelection( value );
}
-wxString wxComboBox::GetValue() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return wxEmptyString;
-}
-
-void wxComboBox::SetValue(const wxString& value)
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
-// Clipboard operations
-void wxComboBox::Copy()
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
-void wxComboBox::Cut()
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
-void wxComboBox::Paste()
+int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
+ unsigned int pos,
+ void **clientData, wxClientDataType type)
{
- wxFAIL_MSG("Method Not Implemented.");
-}
+ const unsigned int numItems = items.GetCount();
+ for( unsigned int i = 0; i < numItems; ++i, ++pos )
+ {
+ unsigned int idx;
-void wxComboBox::SetEditable(bool editable)
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
+ idx = pos;
+ GetComboPeer()->InsertItem( idx, items[i] );
-void wxComboBox::SetInsertionPoint(long pos)
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
+ if (idx > m_datas.GetCount())
+ m_datas.SetCount(idx);
+ m_datas.Insert( NULL, idx );
+ AssignNewItemClientData(idx, clientData, i, type);
+ }
-void wxComboBox::SetInsertionPointEnd()
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
+ m_peer->SetMaximum( GetCount() );
-long wxComboBox::GetInsertionPoint() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return 0;
+ return pos - 1;
}
-wxTextPos wxComboBox::GetLastPosition() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return 0;
-}
-
-void wxComboBox::Replace(long from, long to, const wxString& value)
+// ----------------------------------------------------------------------------
+// client data
+// ----------------------------------------------------------------------------
+void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
{
- wxFAIL_MSG("Method Not Implemented.");
-}
+ wxCHECK_RET( IsValid(n), wxT("wxChoice::DoSetItemClientData: invalid index") );
-void wxComboBox::Remove(long from, long to)
-{
- wxFAIL_MSG("Method Not Implemented.");
+ m_datas[n] = (char*)clientData ;
}
-void wxComboBox::SetSelection(long from, long to)
+void * wxComboBox::DoGetItemClientData(unsigned int n) const
{
- wxFAIL_MSG("Method Not Implemented.");
-}
+ wxCHECK_MSG( IsValid(n), NULL, wxT("wxChoice::DoGetClientData: invalid index") );
-int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
- unsigned int pos,
- void **clientData, wxClientDataType type)
-{
- wxFAIL_MSG("Method Not Implemented.");
- return 0;
-}
-
-void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
-void* wxComboBox::DoGetItemClientData(unsigned int n) const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return NULL;
+ return (void *)m_datas[n];
}
unsigned int wxComboBox::GetCount() const
{
- wxFAIL_MSG("Method Not Implemented.");
- return 0;
+ return GetComboPeer()->GetNumberOfItems();
}
void wxComboBox::DoDeleteOneItem(unsigned int n)
{
- wxFAIL_MSG("Method Not Implemented.");
+ GetComboPeer()->RemoveItem(n);
}
void wxComboBox::DoClear()
{
- wxFAIL_MSG("Method Not Implemented.");
+ GetComboPeer()->Clear();
+ SetValue(wxEmptyString);
}
+void wxComboBox::GetSelection(long *from, long *to) const
+{
+ wxTextEntry::GetSelection(from, to);
+}
+
int wxComboBox::GetSelection() const
{
- wxFAIL_MSG("Method Not Implemented.");
- return 0;
+ return GetComboPeer()->GetSelectedItem();
}
-void wxComboBox::GetSelection(long *from, long *to) const
+void wxComboBox::SetSelection(int n)
{
- wxFAIL_MSG("Method Not Implemented.");
+ GetComboPeer()->SetSelectedItem(n);
}
-void wxComboBox::SetSelection(int n)
+void wxComboBox::SetSelection(long from, long to)
{
- wxFAIL_MSG("Method Not Implemented.");
+ wxTextEntry::SetSelection(from, to);
}
int wxComboBox::FindString(const wxString& s, bool bCase) const
{
- wxFAIL_MSG("Method Not Implemented.");
- return 0;
+ if (!bCase)
+ wxLogWarning("wxComboBox::FindString on Mac doesn't currently support case insensitive search.");
+
+ return GetComboPeer()->FindString(s);
}
wxString wxComboBox::GetString(unsigned int n) const
{
- wxFAIL_MSG("Method Not Implemented.");
- return wxEmptyString;
+ return GetComboPeer()->GetStringAtIndex(n);
}
wxString wxComboBox::GetStringSelection() const
{
- wxFAIL_MSG("Method Not Implemented.");
- return wxEmptyString;
+ return GetString(GetSelection());
}
void wxComboBox::SetString(unsigned int n, const wxString& s)
{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
-bool wxComboBox::IsEditable() const
-{
- return !HasFlag(wxCB_READONLY);
-}
-
-void wxComboBox::Undo()
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
-void wxComboBox::Redo()
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
-void wxComboBox::SelectAll()
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
-bool wxComboBox::CanCopy() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return false;
-}
-
-bool wxComboBox::CanCut() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return false;
-}
-
-bool wxComboBox::CanPaste() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return false;
-}
-
-bool wxComboBox::CanUndo() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return false;
-}
-
-bool wxComboBox::CanRedo() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return false;
+ Delete(n);
+ Insert(s, n);
+ SetValue(s); // changing the item in the list won't update the display item
}
void wxComboBox::EnableTextChangedEvents(bool enable)
wxFAIL_MSG("Method Not Implemented.");
}
-void wxComboBox::WriteText(const wxString& text)
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
-wxString wxComboBox::DoGetValue() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return wxEmptyString;
-}
-
-wxClientDataType wxComboBox::GetClientDataType() const
-{
- wxFAIL_MSG("Method Not Implemented.");
- return wxClientData_None;
-}
-
-void wxComboBox::SetClientDataType(wxClientDataType clientDataItemsType)
-{
- wxFAIL_MSG("Method Not Implemented.");
-}
-
bool wxComboBox::OSXHandleClicked( double timestampsec )
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
return true;
}
-#endif // wxUSE_COMBOBOX && defined(wxOSX_USE_NATIVE_COMBOBOX)
+wxTextWidgetImpl* wxComboBox::GetTextPeer() const
+{
+ return dynamic_cast<wxTextWidgetImpl*> (m_peer);
+}
+
+wxComboWidgetImpl* wxComboBox::GetComboPeer() const
+{
+ return dynamic_cast<wxComboWidgetImpl*> (m_peer);
+}
+
+#endif // wxUSE_COMBOBOX && wxOSX_USE_COCOA
GetTextPeer()->CheckSpelling(check);
}
-wxString wxTextCtrl::DoGetValue() const
-{
- return GetTextPeer()->GetStringValue() ;
-}
-
-void wxTextCtrl::GetSelection(long* from, long* to) const
-{
- GetTextPeer()->GetSelection( from , to ) ;
-}
-
void wxTextCtrl::SetMaxLength(unsigned long len)
{
m_maxLength = len ;
return true ;
}
-// Clipboard operations
-
-void wxTextCtrl::Copy()
-{
- if (CanCopy())
- GetTextPeer()->Copy() ;
-}
-
-void wxTextCtrl::Cut()
-{
- if (CanCut())
- {
- GetTextPeer()->Cut() ;
-
- SendTextUpdatedEvent();
- }
-}
-
-void wxTextCtrl::Paste()
-{
- if (CanPaste())
- {
- GetTextPeer()->Paste() ;
-
- // TODO: eventually we should add setting the default style again
- SendTextUpdatedEvent();
- }
-}
-
-bool wxTextCtrl::CanCopy() const
-{
- // Can copy if there's a selection
- long from, to;
- GetSelection( &from, &to );
-
- return (from != to);
-}
-
-bool wxTextCtrl::CanCut() const
-{
- if ( !IsEditable() )
- return false;
-
- // Can cut if there's a selection
- long from, to;
- GetSelection( &from, &to );
-
- return (from != to);
-}
-
-bool wxTextCtrl::CanPaste() const
-{
- if (!IsEditable())
- return false;
-
- return GetTextPeer()->CanPaste() ;
-}
-
-void wxTextCtrl::SetEditable(bool editable)
-{
- if ( editable != m_editable )
- {
- m_editable = editable ;
- GetTextPeer()->SetEditable( editable ) ;
- }
-}
-
-void wxTextCtrl::SetInsertionPoint(long pos)
-{
- SetSelection( pos , pos ) ;
-}
-
-void wxTextCtrl::SetInsertionPointEnd()
-{
- long pos = GetLastPosition();
- SetInsertionPoint( pos );
-}
-
-long wxTextCtrl::GetInsertionPoint() const
-{
- long begin, end ;
- GetSelection( &begin , &end ) ;
-
- return begin ;
-}
-
-wxTextPos wxTextCtrl::GetLastPosition() const
-{
- return GetTextPeer()->GetLastPosition() ;
-}
-
-void wxTextCtrl::Remove(long from, long to)
-{
- GetTextPeer()->Remove( from , to ) ;
- if ( m_triggerUpdateEvents )
- SendTextUpdatedEvent();
-}
-
-void wxTextCtrl::SetSelection(long from, long to)
-{
- GetTextPeer()->SetSelection( from , to ) ;
-}
-
-void wxTextCtrl::WriteText(const wxString& str)
-{
- GetTextPeer()->WriteText( str ) ;
- if ( m_triggerUpdateEvents )
- SendTextUpdatedEvent();
-}
-
-void wxTextCtrl::Clear()
-{
- GetTextPeer()->Clear() ;
- SendTextUpdatedEvent();
-}
-
bool wxTextCtrl::IsModified() const
{
return m_dirty;
}
-bool wxTextCtrl::IsEditable() const
-{
- return IsEnabled() && m_editable ;
-}
-
bool wxTextCtrl::AcceptsFocus() const
{
// we don't want focus if we can't be edited
return GetTextPeer()->GetStyle(position, style);
}
-// ----------------------------------------------------------------------------
-// Undo/redo
-// ----------------------------------------------------------------------------
-
-void wxTextCtrl::Undo()
-{
- if (CanUndo())
- GetTextPeer()->Undo() ;
-}
-
-void wxTextCtrl::Redo()
-{
- if (CanRedo())
- GetTextPeer()->Redo() ;
-}
-
-bool wxTextCtrl::CanUndo() const
-{
- if ( !IsEditable() )
- return false ;
-
- return GetTextPeer()->CanUndo() ;
-}
-
-bool wxTextCtrl::CanRedo() const
-{
- if ( !IsEditable() )
- return false ;
-
- return GetTextPeer()->CanRedo() ;
-}
-
void wxTextCtrl::MarkDirty()
{
m_dirty = true;
return GetTextPeer()->GetLineText(lineNo) ;
}
-void wxTextCtrl::Command(wxCommandEvent & event)
+void wxTextCtrl::Remove(long from, long to)
{
- SetValue(event.GetString());
- ProcessCommand(event);
+ wxTextEntry::Remove(from, to);
+ if ( m_triggerUpdateEvents )
+ SendTextUpdatedEvent();
+}
+
+void wxTextCtrl::WriteText(const wxString& str)
+{
+ wxTextEntry::WriteText( str ) ;
+ if ( m_triggerUpdateEvents )
+ SendTextUpdatedEvent();
+}
+
+void wxTextCtrl::Clear()
+{
+ wxTextEntry::Clear() ;
+ SendTextUpdatedEvent();
+}
+
+void wxTextCtrl::Cut()
+{
+ if (CanCut())
+ {
+ wxTextEntry::Cut() ;
+
+ SendTextUpdatedEvent();
+ }
+}
+
+void wxTextCtrl::Paste()
+{
+ if (CanPaste())
+ {
+ wxTextEntry::Paste();
+
+ // TODO: eventually we should add setting the default style again
+ SendTextUpdatedEvent();
+ }
}
void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
#endif
}
+void wxTextCtrl::Command(wxCommandEvent & event)
+{
+ SetValue(event.GetString());
+ ProcessCommand(event);
+}
+
// ----------------------------------------------------------------------------
// standard handlers for standard edit menu events
// ----------------------------------------------------------------------------
+// CS: Context Menus only work with MLTE implementations or non-multiline HIViews at the moment
+
void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
{
Cut();
event.Enable(GetLastPosition() > 0);
}
-// CS: Context Menus only work with MLTE implementations or non-multiline HIViews at the moment
-
void wxTextCtrl::OnContextMenu(wxContextMenuEvent& event)
{
if ( GetTextPeer()->HasOwnContextMenu() )
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/osx/textentry_osx.cpp
+// Purpose: wxTextEntry
+// Author: Stefan Csomor
+// Modified by: Kevin Ollivier
+// Created: 1998-01-01
+// RCS-ID: $Id: textctrl.cpp 54820 2008-07-29 20:04:11Z SC $
+// Copyright: (c) Stefan Csomor
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#include "wx/wxprec.h"
+
+#if wxUSE_TEXTCTRL
+
+#include "wx/textctrl.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/intl.h"
+ #include "wx/app.h"
+ #include "wx/utils.h"
+ #include "wx/dc.h"
+ #include "wx/button.h"
+ #include "wx/menu.h"
+ #include "wx/settings.h"
+ #include "wx/msgdlg.h"
+ #include "wx/toplevel.h"
+#endif
+
+#ifdef __DARWIN__
+ #include <sys/types.h>
+ #include <sys/stat.h>
+#else
+ #include <stat.h>
+#endif
+
+#if wxUSE_STD_IOSTREAM
+ #if wxUSE_IOSTREAMH
+ #include <fstream.h>
+ #else
+ #include <fstream>
+ #endif
+#endif
+
+#include "wx/filefn.h"
+#include "wx/sysopt.h"
+#include "wx/thread.h"
+
+#include "wx/osx/private.h"
+
+wxString wxTextEntry::DoGetValue() const
+{
+ return GetTextPeer()->GetStringValue() ;
+}
+
+void wxTextEntry::GetSelection(long* from, long* to) const
+{
+ GetTextPeer()->GetSelection( from , to ) ;
+}
+
+void wxTextEntry::SetMaxLength(unsigned long len)
+{
+ m_maxLength = len ;
+}
+
+// Clipboard operations
+
+void wxTextEntry::Copy()
+{
+ if (CanCopy())
+ GetTextPeer()->Copy() ;
+}
+
+void wxTextEntry::Cut()
+{
+ if (CanCut())
+ GetTextPeer()->Cut() ;
+}
+
+void wxTextEntry::Paste()
+{
+ if (CanPaste())
+ GetTextPeer()->Paste() ;
+}
+
+bool wxTextEntry::CanCopy() const
+{
+ // Can copy if there's a selection
+ long from, to;
+ GetSelection( &from, &to );
+
+ return (from != to);
+}
+
+bool wxTextEntry::CanCut() const
+{
+ if ( !IsEditable() )
+ return false;
+
+ // Can cut if there's a selection
+ long from, to;
+ GetSelection( &from, &to );
+
+ return (from != to);
+}
+
+bool wxTextEntry::CanPaste() const
+{
+ if (!IsEditable())
+ return false;
+
+ return GetTextPeer()->CanPaste() ;
+}
+
+void wxTextEntry::SetEditable(bool editable)
+{
+ if ( editable != m_editable )
+ {
+ m_editable = editable ;
+ GetTextPeer()->SetEditable( editable ) ;
+ }
+}
+
+void wxTextEntry::SetInsertionPoint(long pos)
+{
+ SetSelection( pos , pos ) ;
+}
+
+void wxTextEntry::SetInsertionPointEnd()
+{
+ long pos = GetLastPosition();
+ SetInsertionPoint( pos );
+}
+
+long wxTextEntry::GetInsertionPoint() const
+{
+ long begin, end ;
+ GetSelection( &begin , &end ) ;
+
+ return begin ;
+}
+
+wxTextPos wxTextEntry::GetLastPosition() const
+{
+ return GetTextPeer()->GetLastPosition() ;
+}
+
+void wxTextEntry::Remove(long from, long to)
+{
+ GetTextPeer()->Remove( from , to ) ;
+}
+
+void wxTextEntry::SetSelection(long from, long to)
+{
+ GetTextPeer()->SetSelection( from , to ) ;
+}
+
+void wxTextEntry::WriteText(const wxString& str)
+{
+ GetTextPeer()->WriteText( str ) ;
+}
+
+void wxTextEntry::Clear()
+{
+ GetTextPeer()->Clear() ;
+}
+
+bool wxTextEntry::IsEditable() const
+{
+ return m_editable ;
+}
+
+// ----------------------------------------------------------------------------
+// Undo/redo
+// ----------------------------------------------------------------------------
+
+void wxTextEntry::Undo()
+{
+ if (CanUndo())
+ GetTextPeer()->Undo() ;
+}
+
+void wxTextEntry::Redo()
+{
+ if (CanRedo())
+ GetTextPeer()->Redo() ;
+}
+
+bool wxTextEntry::CanUndo() const
+{
+ if ( !IsEditable() )
+ return false ;
+
+ return GetTextPeer()->CanUndo() ;
+}
+
+bool wxTextEntry::CanRedo() const
+{
+ if ( !IsEditable() )
+ return false ;
+
+ return GetTextPeer()->CanRedo() ;
+}
+
+wxTextWidgetImpl * wxTextEntry::GetTextPeer() const
+{
+ wxFAIL_MSG("You need to implement wxTextWidgetImpl* GetTextPeer() in your wxTextEntry subclass if you want to use the native impls of its methods.");
+ return NULL;
+}
+#endif // wxUSE_TEXTCTRL