return wxSize(minWidth,prefHeight);
}
-void wxComboPopup::PaintComboControl( wxDC& dc, const wxRect& rect )
+void wxComboPopup::DefaultPaintComboControl( wxComboControlBase* combo,
+ wxDC& dc, const wxRect& rect )
{
- if ( m_combo->GetWindowStyle() & wxCB_READONLY ) // ie. no textctrl
+ if ( combo->GetWindowStyle() & wxCB_READONLY ) // ie. no textctrl
{
- m_combo->DrawFocusBackground(dc,rect,0);
+ combo->DrawFocusBackground(dc,rect,0);
- dc.DrawText( GetStringValue(),
- rect.x + m_combo->GetTextIndent(),
- (rect.height-dc.GetCharHeight())/2 + m_combo->m_widthCustomBorder );
+ dc.DrawText( combo->GetValue(),
+ rect.x + combo->GetTextIndent(),
+ (rect.height-dc.GetCharHeight())/2 + rect.y );
}
}
+void wxComboPopup::PaintComboControl( wxDC& dc, const wxRect& rect )
+{
+ DefaultPaintComboControl(m_combo,dc,rect);
+}
+
void wxComboPopup::OnComboKeyEvent( wxKeyEvent& event )
{
event.Skip();
if ( m_combo->IsPopupShown() )
{
// pass it to the popped up control
- m_combo->GetPopupControl()->AddPendingEvent(event);
+ m_combo->GetPopupControl()->GetControl()->AddPendingEvent(event);
}
else // no popup
{
int comboStyle = m_combo->GetWindowStyle();
- wxComboPopup* popupInterface = m_combo->GetPopup();
+ wxComboPopup* popupInterface = m_combo->GetPopupControl();
if ( !popupInterface )
{
m_combo->OnButtonClick();
return;
}
+ else
+ event.Skip();
}
else
popupInterface->OnComboKeyEvent(event);
}
}
-
void wxComboBoxExtraInputHandler::OnFocus(wxFocusEvent& event)
{
// FIXME: This code does run when control is clicked,
m_combo->SetSelection(-1,-1);
}
+ if ( event.GetId() != m_combo->GetId() )
+ {
+ // Add textctrl set focus events as combo set focus events
+ // NOTE: Simply changing the event and skipping didn't seem
+ // to do the trick.
+ wxFocusEvent evt2(wxEVT_SET_FOCUS,m_combo->GetId());
+ evt2.SetEventObject(m_combo);
+ m_combo->GetEventHandler()->ProcessEvent(evt2);
+ }
+ else
+ event.Skip();
+
event.Skip();
}
void OnMouseEvent( wxMouseEvent& event );
- // Called from wxPGComboControlBase::OnPopupDismiss
+ // Called from wxComboControlBase::OnPopupDismiss
void OnPopupDismiss()
{
m_beenInside = false;
protected:
wxComboControlBase* m_combo;
- bool m_beenInside;
+ bool m_beenInside;
private:
DECLARE_EVENT_TABLE()
void wxComboPopupExtraEventHandler::OnMouseEvent( wxMouseEvent& event )
{
wxPoint pt = event.GetPosition();
- wxSize sz = m_combo->GetPopupControl()->GetClientSize();
+ wxSize sz = m_combo->GetPopupControl()->GetControl()->GetClientSize();
int evtType = event.GetEventType();
bool isInside = pt.x >= 0 && pt.y >= 0 && pt.x < sz.x && pt.y < sz.y;
return *gs_doubleBuffer;
}
-
-bool wxComboControlBase::OnDrawListItem( wxDC& WXUNUSED(dc),
- const wxRect& WXUNUSED(rect),
- int WXUNUSED(item),
- int WXUNUSED(flags) )
-{
- return false; // signals caller to make default drawing
-}
-
-wxCoord wxComboControlBase::OnMeasureListItem( int WXUNUSED(item) )
-{
- return -1; // signals caller to use default
-}
-
-wxCoord wxComboControlBase::OnMeasureListItemWidth( int WXUNUSED(item) )
-{
- return -1; // signals caller to use default
-}
-
// ----------------------------------------------------------------------------
// miscellaneous event handlers
// ----------------------------------------------------------------------------
void wxComboControlBase::SetPopupControl( wxComboPopup* iface )
{
+ wxCHECK_RET( iface, wxT("no popup interface set for wxComboControl") );
+
delete m_popupInterface;
delete m_winPopup;
+ iface->InitBase(this);
+ iface->Init();
+
m_popupInterface = iface;
if ( !iface->LazyCreate() || m_winPopup )
m_popup = (wxWindow*) NULL;
}
- // This must be after creation
- if ( m_valueString )
+ // This must be done after creation
+ if ( m_valueString.length() )
+ {
iface->SetStringValue(m_valueString);
+ //Refresh();
+ }
+}
+// Ensures there is atleast the default popup
+void wxComboControlBase::EnsurePopupControl()
+{
+ if ( !m_popupInterface )
+ SetPopupControl(NULL);
}
void wxComboControlBase::OnButtonClick()
void wxComboControlBase::ShowPopup()
{
- wxCHECK_RET( m_popupInterface, wxT("no popup interface set for wxComboControl") );
+ EnsurePopupControl();
wxCHECK_RET( !IsPopupShown(), wxT("popup window already shown") );
SetFocus();
else
{
// This is neede since focus/selection indication may change when popup is shown
- // FIXME: But in that case, would m_isPopupShown need to go before this?
Refresh();
}
m_text->SelectAll();
}
+ m_valueString = value;
+
+ Refresh();
+
// Since wxComboPopup may want to paint the combo as well, we need
// to set the string value here (as well as sometimes in ShowPopup).
if ( m_valueString != value && m_popupInterface )
{
m_popupInterface->SetStringValue(value);
}
+}
+
+// In this SetValue variant wxComboPopup::SetStringValue is not called
+void wxComboControlBase::SetText(const wxString& value)
+{
+ // Unlike in SetValue(), this must be called here or
+ // the behaviour will no be consistent in readonlys.
+ EnsurePopupControl();
m_valueString = value;