wxASSERT_MSG( GetChildren().GetCount() == 0, _T("children not destroyed") );
+ // make sure that there are no dangling pointers left pointing to us
+ wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
+ if ( panel )
+ {
+ if ( panel->GetLastFocus() == this )
+ {
+ panel->SetLastFocus((wxWindow *)NULL);
+ }
+ }
+
#if wxUSE_CARET
if ( m_caret )
delete m_caret;
Move(new_x, new_y);
}
+// Center TopLevel windows over thier parent instead of the whole screen
+void wxWindowBase::CentreOnParent(int direction)
+{
+ wxPoint ppos;
+ wxSize psze;
+ wxSize wsze;
+ wxWindow* parent = GetParent();
+ int x, y;
+
+ if (!parent || !IsTopLevel()) {
+ Centre(direction);
+ return;
+ }
+
+ psze = parent->GetSize();
+ ppos = parent->ClientToScreen(wxPoint(0,0));
+ wsze = GetSize();
+
+ x = y = -1;
+
+ if (direction == wxBOTH || direction == wxHORIZONTAL)
+ x = ppos.x + (psze.x - wsze.x)/2;
+ if (direction == wxBOTH || direction == wxVERTICAL)
+ y = ppos.y + (psze.y - wsze.y)/2;
+
+ Move(x, y);
+}
+
// fits the window around the children
void wxWindowBase::Fit()
{
int maxX = 0,
maxY = 0;
- wxWindowList::Node *node = GetChildren().GetFirst();
- while ( node )
+ for ( wxWindowList::Node *node = GetChildren().GetFirst();
+ node;
+ node = node->GetNext() )
{
wxWindow *win = node->GetData();
if ( win->IsTopLevel() )
maxX = wx + ww;
if ( wy + wh > maxY )
maxY = wy + wh;
-
- node = node->GetNext();
}
// leave a margin
if ( m_caret )
{
wxASSERT_MSG( m_caret->GetWindow() == this,
- "caret should be created associated to this window" );
+ _T("caret should be created associated to this window") );
}
}
#endif // wxUSE_CARET