// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
- // 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());
- // This will invoke the dialog default action, such
- // as the clicking the default button.
-
+ // This will invoke the dialog default action,
+ // such as the clicking the default button.
- 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();
+ }
+
+ void OnText( wxCommandEvent& 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)
- wxComboBoxChoice(wxComboBox *cb, int style)
- : wxChoice( cb , 1 )
+ wxComboBoxChoice( wxComboBox *cb, int style )
+ : wxChoice( cb , 1 , wxDefaultPosition , wxDefaultSize , 0 , NULL , style & (wxCB_SORT) )
virtual wxSize DoGetBestSize() const
{
wxSize sz = wxChoice::DoGetBestSize() ;
if (! m_cb->HasFlag(wxCB_READONLY) )
sz.x = GetPopupWidth() ;
virtual wxSize DoGetBestSize() const
{
wxSize sz = wxChoice::DoGetBestSize() ;
if (! m_cb->HasFlag(wxCB_READONLY) )
sz.x = GetPopupWidth() ;
// delete the controls now, don't leave them alive even though they would
// still be eventually deleted by our parent - but it will be too late, the
// user code expects them to be gone now
// delete the controls now, don't leave them alive even though they would
// still be eventually deleted by our parent - but it will be too late, the
// user code expects them to be gone now
// ----------------------------------------------------------------------------
// geometry
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// geometry
// ----------------------------------------------------------------------------
size.x = m_choice->GetPopupWidth() + sizeText.x + MARGIN;
size.x += TEXTFOCUSBORDER ;
size.y += 2 * TEXTFOCUSBORDER ;
size.x = m_choice->GetPopupWidth() + sizeText.x + MARGIN;
size.x += TEXTFOCUSBORDER ;
size.y += 2 * TEXTFOCUSBORDER ;
return size;
}
void wxComboBox::DoMoveWindow(int x, int y, int width, int height)
{
return size;
}
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 );
+ 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);
}
}
// 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);
}
}
// ----------------------------------------------------------------------------
// operations forwarded to the subcontrols
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// operations forwarded to the subcontrols
// ----------------------------------------------------------------------------
-
-bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style,
- const wxValidator& validator,
- const wxString& name)
+bool wxComboBox::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size,
+ const wxArrayString& choices,
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
chs.GetStrings(), style, validator, name );
}
chs.GetStrings(), style, validator, name );
}
-
-bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- int n, const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString& name)
+bool wxComboBox::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size,
+ int n,
+ const wxString choices[],
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
{
if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style ,
{
if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style ,
void wxComboBox::SetString(int n, const wxString& s)
{
m_choice->SetString( n , s ) ;
void wxComboBox::SetString(int n, const wxString& s)
{
m_choice->SetString( n , s ) ;
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
event.SetInt(GetSelection());
event.SetEventObject(this);
event.SetString(GetStringSelection());
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
event.SetInt(GetSelection());
event.SetEventObject(this);
event.SetString(GetStringSelection());