X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/848332140be2d53aea32d0702f4c0e06c149d24b..8ca1a013e4e699724040ff1f514dab3b4a11d3c9:/src/gtk/popupwin.cpp diff --git a/src/gtk/popupwin.cpp b/src/gtk/popupwin.cpp index f721ea4405..6e1048917c 100644 --- a/src/gtk/popupwin.cpp +++ b/src/gtk/popupwin.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: popupwin.cpp +// Name: src/gtk/popupwin.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -13,15 +13,15 @@ #if wxUSE_POPUPWIN #include "wx/popupwin.h" -#include "wx/frame.h" -#include "wx/app.h" -#include "wx/cursor.h" -#include +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/frame.h" + #include "wx/cursor.h" +#endif // WX_PRECOMP + #include -#include -#include "wx/gtk/private.h" //for idle stuff #include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- @@ -62,22 +62,6 @@ static gint gtk_popup_button_press (GtkWidget *widget, GdkEvent *gdk_event, wxPo } } -//----------------------------------------------------------------------------- -// "focus" from m_window -//----------------------------------------------------------------------------- - -extern "C" { -static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - /* This disables GTK's tab traversal */ - g_signal_stop_emission_by_name (widget, "focus"); - return TRUE; -} -} - //----------------------------------------------------------------------------- // "delete_event" //----------------------------------------------------------------------------- @@ -85,9 +69,6 @@ static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNU extern "C" { bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxPopupWindow *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (win->IsEnabled()) win->Close(); @@ -106,9 +87,6 @@ extern "C" { static gint gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxPopupWindow *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - /* all this is for Motif Window Manager "hints" and is supposed to be recognized by other WM as well. not tested. */ long decor = (long) GDK_DECOR_BORDER; @@ -132,10 +110,10 @@ gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxPopupWindow *win ) * virtual function here as wxWidgets requires different ways to insert * a child in container classes. */ -static void wxInsertChildInDialog( wxPopupWindow* parent, wxWindow* child ) +static void wxInsertChildInPopupWin(wxWindowGTK* parent, wxWindowGTK* child) { gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), - GTK_WIDGET(child->m_widget), + child->m_widget, child->m_x, child->m_y, child->m_width, @@ -165,13 +143,13 @@ wxPopupWindow::~wxPopupWindow() bool wxPopupWindow::Create( wxWindow *parent, int style ) { - m_needParent = FALSE; + m_sizeSet = false; if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("popup") )) { wxFAIL_MSG( wxT("wxPopupWindow creation failed") ); - return FALSE; + return false; } // Unlike windows, top level windows are created hidden by default. @@ -180,7 +158,7 @@ bool wxPopupWindow::Create( wxWindow *parent, int style ) // All dialogs should really have this style m_windowStyle |= wxTAB_TRAVERSAL; - m_insertCallback = (wxInsertChildFunction) wxInsertChildInDialog; + m_insertCallback = wxInsertChildInPopupWin; m_widget = gtk_window_new( GTK_WINDOW_POPUP ); @@ -207,16 +185,12 @@ bool wxPopupWindow::Create( wxWindow *parent, int style ) g_signal_connect (m_widget, "realize", G_CALLBACK (gtk_dialog_realized_callback), this); - // disable native tab traversal - g_signal_connect (m_widget, "focus", - G_CALLBACK (gtk_dialog_focus_callback), this); - m_time = gtk_get_current_event_time(); g_signal_connect (m_widget, "button_press_event", G_CALLBACK (gtk_popup_button_press), this); - return TRUE; + return true; } void wxPopupWindow::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) ) @@ -230,7 +204,7 @@ void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlag wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid dialog") ); if (m_resizing) return; /* I don't like recursions */ - m_resizing = TRUE; + m_resizing = true; int old_x = m_x; int old_y = m_y; @@ -265,15 +239,7 @@ void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlag } */ - int minWidth = GetMinWidth(), - minHeight = GetMinHeight(), - maxWidth = GetMaxWidth(), - maxHeight = GetMaxHeight(); - - if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; - if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; - if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; - if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; + ConstrainSize(); if ((m_x != -1) || (m_y != -1)) { @@ -292,25 +258,18 @@ void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlag /* actual resizing is deferred to GtkOnSize in idle time and when showing the dialog */ - m_sizeSet = FALSE; + m_sizeSet = false; } - m_resizing = FALSE; + m_resizing = false; } -void wxPopupWindow::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) +void wxPopupWindow::GtkOnSize() { - // due to a bug in gtk, x,y are always 0 - // m_x = x; - // m_y = y; - - if ((m_height == height) && (m_width == width) && (m_sizeSet)) return; + if (m_sizeSet) return; if (!m_wxwindow) return; - m_width = width; - m_height = height; - /* FIXME: is this a hack? */ /* Since for some reason GTK will revert to using maximum size ever set for this window, we have to set geometry hints maxsize to match size @@ -330,7 +289,7 @@ void wxPopupWindow::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int (GdkWindowHints) flag ); - m_sizeSet = TRUE; + m_sizeSet = true; wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); @@ -340,7 +299,7 @@ void wxPopupWindow::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int void wxPopupWindow::OnInternalIdle() { if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow)) - GtkOnSize( m_x, m_y, m_width, m_height ); + GtkOnSize(); wxWindow::OnInternalIdle(); } @@ -354,7 +313,7 @@ bool wxPopupWindow::Show( bool show ) much ugly flicker nor from within the size_allocate handler, because GTK 1.1.X forbids that. */ - GtkOnSize( m_x, m_y, m_width, m_height ); + GtkOnSize(); } bool ret = wxWindow::Show( show );