// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// composite combobox implementation by Dan "Bud" Keith bud@otsys.com
static int nextPopUpMenuId = 1000 ;
// composite combobox implementation by Dan "Bud" Keith bud@otsys.com
static int nextPopUpMenuId = 1000 ;
- // Allows processing the tab key to go to the next control
- if (event.GetKeyCode() == WXK_TAB)
- {
- wxNavigationKeyEvent NavEvent;
- 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))
+ // Allows processing the tab key to go to the next control
+ if (event.GetKeyCode() == WXK_TAB)
+ {
+ wxNavigationKeyEvent NavEvent;
+ 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))
+ }
+
+ // send the event to the combobox class in case the user has bound EVT_CHAR
+ wxKeyEvent kevt(event);
+ kevt.SetEventObject(m_cb);
+ if (m_cb->GetEventHandler()->ProcessEvent(kevt))
+ // If the event was handled and not skipped then we're done
+ return;
+
if ( event.GetKeyCode() == WXK_RETURN )
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_cb->GetId());
if ( event.GetKeyCode() == WXK_RETURN )
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_cb->GetId());
- if ( event.GetKeyCode() != WXK_RETURN )
- {
- wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_cb->GetId());
- event.SetString( GetValue() );
- event.SetEventObject( m_cb );
- m_cb->GetEventHandler()->ProcessEvent(event);
- }
+ event.SetEventObject(m_cb);
+ event.SetId(m_cb->GetId());
+ if (! m_cb->GetEventHandler()->ProcessEvent(event))
+ event.Skip();
+ }
+
+ void OnKeyDown( wxKeyEvent& event )
+ {
+ event.SetEventObject(m_cb);
+ event.SetId(m_cb->GetId());
+ if (! m_cb->GetEventHandler()->ProcessEvent(event))
+ event.Skip();
- EVT_CHAR( wxComboBoxText::OnChar)
- EVT_KEY_UP( wxComboBoxText::OnKeyUp)
+ EVT_KEY_DOWN( wxComboBoxText::OnKeyDown)
+ EVT_CHAR( wxComboBoxText::OnChar)
+ EVT_KEY_UP( wxComboBoxText::OnKeyUp)
+ EVT_TEXT( -1, wxComboBoxText::OnText)
END_EVENT_TABLE()
class wxComboBoxChoice : public wxChoice
{
public:
wxComboBoxChoice(wxComboBox *cb, int style)
END_EVENT_TABLE()
class wxComboBoxChoice : public wxChoice
{
public:
wxComboBoxChoice(wxComboBox *cb, int style)
-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 );
{
wxControl::DoMoveWindow(x, y, width , height );
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);
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);
const wxString& name)
{
if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style ,
const wxString& name)
{
if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style ,
DoSetSize(pos.x, pos.y, csize.x, csize.y);
DoSetSize(pos.x, pos.y, csize.x, csize.y);
for ( int i = 0 ; i < n ; i++ )
{
m_choice->DoAppend( choices[ i ] );
}
SetBestSize(size); // Needed because it is a wxControlWithItems
for ( int i = 0 ; i < n ; i++ )
{
m_choice->DoAppend( choices[ i ] );
}
SetBestSize(size); // Needed because it is a wxControlWithItems
- int s = FindString (sel);
- if (s > -1)
- {
- SetSelection (s);
- return TRUE;
- }
+ 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();
-wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
+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) )
{
/* For consistency with other platforms, clicking in the text area does not constitute a selection
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
{
/* For consistency with other platforms, clicking in the text area does not constitute a selection
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );