From: Robert Roebling Date: Sat, 8 Aug 1998 13:44:36 +0000 (+0000) Subject: Correct the wxButton::Setlabel nonsense X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b593568eca4d3baf5010d005756a47adeb519008?hp=b6af8d80dcdd9d7ef9cca3aaaaf8fe4db343d7ae Correct the wxButton::Setlabel nonsense Added wxFrame::SetClientSize git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@477 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index 2c64cb50ff..76e0a5c5b1 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -63,6 +63,7 @@ public: virtual void Enable( bool enable ); virtual void GetClientSize( int *width, int *height ) const; + virtual void SetClientSize( int const width, int const height ); // set minimal/maxmimal size for the frame virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 ); diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index 2c64cb50ff..76e0a5c5b1 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -63,6 +63,7 @@ public: virtual void Enable( bool enable ); virtual void GetClientSize( int *width, int *height ) const; + virtual void SetClientSize( int const width, int const height ); // set minimal/maxmimal size for the frame virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 ); diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 7205e098c5..6588daad60 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -65,8 +65,8 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, PreCreation( parent, id, pos, newSize, style, name ); - SetLabel(label); m_widget = gtk_button_new_with_label( m_label ); + SetLabel(label); if (newSize.x == -1) newSize.x = 15+gdk_string_measure( m_widget->style->font, label ); if (newSize.y == -1) newSize.y = 26; @@ -89,7 +89,7 @@ void wxButton::SetDefault(void) void wxButton::SetLabel( const wxString &label ) { wxControl::SetLabel( label ); - GtkBin *bin = GTK_BIN( m_widget ); + GtkButton *bin = GTK_BUTTON( m_widget ); GtkLabel *g_label = GTK_LABEL( bin->child ); gtk_label_set( g_label, GetLabel() ); }; diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index fb7fd4d3af..7979f34d5c 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -38,6 +38,7 @@ void wxControl::Command( wxCommandEvent &WXUNUSED(event) ) void wxControl::SetLabel( const wxString &label ) { + m_label = ""; for ( const char *pc = label; *pc != '\0'; pc++ ) { if ( *pc == '&' ) { pc++; // skip it @@ -47,7 +48,6 @@ void wxControl::SetLabel( const wxString &label ) #endif } - m_label = ""; m_label << *pc; } }; diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 99d98fcdb8..beb8a3df5c 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -226,6 +226,20 @@ void wxFrame::GetClientSize( int *width, int *height ) const }; }; +void wxFrame::SetClientSize( int const width, int const height ) +{ + int h = height; + if (m_frameMenuBar) h += wxMENU_HEIGHT; + if (m_frameStatusBar) h += wxSTATUS_HEIGHT; + if (m_frameToolBar) + { + int y = 0; + m_frameToolBar->GetSize( NULL, &y ); + h += y; + } + wxWindow::SetClientSize( width, h ); +}; + void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) { // due to a bug in gtk, x,y are always 0 diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index 7205e098c5..6588daad60 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -65,8 +65,8 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, PreCreation( parent, id, pos, newSize, style, name ); - SetLabel(label); m_widget = gtk_button_new_with_label( m_label ); + SetLabel(label); if (newSize.x == -1) newSize.x = 15+gdk_string_measure( m_widget->style->font, label ); if (newSize.y == -1) newSize.y = 26; @@ -89,7 +89,7 @@ void wxButton::SetDefault(void) void wxButton::SetLabel( const wxString &label ) { wxControl::SetLabel( label ); - GtkBin *bin = GTK_BIN( m_widget ); + GtkButton *bin = GTK_BUTTON( m_widget ); GtkLabel *g_label = GTK_LABEL( bin->child ); gtk_label_set( g_label, GetLabel() ); }; diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index fb7fd4d3af..7979f34d5c 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -38,6 +38,7 @@ void wxControl::Command( wxCommandEvent &WXUNUSED(event) ) void wxControl::SetLabel( const wxString &label ) { + m_label = ""; for ( const char *pc = label; *pc != '\0'; pc++ ) { if ( *pc == '&' ) { pc++; // skip it @@ -47,7 +48,6 @@ void wxControl::SetLabel( const wxString &label ) #endif } - m_label = ""; m_label << *pc; } }; diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 99d98fcdb8..beb8a3df5c 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -226,6 +226,20 @@ void wxFrame::GetClientSize( int *width, int *height ) const }; }; +void wxFrame::SetClientSize( int const width, int const height ) +{ + int h = height; + if (m_frameMenuBar) h += wxMENU_HEIGHT; + if (m_frameStatusBar) h += wxSTATUS_HEIGHT; + if (m_frameToolBar) + { + int y = 0; + m_frameToolBar->GetSize( NULL, &y ); + h += y; + } + wxWindow::SetClientSize( width, h ); +}; + void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) { // due to a bug in gtk, x,y are always 0