1. corrected client data deletion in wxListBox (no more memory leaks in controls

sample)
2. added wxST_NO_AUTORESIZE style for wxGTK and wxMSW and added test for it to
   the controls sample


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4161 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-10-24 16:29:08 +00:00
parent e6ebb51430
commit 185fa6bf6f
6 changed files with 62 additions and 42 deletions

View File

@@ -52,7 +52,7 @@ bool wxStaticText::Create(wxWindow *parent,
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{
wxFAIL_MSG( wxT("wxXX creation failed") );
return FALSE;
return FALSE;
}
// notice that we call the base class version which will just remove the
@@ -74,7 +74,7 @@ bool wxStaticText::Create(wxWindow *parent,
// GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2
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 );
@@ -110,14 +110,15 @@ void wxStaticText::SetLabel( const wxString &label )
gtk_label_set( GTK_LABEL(m_widget), m_label.mbc_str() );
// adjust the label size to the new 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 );
// TODO there should be a way to prevent SetLabel() from doing it (an
// additional parameter?)
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
SetSize( req.width, req.height );
SetSize( req.width, req.height );
}
}
void wxStaticText::ApplyWidgetStyle()

View File

@@ -52,7 +52,7 @@ bool wxStaticText::Create(wxWindow *parent,
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{
wxFAIL_MSG( wxT("wxXX creation failed") );
return FALSE;
return FALSE;
}
// notice that we call the base class version which will just remove the
@@ -74,7 +74,7 @@ bool wxStaticText::Create(wxWindow *parent,
// GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2
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 );
@@ -110,14 +110,15 @@ void wxStaticText::SetLabel( const wxString &label )
gtk_label_set( GTK_LABEL(m_widget), m_label.mbc_str() );
// adjust the label size to the new 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 );
// TODO there should be a way to prevent SetLabel() from doing it (an
// additional parameter?)
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
SetSize( req.width, req.height );
SetSize( req.width, req.height );
}
}
void wxStaticText::ApplyWidgetStyle()

View File

@@ -359,13 +359,17 @@ void wxListBox::Clear()
void wxListBox::Free()
{
#if wxUSE_OWNER_DRAWN
size_t uiCount = m_aItems.Count();
while ( uiCount-- != 0 ) {
delete m_aItems[uiCount];
}
if ( m_windowStyle & wxLB_OWNERDRAW )
{
size_t uiCount = m_aItems.Count();
while ( uiCount-- != 0 ) {
delete m_aItems[uiCount];
}
m_aItems.Clear();
#else // !wxUSE_OWNER_DRAWN
m_aItems.Clear();
}
else
#endif // wxUSE_OWNER_DRAWN
if ( HasClientObjectData() )
{
for ( size_t n = 0; n < (size_t)m_noItems; n++ )
@@ -373,7 +377,6 @@ void wxListBox::Free()
delete GetClientObject(n);
}
}
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
}
void wxListBox::SetSelection(int N, bool select)

View File

@@ -129,10 +129,12 @@ void wxStaticText::SetLabel(const wxString& label)
{
SetWindowText(GetHwnd(), label);
// adjust the size of the window to fit to the label (this behaviour is
// backward compatible and generally makes sense but we might want to still
// provide the user a way to disable it) (VZ)
DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
// adjust the size of the window to fit to the label unless autoresizing is
// disabled
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
{
DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
}
}
WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,