X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7d9f12f3b9f997b6308faf336d5381be591b71f4..f00f657d37e530c55d5e98fac2477b477a6f1d36:/src/gtk/toplevel.cpp diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 5e5af4d54f..2d5d03f16d 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -50,10 +50,6 @@ extern int g_openDialogs; // event tables // ---------------------------------------------------------------------------- -#ifndef __WXUNIVERSAL__ - IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow) -#endif - // ---------------------------------------------------------------------------- // data // ---------------------------------------------------------------------------- @@ -133,7 +129,7 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX wxapp_install_idle_handler(); if (win->IsEnabled() && - (g_openDialogs == 0 || (win->GetExtraStyle() & wxTLW_EX_DIALOG))) + (g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG))) win->Close(); return TRUE; @@ -188,48 +184,15 @@ gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK * if (g_isIdle) wxapp_install_idle_handler(); - if ((win->m_miniEdge > 0) || (win->HasFlag(wxSIMPLE_BORDER)) || (win->HasFlag(wxNO_BORDER))) - { - /* 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 ); - } - else - { - /* 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); - } + /* All this is for Motif Window Manager "hints" and is supposed to be + recognized by other WM as well. Not tested. */ + gdk_window_set_decorations(win->m_widget->window, + (GdkWMDecoration)win->m_gdkDecor); + gdk_window_set_functions(win->m_widget->window, + (GdkWMFunction)win->m_gdkFunc); /* GTK's shrinking/growing policy */ - if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0) + if ((win->m_gdkFunc & GDK_FUNC_RESIZE) == 0) gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1); else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); @@ -368,15 +331,16 @@ void wxTopLevelWindowGTK::Init() m_isIconized = FALSE; m_fsIsShowing = FALSE; m_themeEnabled = TRUE; + m_gdkDecor = m_gdkFunc = 0; } bool wxTopLevelWindowGTK::Create( wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& sizeOrig, - long style, - const wxString &name ) + wxWindowID id, + const wxString& title, + const wxPoint& pos, + const wxSize& sizeOrig, + long style, + const wxString &name ) { // always create a frame of some reasonable, even if arbitrary, size (at // least for MSW compatibility) @@ -409,14 +373,17 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, if (style & wxFRAME_TOOL_WINDOW) win_type = GTK_WINDOW_POPUP; - - if (GetExtraStyle() & wxTLW_EX_DIALOG) + + if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) win_type = GTK_WINDOW_DIALOG; m_widget = gtk_window_new( win_type ); - if ((m_parent) && (HasFlag(wxFRAME_FLOAT_ON_PARENT)) && (GTK_IS_WINDOW(m_parent->m_widget))) + if (m_parent && (GTK_IS_WINDOW(m_parent->m_widget)) && + (HasFlag(wxFRAME_FLOAT_ON_PARENT) || (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG))) + { 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() ); @@ -495,6 +462,44 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, gtk_signal_connect( GTK_OBJECT(m_widget), "focus", GTK_SIGNAL_FUNC(gtk_frame_focus_callback), (gpointer)this ); + + /* decorations */ + if ((m_miniEdge > 0) || (style & wxSIMPLE_BORDER) || (style & wxNO_BORDER)) + { + m_gdkDecor = 0; + m_gdkFunc = 0; + } + else + { + m_gdkDecor = (long) GDK_DECOR_BORDER; + m_gdkFunc = (long) GDK_FUNC_MOVE; + + // All this is for Motif Window Manager "hints" and is supposed to be + // recognized by other WM as well. Not tested. + if ((style & wxCAPTION) != 0) + m_gdkDecor |= GDK_DECOR_TITLE; + if ((style & wxSYSTEM_MENU) != 0) + { + m_gdkFunc |= GDK_FUNC_CLOSE; + m_gdkDecor |= GDK_DECOR_MENU; + } + if ((style & wxMINIMIZE_BOX) != 0) + { + m_gdkFunc |= GDK_FUNC_MINIMIZE; + m_gdkDecor |= GDK_DECOR_MINIMIZE; + } + if ((style & wxMAXIMIZE_BOX) != 0) + { + m_gdkFunc |= GDK_FUNC_MAXIMIZE; + m_gdkDecor |= GDK_DECOR_MAXIMIZE; + } + if ((style & wxRESIZE_BORDER) != 0) + { + m_gdkFunc |= GDK_FUNC_RESIZE; + m_gdkDecor |= GDK_DECOR_RESIZEH; + } + } + return TRUE; } @@ -522,7 +527,8 @@ bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long style ) if (show) { - m_fsSaveStyle = m_windowStyle; + m_fsSaveGdkFunc = m_gdkFunc; + m_fsSaveGdkDecor = m_gdkDecor; m_fsSaveFlag = style; GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y ); GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height ); @@ -530,7 +536,8 @@ bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long style ) gtk_widget_hide( m_widget ); gtk_widget_unrealize( m_widget ); - m_windowStyle = wxSIMPLE_BORDER; + m_gdkDecor = (long) GDK_DECOR_BORDER; + m_gdkFunc = (long) GDK_FUNC_MOVE; int x; int y; @@ -545,7 +552,8 @@ bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long style ) gtk_widget_hide( m_widget ); gtk_widget_unrealize( m_widget ); - m_windowStyle = m_fsSaveStyle; + m_gdkFunc = m_fsSaveGdkFunc; + m_gdkDecor = m_fsSaveGdkDecor; SetSize( m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height ); @@ -586,7 +594,7 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - /* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */ + /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */ wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); /* avoid recursions */ @@ -673,12 +681,12 @@ void wxTopLevelWindowGTK::DoSetClientSize( int width, int height ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - DoSetSize(-1, -1, + DoSetSize(-1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0); } void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), - int width, int height ) + int width, int height ) { // due to a bug in gtk, x,y are always 0 // m_x = x; @@ -693,9 +701,9 @@ void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), m_width = width; m_height = height; - /* wxMDIChildFrame derives from wxFrameGTK but it _is_ a wxWindow as it uses + /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses wxWindow::Create to create it's GTK equivalent. m_mainWidget is only - set in wxFrameGTK::Create so it is used to check what kind of frame we + set in wxFrame::Create so it is used to check what kind of frame we have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we skip the part which handles m_frameMenuBar, m_frameToolBar and (most importantly) m_mainWidget */