m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_BTNFACE);
m_foregroundColour = *wxBLACK; // TODO take this from sys settings too?
+#ifndef __WXMAC__
m_font = *wxSWISS_FONT; // and this?
-
+#else
+ m_font = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
+#endif
// no style bits
m_windowStyle = 0;
const wxSize& WXUNUSED(size),
long style,
#if wxUSE_VALIDATORS
-# if defined(__VISAGECPP__)
- const wxValidator* validator,
-# else
const wxValidator& validator,
-# endif
#endif
const wxString& name)
{
}
// ----------------------------------------------------------------------------
-// centre/fit the window
+// size/position related methods
// ----------------------------------------------------------------------------
// centre the window with respect to its parent in either (or both) directions
yNew += posParent.y;
}
+ // move the centre of this window to this position
Move(xNew, yNew);
}
// fits the window around the children
void wxWindowBase::Fit()
{
- int maxX = 0,
- maxY = 0;
+ if ( GetChildren().GetCount() > 0 )
+ {
+ SetClientSize(DoGetBestSize());
+ }
+ //else: do nothing if we have no children
+}
- for ( wxWindowList::Node *node = GetChildren().GetFirst();
- node;
- node = node->GetNext() )
+// return the size best suited for the current window
+wxSize wxWindowBase::DoGetBestSize() const
+{
+ if ( GetChildren().GetCount() > 0 )
{
- wxWindow *win = node->GetData();
- if ( win->IsTopLevel() )
+ // our minimal acceptable size is such that all our windows fit inside
+ int maxX = 0,
+ maxY = 0;
+
+ for ( wxWindowList::Node *node = GetChildren().GetFirst();
+ node;
+ node = node->GetNext() )
{
- // dialogs and frames lie in different top level windows - don't
- // deal with them here
- continue;
+ wxWindow *win = node->GetData();
+ if ( win->IsTopLevel() )
+ {
+ // dialogs and frames lie in different top level windows -
+ // don't deal with them here
+ continue;
+ }
+
+ int wx, wy, ww, wh;
+ win->GetPosition(&wx, &wy);
+ win->GetSize(&ww, &wh);
+ if ( wx + ww > maxX )
+ maxX = wx + ww;
+ if ( wy + wh > maxY )
+ maxY = wy + wh;
}
- int wx, wy, ww, wh;
- win->GetPosition(&wx, &wy);
- win->GetSize(&ww, &wh);
- if ( wx + ww > maxX )
- maxX = wx + ww;
- if ( wy + wh > maxY )
- maxY = wy + wh;
+ // leave a margin
+ return wxSize(maxX + 7, maxY + 14);
+ }
+ else
+ {
+ // for a generic window there is no natural best size - just use the
+ // current one
+ return GetSize();
}
-
- // leave a margin
- SetClientSize(maxX + 7, maxY + 14);
}
// set the min/max size of the window
-
void wxWindowBase::SetSizeHints(int minW, int minH,
int maxW, int maxH,
int WXUNUSED(incW), int WXUNUSED(incH))
// validators
// ----------------------------------------------------------------------------
-# if defined(__VISAGECPP__)
-void wxWindowBase::SetValidator(const wxValidator* validator)
-{
- if ( m_windowValidator )
- delete m_windowValidator;
-
- m_windowValidator = (wxValidator *)validator->Clone();
-
- if ( m_windowValidator )
- m_windowValidator->SetWindow(this) ;
-}
-# else
void wxWindowBase::SetValidator(const wxValidator& validator)
{
if ( m_windowValidator )
if ( m_windowValidator )
m_windowValidator->SetWindow(this) ;
}
-# endif // __VISAGECPP__
#endif // wxUSE_VALIDATORS
// ----------------------------------------------------------------------------