/////////////////////////////////////////////////////////////////////////////
-// Name: sizer.h
+// Name: wx/sizer.h
// Purpose: provide wxSizer class for layout
// Author: Robert Roebling and Robin Dunn
// Modified by: Ron Lee, Vadim Zeitlin (wxSizerFlags)
class WXDLLEXPORT wxSizerItem;
class WXDLLEXPORT wxSizer;
+#ifndef wxUSE_BORDER_BY_DEFAULT
+ #ifdef __SMARTPHONE__
+ // no borders by default on limited size screen
+ #define wxUSE_BORDER_BY_DEFAULT 0
+ #else
+ #define wxUSE_BORDER_BY_DEFAULT 1
+ #endif
+#endif
+
// ----------------------------------------------------------------------------
// wxSizerFlags: flags used for an item in the sizer
// ----------------------------------------------------------------------------
// some shortcuts for Align()
wxSizerFlags& Centre() { return Align(wxCENTRE); }
wxSizerFlags& Center() { return Centre(); }
+ wxSizerFlags& Top() { return Align(wxALIGN_TOP); }
wxSizerFlags& Left() { return Align(wxALIGN_LEFT); }
wxSizerFlags& Right() { return Align(wxALIGN_RIGHT); }
+ wxSizerFlags& Bottom() { return Align(wxALIGN_BOTTOM); }
+
+ // default border size used by Border() below
+ static int GetDefaultBorder()
+ {
+#if wxUSE_BORDER_BY_DEFAULT
+ // FIXME: default border size shouldn't be hardcoded and at the very
+ // least they should depend on the current font size
+ return 5;
+#else
+ return 0;
+#endif
+ }
wxSizerFlags& Border(int direction, int borderInPixels)
wxSizerFlags& Border(int direction = wxALL)
{
- // FIXME: default border size shouldn't be hardcoded
-#ifdef __SMARTPHONE__
+#if wxUSE_BORDER_BY_DEFAULT
+ return Border(direction, GetDefaultBorder());
+#else
// no borders by default on limited size screen
wxUnusedVar(direction);
return *this;
+#endif
+ }
+
+ wxSizerFlags& DoubleBorder(int direction = wxALL)
+ {
+#if wxUSE_BORDER_BY_DEFAULT
+ return Border(direction, 2*GetDefaultBorder());
+#else
+ wxUnusedVar(direction);
+
+ return *this;
+#endif
+ }
+
+ wxSizerFlags& TripleBorder(int direction = wxALL)
+ {
+#if wxUSE_BORDER_BY_DEFAULT
+ return Border(direction, 3*GetDefaultBorder());
+#else
+ wxUnusedVar(direction);
+
+ return *this;
+#endif
+ }
+
+ wxSizerFlags& HorzBorder()
+ {
+#if wxUSE_BORDER_BY_DEFAULT
+ return Border(wxLEFT | wxRIGHT, GetDefaultBorder());
+#else
+ return *this;
+#endif
+ }
+
+ wxSizerFlags& DoubleHorzBorder()
+ {
+#if wxUSE_BORDER_BY_DEFAULT
+ return Border(wxLEFT | wxRIGHT, 2*GetDefaultBorder());
#else
- return Border(direction, 5);
+ return *this;
#endif
}
+ // setters for the others flags
+ wxSizerFlags& Shaped()
+ {
+ m_flags |= wxSHAPED;
+
+ return *this;
+ }
+
+ wxSizerFlags& FixedMinSize()
+ {
+ m_flags |= wxFIXED_MINSIZE;
+
+ return *this;
+ }
// accessors for wxSizer only
int GetProportion() const { return m_proportion; }
{
public:
wxSizer() { m_containingWindow = NULL; }
- ~wxSizer();
+ virtual ~wxSizer();
// methods for adding elements to the sizer: there are Add/Insert/Prepend
// overloads for each of window/sizer/spacer/wxSizerItem
wxSizerItem* PrependStretchSpacer(int prop = 1);
// set (or possibly unset if window is NULL) or get the window this sizer
- // is used in
+ // is used in
void SetContainingWindow(wxWindow *window);
wxWindow *GetContainingWindow() const { return m_containingWindow; }
virtual bool Detach( wxSizer *sizer );
virtual bool Detach( int index );
- virtual bool Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive = false );
- virtual bool Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive = false );
- virtual bool Replace( size_t index, wxSizerItem *newitem );
+ virtual bool Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive = false );
+ virtual bool Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive = false );
+ virtual bool Replace( size_t index, wxSizerItem *newitem );
virtual void Clear( bool delete_windows = false );
virtual void DeleteWindows();
wxSizerItemList& GetChildren()
{ return m_children; }
+ const wxSizerItemList& GetChildren() const
+ { return m_children; }
void SetDimension( int x, int y, int width, int height );
wxSize GetMinWindowSize( wxWindow *window );
wxSize GetMaxClientSize( wxWindow *window ) const;
wxSize GetMinClientSize( wxWindow *window );
- wxSize FitSize( wxWindow *window );
wxSize VirtualFitSize( wxWindow *window );
virtual void DoSetMinSize( int width, int height );
#endif // wxUSE_BUTTON
-#if WXWIN_COMPATIBILITY_2_4
-// NB: wxBookCtrlSizer and wxNotebookSizer are deprecated, they
-// don't do anything. wxBookCtrlBase::DoGetBestSize does the job now.
// ----------------------------------------------------------------------------
-// wxBookCtrlSizer
+// inline functions implementation
// ----------------------------------------------------------------------------
-#if wxUSE_BOOKCTRL
-
-// this sizer works with wxNotebook/wxListbook/... and sizes the control to
-// fit its pages
-class WXDLLEXPORT wxBookCtrlBase;
-
-class WXDLLEXPORT wxBookCtrlSizer : public wxSizer
-{
-public:
-#if WXWIN_COMPATIBILITY_2_6
- wxDEPRECATED( wxBookCtrlSizer(wxBookCtrlBase *bookctrl) );
-#endif // WXWIN_COMPATIBILITY_2_6
-
- wxBookCtrlBase *GetControl() const { return m_bookctrl; }
-
- virtual void RecalcSizes();
- virtual wxSize CalcMin();
-
-protected:
- // this protected ctor lets us mark the real one above as deprecated
- // and still have warning-free build of the library itself:
- wxBookCtrlSizer() {}
-
- wxBookCtrlBase *m_bookctrl;
-
-private:
- DECLARE_CLASS(wxBookCtrlSizer)
- DECLARE_NO_COPY_CLASS(wxBookCtrlSizer)
-};
-
-
-#if wxUSE_NOTEBOOK
-
-// before wxBookCtrlBase we only had wxNotebookSizer, keep it for backwards
-// compatibility
-class WXDLLEXPORT wxNotebook;
-
-class WXDLLEXPORT wxNotebookSizer : public wxBookCtrlSizer
+inline wxSizerItem*
+wxSizer::Add( wxSizerItem *item )
{
-public:
-#if WXWIN_COMPATIBILITY_2_6
- wxDEPRECATED( wxNotebookSizer(wxNotebook *nb) );
-#endif // WXWIN_COMPATIBILITY_2_6
-
- wxNotebook *GetNotebook() const { return (wxNotebook *)m_bookctrl; }
-
-private:
- DECLARE_CLASS(wxNotebookSizer)
- DECLARE_NO_COPY_CLASS(wxNotebookSizer)
-};
-
-#endif // wxUSE_NOTEBOOK
-
-#endif // wxUSE_BOOKCTRL
-
-#endif // WXWIN_COMPATIBILITY_2_4
-
-// ----------------------------------------------------------------------------
-// inline functions implementation
-// ----------------------------------------------------------------------------
+ return Insert( m_children.GetCount(), item );
+}
inline wxSizerItem*
wxSizer::Add( wxWindow *window, int proportion, int flag, int border, wxObject* userData )
return Add( new wxSizerItem(sizer, flags) );
}
-inline wxSizerItem*
-wxSizer::Add( wxSizerItem *item )
-{
- return Insert( m_children.GetCount(), item );
-}
-
inline wxSizerItem*
wxSizer::AddSpacer(int size)
{
return Add(0, 0, prop);
}
+inline wxSizerItem*
+wxSizer::Prepend( wxSizerItem *item )
+{
+ return Insert( 0, item );
+}
+
inline wxSizerItem*
wxSizer::Prepend( wxWindow *window, int proportion, int flag, int border, wxObject* userData )
{
return Prepend( new wxSizerItem( width, height, proportion, flag, border, userData ) );
}
-inline wxSizerItem*
-wxSizer::Prepend( wxSizerItem *item )
-{
- return Insert( 0, item );
-}
-
inline wxSizerItem*
wxSizer::PrependSpacer(int size)
{
#endif // __WXSIZER_H__
-