// classes
//---------------------------------------------------------------------------
-class WXDLLEXPORT wxButton;
-class WXDLLEXPORT wxBoxSizer;
-class WXDLLEXPORT wxSizerItem;
-class WXDLLEXPORT wxSizer;
+class WXDLLIMPEXP_FWD_CORE wxButton;
+class WXDLLIMPEXP_FWD_CORE wxBoxSizer;
+class WXDLLIMPEXP_FWD_CORE wxSizerItem;
+class WXDLLIMPEXP_FWD_CORE wxSizer;
#ifndef wxUSE_BORDER_BY_DEFAULT
#ifdef __SMARTPHONE__
virtual wxRect GetRect() { return m_rect; }
+ // set a sizer item id (different from a window id, all sizer items,
+ // including spacers, can have an associated id)
+ void SetId(int id) { m_id = id; }
+ int GetId() const { return m_id; }
+
bool IsWindow() const { return m_kind == Item_Window; }
bool IsSizer() const { return m_kind == Item_Sizer; }
bool IsSpacer() const { return m_kind == Item_Spacer; }
wxPoint GetPosition() const
{ return m_pos; }
+ // Called once the first component of an item has been decided. This is
+ // used in algorithms that depend on knowing the size in one direction
+ // before the min size in the other direction can be known.
+ // Returns true if it made use of the information (and min size was changed).
+ bool InformFirstDirection( int direction, int size, int availableOtherDir=-1 );
+
// these functions delete the current contents of the item if it's a sizer
// or a spacer but not if it is a window
void AssignWindow(wxWindow *window)
int m_proportion;
int m_border;
int m_flag;
+ int m_id;
// on screen rectangle of this item (not including borders)
wxRect m_rect;
wxObject* userData = NULL);
wxSizerItem* Add( wxWindow *window, const wxSizerFlags& flags);
wxSizerItem* Add( wxSizer *sizer, const wxSizerFlags& flags);
+ wxSizerItem* Add( int width, int height, const wxSizerFlags& flags);
wxSizerItem* Add( wxSizerItem *item);
wxSizerItem* AddSpacer(int size);
wxSizerItem* Insert(size_t index,
wxSizer *sizer,
const wxSizerFlags& flags);
+ wxSizerItem* Insert(size_t index,
+ int width,
+ int height,
+ const wxSizerFlags& flags);
virtual wxSizerItem* Insert( size_t index, wxSizerItem *item);
wxSizerItem* InsertSpacer(size_t index, int size);
wxObject* userData = NULL);
wxSizerItem* Prepend(wxWindow *window, const wxSizerFlags& flags);
wxSizerItem* Prepend(wxSizer *sizer, const wxSizerFlags& flags);
+ wxSizerItem* Prepend(int width, int height, const wxSizerFlags& flags);
wxSizerItem* Prepend(wxSizerItem *item);
wxSizerItem* PrependSpacer(int size);
virtual void Clear( bool delete_windows = false );
virtual void DeleteWindows();
+ // Inform sizer about the first direction that has been decided (by parent item)
+ // Returns true if it made use of the informtion (and recalculated min size)
+ virtual bool InformFirstDirection( int WXUNUSED(direction), int WXUNUSED(size), int WXUNUSED(availableOtherDir) )
+ { return false; }
+
void SetMinSize( int width, int height )
{ DoSetMinSize( width, height ); }
void SetMinSize( const wxSize& size )
wxSize Fit( wxWindow *window );
void FitInside( wxWindow *window );
void SetSizeHints( wxWindow *window );
- void SetVirtualSizeHints( wxWindow *window );
+#if WXWIN_COMPATIBILITY_2_8
+ // This only calls FitInside() since 2.9
+ wxDEPRECATED( void SetVirtualSizeHints( wxWindow *window ) );
+#endif
wxSizerItemList& GetChildren()
{ return m_children; }
wxSizerItem* GetItem( wxWindow *window, bool recursive = false );
wxSizerItem* GetItem( wxSizer *sizer, bool recursive = false );
wxSizerItem* GetItem( size_t index );
+ wxSizerItem* GetItemById( int id, bool recursive = false );
// Manage whether individual scene items are considered
// in the layout calculations or not.
protected:
void AdjustForFlexDirection();
- void AdjustForGrowables(const wxSize& sz, const wxSize& minsz,
- int nrows, int ncols);
+ void AdjustForGrowables(const wxSize& sz);
+ void FindWidthsAndHeights(int nrows, int ncols);
// the heights/widths of all rows/columns
wxArrayInt m_rowHeights,
wxBoxSizer(int orient)
{
m_orient = orient;
+ m_totalProportion = 0;
wxASSERT_MSG( m_orient == wxHORIZONTAL || m_orient == wxVERTICAL,
_T("invalid value for wxBoxSizer orientation") );
protected:
// helpers for our code: this returns the component of the given wxSize in
// the direction of the sizer and in the other direction, respectively
- int SizeInMajorDir(const wxSize& sz) const
+ int GetSizeInMajorDir(const wxSize& sz) const
{
return m_orient == wxHORIZONTAL ? sz.x : sz.y;
}
return m_orient == wxHORIZONTAL ? pt.x : pt.y;
}
- int SizeInMinorDir(const wxSize& sz) const
+ int GetSizeInMinorDir(const wxSize& sz) const
{
return m_orient == wxHORIZONTAL ? sz.y : sz.x;
}
DECLARE_CLASS(wxBoxSizer)
};
+//---------------------------------------------------------------------------
+// wxWrapSizer - A box sizer that can wrap items on several lines when
+// widths exceed available width.
+//---------------------------------------------------------------------------
+
+// Borrow unused flag value
+#define wxEXTEND_LAST_ON_EACH_LINE wxFULL_REPAINT_ON_RESIZE
+
+class WXDLLEXPORT wxWrapSizer: public wxBoxSizer
+{
+public:
+ wxWrapSizer( int orient=wxHORIZONTAL, int flags=wxEXTEND_LAST_ON_EACH_LINE );
+ virtual ~wxWrapSizer();
+
+ virtual void RecalcSizes();
+ virtual wxSize CalcMin();
+
+ virtual bool InformFirstDirection( int direction, int size, int availableOtherDir );
+
+protected:
+ int m_prim_size_last; // Size in primary direction last time
+ int m_n_line; // Number of lines
+ wxBoxSizer m_rows; // Rows of items
+ int m_flags;
+
+ void AdjustPropLastItem(wxSizer *psz, wxSizerItem *itemLast);
+
+ DECLARE_DYNAMIC_CLASS(wxWrapSizer)
+};
+
//---------------------------------------------------------------------------
// wxStaticBoxSizer
//---------------------------------------------------------------------------
#if wxUSE_STATBOX
-class WXDLLEXPORT wxStaticBox;
+class WXDLLIMPEXP_FWD_CORE wxStaticBox;
class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer
{
return Add( new wxSizerItem(sizer, flags) );
}
+inline wxSizerItem*
+wxSizer::Add( int width, int height, const wxSizerFlags& flags )
+{
+ return Add( new wxSizerItem(width, height, flags) );
+}
+
inline wxSizerItem*
wxSizer::AddSpacer(int size)
{
return Prepend( new wxSizerItem(sizer, flags) );
}
+inline wxSizerItem*
+wxSizer::Prepend( int width, int height, const wxSizerFlags& flags )
+{
+ return Prepend( new wxSizerItem(width, height, flags) );
+}
+
inline wxSizerItem*
wxSizer::Insert( size_t index,
wxWindow *window,
return Insert( index, new wxSizerItem(sizer, flags) );
}
+inline wxSizerItem*
+wxSizer::Insert( size_t index, int width, int height, const wxSizerFlags& flags )
+{
+ return Insert( index, new wxSizerItem(width, height, flags) );
+}
+
inline wxSizerItem*
wxSizer::InsertSpacer(size_t index, int size)
{