added wxSizer::Get/SetContainingWindow()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40992 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -233,6 +233,13 @@ windows which manage it.
|
|||||||
\helpref{wxSizer::SetVirtualSizeHints}{wxsizersetvirtualsizehints}
|
\helpref{wxSizer::SetVirtualSizeHints}{wxsizersetvirtualsizehints}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxSizer::GetContainingWindow}\label{wxsizergetcontainingwindow}
|
||||||
|
|
||||||
|
\constfunc{wxWindow *}{GetContainingWindow}{\void}
|
||||||
|
|
||||||
|
Returns the window this sizer is used in or \NULL if none.
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxSizer::GetItem}\label{wxsizergetitem}
|
\membersection{wxSizer::GetItem}\label{wxsizergetitem}
|
||||||
|
|
||||||
\func{wxSizerItem *}{GetItem}{\param{wxWindow* }{window}, \param{bool }{recursive = false}}
|
\func{wxSizerItem *}{GetItem}{\param{wxWindow* }{window}, \param{bool }{recursive = false}}
|
||||||
|
@@ -329,7 +329,7 @@ WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList );
|
|||||||
class WXDLLEXPORT wxSizer: public wxObject, public wxClientDataContainer
|
class WXDLLEXPORT wxSizer: public wxObject, public wxClientDataContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxSizer() { }
|
wxSizer() { m_containingWindow = NULL; }
|
||||||
~wxSizer();
|
~wxSizer();
|
||||||
|
|
||||||
// methods for adding elements to the sizer: there are Add/Insert/Prepend
|
// methods for adding elements to the sizer: there are Add/Insert/Prepend
|
||||||
@@ -410,6 +410,10 @@ public:
|
|||||||
inline wxSizerItem* PrependSpacer(int size);
|
inline wxSizerItem* PrependSpacer(int size);
|
||||||
inline wxSizerItem* PrependStretchSpacer(int prop = 1);
|
inline wxSizerItem* PrependStretchSpacer(int prop = 1);
|
||||||
|
|
||||||
|
// set (or possibly unset if window is NULL) or get the window this sizer
|
||||||
|
// is used in
|
||||||
|
void SetContainingWindow(wxWindow *window);
|
||||||
|
wxWindow *GetContainingWindow() const { return m_containingWindow; }
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_2_6
|
#if WXWIN_COMPATIBILITY_2_6
|
||||||
// Deprecated in 2.6 since historically it does not delete the window,
|
// Deprecated in 2.6 since historically it does not delete the window,
|
||||||
@@ -508,6 +512,9 @@ protected:
|
|||||||
wxPoint m_position;
|
wxPoint m_position;
|
||||||
wxSizerItemList m_children;
|
wxSizerItemList m_children;
|
||||||
|
|
||||||
|
// the window this sizer is used in, can be NULL
|
||||||
|
wxWindow *m_containingWindow;
|
||||||
|
|
||||||
wxSize GetMaxWindowSize( wxWindow *window ) const;
|
wxSize GetMaxWindowSize( wxWindow *window ) const;
|
||||||
wxSize GetMinWindowSize( wxWindow *window );
|
wxSize GetMinWindowSize( wxWindow *window );
|
||||||
wxSize GetMaxClientSize( wxWindow *window ) const;
|
wxSize GetMaxClientSize( wxWindow *window ) const;
|
||||||
|
@@ -506,6 +506,29 @@ wxSizerItem* wxSizer::Insert( size_t index, wxSizerItem *item )
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxSizer::SetContainingWindow(wxWindow *win)
|
||||||
|
{
|
||||||
|
if ( win == m_containingWindow )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_containingWindow = win;
|
||||||
|
|
||||||
|
// set the same window for all nested sizers as well, they also are in the
|
||||||
|
// same window
|
||||||
|
for ( wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
|
||||||
|
node;
|
||||||
|
node = node->GetNext() )
|
||||||
|
{
|
||||||
|
wxSizerItem *const item = node->GetData();
|
||||||
|
wxSizer *const sizer = item->GetSizer();
|
||||||
|
|
||||||
|
if ( sizer )
|
||||||
|
{
|
||||||
|
sizer->SetContainingWindow(win);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_2_6
|
#if WXWIN_COMPATIBILITY_2_6
|
||||||
bool wxSizer::Remove( wxWindow *window )
|
bool wxSizer::Remove( wxWindow *window )
|
||||||
{
|
{
|
||||||
@@ -643,7 +666,7 @@ bool wxSizer::Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive )
|
|||||||
if (item->GetSizer()->Replace( oldwin, newwin, true ))
|
if (item->GetSizer()->Replace( oldwin, newwin, true ))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->GetNext();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,8 +694,8 @@ bool wxSizer::Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive )
|
|||||||
{
|
{
|
||||||
if (item->GetSizer()->Replace( oldsz, newsz, true ))
|
if (item->GetSizer()->Replace( oldsz, newsz, true ))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->GetNext();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,7 +713,7 @@ bool wxSizer::Replace( size_t old, wxSizerItem *newitem )
|
|||||||
|
|
||||||
wxSizerItem *item = node->GetData();
|
wxSizerItem *item = node->GetData();
|
||||||
node->SetData(newitem);
|
node->SetData(newitem);
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -1650,12 +1650,21 @@ void wxWindowBase::SetSizer(wxSizer *sizer, bool deleteOld)
|
|||||||
if ( sizer == m_windowSizer)
|
if ( sizer == m_windowSizer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( deleteOld )
|
if ( m_windowSizer )
|
||||||
delete m_windowSizer;
|
{
|
||||||
|
m_windowSizer->SetContainingWindow(NULL);
|
||||||
|
|
||||||
|
if ( deleteOld )
|
||||||
|
delete m_windowSizer;
|
||||||
|
}
|
||||||
|
|
||||||
m_windowSizer = sizer;
|
m_windowSizer = sizer;
|
||||||
|
if ( m_windowSizer )
|
||||||
|
{
|
||||||
|
m_windowSizer->SetContainingWindow((wxWindow *)this);
|
||||||
|
}
|
||||||
|
|
||||||
SetAutoLayout( sizer != NULL );
|
SetAutoLayout(m_windowSizer != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowBase::SetSizerAndFit(wxSizer *sizer, bool deleteOld)
|
void wxWindowBase::SetSizerAndFit(wxSizer *sizer, bool deleteOld)
|
||||||
|
Reference in New Issue
Block a user