From 1f3c610d03848f7953b52f66d6ba5aa1719b8cc2 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 19 Mar 2000 19:51:08 +0000 Subject: [PATCH] The Return of WM Size Hints Part IV. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6865 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/dialog.cpp | 27 ++++++++++++++------------- src/gtk/frame.cpp | 40 +++++++++++++++++++--------------------- src/gtk1/dialog.cpp | 27 ++++++++++++++------------- src/gtk1/frame.cpp | 40 +++++++++++++++++++--------------------- 4 files changed, 66 insertions(+), 68 deletions(-) diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 7550d74cef..33bceb74e8 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -175,19 +175,6 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); - /* set size hints */ - gint flag = 0; // GDK_HINT_POS; - if ((win->GetMinWidth() != -1) || (win->GetMinHeight() != -1)) flag |= GDK_HINT_MIN_SIZE; - if ((win->GetMaxWidth() != -1) || (win->GetMaxHeight() != -1)) flag |= GDK_HINT_MAX_SIZE; - if (flag) - { - gdk_window_set_hints( win->m_widget->window, - win->m_x, win->m_y, - win->GetMinWidth(), win->GetMinHeight(), - win->GetMaxWidth(), win->GetMaxHeight(), - flag ); - } - /* reset the icon */ if (win->m_icon != wxNullIcon) { @@ -556,6 +543,20 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; + /* set size hints */ + gint flag = 0; // GDK_HINT_POS; + if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; + if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; + GdkGeometry geom; + geom.min_width = m_minWidth; + geom.min_height = m_minHeight; + geom.max_width = m_maxWidth; + geom.max_height = m_maxHeight; + gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), + (GtkWidget*) NULL, + &geom, + (GdkWindowHints) flag ); + m_sizeSet = TRUE; wxSizeEvent event( wxSize(m_width,m_height), GetId() ); diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 04d2407999..f4e2970ad0 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -294,19 +294,6 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); - /* set size hints */ - gint flag = 0; // GDK_HINT_POS; - if ((win->GetMinWidth() != -1) || (win->GetMinHeight() != -1)) flag |= GDK_HINT_MIN_SIZE; - if ((win->GetMaxWidth() != -1) || (win->GetMaxHeight() != -1)) flag |= GDK_HINT_MAX_SIZE; - if (flag) - { - gdk_window_set_hints( win->m_widget->window, - win->m_x, win->m_y, - win->GetMinWidth(), win->GetMinHeight(), - win->GetMaxWidth(), win->GetMaxHeight(), - flag ); - } - /* reset the icon */ wxIcon iconOld = win->GetIcon(); if ( iconOld != wxNullIcon ) @@ -747,13 +734,27 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), skip the part which handles m_frameMenuBar, m_frameToolBar and (most importantly) m_mainWidget */ + 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_maxWidth; + if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; + + /* set size hints */ + gint flag = 0; // GDK_HINT_POS; + if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; + if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; + GdkGeometry geom; + geom.min_width = m_minWidth; + geom.min_height = m_minHeight; + geom.max_width = m_maxWidth; + geom.max_height = m_maxHeight; + gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), + (GtkWidget*) NULL, + &geom, + (GdkWindowHints) flag ); + if (m_mainWidget) { - /* check if size is in legal range */ - 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_maxWidth; - if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; /* I revert back to wxGTK's original behaviour. m_mainWidget holds the * menubar, the toolbar and the client area, which is represented by @@ -852,9 +853,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), } #endif - /* we actually set the size of a frame here and no-where else */ -// gtk_widget_set_usize( m_widget, m_width, m_height ); - m_sizeSet = TRUE; // send size event to frame diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 7550d74cef..33bceb74e8 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -175,19 +175,6 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); - /* set size hints */ - gint flag = 0; // GDK_HINT_POS; - if ((win->GetMinWidth() != -1) || (win->GetMinHeight() != -1)) flag |= GDK_HINT_MIN_SIZE; - if ((win->GetMaxWidth() != -1) || (win->GetMaxHeight() != -1)) flag |= GDK_HINT_MAX_SIZE; - if (flag) - { - gdk_window_set_hints( win->m_widget->window, - win->m_x, win->m_y, - win->GetMinWidth(), win->GetMinHeight(), - win->GetMaxWidth(), win->GetMaxHeight(), - flag ); - } - /* reset the icon */ if (win->m_icon != wxNullIcon) { @@ -556,6 +543,20 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; + /* set size hints */ + gint flag = 0; // GDK_HINT_POS; + if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; + if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; + GdkGeometry geom; + geom.min_width = m_minWidth; + geom.min_height = m_minHeight; + geom.max_width = m_maxWidth; + geom.max_height = m_maxHeight; + gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), + (GtkWidget*) NULL, + &geom, + (GdkWindowHints) flag ); + m_sizeSet = TRUE; wxSizeEvent event( wxSize(m_width,m_height), GetId() ); diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 04d2407999..f4e2970ad0 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -294,19 +294,6 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); - /* set size hints */ - gint flag = 0; // GDK_HINT_POS; - if ((win->GetMinWidth() != -1) || (win->GetMinHeight() != -1)) flag |= GDK_HINT_MIN_SIZE; - if ((win->GetMaxWidth() != -1) || (win->GetMaxHeight() != -1)) flag |= GDK_HINT_MAX_SIZE; - if (flag) - { - gdk_window_set_hints( win->m_widget->window, - win->m_x, win->m_y, - win->GetMinWidth(), win->GetMinHeight(), - win->GetMaxWidth(), win->GetMaxHeight(), - flag ); - } - /* reset the icon */ wxIcon iconOld = win->GetIcon(); if ( iconOld != wxNullIcon ) @@ -747,13 +734,27 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), skip the part which handles m_frameMenuBar, m_frameToolBar and (most importantly) m_mainWidget */ + 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_maxWidth; + if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; + + /* set size hints */ + gint flag = 0; // GDK_HINT_POS; + if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; + if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; + GdkGeometry geom; + geom.min_width = m_minWidth; + geom.min_height = m_minHeight; + geom.max_width = m_maxWidth; + geom.max_height = m_maxHeight; + gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), + (GtkWidget*) NULL, + &geom, + (GdkWindowHints) flag ); + if (m_mainWidget) { - /* check if size is in legal range */ - 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_maxWidth; - if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; /* I revert back to wxGTK's original behaviour. m_mainWidget holds the * menubar, the toolbar and the client area, which is represented by @@ -852,9 +853,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), } #endif - /* we actually set the size of a frame here and no-where else */ -// gtk_widget_set_usize( m_widget, m_width, m_height ); - m_sizeSet = TRUE; // send size event to frame -- 2.45.2