From d6538e2c55535a747aec939d0f6659f91bc623d4 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 19 Oct 1999 10:51:48 +0000 Subject: [PATCH] Added size hints to dialog, Corrected client data "code" for wxChoice, git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4065 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/gtk/changes.txt | 15 +++++++-- include/wx/gtk/choice.h | 13 ++++++-- include/wx/gtk1/choice.h | 13 ++++++-- src/gtk/choice.cpp | 33 ++++++++++--------- src/gtk/dialog.cpp | 69 ++++++++++++++-------------------------- src/gtk1/choice.cpp | 33 ++++++++++--------- src/gtk1/dialog.cpp | 69 ++++++++++++++-------------------------- 7 files changed, 112 insertions(+), 133 deletions(-) diff --git a/docs/gtk/changes.txt b/docs/gtk/changes.txt index 0c3e95c6cf..d82d9eba54 100644 --- a/docs/gtk/changes.txt +++ b/docs/gtk/changes.txt @@ -17,14 +17,23 @@ Support for GTK 1.0 has been dropped. This version has been tested with GTK 1.2.3 and GTK 1.2.6 - it is known not work with some other versions. +wxChoice can now handle only either void client data +(which it will not delete on destruction) or client +data of the wxClientData type (which it will delete), +instead of both at the same time. The same will happen +to wxListBox and wxComboBox some time. + Many build fixes for various platforms have been applied, try again, poor HP-UX and *BSD users, but don't reckon with immediate success. Actually, when using GNU compilers, your chances are quite good. -My total rewrite of the wxWindows underlying GTK widget +My rewrite of the wxWindows underlying GTK widget has turned scrolling including subwindows from barely -functional to pretty and fast. +functional to pretty and fast. I also added scrolling +of foreign windows to wxScrolledWindow. + +Setting size hints for the window manager might work now. wxSocket and Co. have been improved up to the point of calling it a rewrite. It works on wxMSW now too and @@ -40,7 +49,7 @@ Several printing things fixed. HTML widget and the wxWindows' help system based upon it have been reorganized and improved for easier use -from Python and C++. +from Python and C++. Also HTML printing has been added. wxSpinCtrl added. Like a wxSpinButton and a wxTextCtrl. diff --git a/include/wx/gtk/choice.h b/include/wx/gtk/choice.h index 6631f12bcc..b7dd865d98 100644 --- a/include/wx/gtk/choice.h +++ b/include/wx/gtk/choice.h @@ -53,8 +53,7 @@ public: wxString GetString( int n ) const; // implementation - wxList m_clientDataList; - wxList m_clientObjectList; + wxList m_clientList; void DisableEvents(); void EnableEvents(); @@ -69,6 +68,16 @@ protected: virtual void DoSetClientObject( int n, wxClientData* clientData ); virtual wxClientData* DoGetClientObject( int n ) const; + // the above virtuals hide these virtuals in wxChoiceBase + virtual void DoSetClientData(void* clientData ) + { wxWindowBase::DoSetClientData(clientData); }; + virtual void* DoGetClientData() const + { return(wxWindowBase::DoGetClientData()); }; + virtual void DoSetClientObject( wxClientData* clientData ) + { wxWindowBase::DoSetClientObject(clientData); }; + virtual wxClientData* DoGetClientObject() const + { return(wxWindowBase::DoGetClientObject()); }; + private: DECLARE_DYNAMIC_CLASS(wxChoice) }; diff --git a/include/wx/gtk1/choice.h b/include/wx/gtk1/choice.h index 6631f12bcc..b7dd865d98 100644 --- a/include/wx/gtk1/choice.h +++ b/include/wx/gtk1/choice.h @@ -53,8 +53,7 @@ public: wxString GetString( int n ) const; // implementation - wxList m_clientDataList; - wxList m_clientObjectList; + wxList m_clientList; void DisableEvents(); void EnableEvents(); @@ -69,6 +68,16 @@ protected: virtual void DoSetClientObject( int n, wxClientData* clientData ); virtual wxClientData* DoGetClientObject( int n ) const; + // the above virtuals hide these virtuals in wxChoiceBase + virtual void DoSetClientData(void* clientData ) + { wxWindowBase::DoSetClientData(clientData); }; + virtual void* DoGetClientData() const + { return(wxWindowBase::DoGetClientData()); }; + virtual void DoSetClientObject( wxClientData* clientData ) + { wxWindowBase::DoSetClientObject(clientData); }; + virtual wxClientData* DoGetClientObject() const + { return(wxWindowBase::DoGetClientObject()); }; + private: DECLARE_DYNAMIC_CLASS(wxChoice) }; diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index a166de9863..81d2380a01 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -92,8 +92,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, for (int i = 0; i < n; i++) { - m_clientDataList.Append( (wxObject*) NULL ); - m_clientObjectList.Append( (wxObject*) NULL ); + m_clientList.Append( (wxObject*) NULL ); GtkWidget *item = gtk_menu_item_new_with_label( choices[i].mbc_str() ); gtk_menu_append( GTK_MENU(menu), item ); @@ -145,18 +144,17 @@ int wxChoice::DoAppend( const wxString &item ) gtk_widget_show( menu_item ); - m_clientDataList.Append( (wxObject*) NULL ); - m_clientObjectList.Append( (wxObject*) NULL ); + m_clientList.Append( (wxObject*) NULL ); // return the index of the item in the control - return GetCount(); + return GetCount() - 1; } void wxChoice::DoSetClientData( int n, void* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - wxNode *node = m_clientDataList.Nth( n ); + wxNode *node = m_clientList.Nth( n ); wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientData") ); node->SetData( (wxObject*) clientData ); @@ -166,7 +164,7 @@ void* wxChoice::DoGetClientData( int n ) const { wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid combobox") ); - wxNode *node = m_clientDataList.Nth( n ); + wxNode *node = m_clientList.Nth( n ); wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetClientData") ); return node->Data(); @@ -176,7 +174,7 @@ void wxChoice::DoSetClientObject( int n, wxClientData* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - wxNode *node = m_clientObjectList.Nth( n ); + wxNode *node = m_clientList.Nth( n ); wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientObject") ); wxClientData *cd = (wxClientData*) node->Data(); @@ -189,7 +187,7 @@ wxClientData* wxChoice::DoGetClientObject( int n ) const { wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid combobox") ); - wxNode *node = m_clientObjectList.Nth( n ); + wxNode *node = m_clientList.Nth( n ); wxCHECK_MSG( node, (wxClientData *)NULL, wxT("invalid index in wxChoice::DoGetClientObject") ); @@ -204,16 +202,17 @@ void wxChoice::Clear() GtkWidget *menu = gtk_menu_new(); gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); - wxNode *node = m_clientObjectList.First(); - while (node) + if (m_clientDataItemsType == ClientData_Object) { - wxClientData *cd = (wxClientData*)node->Data(); - if (cd) delete cd; - node = node->Next(); + wxNode *node = m_clientList.First(); + while (node) + { + wxClientData *cd = (wxClientData*)node->Data(); + if (cd) delete cd; + node = node->Next(); + } } - m_clientObjectList.Clear(); - - m_clientDataList.Clear(); + m_clientList.Clear(); } void wxChoice::Delete( int WXUNUSED(n) ) diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 703e8320c6..7cf4f752b5 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -118,50 +118,11 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) if (g_isIdle) wxapp_install_idle_handler(); - /* I haven''t been able to set the position of + /* 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" */ + position in "realize" */ gtk_widget_set_uposition( widget, win->m_x, win->m_y ); - /* set size hints */ - gint flag = 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) - { - wxIcon icon( win->m_icon ); - win->m_icon = wxNullIcon; - win->SetIcon( icon ); - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "map" from m_widget -//----------------------------------------------------------------------------- - -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 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. */ long decor = (long) GDK_DECOR_BORDER; @@ -198,6 +159,27 @@ gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); + /* set size hints */ + gint flag = 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) + { + wxIcon icon( win->m_icon ); + win->m_icon = wxNullIcon; + win->SetIcon( icon ); + } + return FALSE; } @@ -304,11 +286,6 @@ bool wxDialog::Create( wxWindow *parent, gtk_signal_connect( GTK_OBJECT(m_widget), "realize", GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this ); - /* we set the position of the window after the map event. setting it - before has no effect (with KWM) */ - gtk_signal_connect( GTK_OBJECT(m_widget), "map", - GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this ); - /* the user resized the frame by dragging etc. */ gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index a166de9863..81d2380a01 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -92,8 +92,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, for (int i = 0; i < n; i++) { - m_clientDataList.Append( (wxObject*) NULL ); - m_clientObjectList.Append( (wxObject*) NULL ); + m_clientList.Append( (wxObject*) NULL ); GtkWidget *item = gtk_menu_item_new_with_label( choices[i].mbc_str() ); gtk_menu_append( GTK_MENU(menu), item ); @@ -145,18 +144,17 @@ int wxChoice::DoAppend( const wxString &item ) gtk_widget_show( menu_item ); - m_clientDataList.Append( (wxObject*) NULL ); - m_clientObjectList.Append( (wxObject*) NULL ); + m_clientList.Append( (wxObject*) NULL ); // return the index of the item in the control - return GetCount(); + return GetCount() - 1; } void wxChoice::DoSetClientData( int n, void* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - wxNode *node = m_clientDataList.Nth( n ); + wxNode *node = m_clientList.Nth( n ); wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientData") ); node->SetData( (wxObject*) clientData ); @@ -166,7 +164,7 @@ void* wxChoice::DoGetClientData( int n ) const { wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid combobox") ); - wxNode *node = m_clientDataList.Nth( n ); + wxNode *node = m_clientList.Nth( n ); wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetClientData") ); return node->Data(); @@ -176,7 +174,7 @@ void wxChoice::DoSetClientObject( int n, wxClientData* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - wxNode *node = m_clientObjectList.Nth( n ); + wxNode *node = m_clientList.Nth( n ); wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientObject") ); wxClientData *cd = (wxClientData*) node->Data(); @@ -189,7 +187,7 @@ wxClientData* wxChoice::DoGetClientObject( int n ) const { wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid combobox") ); - wxNode *node = m_clientObjectList.Nth( n ); + wxNode *node = m_clientList.Nth( n ); wxCHECK_MSG( node, (wxClientData *)NULL, wxT("invalid index in wxChoice::DoGetClientObject") ); @@ -204,16 +202,17 @@ void wxChoice::Clear() GtkWidget *menu = gtk_menu_new(); gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); - wxNode *node = m_clientObjectList.First(); - while (node) + if (m_clientDataItemsType == ClientData_Object) { - wxClientData *cd = (wxClientData*)node->Data(); - if (cd) delete cd; - node = node->Next(); + wxNode *node = m_clientList.First(); + while (node) + { + wxClientData *cd = (wxClientData*)node->Data(); + if (cd) delete cd; + node = node->Next(); + } } - m_clientObjectList.Clear(); - - m_clientDataList.Clear(); + m_clientList.Clear(); } void wxChoice::Delete( int WXUNUSED(n) ) diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 703e8320c6..7cf4f752b5 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -118,50 +118,11 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) if (g_isIdle) wxapp_install_idle_handler(); - /* I haven''t been able to set the position of + /* 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" */ + position in "realize" */ gtk_widget_set_uposition( widget, win->m_x, win->m_y ); - /* set size hints */ - gint flag = 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) - { - wxIcon icon( win->m_icon ); - win->m_icon = wxNullIcon; - win->SetIcon( icon ); - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "map" from m_widget -//----------------------------------------------------------------------------- - -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 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. */ long decor = (long) GDK_DECOR_BORDER; @@ -198,6 +159,27 @@ gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); + /* set size hints */ + gint flag = 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) + { + wxIcon icon( win->m_icon ); + win->m_icon = wxNullIcon; + win->SetIcon( icon ); + } + return FALSE; } @@ -304,11 +286,6 @@ bool wxDialog::Create( wxWindow *parent, gtk_signal_connect( GTK_OBJECT(m_widget), "realize", GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this ); - /* we set the position of the window after the map event. setting it - before has no effect (with KWM) */ - gtk_signal_connect( GTK_OBJECT(m_widget), "map", - GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this ); - /* the user resized the frame by dragging etc. */ gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); -- 2.45.2