#include "wx/log.h"
#include "wx/dcclient.h"
#include "wx/settings.h"
- #include "wx/dialog.h"
#include "wx/timer.h"
#include "wx/textctrl.h"
#endif
#if defined(__WXMSW__)
+// Let's use wxFrame as a fall-back solution until wxMSW gets wxNonOwnedWindow
+#include "wx/frame.h"
+#define wxCC_GENERIC_TLW_IS_FRAME
+#define wxComboCtrlGenericTLW wxFrame
+
#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
// native controls work on it like normal.
#elif defined(__WXGTK__)
-#include "wx/gtk/private.h"
-
// NB: It is not recommended to use wxDialog as popup on wxGTK, because of
// this bug: If wxDialog is hidden, its position becomes corrupt
// between hide and next show, but without internal coordinates being
// reflected (or something like that - atleast commenting out ->Hide()
// seemed to eliminate the position change).
+#include "wx/dialog.h"
+#define wxCC_GENERIC_TLW_IS_DIALOG
+#define wxComboCtrlGenericTLW wxDialog
+
+#include "wx/gtk/private.h"
+
// 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.
#elif defined(__WXMAC__)
+#include "wx/nonownedwnd.h"
+#define wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW
+#define wxComboCtrlGenericTLW wxNonOwnedWindow
+
#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.
#else
+#include "wx/dialog.h"
+#define wxCC_GENERIC_TLW_IS_DIALOG
+#define wxComboCtrlGenericTLW wxDialog
+
#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
// native controls work on it like normal.
POPUPWIN_NONE = 0,
POPUPWIN_WXPOPUPTRANSIENTWINDOW = 1,
POPUPWIN_WXPOPUPWINDOW = 2,
- POPUPWIN_WXDIALOG = 3
+ POPUPWIN_GENERICTLW = 3
};
#define SECONDARY_POPUP_TYPE POPUPWIN_WXPOPUPWINDOW
#define USES_WXPOPUPWINDOW 1
#else
- #define wxComboPopupWindowBase2 wxDialog
- #define SECONDARY_POPUP_TYPE POPUPWIN_WXDIALOG
- #define USES_WXDIALOG 1
+ #define wxComboPopupWindowBase2 wxComboCtrlGenericTLW
+ #define SECONDARY_POPUP_TYPE POPUPWIN_GENERICTLW
+ #define USES_GENERICTLW 1
#endif
#elif wxUSE_POPUPWIN
#define USES_WXPOPUPWINDOW 1
#if !POPUPWIN_IS_PERFECT
- #define wxComboPopupWindowBase2 wxDialog
- #define SECONDARY_POPUP_TYPE POPUPWIN_WXDIALOG
- #define USES_WXDIALOG 1
+ #define wxComboPopupWindowBase2 wxComboCtrlGenericTLW
+ #define SECONDARY_POPUP_TYPE POPUPWIN_GENERICTLW
+ #define USES_GENERICTLW 1
#endif
#else
// wxPopupWindow is not implemented
- #define wxComboPopupWindowBase wxDialog
- #define PRIMARY_POPUP_TYPE POPUPWIN_WXDIALOG
- #define USES_WXDIALOG 1
+ #define wxComboPopupWindowBase wxComboCtrlGenericTLW
+ #define PRIMARY_POPUP_TYPE POPUPWIN_GENERICTLW
+ #define USES_GENERICTLW 1
#endif
#define USES_WXPOPUPWINDOW 0
#endif
-#ifndef USES_WXDIALOG
- #define USES_WXDIALOG 0
+#ifndef USES_GENERICTLW
+ #define USES_GENERICTLW 0
#endif
winFocused != m_combo->GetButton() // GTK (atleast) requires this
)
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
}
event.Skip();
void wxComboFrameEventHandler::OnMenuEvent( wxMenuEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnMouseEvent( wxMouseEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnClose( wxCloseEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnActivate( wxActivateEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnResize( wxSizeEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnMove( wxMoveEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxComboCtrlBase)),
wxT("parent might not be wxComboCtrl, but check IMPLEMENT_DYNAMIC_CLASS(2) macro for correctness") );
- combo->OnPopupDismiss();
+ combo->OnPopupDismiss(true);
}
#endif // USES_WXPOPUPTRANSIENTWINDOW
void OnSizeEvent( wxSizeEvent& event );
void OnKeyEvent(wxKeyEvent& event);
-#if USES_WXDIALOG
+#if USES_GENERICTLW
void OnActivate( wxActivateEvent& event );
#endif
BEGIN_EVENT_TABLE(wxComboPopupWindowEvtHandler, wxEvtHandler)
EVT_KEY_DOWN(wxComboPopupWindowEvtHandler::OnKeyEvent)
EVT_KEY_UP(wxComboPopupWindowEvtHandler::OnKeyEvent)
-#if USES_WXDIALOG
+#if USES_GENERICTLW
EVT_ACTIVATE(wxComboPopupWindowEvtHandler::OnActivate)
#endif
EVT_SIZE(wxComboPopupWindowEvtHandler::OnSizeEvent)
child->GetEventHandler()->AddPendingEvent(event);
}
-#if USES_WXDIALOG
+#if USES_GENERICTLW
void wxComboPopupWindowEvtHandler::OnActivate( wxActivateEvent& event )
{
if ( !event.GetActive() )
{
// Tell combo control that we are dismissed.
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboPopup::Dismiss()
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
}
// ----------------------------------------------------------------------------
wxLongLong t = ::wxGetLocalTimeMillis();
int evtType = event.GetEventType();
-#if USES_WXPOPUPWINDOW || USES_WXDIALOG
+#if USES_WXPOPUPWINDOW || USES_GENERICTLW
if ( m_popupWinType != POPUPWIN_WXPOPUPTRANSIENTWINDOW )
{
if ( IsPopupWindowState(Visible) &&
( evtType == wxEVT_LEFT_DOWN || evtType == wxEVT_RIGHT_DOWN ) )
{
- HidePopup();
+ HidePopup(true);
return true;
}
}
#if USES_WXPOPUPWINDOW
// Click here always hides the popup.
if ( m_popupWinType == POPUPWIN_WXPOPUPWINDOW )
- HidePopup();
+ HidePopup(true);
#endif
}
else
#ifdef wxComboPopupWindowBase2
if ( m_iFlags & wxCC_IFLAG_USE_ALT_POPUP )
{
- #if !USES_WXDIALOG
+ #if !USES_GENERICTLW
m_winPopup = new wxComboPopupWindowBase2( this, wxNO_BORDER );
#else
+ int tlwFlags = wxNO_BORDER;
+ #ifdef wxCC_GENERIC_TLW_IS_FRAME
+ tlwFlags |= wxFRAME_NO_TASKBAR;
+ #endif
+
+ #ifdef wxCC_GENERIC_TLW_IS_NONOWNEDWINDOW
+ m_winPopup = new wxComboPopupWindowBase2( this, wxID_ANY,
+ wxPoint(-21,-21), wxSize(20, 20),
+ tlwFlags );
+ #else
m_winPopup = new wxComboPopupWindowBase2( this, wxID_ANY, wxEmptyString,
wxPoint(-21,-21), wxSize(20, 20),
- wxNO_BORDER );
+ tlwFlags );
+ #endif
#endif
m_popupWinType = SECONDARY_POPUP_TYPE;
}
// Destroy popup window and the child control
void wxComboCtrlBase::DestroyPopup()
{
- HidePopup();
+ HidePopup(true);
if ( m_popup )
m_popup->RemoveEventHandler(m_popupExtraHandler);
// Derived classes can override this method for totally custom
// popup action
if ( !IsPopupWindowState(Visible) )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId());
+ event.SetEventObject(this);
+ HandleWindowEvent(event);
+
ShowPopup();
+ }
else
- HidePopup();
+ {
+ HidePopup(true);
+ }
}
void wxComboCtrlBase::ShowPopup()
Refresh();
}
-void wxComboCtrlBase::OnPopupDismiss()
+void wxComboCtrlBase::OnPopupDismiss(bool generateEvent)
{
// Just in case, avoid double dismiss
if ( IsPopupWindowState(Hidden) )
Refresh();
SetFocus();
+
+ if ( generateEvent )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_CLOSEUP, GetId());
+ event.SetEventObject(this);
+ HandleWindowEvent(event);
+ }
}
-void wxComboCtrlBase::HidePopup()
+void wxComboCtrlBase::HidePopup(bool generateEvent)
{
// Should be able to call this without popup interface
if ( IsPopupWindowState(Hidden) )
m_winPopup->Hide();
- OnPopupDismiss();
+ OnPopupDismiss(generateEvent);
}
// ----------------------------------------------------------------------------
return wxPoint(m_marginLeft, -1);
}
-#if WXWIN_COMPATIBILITY_2_6
+#if WXWIN_COMPATIBILITY_2_8
void wxComboCtrlBase::SetTextIndent( int indent )
{
if ( indent < 0 )