X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e52f60e65236befe1a509cc3c1823607be0d2b3c..03ab016d6692ccceafb0f324a063bbf8f334f020:/src/gtk/dialog.cpp diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index bde6b7e6b4..e1da79d411 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -14,6 +14,9 @@ #include "wx/dialog.h" #include "wx/frame.h" #include "wx/app.h" + +#include "gdk/gdk.h" +#include "gtk/gtk.h" #include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- @@ -56,6 +59,24 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height ); } +//----------------------------------------------------------------------------- +// "configure_event" +//----------------------------------------------------------------------------- + +static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win ) +{ + if (!win->HasVMT()) return FALSE; + + win->m_x = event->x; + win->m_y = event->y; + + wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() ); + mevent.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( mevent ); + + return FALSE; +} + //----------------------------------------------------------------------------- // wxDialog //----------------------------------------------------------------------------- @@ -74,7 +95,6 @@ wxDialog::wxDialog() { m_title = ""; m_modalShowing = FALSE; - wxTopLevelWindows.Insert( this ); } wxDialog::wxDialog( wxWindow *parent, @@ -83,7 +103,6 @@ wxDialog::wxDialog( wxWindow *parent, long style, const wxString &name ) { m_modalShowing = FALSE; - wxTopLevelWindows.Insert( this ); Create( parent, id, title, pos, size, style, name ); } @@ -92,6 +111,8 @@ bool wxDialog::Create( wxWindow *parent, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + wxTopLevelWindows.Append( this ); + m_needParent = FALSE; PreCreation( parent, id, pos, size, style, name ); @@ -104,9 +125,6 @@ bool wxDialog::Create( wxWindow *parent, gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); - m_wxwindow = gtk_myfixed_new(); gtk_widget_show( m_wxwindow ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); @@ -120,9 +138,14 @@ bool wxDialog::Create( wxWindow *parent, gtk_widget_set_usize( m_widget, m_width, m_height ); + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); + + gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", + GTK_SIGNAL_FUNC(gtk_dialog_configure_callback), (gpointer)this ); + if (m_parent) m_parent->AddChild( this ); - PostCreation(); return TRUE; @@ -131,7 +154,16 @@ bool wxDialog::Create( wxWindow *parent, wxDialog::~wxDialog() { wxTopLevelWindows.DeleteObject( this ); - if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); + + if (wxTheApp->GetTopWindow() == this) + { + wxTheApp->SetTopWindow( (wxWindow*) NULL ); + } + + if (wxTopLevelWindows.Number() == 0) + { + wxTheApp->ExitMainLoop(); + } } void wxDialog::SetTitle( const wxString& title ) @@ -231,8 +263,8 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; - if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; - if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; + if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; + if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; gtk_widget_set_usize( m_widget, m_width, m_height ); @@ -245,7 +277,7 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) { - wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); + wxASSERT_MSG( (m_widget != NULL), "invalid dialog" ); if (GetAutoLayout()) { @@ -254,14 +286,14 @@ void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) else { // no child: go out ! - if (!GetChildren()->First()) return; + if (!GetChildren().First()) return; // do we have exactly one child? wxWindow *child = (wxWindow *) NULL; - for(wxNode *node = GetChildren()->First(); node; node = node->Next()) + for(wxNode *node = GetChildren().First(); node; node = node->Next()) { wxWindow *win = (wxWindow *)node->Data(); - if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)) + if (!wxIS_KIND_OF(win,wxFrame) && !wxIS_KIND_OF(win,wxDialog)) { // it's the second one: do nothing if (child) return; @@ -318,8 +350,8 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; - if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; - if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; + if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; + if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; if ((m_x != -1) || (m_y != -1)) {