1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/wrapsizer.h
3 // Purpose: provide wrapping sizer for layout (wxWrapSizer)
4 // Author: Arne Steinarson
6 // Copyright: (c) Arne Steinarson
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_WRAPSIZER_H_
11 #define _WX_WRAPSIZER_H_
15 // flags for wxWrapSizer
18 wxEXTEND_LAST_ON_EACH_LINE
= 1,
19 // don't leave spacers in the beginning of a new row
20 wxREMOVE_LEADING_SPACES
= 2,
22 wxWRAPSIZER_DEFAULT_FLAGS
= wxEXTEND_LAST_ON_EACH_LINE
|
23 wxREMOVE_LEADING_SPACES
26 // ----------------------------------------------------------------------------
27 // A box sizer that can wrap items on several lines when sum of widths exceed
28 // available line width.
29 // ----------------------------------------------------------------------------
31 class WXDLLEXPORT wxWrapSizer
: public wxBoxSizer
34 wxWrapSizer(int orient
= wxHORIZONTAL
, int flags
= wxWRAPSIZER_DEFAULT_FLAGS
);
35 virtual ~wxWrapSizer();
37 // override base class virtual methods
38 virtual wxSize
CalcMin();
39 virtual void RecalcSizes();
41 virtual bool InformFirstDirection(int direction
,
43 int availableOtherDir
);
46 // This method is called to decide if an item represents empty space or
47 // not. We do this to avoid having space-only items first or last on a
48 // wrapped line (left alignment).
50 // By default only spacers are considered to be empty items but a derived
51 // class may override this item if some other kind of sizer elements should
52 // be also considered empty for some reason.
53 virtual bool IsSpaceItem(wxSizerItem
*item
) const
55 return item
->IsSpacer();
58 // helpers of CalcMin()
59 void CalcMinFromMinor(int totMinor
);
60 void CalcMinFromMajor(int totMajor
);
61 void CalcMinUsingCurrentLayout();
62 void CalcMinFittingSize(const wxSize
& szBoundary
);
63 void CalcMaxSingleItemSize();
65 // temporarily change the proportion of the last item of the N-th row to
66 // extend to the end of line if the appropriate flag is set
67 void AdjustLastRowItemProp(size_t n
, wxSizerItem
*itemLast
);
69 // remove all the items from m_rows
72 // return the N-th row sizer from m_rows creating it if necessary
73 wxSizer
*GetRowSizer(size_t n
);
75 // should be called after completion of each row
76 void FinishRow(size_t n
, int rowMajor
, int rowMinor
, wxSizerItem
*itemLast
);
79 const int m_flags
; // Flags specified in the ctor
81 int m_dirInform
; // Direction for size information
82 int m_availSize
; // Size available in m_dirInform direction
83 int m_availableOtherDir
; // Size available in the other direction
84 bool m_lastUsed
; // Indicates whether value from InformFirst... has
87 // The sizes below are computed by RecalcSizes(), i.e. they don't have
88 // valid values during the initial call to CalcMin() and they are only
89 // valid for the current layout (i.e. the current number of rows)
90 int m_minSizeMinor
; // Min size in minor direction
91 int m_maxSizeMajor
; // Size of longest row
92 int m_minItemMajor
; // Size of smallest item in major direction
94 wxBoxSizer m_rows
; // Sizer containing multiple rows of our items
96 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWrapSizer
)
99 #endif // _WX_WRAPSIZER_H_