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