]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/frame.cpp
1. corrected HAVE_PW_GECOS detection in configure (which never worked)
[wxWidgets.git] / src / gtk1 / frame.cpp
index 564c0d857518f21bace5d85b6b0e32a0601bd590..04d24079999c66e73fa11dd6e424f4aebc2e60b1 100644 (file)
@@ -126,7 +126,8 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
 
         win->m_width = alloc->width;
         win->m_height = alloc->height;
-        win->UpdateSize();
+        win->m_queuedFullRedraw = TRUE;
+        win->GtkUpdateSize();
     }
 }
 
@@ -139,7 +140,7 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX
     if (g_isIdle)
         wxapp_install_idle_handler();
 
-    if (g_openDialogs == 0)
+    if ((g_openDialogs == 0) && (win->IsEnabled()))
         win->Close();
 
     return TRUE;
@@ -154,7 +155,7 @@ static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *
     if (!win->m_hasVMT) return;
 
     win->m_menuBarDetached = FALSE;
-    win->UpdateSize();
+    win->GtkUpdateSize();
 }
 
 //-----------------------------------------------------------------------------
@@ -166,7 +167,7 @@ static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *
     if (!win->m_hasVMT) return;
 
     win->m_menuBarDetached = TRUE;
-    win->UpdateSize();
+    win->GtkUpdateSize();
 }
 
 #if wxUSE_TOOLBAR
@@ -180,7 +181,7 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
 
     win->m_toolBarDetached = FALSE;
 
-    win->UpdateSize();
+    win->GtkUpdateSize();
 }
 
 //-----------------------------------------------------------------------------
@@ -195,7 +196,7 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
     if (!win->m_hasVMT) return;
 
     win->m_toolBarDetached = TRUE;
-    win->UpdateSize();
+    win->GtkUpdateSize();
 }
 #endif // wxUSE_TOOLBAR
 
@@ -215,7 +216,7 @@ gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *ev
 
     if (!win->m_hasVMT)
         return FALSE;
-
+    
 #if (GTK_MINOR_VERSION > 0)
     int x = 0;
     int y = 0;
@@ -247,42 +248,46 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *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 set the
-       position in "realize" */
-    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. */
-    long decor = (long) GDK_DECOR_BORDER;
-    long func = (long) GDK_FUNC_MOVE;
-
-    if ((win->GetWindowStyle() & wxCAPTION) != 0)
-        decor |= GDK_DECOR_TITLE;
-    if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
-    {
-       decor |= GDK_DECOR_MENU;
-       func |= GDK_FUNC_CLOSE;
-    }
-    if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
-    {
-        func |= GDK_FUNC_MINIMIZE;
-        decor |= GDK_DECOR_MINIMIZE;
-    }
-    if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
+    if ((win->m_miniEdge > 0) || (win->HasFlag(wxSIMPLE_BORDER)))
     {
-        func |= GDK_FUNC_MAXIMIZE;
-        decor |= GDK_DECOR_MAXIMIZE;
+        /* This is a mini-frame or a borderless frame. */
+        gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)0 );
+        gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)0 );
     }
-    if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
+    else
     {
-       func |= GDK_FUNC_RESIZE;
-       decor |= GDK_DECOR_RESIZEH;
+        /* 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;
+        long func = (long) GDK_FUNC_MOVE;
+
+        if ((win->GetWindowStyle() & wxCAPTION) != 0)
+            decor |= GDK_DECOR_TITLE;
+        if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
+        {
+            decor |= GDK_DECOR_MENU;
+            func |= GDK_FUNC_CLOSE;
+        }
+        if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
+        {
+            func |= GDK_FUNC_MINIMIZE;
+            decor |= GDK_DECOR_MINIMIZE;
+        }
+        if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
+        {
+            func |= GDK_FUNC_MAXIMIZE;
+            decor |= GDK_DECOR_MAXIMIZE;
+        }
+        if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
+        {
+           func |= GDK_FUNC_RESIZE;
+           decor |= GDK_DECOR_RESIZEH;
+        }
+        
+        gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+        gdk_window_set_functions( win->m_widget->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->m_widget), 0, 0, 1);
@@ -386,7 +391,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
     }
 
     /* resize on OnInternalIdle */
-    parent->UpdateSize();
+    parent->GtkUpdateSize();
 }
 
 // ----------------------------------------------------------------------------
@@ -402,7 +407,7 @@ void wxFrame::Init()
     m_menuBarDetached = FALSE;
     m_toolBarDetached = FALSE;
     m_insertInClientArea = TRUE;
-    m_isFrame = TRUE;
+    m_isFrame = FALSE;
 }
 
 bool wxFrame::Create( wxWindow *parent,
@@ -416,6 +421,7 @@ bool wxFrame::Create( wxWindow *parent,
     wxTopLevelWindows.Append( this );
 
     m_needParent = FALSE;
+    m_isFrame = TRUE;
 
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
@@ -429,10 +435,12 @@ bool wxFrame::Create( wxWindow *parent,
     m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
 
     GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
-    if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
 
     m_widget = gtk_window_new( win_type );
 
+    if ((m_parent) && (HasFlag(wxFRAME_FLOAT_ON_PARENT)) && (GTK_IS_WINDOW(m_parent->m_widget)))
+        gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
+
     if (!name.IsEmpty())
         gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
 
@@ -477,6 +485,10 @@ bool wxFrame::Create( wxWindow *parent,
 
     PostCreation();
 
+    if ((m_x != -1) || (m_y != -1))
+        gtk_widget_set_uposition( m_widget, m_x, m_y );
+    gtk_widget_set_usize( m_widget, m_width, m_height );
+        
     /*  we cannot set MWM hints and icons before the widget has
         been realized, so we do this directly after realization */
     gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
@@ -504,8 +516,11 @@ wxFrame::~wxFrame()
     if (wxTheApp->GetTopWindow() == this)
         wxTheApp->SetTopWindow( (wxWindow*) NULL );
 
-    if (wxTopLevelWindows.Number() == 0)
+    if ((wxTopLevelWindows.Number() == 0) &&
+        (wxTheApp->GetExitOnFrameDelete()))
+    {
         wxTheApp->ExitMainLoop();
+    }
 }
 
 // ----------------------------------------------------------------------------
@@ -529,6 +544,11 @@ bool wxFrame::Show( bool show )
     return wxWindow::Show( show );
 }
 
+void wxFrame::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
+{
+    wxFAIL_MSG( wxT("DoMoveWindow called for wxFrame") );
+}
+    
 void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 {
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
@@ -589,6 +609,8 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 
     if ((m_width != old_width) || (m_height != old_height))
     {
+        gtk_widget_set_usize( m_widget, m_width, m_height );
+
         /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
            done either directly before the frame is shown or in idle time
            so that different calls to SetSize() don't lead to flicker. */
@@ -826,11 +848,12 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
         gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
                             m_frameStatusBar->m_widget,
                             xx, yy, ww, hh );
+        gtk_widget_draw( m_frameStatusBar->m_widget, (GdkRectangle*) NULL );
     }
 #endif
 
     /* we actually set the size of a frame here and no-where else */
-    gtk_widget_set_usize( m_widget, m_width, m_height );
+//    gtk_widget_set_usize( m_widget, m_width, m_height );
 
     m_sizeSet = TRUE;
 
@@ -890,33 +913,51 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
     wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
 
+    if (menuBar == m_frameMenuBar)
+        return;
+
+    if (m_frameMenuBar)
+    {
+        m_frameMenuBar->UnsetInvokingWindow( this );
+
+        if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE)
+        {
+            gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget),
+                GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this );
+
+            gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget),
+                GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
+        }
+        
+        gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget );
+        gtk_widget_ref( m_frameMenuBar->m_widget );
+        gtk_widget_unparent( m_frameMenuBar->m_widget );
+    }
+
     m_frameMenuBar = menuBar;
 
     if (m_frameMenuBar)
     {
         m_frameMenuBar->SetInvokingWindow( this );
 
-        if (m_frameMenuBar->GetParent() != this)
-        {
-            m_frameMenuBar->SetParent(this);
-            gtk_pizza_put( GTK_PIZZA(m_mainWidget),
+        m_frameMenuBar->SetParent(this);
+        gtk_pizza_put( GTK_PIZZA(m_mainWidget),
                 m_frameMenuBar->m_widget,
                 m_frameMenuBar->m_x,
                 m_frameMenuBar->m_y,
                 m_frameMenuBar->m_width,
                 m_frameMenuBar->m_height );
 
-            if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
-            {
-                gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached",
-                    GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this );
-
-                gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
-                    GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
-            }
+        if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
+        {
+            gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached",
+                GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this );
 
-            m_frameMenuBar->Show( TRUE );
+            gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
+                GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
         }
+
+        m_frameMenuBar->Show( TRUE );
     }
 
     /* resize window in OnInternalIdle */
@@ -955,7 +996,7 @@ void wxFrame::SetToolBar(wxToolBar *toolbar)
             GetChildren().DeleteObject( m_frameToolBar );
 
             gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
-            UpdateSize();
+            GtkUpdateSize();
         }
     }
 }
@@ -977,6 +1018,13 @@ wxStatusBar* wxFrame::CreateStatusBar(int number,
     return wxFrameBase::CreateStatusBar( number, style, id, name );
 }
 
+void wxFrame::PositionStatusBar()
+{
+    if ( !m_frameStatusBar )
+        return;
+
+    m_sizeSet = FALSE;
+}
 #endif // wxUSE_STATUSBAR
 
 // ----------------------------------------------------------------------------