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
This commit is contained in:
Robert Roebling
1998-08-08 13:44:36 +00:00
parent b6af8d80dc
commit b593568eca
8 changed files with 36 additions and 6 deletions

View File

@@ -63,6 +63,7 @@ public:
virtual void Enable( bool enable ); virtual void Enable( bool enable );
virtual void GetClientSize( int *width, int *height ) const; virtual void GetClientSize( int *width, int *height ) const;
virtual void SetClientSize( int const width, int const height );
// set minimal/maxmimal size for the frame // set minimal/maxmimal size for the frame
virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 ); virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 );

View File

@@ -63,6 +63,7 @@ public:
virtual void Enable( bool enable ); virtual void Enable( bool enable );
virtual void GetClientSize( int *width, int *height ) const; virtual void GetClientSize( int *width, int *height ) const;
virtual void SetClientSize( int const width, int const height );
// set minimal/maxmimal size for the frame // set minimal/maxmimal size for the frame
virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 ); virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 );

View File

@@ -65,8 +65,8 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
PreCreation( parent, id, pos, newSize, style, name ); PreCreation( parent, id, pos, newSize, style, name );
SetLabel(label);
m_widget = gtk_button_new_with_label( m_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.x == -1) newSize.x = 15+gdk_string_measure( m_widget->style->font, label );
if (newSize.y == -1) newSize.y = 26; if (newSize.y == -1) newSize.y = 26;
@@ -89,7 +89,7 @@ void wxButton::SetDefault(void)
void wxButton::SetLabel( const wxString &label ) void wxButton::SetLabel( const wxString &label )
{ {
wxControl::SetLabel( label ); wxControl::SetLabel( label );
GtkBin *bin = GTK_BIN( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child ); GtkLabel *g_label = GTK_LABEL( bin->child );
gtk_label_set( g_label, GetLabel() ); gtk_label_set( g_label, GetLabel() );
}; };

View File

@@ -38,6 +38,7 @@ void wxControl::Command( wxCommandEvent &WXUNUSED(event) )
void wxControl::SetLabel( const wxString &label ) void wxControl::SetLabel( const wxString &label )
{ {
m_label = "";
for ( const char *pc = label; *pc != '\0'; pc++ ) { for ( const char *pc = label; *pc != '\0'; pc++ ) {
if ( *pc == '&' ) { if ( *pc == '&' ) {
pc++; // skip it pc++; // skip it
@@ -47,7 +48,6 @@ void wxControl::SetLabel( const wxString &label )
#endif #endif
} }
m_label = "";
m_label << *pc; m_label << *pc;
} }
}; };

View File

@@ -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 ) void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
{ {
// due to a bug in gtk, x,y are always 0 // due to a bug in gtk, x,y are always 0

View File

@@ -65,8 +65,8 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
PreCreation( parent, id, pos, newSize, style, name ); PreCreation( parent, id, pos, newSize, style, name );
SetLabel(label);
m_widget = gtk_button_new_with_label( m_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.x == -1) newSize.x = 15+gdk_string_measure( m_widget->style->font, label );
if (newSize.y == -1) newSize.y = 26; if (newSize.y == -1) newSize.y = 26;
@@ -89,7 +89,7 @@ void wxButton::SetDefault(void)
void wxButton::SetLabel( const wxString &label ) void wxButton::SetLabel( const wxString &label )
{ {
wxControl::SetLabel( label ); wxControl::SetLabel( label );
GtkBin *bin = GTK_BIN( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child ); GtkLabel *g_label = GTK_LABEL( bin->child );
gtk_label_set( g_label, GetLabel() ); gtk_label_set( g_label, GetLabel() );
}; };

View File

@@ -38,6 +38,7 @@ void wxControl::Command( wxCommandEvent &WXUNUSED(event) )
void wxControl::SetLabel( const wxString &label ) void wxControl::SetLabel( const wxString &label )
{ {
m_label = "";
for ( const char *pc = label; *pc != '\0'; pc++ ) { for ( const char *pc = label; *pc != '\0'; pc++ ) {
if ( *pc == '&' ) { if ( *pc == '&' ) {
pc++; // skip it pc++; // skip it
@@ -47,7 +48,6 @@ void wxControl::SetLabel( const wxString &label )
#endif #endif
} }
m_label = "";
m_label << *pc; m_label << *pc;
} }
}; };

View File

@@ -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 ) void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
{ {
// due to a bug in gtk, x,y are always 0 // due to a bug in gtk, x,y are always 0