- /** Sets the style of the caption bar (called wxCaptionBar) of the wxFoldPanel. The changes are applied immediately.
- All styles not set in the wxCaptionBarStyle class are not applied. Use the wxCaptionBar reference to indicate
- what captionbar you want to apply the style to. To apply one style to all wxCaptionBar items, use
- ApplyCaptionStyleAll() */
- void ApplyCaptionStyle(wxFoldPanel &fp, const wxCaptionBarStyle &style) {
- wxCHECK2(fp.IsOk(), return);
- fp.GetItem()->ApplyCaptionStyle(style);
- };
-
- /** Sets the style of all the caption bars of the wxFoldPanel. The changes are applied immediately */
- void ApplyCaptionStyleAll(const wxCaptionBarStyle &style) {
- for(size_t i = 0; i < GetCount(); i++)
- {
- wxFoldPanel item = Item(i);
- ApplyCaptionStyle(item, style);
- }
- };
-
- /** Returns the currently used caption style for the wxFoldPanel. It is returned as a wxCaptionBarStyle class.
- after modifying it, it can be set again */
- wxCaptionBarStyle GetCaptionStyle(wxFoldPanel &fp) const {
- wxCHECK2(fp.IsOk(), wxEmptyCaptionBarStyle);
- return fp.GetItem()->GetCaptionStyle();
- };
+ The wxWindow to be added can be slightly indented from left and right so it is more visibly placed
+ in the wxFoldPanel. Use ySpacing > 0 to give the control an y offset from the previous wxWindow added,
+ use leftSpacing to give it a slight indent from the left, and rightSpacing also reserves a little space
+ on the right so the wxWindow can be properly placed in the wxFoldPanel.
+
+ The following example adds a wxFoldPanel to the wxFoldPanelBar and adds two wxWindow derived controls
+ to the wxFoldPanel:
+
+ \code
+
+ // create the wxFoldPanelBar
+ m_pnl = new wxFoldPanelBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, wxFPB_COLLAPSE_TO_BOTTOM);
+
+ // add a foldpanel to the control. "Test me" is the caption and it is initially not collapsed.
+ wxFoldPanel item = m_pnl->AddFoldPanel(wxT("Test me"), false);
+
+ // now add a button to the fold panel. Mind that the button should be made child of the
+ // wxFoldPanel and not of the main form.
+ m_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, wxT("Collapse Me")));
+
+ // add a separator between the two controls. This is purely a visual line that can have a certain
+ // color and also the indents and width alligning like a control.
+ m_pnl->AddFoldPanelSeperator(item);
+
+ // now add a text ctrl. Also very easy. Align this on width so that when the control gets wider
+ // the text control also sizes along.
+ m_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, wxT("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 20);
+
+ \endcode
+ */
+ int AddFoldPanelWindow(const wxFoldPanel &panel, wxWindow *window, int flags = wxFPB_ALIGN_WIDTH,
+ int Spacing = wxFPB_DEFAULT_SPACING, int leftSpacing = wxFPB_DEFAULT_LEFTSPACING,
+ int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING);
+
+ /** Adds a separator line to the current wxFoldPanel. The separator is a simple line which is drawn and is no
+ real component. It can be used to separate groups of controls which belong to each other. The colour is
+ adjustable, and it takes the same ySpacing, leftSpacing and rightSpacing as AddFoldPanelWindow(). */
+ int AddFoldPanelSeperator(const wxFoldPanel &panel, const wxColour &color = wxColour(167,167,167),
+ int Spacing = wxFPB_DEFAULT_SPACING, int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
+ int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING);
+
+ /** Returns the number of panels currently present in the wxFoldPanelBar. This is independent if they are
+ visible or hidden. */
+ size_t GetCount() const {
+ return m_panels.GetCount();
+ };
+
+ inline bool IsVertical() const
+ {
+ return HasFlag(wxFPB_VERTICAL);
+ }
+
+ /** Returns the wxFoldPanel reference belonging to the current index. An empty panel is returned when the
+ index is out of bounds. Use GetCount() to get the amount of panels present. Collapsing and folding the
+ panel does not change the order in which they are indexed. So it is safe enough to keep a reference
+ to the panel by number. */
+ wxFoldPanel Item(size_t i) {
+ wxCHECK((int)i >= 0 && i < GetCount(), wxFoldPanel(0));
+ return wxFoldPanel(m_panels.Item(i));
+ };
+
+ /** Collapses the given wxFoldPanel reference, and updates the foldpanel bar. In the wxFPB_COLLAPSE_TO_BOTTOM
+ style, all collapsed captions are put at the bottom of the control. In the normal mode, they stay where
+ they are */
+ void Collapse(const wxFoldPanel &item) {
+ wxCHECK2(item.IsOk(), return);
+ item.GetItem()->Collapse();
+
+ RefreshPanelsFrom(item.GetItem());
+ };
+
+ /** Expands the given wxFoldPanel reference, and updates the foldpanel bar. In the wxFPB_COLLAPSE_TO_BOTTOM
+ they will be removed from the bottom and the order where the panel originally was placed is restored. */
+ void Expand(const wxFoldPanel &item) {
+ wxCHECK2(item.IsOk(), return);
+ item.GetItem()->Expand();
+
+ RefreshPanelsFrom(item.GetItem());
+ };