// reflected (or something like that - atleast commenting out ->Hide()
// seemed to eliminate the position change).
+// NB: Let's not be afraid to use wxGTK's wxPopupTransientWindow as a
+// 'perfect' popup, as it can succesfully host child controls even in
+// popups that are shown in modal dialogs.
+
#define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
-#define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common
+#define TRANSIENT_POPUPWIN_IS_PERFECT 1 // wxPopupTransientWindow works, its child can have focus, and common
// native controls work on it like normal.
#define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
#elif defined(__WXMAC__)
-#define USE_TRANSIENT_POPUP 0 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
-#define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common
+#define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
+#define TRANSIENT_POPUPWIN_IS_PERFECT 1 // wxPopupTransientWindow works, its child can have focus, and common
// native controls work on it like normal.
-#define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
+#define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
#define FOCUS_RING 3 // Reserve room for the textctrl's focus ring to display
// Popupwin is really only supported on wxMSW (not WINCE) and wxGTK, regardless
// what the wxUSE_POPUPWIN says.
// FIXME: Why isn't wxUSE_POPUPWIN reliable any longer? (it was in wxW2.6.2)
-#if (!defined(__WXMSW__) && !defined(__WXGTK__)) || defined(__WXWINCE__)
+#if (!defined(__WXMSW__) && !defined(__WXGTK__) && !defined(__WXMAC__)) || defined(__WXWINCE__)
#undef wxUSE_POPUPWIN
#define wxUSE_POPUPWIN 0
#endif
wxWindowList children = m_combo->GetPopupWindow()->GetChildren();
wxWindowList::iterator node = children.begin();
wxWindow* child = (wxWindow*)*node;
- child->AddPendingEvent(event);
+ child->GetEventHandler()->AddPendingEvent(event);
}
#if USES_WXDIALOG
{
}
+wxComboCtrl* wxComboPopup::GetComboCtrl() const
+{
+ return wxStaticCast(m_combo, wxComboCtrl);
+}
+
wxSize wxComboPopup::GetAdjustedSize( int minWidth,
int prefHeight,
int WXUNUSED(maxHeight) )
BEGIN_EVENT_TABLE(wxComboBoxExtraInputHandler, wxEvtHandler)
EVT_KEY_DOWN(wxComboBoxExtraInputHandler::OnKey)
+ EVT_KEY_UP(wxComboBoxExtraInputHandler::OnKey)
+ EVT_CHAR(wxComboBoxExtraInputHandler::OnKey)
EVT_SET_FOCUS(wxComboBoxExtraInputHandler::OnFocus)
EVT_KILL_FOCUS(wxComboBoxExtraInputHandler::OnFocus)
END_EVENT_TABLE()
{
// Let the wxComboCtrl event handler have a go first.
wxComboCtrlBase* combo = m_combo;
- wxObject* prevObj = event.GetEventObject();
- event.SetId(combo->GetId());
- event.SetEventObject(combo);
- combo->GetEventHandler()->ProcessEvent(event);
+ wxKeyEvent redirectedEvent(event);
+ redirectedEvent.SetId(combo->GetId());
+ redirectedEvent.SetEventObject(combo);
- event.SetId(((wxWindow*)prevObj)->GetId());
- event.SetEventObject(prevObj);
+ if ( !combo->GetEventHandler()->ProcessEvent(redirectedEvent) )
+ {
+ // Don't let TAB through to the text ctrl - looks ugly
+ if ( event.GetKeyCode() != WXK_TAB )
+ event.Skip();
+ }
}
void wxComboBoxExtraInputHandler::OnFocus(wxFocusEvent& event)
void wxComboCtrlBase::Init()
{
- m_winPopup = (wxWindow *)NULL;
- m_popup = (wxWindow *)NULL;
+ m_winPopup = NULL;
+ m_popup = NULL;
m_popupWinState = Hidden;
- m_btn = (wxWindow*) NULL;
- m_text = (wxTextCtrl*) NULL;
- m_popupInterface = (wxComboPopup*) NULL;
+ m_btn = NULL;
+ m_text = NULL;
+ m_popupInterface = NULL;
- m_popupExtraHandler = (wxEvtHandler*) NULL;
- m_textEvtHandler = (wxEvtHandler*) NULL;
+ m_popupExtraHandler = NULL;
+ m_textEvtHandler = NULL;
#if INSTALL_TOPLEV_HANDLER
- m_toplevEvtHandler = (wxEvtHandler*) NULL;
+ m_toplevEvtHandler = NULL;
#endif
m_mainCtrlWnd = this;
#if INSTALL_TOPLEV_HANDLER
delete ((wxComboFrameEventHandler*)m_toplevEvtHandler);
- m_toplevEvtHandler = (wxEvtHandler*) NULL;
+ m_toplevEvtHandler = NULL;
#endif
DestroyPopup();
if ( m_text )
m_text->Enable(enable);
+ Refresh();
+
return true;
}
}
else
{
- if ( m_text ) m_text->SetToolTip( (wxToolTip*) NULL );
- if ( m_btn ) m_btn->SetToolTip( (wxToolTip*) NULL );
+ if ( m_text ) m_text->SetToolTip( NULL );
+ if ( m_btn ) m_btn->SetToolTip( NULL );
}
}
#endif // wxUSE_TOOLTIPS
if ( textCtrl )
textCtrl->SetValidator( validator );
+ else
+ wxControl::SetValidator( validator );
}
wxValidator* wxComboCtrlBase::GetValidator()
{
wxTextCtrl* textCtrl = GetTextCtrl();
- if ( textCtrl )
- return textCtrl->GetValidator();
-
- return wxControl::GetValidator();
+ return textCtrl ? textCtrl->GetValidator() : wxControl::GetValidator();
}
#endif // wxUSE_VALIDATORS
{
// relay (some) mouse events to the popup
if ( evtType == wxEVT_MOUSEWHEEL )
- m_popup->AddPendingEvent(event);
+ m_popup->GetEventHandler()->AddPendingEvent(event);
}
else if ( evtType )
event.Skip();
if ( IsPopupShown() )
{
// pass it to the popped up control
- GetPopupControl()->GetControl()->AddPendingEvent(event);
+ GetPopupControl()->GetControl()->GetEventHandler()->AddPendingEvent(event);
}
else // no popup
{
- int keycode = event.GetKeyCode();
-
- if ( keycode == WXK_TAB )
- {
- wxNavigationKeyEvent evt;
-
- wxWindow* mainCtrl = GetMainWindowOfCompositeControl();
-
- evt.SetFlags(wxNavigationKeyEvent::FromTab|
- (!event.ShiftDown() ? wxNavigationKeyEvent::IsForward
- : wxNavigationKeyEvent::IsBackward));
- evt.SetEventObject(mainCtrl);
- evt.SetCurrentFocus(mainCtrl);
- mainCtrl->GetParent()->GetEventHandler()->AddPendingEvent(evt);
+ if ( GetParent()->HasFlag(wxTAB_TRAVERSAL) &&
+ HandleAsNavigationKey(event) )
return;
- }
if ( IsKeyPopupToggle(event) )
{
return;
}
+ int keycode = event.GetKeyCode();
+
if ( (comboStyle & wxCB_READONLY) ||
(keycode != WXK_RIGHT && keycode != WXK_LEFT) )
{
m_winPopup->Destroy();
}
- m_popupExtraHandler = (wxEvtHandler*) NULL;
- m_popupInterface = (wxComboPopup*) NULL;
- m_winPopup = (wxWindow*) NULL;
- m_popup = (wxWindow*) NULL;
+ m_popupExtraHandler = NULL;
+ m_popupInterface = NULL;
+ m_winPopup = NULL;
+ m_popup = NULL;
}
void wxComboCtrlBase::DoSetPopupControl(wxComboPopup* iface)
}
else
{
- m_popup = (wxWindow*) NULL;
+ m_popup = NULL;
}
// This must be done after creation
{
// Derived classes can override this method for totally custom
// popup action
- ShowPopup();
+ if ( !IsPopupWindowState(Visible) )
+ ShowPopup();
+ else
+ HidePopup();
}
void wxComboCtrlBase::ShowPopup()