]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/dialog.cpp
Small correction to list ctrl and default button size.
[wxWidgets.git] / src / gtk / dialog.cpp
index 271c41ea99fba3815873f05924b92b35ca8e2c8f..987c3b9c343ece46f657a7bde8b8aad423df2349 100644 (file)
@@ -38,14 +38,8 @@ extern wxList wxPendingDelete;
 
 bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
 {
-    if (g_isIdle) wxapp_install_idle_handler();
-
-/*
-    printf( "OnDelete from " );
-    if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
-        printf( win->GetClassInfo()->GetClassName() );
-    printf( ".\n" );
-*/
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
 
     win->Close();
 
@@ -58,21 +52,17 @@ bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED
 
 static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxDialog *win )
 {
-    if (g_isIdle) wxapp_install_idle_handler();
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
 
-    if (!win->HasVMT()) return;
-
-/*
-    printf( "OnDialogResize from " );
-    if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
-        printf( win->GetClassInfo()->GetClassName() );
-    printf( ".\n" );
-*/
+    if (!win->m_hasVMT) return;
 
-   if ((win->GetWidth() != alloc->width) || (win->GetHeight() != alloc->height))
-   {
-       win->InternalSetSize( alloc->width, alloc->height );
-   }
+    if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
+    {
+        win->m_width = alloc->width;
+        win->m_height = alloc->height;
+        win->UpdateSize();
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -81,13 +71,15 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation
 
 static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win )
 {
-    if (g_isIdle) wxapp_install_idle_handler();
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
 
-    if (!win->HasVMT()) return FALSE;
+    if (!win->m_hasVMT) return FALSE;
 
-    win->InternalSetPosition(event->x, event->y);
+    win->m_x = event->x;
+    win->m_y = event->y;
 
-    wxMoveEvent mevent( wxPoint(win->GetX(),win->GetY()), win->GetId() );
+    wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
     mevent.SetEventObject( win );
     win->GetEventHandler()->ProcessEvent( mevent );
 
@@ -104,7 +96,13 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent
 static gint 
 gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
 {
-    if (g_isIdle) wxapp_install_idle_handler();
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
+
+    /* I haven''t been able to set the position of
+       the dialog before it is shown, so I set the
+       position in "realize" and "map" */
+    gtk_widget_set_uposition( widget, win->m_x, win->m_y );
 
     /* reset the icon */
     if (win->m_icon != wxNullIcon)
@@ -124,9 +122,13 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
 static gint 
 gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win )
 {
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
+
     /* I haven''t been able to set the position of
-       the dialog before it is shown, so I do it here */
-    gtk_widget_set_uposition( widget, win->GetX(), win->GetY() );
+       the dialog before it is shown, so I set the
+       position in "realize" and "map" */
+    gtk_widget_set_uposition( widget, win->m_x, win->m_y );
     
     /* all this is for Motif Window Manager "hints" and is supposed to be
        recognized by other WM as well. not tested. */
@@ -155,14 +157,14 @@ gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win )
        func |= GDK_FUNC_RESIZE;
        decor |= GDK_DECOR_RESIZEH;
     }
-    gdk_window_set_decorations( win->GetHandle()->window, (GdkWMDecoration)decor);
-    gdk_window_set_functions( win->GetHandle()->window, (GdkWMFunction)func);
+    gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+    gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
       
     /* GTK's shrinking/growing policy */
     if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
-        gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 0, 0, 1);
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
     else
-        gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 1, 1, 1);
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
     
     return FALSE;
 }
@@ -253,6 +255,8 @@ bool wxDialog::Create( wxWindow *parent,
 
 wxDialog::~wxDialog()
 {
+    m_isBeingDeleted = TRUE;
+    
     wxTopLevelWindows.DeleteObject( this );
 
     if (wxTheApp->GetTopWindow() == this)
@@ -292,13 +296,13 @@ void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )
     else
     {
         SetReturnCode(wxID_CANCEL);
-        this->Show(FALSE);
+        Show(FALSE);
     }
 }
 
 void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) )
 {
-    if ( Validate() && TransferDataFromWindow())
+    if (Validate() && TransferDataFromWindow())
     {
         if (IsModal())
         {
@@ -512,21 +516,11 @@ bool wxDialog::Show( bool show )
         GtkOnSize( m_x, m_y, m_width, m_height );
     }
 
-    if (show != m_isShown)
-    {
-        if (show)
-        {
-            gtk_widget_show( m_widget );
-        }
-        else
-            gtk_widget_hide( m_widget );
-            
-        m_isShown = show;
-    }
+    bool ret = wxWindow::Show( show );
 
     if (show) InitDialog();
 
-    return TRUE;
+    return ret;
 }
 
 bool wxDialog::IsModal() const
@@ -591,6 +585,8 @@ void wxDialog::SetIcon( const wxIcon &icon )
     m_icon = icon;
     if (!icon.Ok()) return;
 
+    if (!m_widget->window) return;
+
     wxMask *mask = icon.GetMask();
     GdkBitmap *bm = (GdkBitmap *) NULL;
     if (mask) bm = mask->GetBitmap();