should call or replace this function. See \helpref{wxComboBox::wxComboBox}{wxcomboboxctor}\rtfsp
for further details.
+\membersection{wxComboBox::CanCopy}\label{wxcomboboxcancopy}
+
+\constfunc{bool}{CanCopy}{\void}
+
+Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
+Only available on Windows.
+
+\membersection{wxComboBox::CanCut}\label{wxcomboboxcancut}
+
+\constfunc{bool}{CanCut}{\void}
+
+Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
+Only available on Windows.
+
+\membersection{wxComboBox::CanPaste}\label{wxcomboboxcanpaste}
+
+\constfunc{bool}{CanPaste}{\void}
+
+Returns true if the combobox is editable and there is text on the clipboard that can be pasted into the
+text field. Only available on Windows.
+
+\membersection{wxComboBox::CanRedo}\label{wxcomboboxcanredo}
+
+\constfunc{bool}{CanRedo}{\void}
+
+Returns true if the combobox is editable and the last undo can be redone.
+Only available on Windows.
+
+\membersection{wxComboBox::CanUndo}\label{wxcomboboxcanundo}
+
+\constfunc{bool}{CanUndo}{\void}
+
+Returns true if the combobox is editable and the last edit can be undone.
+Only available on Windows.
+
\membersection{wxComboBox::Copy}\label{wxcomboboxcopy}
\func{void}{Copy}{\void}
Pastes text from the clipboard to the text field.
+\membersection{wxComboBox::Redo}\label{wxcomboboxredo}
+
+\func{void}{Redo}{\void}
+
+Redoes the last undo in the text field. Windows only.
+
\membersection{wxComboBox::Replace}\label{wxcomboboxreplace}
\func{void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{text}}
\docparam{text}{The text to set.}
+\membersection{wxComboBox::Undo}\label{wxcomboboxundo}
+
+\func{void}{Undo}{\void}
+
+Undoes the last edit in the text field. Windows only.
{ wxTextCtrl::SetSelection(from,to); }
virtual void SetEditable(bool editable)
{ wxTextCtrl::SetEditable(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 = 0
+ { 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__
{ SetInsertionPoint(GetLastPosition()); }
virtual void Remove(long from, long to)
{ Replace(from, to, wxEmptyString); }
+
+ virtual bool IsEditable() const = 0;
+
+ virtual void Undo() = 0;
+ virtual void Redo() = 0;
+ virtual void SelectAll() = 0;
+
+ virtual bool CanCopy() const = 0;
+ virtual bool CanCut() const = 0;
+ virtual bool CanPaste() const = 0;
+ virtual bool CanUndo() const = 0;
+ virtual bool CanRedo() const = 0;
+
};
// ----------------------------------------------------------------------------
void Copy();
void Cut();
void Paste();
+ bool CanCopy() const;
+ bool CanCut() const;
+ bool CanPaste() const;
void SetInsertionPoint( long pos );
void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
long GetInsertionPoint() const;
void Remove(long from, long to) { Replace(from, to, wxEmptyString); }
void Replace( long from, long to, const wxString& value );
void SetSelection( long from, long to );
+ void GetSelection( long* from, long* to ) const;
void SetEditable( bool editable );
+ void Undo() ;
+ void Redo() ;
+ bool CanUndo() const;
+ bool CanRedo() const;
+ void SelectAll();
+ bool IsEditable() const { return !HasFlag(wxCB_READONLY); }
+ bool HasSelection() const ;
// implementation
void OnSize( wxSizeEvent &event );
void OnChar( wxKeyEvent &event );
+ // Standard event handling
+ void OnCut(wxCommandEvent& event);
+ void OnCopy(wxCommandEvent& event);
+ void OnPaste(wxCommandEvent& event);
+ void OnUndo(wxCommandEvent& event);
+ void OnRedo(wxCommandEvent& event);
+ void OnDelete(wxCommandEvent& event);
+ void OnSelectAll(wxCommandEvent& event);
+
+ void OnUpdateCut(wxUpdateUIEvent& event);
+ void OnUpdateCopy(wxUpdateUIEvent& event);
+ void OnUpdatePaste(wxUpdateUIEvent& event);
+ void OnUpdateUndo(wxUpdateUIEvent& event);
+ void OnUpdateRedo(wxUpdateUIEvent& event);
+ void OnUpdateDelete(wxUpdateUIEvent& event);
+ void OnUpdateSelectAll(wxUpdateUIEvent& event);
+
bool m_ignoreNextUpdate:1;
wxList m_clientDataList;
wxList m_clientObjectList;
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
-
+
protected:
virtual int DoAppend(const wxString& item);
virtual int DoInsert(const wxString& item, int pos);
void Copy();
void Cut();
void Paste();
+ bool CanCopy() const;
+ bool CanCut() const;
+ bool CanPaste() const;
void SetInsertionPoint( long pos );
void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
long GetInsertionPoint() const;
void Remove(long from, long to) { Replace(from, to, wxEmptyString); }
void Replace( long from, long to, const wxString& value );
void SetSelection( long from, long to );
+ void GetSelection( long* from, long* to ) const;
void SetEditable( bool editable );
+ void Undo() ;
+ void Redo() ;
+ bool CanUndo() const;
+ bool CanRedo() const;
+ void SelectAll();
+ bool IsEditable() const { return !HasFlag(wxCB_READONLY); }
+ bool HasSelection() const ;
// implementation
void OnSize( wxSizeEvent &event );
void OnChar( wxKeyEvent &event );
+ // Standard event handling
+ void OnCut(wxCommandEvent& event);
+ void OnCopy(wxCommandEvent& event);
+ void OnPaste(wxCommandEvent& event);
+ void OnUndo(wxCommandEvent& event);
+ void OnRedo(wxCommandEvent& event);
+ void OnDelete(wxCommandEvent& event);
+ void OnSelectAll(wxCommandEvent& event);
+
+ void OnUpdateCut(wxUpdateUIEvent& event);
+ void OnUpdateCopy(wxUpdateUIEvent& event);
+ void OnUpdatePaste(wxUpdateUIEvent& event);
+ void OnUpdateUndo(wxUpdateUIEvent& event);
+ void OnUpdateRedo(wxUpdateUIEvent& event);
+ void OnUpdateDelete(wxUpdateUIEvent& event);
+ void OnUpdateSelectAll(wxUpdateUIEvent& event);
+
bool m_ignoreNextUpdate:1;
wxList m_clientDataList;
wxList m_clientObjectList;
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
-
+
protected:
virtual int DoAppend(const wxString& item);
virtual int DoInsert(const wxString& item, int pos);
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
virtual int GetCount() const ;
+
+ virtual bool IsEditable() const ;
+
+ virtual void Undo() ;
+ virtual void Redo() ;
+ virtual void SelectAll() ;
+
+ virtual bool CanCopy() const ;
+ virtual bool CanCut() const ;
+ virtual bool CanPaste() const ;
+ virtual bool CanUndo() const ;
+ virtual bool CanRedo() const ;
+
wxInt32 MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ;
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
virtual int GetCount() const { return m_choice->GetCount() ; }
+
+ virtual bool IsEditable() const ;
+
+ virtual void Undo() ;
+ virtual void Redo() ;
+ virtual void SelectAll() ;
+
+ virtual bool CanCopy() const ;
+ virtual bool CanCut() const ;
+ virtual bool CanPaste() const ;
+ virtual bool CanUndo() const ;
+ virtual bool CanRedo() const ;
+
void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
virtual void Copy();
virtual void Cut();
virtual void Paste();
+ virtual bool CanCopy() const;
+ virtual bool CanCut() const;
+ virtual bool CanPaste() const;
virtual void SetInsertionPoint(long pos);
virtual void SetInsertionPointEnd();
virtual long GetInsertionPoint() const;
virtual void SetEditable(bool editable);
virtual void Clear() { wxChoice::Clear(); m_selectionOld = -1; }
+ virtual void Undo() ;
+ virtual void Redo() ;
+ virtual bool CanUndo() const;
+ virtual bool CanRedo() const;
+ virtual void SelectAll();
+ virtual bool IsEditable() const ;
+ virtual bool HasSelection() const;
+
// implementation only from now on
virtual bool MSWCommand(WXUINT param, WXWORD id);
bool MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam);
WXHWND GetEditHWND() const;
+ // Standard event handling
+ void OnCut(wxCommandEvent& event);
+ void OnCopy(wxCommandEvent& event);
+ void OnPaste(wxCommandEvent& event);
+ void OnUndo(wxCommandEvent& event);
+ void OnRedo(wxCommandEvent& event);
+ void OnDelete(wxCommandEvent& event);
+ void OnSelectAll(wxCommandEvent& event);
+
+ void OnUpdateCut(wxUpdateUIEvent& event);
+ void OnUpdateCopy(wxUpdateUIEvent& event);
+ void OnUpdatePaste(wxUpdateUIEvent& event);
+ void OnUpdateUndo(wxUpdateUIEvent& event);
+ void OnUpdateRedo(wxUpdateUIEvent& event);
+ void OnUpdateDelete(wxUpdateUIEvent& event);
+ void OnUpdateSelectAll(wxUpdateUIEvent& event);
+
protected:
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
+ DECLARE_EVENT_TABLE()
};
#endif // wxUSE_COMBOBOX
// Author: William Osborne
// Modified by:
// Created: 10/13/04
-// RCS-ID: $Id:
+// RCS-ID: $Id:
// Copyright: (c) William Osborne
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
+ virtual bool IsEditable() const;
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void SelectAll();
+
+ virtual bool CanCopy() const;
+ virtual bool CanCut() const;
+ virtual bool CanPaste() const;
+ virtual bool CanUndo() const;
+ virtual bool CanRedo() const;
// implementation only from now on
virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual void Remove(long from, long to);
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
+ virtual bool IsEditable() const;
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void SelectAll();
+
+ virtual bool CanCopy() const;
+ virtual bool CanCut() const;
+ virtual bool CanPaste() const;
+ virtual bool CanUndo() const;
+ virtual bool CanRedo() const;
// wxControlWithItems methods
virtual void Clear();
if (g_isIdle) wxapp_install_idle_handler();
if (combo->m_ignoreNextUpdate)
- {
+ {
combo->m_ignoreNextUpdate = FALSE;
return;
}
GtkWidget *list = GTK_COMBO(combo->m_widget)->list;
gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection );
-
+
combo->m_prevSelection = curSelection;
// Quickly set the value of the combo box
event.SetInt( curSelection );
event.SetString( combo->GetStringSelection() );
event.SetEventObject( combo );
-
+
combo->GetEventHandler()->ProcessEvent( event );
- // Now send the event ourselves
+ // Now send the event ourselves
wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
event2.SetString( combo->GetValue() );
event2.SetEventObject( combo );
BEGIN_EVENT_TABLE(wxComboBox, wxControl)
EVT_SIZE(wxComboBox::OnSize)
EVT_CHAR(wxComboBox::OnChar)
+
+ EVT_MENU(wxID_CUT, wxComboBox::OnCut)
+ EVT_MENU(wxID_COPY, wxComboBox::OnCopy)
+ EVT_MENU(wxID_PASTE, wxComboBox::OnPaste)
+ EVT_MENU(wxID_UNDO, wxComboBox::OnUndo)
+ EVT_MENU(wxID_REDO, wxComboBox::OnRedo)
+ EVT_MENU(wxID_CLEAR, wxComboBox::OnDelete)
+ EVT_MENU(wxID_SELECTALL, wxComboBox::OnSelectAll)
+
+ EVT_UPDATE_UI(wxID_CUT, wxComboBox::OnUpdateCut)
+ EVT_UPDATE_UI(wxID_COPY, wxComboBox::OnUpdateCopy)
+ EVT_UPDATE_UI(wxID_PASTE, wxComboBox::OnUpdatePaste)
+ EVT_UPDATE_UI(wxID_UNDO, wxComboBox::OnUpdateUndo)
+ EVT_UPDATE_UI(wxID_REDO, wxComboBox::OnUpdateRedo)
+ EVT_UPDATE_UI(wxID_CLEAR, wxComboBox::OnUpdateDelete)
+ EVT_UPDATE_UI(wxID_SELECTALL, wxComboBox::OnUpdateSelectAll)
END_EVENT_TABLE()
bool wxComboBox::Create( wxWindow *parent, wxWindowID id,
// This is required for tool bar support
wxSize setsize = GetSize();
gtk_widget_set_usize( m_widget, setsize.x, setsize.y );
-
+
return TRUE;
}
m_clientObjectList.Insert( pos, (wxObject*) NULL );
EnableEvents();
-
+
InvalidateBestSize();
return pos;
node = m_clientDataList.Item( n );
if (node)
m_clientDataList.Erase( node );
-
+
EnableEvents();
-
+
InvalidateBestSize();
}
{
wxFAIL_MSG( wxT("wxComboBox: wrong index") );
}
-
+
InvalidateBestSize();
}
wxString tmp = wxT("");
if (!value.IsNull()) tmp = value;
gtk_entry_set_text( GTK_ENTRY(entry), wxGTK_CONV( tmp ) );
-
+
InvalidateBestSize();
}
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG);
}
+void wxComboBox::Undo()
+{
+ // TODO
+}
+
+void wxComboBox::Redo()
+{
+ // TODO
+}
+
+void wxComboBox::SelectAll()
+{
+ Select(0, GetLastPosition());
+}
+
+bool wxComboBox::CanUndo() const
+{
+ // TODO
+ return false;
+}
+
+bool wxComboBox::CanRedo() const
+{
+ // TODO
+ return false;
+}
+
+bool wxComboBox::HasSelection() const
+{
+ long from, to;
+ GetSelection(&from, &to);
+ return from != to;
+}
+
+bool wxComboBox::CanCopy() const
+{
+ // Can copy if there's a selection
+ return HasSelection();
+}
+
+bool wxComboBox::CanCut() const
+{
+ return CanCopy() && IsEditable();
+}
+
+bool wxComboBox::CanPaste() const
+{
+ // TODO: check for text on the clipboard
+ return IsEditable() ;
+}
+
+bool wxComboBox::IsEditable() const
+{
+ return !HasFlag(wxCB_READONLY);
+}
+
+
void wxComboBox::SetInsertionPoint( long pos )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
gtk_editable_select_region( GTK_EDITABLE(entry), (gint)from, (gint)to );
}
+void wxComboBox::GetSelection( long* from, long* to ) const
+{
+ if (IsEditable())
+ {
+ GtkEditable *editable = GTK_EDITABLE(GTK_COMBO(m_widget)->entry);
+ *from = (long) editable->selection_start_pos;
+ *to = (long) editable->selection_end_pos;
+ }
+}
+
void wxComboBox::SetEditable( bool editable )
{
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
if (window->default_widget)
- gtk_widget_activate (window->default_widget);
+ gtk_widget_activate (window->default_widget);
}
}
return GetDefaultAttributesFromGTKWidget(gtk_combo_new, true);
}
+// ----------------------------------------------------------------------------
+// standard event handling
+// ----------------------------------------------------------------------------
+
+void wxComboBox::OnCut(wxCommandEvent& WXUNUSED(event))
+{
+ Cut();
+}
+
+void wxComboBox::OnCopy(wxCommandEvent& WXUNUSED(event))
+{
+ Copy();
+}
+
+void wxComboBox::OnPaste(wxCommandEvent& WXUNUSED(event))
+{
+ Paste();
+}
+
+void wxComboBox::OnUndo(wxCommandEvent& WXUNUSED(event))
+{
+ Undo();
+}
+
+void wxComboBox::OnRedo(wxCommandEvent& WXUNUSED(event))
+{
+ Redo();
+}
+
+void wxComboBox::OnDelete(wxCommandEvent& WXUNUSED(event))
+{
+ long from, to;
+ GetSelection(& from, & to);
+ if (from != -1 && to != -1)
+ Remove(from, to);
+}
+
+void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event))
+{
+ SetSelection(-1, -1);
+}
+
+void wxComboBox::OnUpdateCut(wxUpdateUIEvent& event)
+{
+ event.Enable( CanCut() );
+}
+
+void wxComboBox::OnUpdateCopy(wxUpdateUIEvent& event)
+{
+ event.Enable( CanCopy() );
+}
+
+void wxComboBox::OnUpdatePaste(wxUpdateUIEvent& event)
+{
+ event.Enable( CanPaste() );
+}
+
+void wxComboBox::OnUpdateUndo(wxUpdateUIEvent& event)
+{
+ event.Enable( CanUndo() );
+}
+
+void wxComboBox::OnUpdateRedo(wxUpdateUIEvent& event)
+{
+ event.Enable( CanRedo() );
+}
+
+void wxComboBox::OnUpdateDelete(wxUpdateUIEvent& event)
+{
+ event.Enable(HasSelection() && IsEditable()) ;
+}
+
+void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event)
+{
+ event.Enable(GetLastPosition() > 0);
+}
+
#endif
+
if (g_isIdle) wxapp_install_idle_handler();
if (combo->m_ignoreNextUpdate)
- {
+ {
combo->m_ignoreNextUpdate = FALSE;
return;
}
GtkWidget *list = GTK_COMBO(combo->m_widget)->list;
gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection );
-
+
combo->m_prevSelection = curSelection;
// Quickly set the value of the combo box
event.SetInt( curSelection );
event.SetString( combo->GetStringSelection() );
event.SetEventObject( combo );
-
+
combo->GetEventHandler()->ProcessEvent( event );
- // Now send the event ourselves
+ // Now send the event ourselves
wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
event2.SetString( combo->GetValue() );
event2.SetEventObject( combo );
BEGIN_EVENT_TABLE(wxComboBox, wxControl)
EVT_SIZE(wxComboBox::OnSize)
EVT_CHAR(wxComboBox::OnChar)
+
+ EVT_MENU(wxID_CUT, wxComboBox::OnCut)
+ EVT_MENU(wxID_COPY, wxComboBox::OnCopy)
+ EVT_MENU(wxID_PASTE, wxComboBox::OnPaste)
+ EVT_MENU(wxID_UNDO, wxComboBox::OnUndo)
+ EVT_MENU(wxID_REDO, wxComboBox::OnRedo)
+ EVT_MENU(wxID_CLEAR, wxComboBox::OnDelete)
+ EVT_MENU(wxID_SELECTALL, wxComboBox::OnSelectAll)
+
+ EVT_UPDATE_UI(wxID_CUT, wxComboBox::OnUpdateCut)
+ EVT_UPDATE_UI(wxID_COPY, wxComboBox::OnUpdateCopy)
+ EVT_UPDATE_UI(wxID_PASTE, wxComboBox::OnUpdatePaste)
+ EVT_UPDATE_UI(wxID_UNDO, wxComboBox::OnUpdateUndo)
+ EVT_UPDATE_UI(wxID_REDO, wxComboBox::OnUpdateRedo)
+ EVT_UPDATE_UI(wxID_CLEAR, wxComboBox::OnUpdateDelete)
+ EVT_UPDATE_UI(wxID_SELECTALL, wxComboBox::OnUpdateSelectAll)
END_EVENT_TABLE()
bool wxComboBox::Create( wxWindow *parent, wxWindowID id,
// This is required for tool bar support
wxSize setsize = GetSize();
gtk_widget_set_usize( m_widget, setsize.x, setsize.y );
-
+
return TRUE;
}
m_clientObjectList.Insert( pos, (wxObject*) NULL );
EnableEvents();
-
+
InvalidateBestSize();
return pos;
node = m_clientDataList.Item( n );
if (node)
m_clientDataList.Erase( node );
-
+
EnableEvents();
-
+
InvalidateBestSize();
}
{
wxFAIL_MSG( wxT("wxComboBox: wrong index") );
}
-
+
InvalidateBestSize();
}
wxString tmp = wxT("");
if (!value.IsNull()) tmp = value;
gtk_entry_set_text( GTK_ENTRY(entry), wxGTK_CONV( tmp ) );
-
+
InvalidateBestSize();
}
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG);
}
+void wxComboBox::Undo()
+{
+ // TODO
+}
+
+void wxComboBox::Redo()
+{
+ // TODO
+}
+
+void wxComboBox::SelectAll()
+{
+ Select(0, GetLastPosition());
+}
+
+bool wxComboBox::CanUndo() const
+{
+ // TODO
+ return false;
+}
+
+bool wxComboBox::CanRedo() const
+{
+ // TODO
+ return false;
+}
+
+bool wxComboBox::HasSelection() const
+{
+ long from, to;
+ GetSelection(&from, &to);
+ return from != to;
+}
+
+bool wxComboBox::CanCopy() const
+{
+ // Can copy if there's a selection
+ return HasSelection();
+}
+
+bool wxComboBox::CanCut() const
+{
+ return CanCopy() && IsEditable();
+}
+
+bool wxComboBox::CanPaste() const
+{
+ // TODO: check for text on the clipboard
+ return IsEditable() ;
+}
+
+bool wxComboBox::IsEditable() const
+{
+ return !HasFlag(wxCB_READONLY);
+}
+
+
void wxComboBox::SetInsertionPoint( long pos )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
gtk_editable_select_region( GTK_EDITABLE(entry), (gint)from, (gint)to );
}
+void wxComboBox::GetSelection( long* from, long* to ) const
+{
+ if (IsEditable())
+ {
+ GtkEditable *editable = GTK_EDITABLE(GTK_COMBO(m_widget)->entry);
+ *from = (long) editable->selection_start_pos;
+ *to = (long) editable->selection_end_pos;
+ }
+}
+
void wxComboBox::SetEditable( bool editable )
{
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
if (window->default_widget)
- gtk_widget_activate (window->default_widget);
+ gtk_widget_activate (window->default_widget);
}
}
return GetDefaultAttributesFromGTKWidget(gtk_combo_new, true);
}
+// ----------------------------------------------------------------------------
+// standard event handling
+// ----------------------------------------------------------------------------
+
+void wxComboBox::OnCut(wxCommandEvent& WXUNUSED(event))
+{
+ Cut();
+}
+
+void wxComboBox::OnCopy(wxCommandEvent& WXUNUSED(event))
+{
+ Copy();
+}
+
+void wxComboBox::OnPaste(wxCommandEvent& WXUNUSED(event))
+{
+ Paste();
+}
+
+void wxComboBox::OnUndo(wxCommandEvent& WXUNUSED(event))
+{
+ Undo();
+}
+
+void wxComboBox::OnRedo(wxCommandEvent& WXUNUSED(event))
+{
+ Redo();
+}
+
+void wxComboBox::OnDelete(wxCommandEvent& WXUNUSED(event))
+{
+ long from, to;
+ GetSelection(& from, & to);
+ if (from != -1 && to != -1)
+ Remove(from, to);
+}
+
+void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event))
+{
+ SetSelection(-1, -1);
+}
+
+void wxComboBox::OnUpdateCut(wxUpdateUIEvent& event)
+{
+ event.Enable( CanCut() );
+}
+
+void wxComboBox::OnUpdateCopy(wxUpdateUIEvent& event)
+{
+ event.Enable( CanCopy() );
+}
+
+void wxComboBox::OnUpdatePaste(wxUpdateUIEvent& event)
+{
+ event.Enable( CanPaste() );
+}
+
+void wxComboBox::OnUpdateUndo(wxUpdateUIEvent& event)
+{
+ event.Enable( CanUndo() );
+}
+
+void wxComboBox::OnUpdateRedo(wxUpdateUIEvent& event)
+{
+ event.Enable( CanRedo() );
+}
+
+void wxComboBox::OnUpdateDelete(wxUpdateUIEvent& event)
+{
+ event.Enable(HasSelection() && IsEditable()) ;
+}
+
+void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event)
+{
+ event.Enable(GetLastPosition() > 0);
+}
+
#endif
+
static int nextPopUpMenuId = 1000 ;
-MenuHandle NewUniqueMenu()
+MenuHandle NewUniqueMenu()
{
MenuHandle handle = NewMenu( nextPopUpMenuId , "\pMenu" ) ;
nextPopUpMenuId++ ;
NavEvent.SetEventObject(this);
NavEvent.SetDirection(true);
NavEvent.SetWindowChange(false);
-
+
// Get the parent of the combo and have it process the navigation?
if (m_cb->GetParent()->GetEventHandler()->ProcessEvent(NavEvent))
return;
return;
}
}
-
+
event.Skip();
}
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_cb->GetId());
event.SetString( GetValue() );
event.SetEventObject( m_cb );
- m_cb->GetEventHandler()->ProcessEvent(event);
+ m_cb->GetEventHandler()->ProcessEvent(event);
}
}
private:
if (! m_cb->HasFlag(wxCB_READONLY) )
sz.x = GetPopupWidth() ;
return sz ;
- }
+ }
private:
wxComboBox *m_cb;
if (!m_choice && !m_text)
return GetSize();
wxSize size = m_choice->GetBestSize();
-
+
if ( m_text != NULL )
{
wxSize sizeText = m_text->GetBestSize();
return size;
}
-void wxComboBox::DoMoveWindow(int x, int y, int width, int height)
+void wxComboBox::DoMoveWindow(int x, int y, int width, int height)
{
wxControl::DoMoveWindow(x, y, width , height );
-
+
if ( m_text == NULL )
{
// we might not be fully constructed yet, therefore watch out...
m_text->SetSize(TEXTFOCUSBORDER, TEXTFOCUSBORDER, wText, -1 );
// put it at an inset of 1 to have outer area shadows drawn as well
m_choice->SetSize(TEXTFOCUSBORDER + wText + MARGIN - 1 , TEXTFOCUSBORDER, m_choice->GetPopupWidth() , -1);
- }
+ }
}
else
{
m_text = new wxComboBoxText(this);
- if ( size.y == -1 )
+ if ( size.y == -1 )
{
csize.y = m_text->GetSize().y ;
csize.y += 2 * TEXTFOCUSBORDER ;
}
}
-
+
DoSetSize(pos.x, pos.y, csize.x, csize.y);
-
+
for ( int i = 0 ; i < n ; i++ )
{
m_choice->DoAppend( choices[ i ] );
wxString wxComboBox::GetValue() const
{
wxString result;
-
+
if ( m_text == NULL )
{
result = m_choice->GetString( m_choice->GetSelection() );
}
int wxComboBox::GetCount() const
-{
- return m_choice->GetCount() ;
+{
+ return m_choice->GetCount() ;
}
void wxComboBox::SetValue(const wxString& value)
int currentX, currentY;
GetPosition( ¤tX, ¤tY );
-
+
int currentW, currentH;
GetSize( ¤tW, ¤tH );
// TODO
}
-int wxComboBox::DoAppend(const wxString& item)
+int wxComboBox::DoAppend(const wxString& item)
{
return m_choice->DoAppend( item ) ;
}
-int wxComboBox::DoInsert(const wxString& item, int pos)
+int wxComboBox::DoInsert(const wxString& item, int pos)
{
return m_choice->DoInsert( item , pos ) ;
}
-void wxComboBox::DoSetItemClientData(int n, void* clientData)
+void wxComboBox::DoSetItemClientData(int n, void* clientData)
{
return m_choice->DoSetItemClientData( n , clientData ) ;
}
return m_choice->DoSetItemClientObject( n , clientData ) ;
}
-wxClientData* wxComboBox::DoGetItemClientObject(int n) const
+wxClientData* wxComboBox::DoGetItemClientObject(int n) const
{
return m_choice->DoGetItemClientObject( n ) ;
}
void wxComboBox::SetSelection(int n)
{
m_choice->SetSelection( n );
-
+
if ( m_text != NULL )
{
m_text->SetValue( GetString( n ) );
return FALSE;
}
-void wxComboBox::SetString(int n, const wxString& s)
+void wxComboBox::SetString(int n, const wxString& s)
{
m_choice->SetString( n , s ) ;
}
+bool wxComboBox::IsEditable() const
+{
+ return m_text != NULL && !HasFlag(wxCB_READONLY);
+}
+
+void wxComboBox::Undo()
+{
+ if (m_text != NULL)
+ m_text->Undo();
+}
+
+void wxComboBox::Redo()
+{
+ if (m_text != NULL)
+ m_text->Redo();
+}
+
+void wxComboBox::SelectAll()
+{
+ if (m_text != NULL)
+ m_text->SelectAll();
+}
+
+bool wxComboBox::CanCopy() const
+{
+ if (m_text != NULL)
+ return m_text->CanCopy();
+ else
+ return false;
+}
+
+bool wxComboBox::CanCut() const
+{
+ if (m_text != NULL)
+ return m_text->CanCut();
+ else
+ return false;
+}
+
+bool wxComboBox::CanPaste() const
+{
+ if (m_text != NULL)
+ return m_text->CanPaste();
+ else
+ return false;
+}
+
+bool wxComboBox::CanUndo() const
+{
+ if (m_text != NULL)
+ return m_text->CanUndo();
+ else
+ return false;
+}
+
+bool wxComboBox::CanRedo() const
+{
+ if (m_text != NULL)
+ return m_text->CanRedo();
+ else
+ return false;
+}
-wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
+wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
/* For consistency with other platforms, clicking in the text area does not constitute a selection
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
#endif
static int nextPopUpMenuId = 1000 ;
-MenuHandle NewUniqueMenu()
+MenuHandle NewUniqueMenu()
{
MenuHandle handle = NewMenu( nextPopUpMenuId , "\pMenu" ) ;
nextPopUpMenuId++ ;
{
OSStatus result = eventNotHandledErr ;
wxComboBox* cb = (wxComboBox*) data ;
-
+
wxMacCarbonEvent cEvent( event ) ;
switch( cEvent.GetClass() )
default :
break ;
}
-
+
return result ;
}
return;
}
}
-
+
event.Skip();
}
private:
wxSize sz = wxChoice::DoGetBestSize() ;
sz.x = POPUPWIDTH ;
return sz ;
- }
+ }
private:
wxComboBox *m_cb;
return wxControl::DoGetBestSize();
#else
wxSize size = m_choice->GetBestSize();
-
+
if ( m_text != NULL )
{
wxSize sizeText = m_text->GetBestSize();
-
+
size.x = POPUPWIDTH + sizeText.x + MARGIN;
}
wxControl::DoMoveWindow(x, y, width, height);
#else
height = POPUPHEIGHT;
-
+
wxControl::DoMoveWindow(x, y, width, height);
if ( m_text == NULL )
m_text->SetSize(0, 0, wText, height);
m_choice->SetSize(0 + wText + MARGIN, 0, POPUPWIDTH, -1);
}
-#endif
+#endif
}
#if USE_HICOMBOBOX
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
HIRect hiRect;
-
+
hiRect.origin.x = 20; //bounds.left;
hiRect.origin.y = 25; //bounds.top;
hiRect.size.width = 120;// bounds.right - bounds.left;
- hiRect.size.height = 24;
-
+ hiRect.size.height = 24;
+
//For some reason, this code causes the combo box not to be displayed at all.
//hiRect.origin.x = bounds.left;
//hiRect.origin.y = bounds.top;
//printf("x = %d, y = %d, width = %d, height = %d\n", hibounds.origin.x, hibounds.origin.y, hibounds.size.width, hibounds.size.height);
m_peer = new wxMacControl() ;
verify_noerr( HIComboBoxCreate( &hiRect, CFSTR(""), NULL, NULL, kHIComboBoxStandardAttributes, *m_peer ) );
-
+
SetControl32BitMinimum( *m_peer , 0 ) ;
SetControl32BitMaximum( *m_peer , 100) ;
if ( n > 0 )
SetControl32BitValue( *m_peer , 1 ) ;
-
+
MacPostControlCreate(pos,size) ;
-
+
for ( int i = 0 ; i < n ; i++ )
{
DoAppend( choices[ i ] );
}
-
+
HIViewSetVisible( *m_peer, true );
SetSelection(0);
EventHandlerRef comboEventHandler ;
InstallControlEventHandler( *m_peer, GetwxMacComboBoxEventHandlerUPP(),
- GetEventTypeCount(eventList), eventList, this,
+ GetEventTypeCount(eventList), eventList, this,
(EventHandlerRef *)&comboEventHandler);
#else
m_choice = new wxComboBoxChoice(this, style );
m_choice = new wxComboBoxChoice(this, style );
m_choice->SetSizeHints( wxSize( POPUPWIDTH , POPUPHEIGHT ) ) ;
-
+
wxSize csize = size;
if ( style & wxCB_READONLY )
{
csize.y = m_text->GetSize().y ;
}
}
-
+
DoSetSize(pos.x, pos.y, csize.x, csize.y);
-
+
for ( int i = 0 ; i < n ; i++ )
{
m_choice->DoAppend( choices[ i ] );
return wxMacCFStringHolder( myString, m_font.GetEncoding() ).AsString();
#else
wxString result;
-
+
if ( m_text == NULL )
{
result = m_choice->GetString( m_choice->GetSelection() );
{
result = m_text->GetValue();
}
-
+
return result;
#endif
}
void wxComboBox::SetValue(const wxString& value)
{
#if USE_HICOMBOBOX
-
+
#else
int s = FindString (value);
if (s == wxNOT_FOUND && !HasFlag(wxCB_READONLY) )
int currentX, currentY;
GetPosition( ¤tX, ¤tY );
-
+
int currentW, currentH;
GetSize( ¤tW, ¤tH );
// TODO
}
-int wxComboBox::DoAppend(const wxString& item)
+int wxComboBox::DoAppend(const wxString& item)
{
#if USE_HICOMBOBOX
CFIndex outIndex;
#endif
}
-int wxComboBox::DoInsert(const wxString& item, int pos)
+int wxComboBox::DoInsert(const wxString& item, int pos)
{
#if USE_HICOMBOBOX
HIComboBoxInsertTextItemAtIndex( *m_peer, (CFIndex)pos, wxMacCFStringHolder(item, m_font.GetEncoding()) );
-
+
//SetControl32BitMaximum( *m_peer, GetCount() );
-
+
return pos;
#else
return m_choice->DoInsert( item , pos ) ;
#endif
}
-void wxComboBox::DoSetItemClientData(int n, void* clientData)
+void wxComboBox::DoSetItemClientData(int n, void* clientData)
{
#if USE_HICOMBOBOX
return; //TODO
#endif
}
-wxClientData* wxComboBox::DoGetItemClientObject(int n) const
+wxClientData* wxComboBox::DoGetItemClientObject(int n) const
{
#if USE_HICOMBOBOX
return NULL;
#if USE_HICOMBOBOX
return (int) HIComboBoxGetItemCount( *m_peer );
#else
- return m_choice->GetCount() ;
+ return m_choice->GetCount() ;
#endif
}
SetControl32BitValue( *m_peer , n + 1 ) ;
#else
m_choice->SetSelection( n );
-
+
if ( m_text != NULL )
{
m_text->SetValue( GetString( n ) );
return FALSE;
}
-void wxComboBox::SetString(int n, const wxString& s)
+void wxComboBox::SetString(int n, const wxString& s)
{
#if USE_HICOMBOBOX
- verify_noerr ( HIComboBoxInsertTextItemAtIndex( *m_peer, (CFIndex) n,
+ verify_noerr ( HIComboBoxInsertTextItemAtIndex( *m_peer, (CFIndex) n,
wxMacCFStringHolder(s, m_font.GetEncoding()) ) );
verify_noerr ( HIComboBoxRemoveItemAtIndex( *m_peer, (CFIndex) n + 1 ) );
#else
#endif
}
+bool wxComboBox::IsEditable() const
+{
+#if USE_HICOMBOBOX
+ // TODO
+ return !HasFlag(wxCB_READONLY);
+#else
+ return m_text != NULL && !HasFlag(wxCB_READONLY);
+#endif
+}
+
+void wxComboBox::Undo()
+{
+#if USE_HICOMBOBOX
+ // TODO
+#else
+ if (m_text != NULL)
+ m_text->Undo();
+#endif
+}
+
+void wxComboBox::Redo()
+{
+#if USE_HICOMBOBOX
+ // TODO
+#else
+ if (m_text != NULL)
+ m_text->Redo();
+#endif
+}
+
+void wxComboBox::SelectAll()
+{
+#if USE_HICOMBOBOX
+ // TODO
+#else
+ if (m_text != NULL)
+ m_text->SelectAll();
+#endif
+}
+
+bool wxComboBox::CanCopy() const
+{
+#if USE_HICOMBOBOX
+ // TODO
+ return false;
+#else
+ if (m_text != NULL)
+ return m_text->CanCopy();
+ else
+ return false;
+#endif
+}
+
+bool wxComboBox::CanCut() const
+{
+#if USE_HICOMBOBOX
+ // TODO
+ return false;
+#else
+ if (m_text != NULL)
+ return m_text->CanCut();
+ else
+ return false;
+#endif
+}
+
+bool wxComboBox::CanPaste() const
+{
+#if USE_HICOMBOBOX
+ // TODO
+ return false;
+#else
+ if (m_text != NULL)
+ return m_text->CanPaste();
+ else
+ return false;
+#endif
+}
+
+bool wxComboBox::CanUndo() const
+{
+#if USE_HICOMBOBOX
+ // TODO
+ return false;
+#else
+ if (m_text != NULL)
+ return m_text->CanUndo();
+ else
+ return false;
+#endif
+}
+
+bool wxComboBox::CanRedo() const
+{
+#if USE_HICOMBOBOX
+ // TODO
+ return false;
+#else
+ if (m_text != NULL)
+ return m_text->CanRedo();
+ else
+ return false;
+#endif
+}
-wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
+wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
event.SetInt(GetSelection());
static int nextPopUpMenuId = 1000 ;
-MenuHandle NewUniqueMenu()
+MenuHandle NewUniqueMenu()
{
MenuHandle handle = NewMenu( nextPopUpMenuId , "\pMenu" ) ;
nextPopUpMenuId++ ;
return;
}
}
-
+
event.Skip();
}
wxSize wxComboBox::DoGetBestSize() const
{
wxSize size = m_choice->GetBestSize();
-
+
if ( m_text != NULL )
{
wxSize sizeText = m_text->GetBestSize();
-
+
size.x = POPUPWIDTH + sizeText.x + MARGIN;
}
void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
height = POPUPHEIGHT;
-
+
wxControl::DoMoveWindow(x, y, width, height);
if ( m_text == NULL )
wxCoord wText = width - POPUPWIDTH - MARGIN;
m_text->SetSize(0, 0, wText, height);
m_choice->SetSize(0 + wText + MARGIN, 0, POPUPWIDTH, -1);
- }
+ }
}
csize.y = m_text->GetSize().y ;
}
}
-
+
DoSetSize(pos.x, pos.y, csize.x, csize.y);
-
+
for ( int i = 0 ; i < n ; i++ )
{
m_choice->DoAppend( choices[ i ] );
wxString wxComboBox::GetValue() const
{
wxString result;
-
+
if ( m_text == NULL )
{
result = m_choice->GetString( m_choice->GetSelection() );
int currentX, currentY;
GetPosition( ¤tX, ¤tY );
-
+
int currentW, currentH;
GetSize( ¤tW, ¤tH );
// TODO
}
-int wxComboBox::DoAppend(const wxString& item)
+int wxComboBox::DoAppend(const wxString& item)
{
return m_choice->DoAppend( item ) ;
}
-int wxComboBox::DoInsert(const wxString& item, int pos)
+int wxComboBox::DoInsert(const wxString& item, int pos)
{
return m_choice->DoInsert( item , pos ) ;
}
-void wxComboBox::DoSetItemClientData(int n, void* clientData)
+void wxComboBox::DoSetItemClientData(int n, void* clientData)
{
return m_choice->DoSetItemClientData( n , clientData ) ;
}
return m_choice->DoSetItemClientObject( n , clientData ) ;
}
-wxClientData* wxComboBox::DoGetItemClientObject(int n) const
+wxClientData* wxComboBox::DoGetItemClientObject(int n) const
{
return m_choice->DoGetItemClientObject( n ) ;
}
void wxComboBox::SetSelection(int n)
{
m_choice->SetSelection( n );
-
+
if ( m_text != NULL )
{
m_text->SetValue( GetString( n ) );
return FALSE;
}
-void wxComboBox::SetString(int n, const wxString& s)
+void wxComboBox::SetString(int n, const wxString& s)
{
m_choice->SetString( n , s ) ;
}
+bool wxComboBox::IsEditable() const
+{
+
+ return m_text != NULL && !HasFlag(wxCB_READONLY);
+}
+
+void wxComboBox::Undo()
+{
+ if (m_text != NULL)
+ m_text->Undo();
+}
+
+void wxComboBox::Redo()
+{
+ if (m_text != NULL)
+ m_text->Redo();
+}
+
+void wxComboBox::SelectAll()
+{
+ if (m_text != NULL)
+ m_text->SelectAll();
+}
+
+bool wxComboBox::CanCopy() const
+{
+ if (m_text != NULL)
+ return m_text->CanCopy();
+ else
+ return false;
+}
+
+bool wxComboBox::CanCut() const
+{
+ if (m_text != NULL)
+ return m_text->CanCut();
+ else
+ return false;
+}
+
+bool wxComboBox::CanPaste() const
+{
+ if (m_text != NULL)
+ return m_text->CanPaste();
+ else
+ return false;
+}
+
+bool wxComboBox::CanUndo() const
+{
+ if (m_text != NULL)
+ return m_text->CanUndo();
+ else
+ return false;
+}
+
+bool wxComboBox::CanRedo() const
+{
+ if (m_text != NULL)
+ return m_text->CanRedo();
+ else
+ return false;
+}
-void wxComboBox::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown))
+void wxComboBox::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown))
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
event.SetInt(GetSelection());
wxCONSTRUCTOR_5( wxComboBox , wxWindow* , Parent , wxWindowID , Id , wxString , Value , wxPoint , Position , wxSize , Size )
#else
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
+
+BEGIN_EVENT_TABLE(wxComboBox, wxControl)
+ EVT_MENU(wxID_CUT, wxComboBox::OnCut)
+ EVT_MENU(wxID_COPY, wxComboBox::OnCopy)
+ EVT_MENU(wxID_PASTE, wxComboBox::OnPaste)
+ EVT_MENU(wxID_UNDO, wxComboBox::OnUndo)
+ EVT_MENU(wxID_REDO, wxComboBox::OnRedo)
+ EVT_MENU(wxID_CLEAR, wxComboBox::OnDelete)
+ EVT_MENU(wxID_SELECTALL, wxComboBox::OnSelectAll)
+
+ EVT_UPDATE_UI(wxID_CUT, wxComboBox::OnUpdateCut)
+ EVT_UPDATE_UI(wxID_COPY, wxComboBox::OnUpdateCopy)
+ EVT_UPDATE_UI(wxID_PASTE, wxComboBox::OnUpdatePaste)
+ EVT_UPDATE_UI(wxID_UNDO, wxComboBox::OnUpdateUndo)
+ EVT_UPDATE_UI(wxID_REDO, wxComboBox::OnUpdateRedo)
+ EVT_UPDATE_UI(wxID_CLEAR, wxComboBox::OnUpdateDelete)
+ EVT_UPDATE_UI(wxID_SELECTALL, wxComboBox::OnUpdateSelectAll)
+END_EVENT_TABLE()
+
#endif
// ----------------------------------------------------------------------------
// Clipboard operations
void wxComboBox::Copy()
{
- SendMessage(GetHwnd(), WM_COPY, 0, 0L);
+ SendMessage(GetHwnd(), WM_COPY, 0, 0L);
}
void wxComboBox::Cut()
{
- SendMessage(GetHwnd(), WM_CUT, 0, 0L);
+ SendMessage(GetHwnd(), WM_CUT, 0, 0L);
}
void wxComboBox::Paste()
{
- SendMessage(GetHwnd(), WM_PASTE, 0, 0L);
+ SendMessage(GetHwnd(), WM_PASTE, 0, 0L);
+}
+
+void wxComboBox::Undo()
+{
+ if (CanUndo())
+ {
+ HWND hEditWnd = (HWND) GetEditHWND() ;
+ if ( hEditWnd )
+ ::SendMessage(hEditWnd, EM_UNDO, 0, 0);
+ }
+}
+
+void wxComboBox::Redo()
+{
+ if (CanUndo())
+ {
+ // Same as Undo, since Undo undoes the undo, i.e. a redo.
+ HWND hEditWnd = (HWND) GetEditHWND() ;
+ if ( hEditWnd )
+ ::SendMessage(hEditWnd, EM_UNDO, 0, 0);
+ }
+}
+
+void wxComboBox::SelectAll()
+{
+ SetSelection(0, GetLastPosition());
+}
+
+bool wxComboBox::CanUndo() const
+{
+ HWND hEditWnd = (HWND) GetEditHWND() ;
+ if ( hEditWnd )
+ return ::SendMessage(hEditWnd, EM_CANUNDO, 0, 0) != 0;
+ else
+ return false;
+}
+
+bool wxComboBox::CanRedo() const
+{
+ HWND hEditWnd = (HWND) GetEditHWND() ;
+ if ( hEditWnd )
+ return ::SendMessage(hEditWnd, EM_CANUNDO, 0, 0) != 0;
+ else
+ return false;
+}
+
+bool wxComboBox::HasSelection() const
+{
+ long from, to;
+ GetSelection(&from, &to);
+ return from != to;
+}
+
+bool wxComboBox::CanCopy() const
+{
+ // Can copy if there's a selection
+ return HasSelection();
+}
+
+bool wxComboBox::CanCut() const
+{
+ return CanCopy() && IsEditable();
+}
+
+bool wxComboBox::CanPaste() const
+{
+ if ( !IsEditable() )
+ return false;
+
+ // Standard edit control: check for straight text on clipboard
+ if ( !::OpenClipboard(GetHwndOf(wxTheApp->GetTopWindow())) )
+ return false;
+
+ bool isTextAvailable = ::IsClipboardFormatAvailable(CF_TEXT) != 0;
+ ::CloseClipboard();
+
+ return isTextAvailable;
+}
+
+bool wxComboBox::IsEditable() const
+{
+ return !HasFlag(wxCB_READONLY);
}
void wxComboBox::SetEditable(bool WXUNUSED(editable))
return wxChoice::GetSelection();
}
+// ----------------------------------------------------------------------------
+// standard event handling
+// ----------------------------------------------------------------------------
+
+void wxComboBox::OnCut(wxCommandEvent& WXUNUSED(event))
+{
+ Cut();
+}
+
+void wxComboBox::OnCopy(wxCommandEvent& WXUNUSED(event))
+{
+ Copy();
+}
+
+void wxComboBox::OnPaste(wxCommandEvent& WXUNUSED(event))
+{
+ Paste();
+}
+
+void wxComboBox::OnUndo(wxCommandEvent& WXUNUSED(event))
+{
+ Undo();
+}
+
+void wxComboBox::OnRedo(wxCommandEvent& WXUNUSED(event))
+{
+ Redo();
+}
+
+void wxComboBox::OnDelete(wxCommandEvent& WXUNUSED(event))
+{
+ long from, to;
+ GetSelection(& from, & to);
+ if (from != -1 && to != -1)
+ Remove(from, to);
+}
+
+void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event))
+{
+ SetSelection(-1, -1);
+}
+
+void wxComboBox::OnUpdateCut(wxUpdateUIEvent& event)
+{
+ event.Enable( CanCut() );
+}
+
+void wxComboBox::OnUpdateCopy(wxUpdateUIEvent& event)
+{
+ event.Enable( CanCopy() );
+}
+
+void wxComboBox::OnUpdatePaste(wxUpdateUIEvent& event)
+{
+ event.Enable( CanPaste() );
+}
+
+void wxComboBox::OnUpdateUndo(wxUpdateUIEvent& event)
+{
+ event.Enable( CanUndo() );
+}
+
+void wxComboBox::OnUpdateRedo(wxUpdateUIEvent& event)
+{
+ event.Enable( CanRedo() );
+}
+
+void wxComboBox::OnUpdateDelete(wxUpdateUIEvent& event)
+{
+ event.Enable(HasSelection() && IsEditable()) ;
+}
+
+void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event)
+{
+ event.Enable(GetLastPosition() > 0);
+}
+
#endif // wxUSE_COMBOBOX
// Author: William Osborne
// Modified by:
// Created: 10/13/04
-// RCS-ID: $Id:
+// RCS-ID: $Id:
// Copyright: (c) William Osborne
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
wxFLAGS_MEMBER(wxBORDER_RAISED)
wxFLAGS_MEMBER(wxBORDER_STATIC)
wxFLAGS_MEMBER(wxBORDER_NONE)
-
+
// old style border flags
wxFLAGS_MEMBER(wxSIMPLE_BORDER)
wxFLAGS_MEMBER(wxSUNKEN_BORDER)
{
}
+bool wxComboBox::IsEditable() const
+{
+ return false;
+}
+
+void wxComboBox::Undo()
+{
+}
+
+void wxComboBox::Redo()
+{
+}
+
+void wxComboBox::SelectAll()
+{
+}
+
+bool wxComboBox::CanCopy() const
+{
+ return false;
+}
+
+bool wxComboBox::CanCut() const
+{
+ return false;
+}
+
+bool wxComboBox::CanPaste() const
+{
+ return false;
+}
+
+bool wxComboBox::CanUndo() const
+{
+ return false;
+}
+
+bool wxComboBox::CanRedo() const
+{
+ return false;
+}
+
+
#endif // wxUSE_COMBOBOX
widthPopup = m_popup->GetBestWidth();
}
- return wxSize(wxMax(sizeText.x + g_comboMargin + sizeBtn.x, widthPopup),
+ return wxSize(wxMax(sizeText.x + g_comboMargin + sizeBtn.x, widthPopup),
wxMax(sizeBtn.y, sizeText.y));
}
#if wxUSE_TOOLTIPS
void wxComboControl::DoSetToolTip(wxToolTip *tooltip)
{
- wxControl::DoSetToolTip(tooltip);
+ wxControl::DoSetToolTip(tooltip);
// Set tool tip for button and text box
if (m_text && m_btn)
#if 1 // FIXME:: What is the correct behavior?
// if the current value isn't one of the listbox strings, return -1
return GetLBox()->GetSelection();
-#else
- // Why oh why is this done this way?
- // It is not because the value displayed in the text can be found
+#else
+ // Why oh why is this done this way?
+ // It is not because the value displayed in the text can be found
// in the list that it is the item that is selected!
return FindString(GetText()->GetValue());
#endif
return GetLBox()->GetClientObject(n);
}
+bool wxComboBox::IsEditable() const
+{
+ return GetText() != NULL && (!HasFlag(wxCB_READONLY) || GetText()->IsEditable());
+}
+
+void wxComboBox::Undo()
+{
+ if (IsEditable())
+ GetText()->Undo();
+}
+
+void wxComboBox::Redo()
+{
+ if (IsEditable())
+ GetText()->Redo();
+}
+
+void wxComboBox::SelectAll()
+{
+ GetText()->SelectAll();
+}
+
+bool wxComboBox::CanCopy() const
+{
+ if (GetText() != NULL)
+ return GetText()->CanCopy();
+ else
+ return false;
+}
+
+bool wxComboBox::CanCut() const
+{
+ if (GetText() != NULL)
+ return GetText()->CanCut();
+ else
+ return false;
+}
+
+bool wxComboBox::CanPaste() const
+{
+ if (IsEditable())
+ return GetText()->CanPaste();
+ else
+ return false;
+}
+
+bool wxComboBox::CanUndo() const
+{
+ if (IsEditable())
+ return GetText()->CanUndo();
+ else
+ return false;
+}
+
+bool wxComboBox::CanRedo() const
+{
+ if (IsEditable())
+ return GetText()->CanRedo();
+ else
+ return false;
+}
+
+
// ----------------------------------------------------------------------------
// input handling
// ----------------------------------------------------------------------------