Ok, so we don't need the extra bool at all, we can just zero the sizer

pointer in wxSizerItem.  :-)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18461 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ron Lee 2002-12-30 15:26:47 +00:00
parent 00976fe56b
commit 96fdbb60f1
2 changed files with 7 additions and 16 deletions

View File

@ -50,6 +50,10 @@ public:
virtual void DeleteWindows();
// Enable deleting the SizerItem without destroying the contained sizer.
void DetachSizer()
{ m_sizer = 0; }
virtual wxSize GetSize();
virtual wxSize CalcMin();
virtual void SetDimension( wxPoint pos, wxSize size );
@ -82,8 +86,6 @@ public:
{ m_border = border; }
void Show ( bool show )
{ m_show = show; }
void SetDeleteItem( bool deleteItem = TRUE )
{ m_deleteItem = deleteItem; }
wxWindow *GetWindow() const
{ return m_window; }
@ -124,11 +126,6 @@ protected:
// is shrinked. it is safer to preserve initial value.
float m_ratio;
// If TRUE, and the item is a sizer, delete it when the
// sizeritem is destroyed. Not used for any other type
// of item right now.
bool m_deleteItem;
wxObject *m_userData;
private:

View File

@ -52,7 +52,6 @@ wxSizerItem::wxSizerItem( int width, int height, int option, int flag, int borde
, m_border( border )
, m_flag( flag )
, m_show( TRUE ) // Cannot be changed
, m_deleteItem( FALSE ) // unused for spacer
, m_userData( userData )
{
SetRatio( m_size );
@ -66,7 +65,6 @@ wxSizerItem::wxSizerItem( wxWindow *window, int option, int flag, int border, wx
, m_border( border )
, m_flag( flag )
, m_show( TRUE )
, m_deleteItem( FALSE ) // currently unused for window
, m_userData( userData )
{
// aspect ratio calculated from initial size
@ -83,7 +81,6 @@ wxSizerItem::wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxOb
, m_flag( flag )
, m_show( TRUE )
, m_ratio( 0 )
, m_deleteItem( TRUE ) // we delete sizer items by default.
, m_userData( userData )
{
// m_minSize is calculated later
@ -92,12 +89,9 @@ wxSizerItem::wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxOb
wxSizerItem::~wxSizerItem()
{
// User data is bound to the sizeritem, always delete it.
if (m_userData)
delete m_userData;
// To be able to Detach a sizer, we must be able to veto its deletion here.
if (m_deleteItem && m_sizer)
if (m_sizer)
delete m_sizer;
}
@ -373,7 +367,7 @@ bool wxSizer::Detach( wxSizer *sizer )
wxSizerItem *item = (wxSizerItem*)node->Data();
if (item->GetSizer() == sizer)
{
item->SetDeleteItem( FALSE );
item->DetachSizer();
m_children.DeleteNode( node );
return TRUE;
}
@ -390,7 +384,7 @@ bool wxSizer::Detach( int pos )
wxNode *node = m_children.Nth( pos );
if (!node) return FALSE;
( (wxSizerItem*)node->Data() )->SetDeleteItem( FALSE );
( (wxSizerItem*)node->Data() )->DetachSizer();
m_children.DeleteNode( node );
return TRUE;