// ----------------------------------------------------------------------------
#ifdef __GNUG__
- #pragma implementation "popupwin.h"
+ #pragma implementation "popupwinbase.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#pragma hdrstop
#endif
-#if wxUSE_POPUPWIN
+#if wxUSE_POPUPWIN && !defined(__WXMOTIF__)
#include "wx/popupwin.h"
#include "wx/univ/renderer.h"
#endif // __WXUNIVERSAL__
+// there is no src/{msw,mgl}/popupwin.cpp to put this in, so we do it here - BTW we
+// probably could do it for all ports here just as well
+#if defined(__WXMSW__) || defined(__WXMGL__)
+ IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow)
+#endif // __WXMSW__
+
+IMPLEMENT_DYNAMIC_CLASS(wxPopupTransientWindow, wxPopupWindow)
+
+#if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)
+ IMPLEMENT_DYNAMIC_CLASS(wxPopupComboWindow, wxPopupTransientWindow)
+#endif
+
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
protected:
// event handlers
void OnKillFocus(wxFocusEvent& event);
+ void OnKeyUp(wxKeyEvent& event);
private:
wxPopupTransientWindow *m_popup;
BEGIN_EVENT_TABLE(wxPopupFocusHandler, wxEvtHandler)
EVT_KILL_FOCUS(wxPopupFocusHandler::OnKillFocus)
+ EVT_KEY_UP(wxPopupFocusHandler::OnKeyUp)
END_EVENT_TABLE()
// ============================================================================
// wxPopupWindowBase
// ----------------------------------------------------------------------------
+wxPopupWindowBase::~wxPopupWindowBase()
+{
+ // this destructor is required for Darwin
+}
+
bool wxPopupWindowBase::Create(wxWindow* WXUNUSED(parent), int WXUNUSED(flags))
{
return TRUE;
m_focus = (wxWindow *)NULL;
}
-wxPopupTransientWindow::wxPopupTransientWindow(wxWindow *parent)
+wxPopupTransientWindow::wxPopupTransientWindow(wxWindow *parent, int style)
{
Init();
- (void)Create(parent);
+ (void)Create(parent, style);
}
wxPopupTransientWindow::~wxPopupTransientWindow()
m_child = this;
}
+ // we can't capture mouse before the window is shown in wxGTK
+#ifdef __WXGTK__
+ Show();
+#endif
+
m_child->CaptureMouse();
m_child->PushEventHandler(new wxPopupWindowHandler(this));
+#ifndef __WXGTK__
Show();
+#endif
m_focus = winFocus ? winFocus : this;
- m_focus->PushEventHandler(new wxPopupFocusHandler(this));
m_focus->SetFocus();
+
+ // FIXME: I don't know why does this happen but sometimes SetFocus() simply
+ // refuses to work under MSW - no error happens but the focus is not
+ // given to the window, i.e. the assert below is triggered
+ //
+ // Try work around this as we can...
+#if 0
+ wxASSERT_MSG( FindFocus() == m_focus, _T("setting focus failed") );
+#else
+ m_focus = FindFocus();
+#endif
+
+ if ( m_focus )
+ {
+ m_focus->PushEventHandler(new wxPopupFocusHandler(this));
+ }
}
void wxPopupTransientWindow::Dismiss()
return FALSE;
}
-#if wxUSE_COMBOBOX
+#if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)
// ----------------------------------------------------------------------------
// wxPopupComboWindow
// the origin point must be in screen coords
wxPoint ptOrigin = m_combo->ClientToScreen(wxPoint(0, 0));
-#ifdef __WXUNIVERSAL__
+#if 0 //def __WXUNIVERSAL__
// account for the fact that (0, 0) is not the top left corner of the
// window: there is also the border
wxRect rectBorders = m_combo->GetRenderer()->
m_combo->OnDismiss();
}
-#endif // wxUSE_COMBOBOX
+#endif // wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)
// ----------------------------------------------------------------------------
// wxPopupWindowHandler
m_popup->DismissAndNotify();
break;
+#ifdef __WXUNIVERSAL__
case wxHT_WINDOW_HORZ_SCROLLBAR:
sbar = win->GetScrollbar(wxHORIZONTAL);
break;
case wxHT_WINDOW_VERT_SCROLLBAR:
sbar = win->GetScrollbar(wxVERTICAL);
break;
+#endif
default:
// forgot to update the switch after adding a new hit test code?
void wxPopupFocusHandler::OnKillFocus(wxFocusEvent& event)
{
- // when we lose focus we always disappear
+ // when we lose focus we always disappear - unless it goes to the popup (in
+ // which case we don't really lose it)
+ if ( event.GetWindow() != m_popup )
+ m_popup->DismissAndNotify();
+}
- // But if m_popup was about to get the focus,
- // don't disappear.
- if (event.GetWindow() != m_popup)
+void wxPopupFocusHandler::OnKeyUp(wxKeyEvent& event)
+{
+ // let the window have it first, it might process the keys
+ if ( !m_popup->ProcessEvent(event) )
+ {
+ // by default, dismiss the popup
m_popup->DismissAndNotify();
+ }
}
#endif // wxUSE_POPUPWIN
+