wxWindow::GetBestSize() added

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-11-19 21:01:20 +00:00
parent 33879bb218
commit f68586e51b
61 changed files with 378 additions and 221 deletions

View File

@@ -106,16 +106,7 @@ bool wxCheckBox::Create(wxWindow *parent,
m_widget = m_widgetCheckbox;
}
wxSize newSize(size);
if (newSize.x == -1)
{
newSize.x = 25 + gdk_string_measure( m_widgetCheckbox->style->font,
m_label.mbc_str() );
}
if (newSize.y == -1)
newSize.y = 26;
SetSize( newSize.x, newSize.y );
SetSizeOrDefault( size );
gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox),
"clicked",
@@ -210,4 +201,10 @@ void wxCheckBox::OnInternalIdle()
UpdateWindowUI();
}
wxSize wxCheckBox::DoGetBestSize() const
{
return wxSize( 25 + gdk_string_measure( m_widgetCheckbox->style->font,
m_label.mbc_str() ), 26 );
}
#endif

View File

@@ -90,12 +90,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
m_widget = gtk_option_menu_new();
wxSize newSize(size);
if (newSize.x == -1)
newSize.x = 80;
if (newSize.y == -1)
newSize.y = 26;
SetSize( newSize.x, newSize.y );
SetSizeOrDefault( size );
if ( style & wxCB_SORT )
{
@@ -429,4 +424,9 @@ size_t wxChoice::AppendHelper(GtkWidget *menu, const wxString& item)
return index;
}
wxSize wxChoice::DoGetBestSize() const
{
return wxSize(80, 26);
}
#endif

View File

@@ -113,12 +113,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
// make it more useable
gtk_combo_set_use_arrows_always(GTK_COMBO(m_widget), TRUE);
wxSize newSize = size;
if (newSize.x == -1)
newSize.x = 100;
if (newSize.y == -1)
newSize.y = 26;
SetSize( newSize.x, newSize.y );
SetSizeOrDefault( size );
GtkWidget *list = GTK_COMBO(m_widget)->list;
@@ -660,4 +655,9 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
(window == GTK_COMBO(m_widget)->button->window ) );
}
wxSize wxComboBox::DoGetBestSize() const
{
return wxSize(100, 26);
}
#endif

View File

@@ -13,7 +13,7 @@
#include "wx/control.h"
#include "gtk/gtkfeatures.h"
#include "gtk/gtk.h"
//-----------------------------------------------------------------------------
// wxControl
@@ -58,3 +58,12 @@ wxString wxControl::GetLabel() const
}
wxSize wxControl::DoGetBestSize() const
{
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request )
(m_widget, &req );
return wxSize(req.width, req.height);
}

View File

@@ -327,12 +327,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_widget_show( GTK_WIDGET(m_list) );
wxSize newSize = size;
if (newSize.x == -1)
newSize.x = 100;
if (newSize.y == -1)
newSize.y = 110;
SetSize( newSize.x, newSize.y );
SetSizeOrDefault( size );
if ( style & wxLB_SORT )
{
@@ -939,4 +934,9 @@ void wxListBox::OnInternalIdle()
UpdateWindowUI();
}
wxSize wxListBox::DoGetBestSize() const
{
return wxSize(100, 110);
}
#endif

View File

@@ -69,16 +69,12 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
if (m_bitmap.Ok())
{
wxSize newSize = size;
GdkBitmap *mask = (GdkBitmap *) NULL;
if ( m_bitmap.GetMask() )
mask = m_bitmap.GetMask()->GetBitmap();
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
if (newSize.x == -1) newSize.x = m_bitmap.GetWidth();
if (newSize.y == -1) newSize.y = m_bitmap.GetHeight();
SetSize( newSize.x, newSize.y );
SetSizeOrDefault( size );
}
else
{
@@ -116,8 +112,16 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
}
SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
SetSizeOrDefault();
}
}
wxSize wxStaticBitmap::DoGetBestSize() const
{
if ( m_bitmap.Ok() )
return wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight());
else
return wxSize(16, 16); // completely arbitrary
}
#endif

View File

@@ -79,13 +79,7 @@ bool wxStaticText::Create(wxWindow *parent,
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
wxSize newSize = size;
if (newSize.x == -1) newSize.x = req.width;
if (newSize.y == -1) newSize.y = req.height;
SetSize( newSize.x, newSize.y );
SetSizeOrDefault( size );
m_parent->DoAddChild( this );
@@ -115,11 +109,7 @@ void wxStaticText::SetLabel( const wxString &label )
// adjust the label size to the new label unless disabled
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
{
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request )
(m_widget, &req );
SetSize( req.width, req.height );
SetSize( GetBestSize() );
}
}
@@ -128,4 +118,3 @@ void wxStaticText::ApplyWidgetStyle()
SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle );
}

View File

@@ -182,10 +182,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
m_text = gtk_entry_new();
}
wxSize newSize = size;
if (newSize.x == -1) newSize.x = 80;
if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y );
SetSizeOrDefault( size );
m_parent->DoAddChild( this );
@@ -966,3 +963,9 @@ void wxTextCtrl::OnInternalIdle()
UpdateWindowUI();
}
wxSize wxTextCtrl::DoGetBestSize() const
{
// FIXME should be different for multi-line controls...
return wxSize(80, 26);
}

View File

@@ -185,7 +185,8 @@ extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL;
extern wxWindow *g_focusWindow = (wxWindow*) NULL;
/* extern */ wxWindow *g_focusWindow = (wxWindow*) NULL;
// if we detect that the app has got/lost the focus, we set this variable to
// either TRUE or FALSE and an activate event will be sent during the next