X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3c7fc996a73e9f6a83067bc28a3c5581a3fee65..533bedbf307fd324ebc864ad1b5292977c4fa7bc:/include/wx/sizer.h?ds=sidebyside diff --git a/include/wx/sizer.h b/include/wx/sizer.h index e278b0d2ba..f05a5e3e66 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// 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) @@ -25,6 +25,15 @@ class WXDLLEXPORT wxBoxSizer; 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 // ---------------------------------------------------------------------------- @@ -69,6 +78,18 @@ public: wxSizerFlags& Left() { return Align(wxALIGN_LEFT); } wxSizerFlags& Right() { return Align(wxALIGN_RIGHT); } + // 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) { @@ -82,17 +103,55 @@ public: 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 - return Border(direction, 5); + 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 *this; +#endif + } // accessors for wxSizer only int GetProportion() const { return m_proportion; } @@ -408,7 +467,7 @@ public: 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; } @@ -425,9 +484,9 @@ public: 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(); @@ -835,6 +894,12 @@ private: // inline functions implementation // ---------------------------------------------------------------------------- +inline wxSizerItem* +wxSizer::Add( wxSizerItem *item ) +{ + return Insert( m_children.GetCount(), item ); +} + inline wxSizerItem* wxSizer::Add( wxWindow *window, int proportion, int flag, int border, wxObject* userData ) { @@ -865,12 +930,6 @@ wxSizer::Add( wxSizer *sizer, const wxSizerFlags& flags ) return Add( new wxSizerItem(sizer, flags) ); } -inline wxSizerItem* -wxSizer::Add( wxSizerItem *item ) -{ - return Insert( m_children.GetCount(), item ); -} - inline wxSizerItem* wxSizer::AddSpacer(int size) { @@ -883,6 +942,12 @@ wxSizer::AddStretchSpacer(int prop) 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 ) { @@ -901,12 +966,6 @@ wxSizer::Prepend( int width, int height, int proportion, int flag, int border, w 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) { @@ -991,4 +1050,3 @@ wxSizer::InsertStretchSpacer(size_t index, int prop) #endif // __WXSIZER_H__ -