1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wxFoldPanelItem.h
4 // Created: Tuesday, June 22, 2004 21:01:02
6 /////////////////////////////////////////////////////////////////////////////
8 #ifndef __WXFOLDPANELITEM_H__
9 #define __WXFOLDPANELITEM_H__
15 #include "captionbar.h"
17 #define wxFPB_ALIGN_LEFT 0
18 #define wxFPB_ALIGN_WIDTH 1
20 #define wxFPB_DEFAULT_LEFTSPACING 5
21 #define wxFPB_DEFAULT_RIGHTSPACING 10
22 #define wxFPB_DEFAULT_YSPACING 8
24 #define wxFPB_DEFAULT_LEFTLINESPACING 2
25 #define wxFPB_DEFAULT_RIGHTLINESPACING 2
27 class wxFoldWindowItem
35 int _lineWidth
, _lineY
;
36 wxColour _sepLineColour
;
45 // wxWindow constructor. This initialises the class as a wxWindow type
46 wxFoldWindowItem(wxWindow
*wnd
, int flags
= wxFPB_ALIGN_WIDTH
, int ySpacing
= wxFPB_DEFAULT_YSPACING
,
47 int leftSpacing
= wxFPB_DEFAULT_LEFTSPACING
, int rightSpacing
= wxFPB_DEFAULT_RIGHTSPACING
)
51 , _leftSpacing(leftSpacing
)
52 , _rightSpacing(rightSpacing
)
59 // separator constructor. This initialises the class as a separator type
60 wxFoldWindowItem(int y
, const wxColour
&lineColor
= *wxBLACK
, int ySpacing
= wxFPB_DEFAULT_YSPACING
,
61 int leftSpacing
= wxFPB_DEFAULT_LEFTLINESPACING
,
62 int rightSpacing
= wxFPB_DEFAULT_RIGHTLINESPACING
)
66 , _leftSpacing(leftSpacing
)
67 , _rightSpacing(rightSpacing
)
68 , _flags(wxFPB_ALIGN_WIDTH
)
69 , _sepLineColour(lineColor
)
75 // TODO: Make a c'tor for a captioned splitter
81 int GetLineY() const {
85 int GetLineWidth() const {
89 const wxColour
&GetLineColour() const {
90 return _sepLineColour
;
93 int GetLeftSpacing() const {
97 int GetRightSpacing() const {
101 int GetYSpacing() const {
105 // returns the window height if type is wxFoldWindowItem::WINDOW
106 // and returns the total size plus the extra spacing
108 int GetWindowHeight() const {
113 wxSize size
= _wnd
->GetSize();
114 value
= size
.GetHeight() + _ySpacing
;
116 else if(_type
== SEPARATOR
)
117 value
= 1 + _ySpacing
;
122 // resize the element, whatever it is. A separator or
123 // line will be always alligned by width
125 void ResizeItem(int width
) {
126 if((_flags
& wxFPB_ALIGN_WIDTH
))
128 // allign by taking full width
129 int myWidth
= width
- _leftSpacing
- _rightSpacing
;
132 myWidth
= 10; // can't have negative width
134 if(_type
== SEPARATOR
)
135 _lineWidth
= myWidth
;
138 wxCHECK2(_wnd
, return);
139 _wnd
->SetSize(wxSize(myWidth
, -1));
146 #include <wx/dynarray.h>
147 WX_DECLARE_OBJARRAY(wxFoldWindowItem
, wxFoldWindowItemArray
);
152 This class is a child sibling of the wxFoldPanelBar class. It will be containing a wxCaptionBar class
153 for receiving of events, and a the rest of the area can be populated by a wxPanel derived class.
156 class wxFoldPanelItem
: public wxPanel
159 wxCaptionBar
*_captionBar
;
161 bool _controlCreated
;
169 DECLARE_CLASS( wxFoldPanelItem
)
170 DECLARE_EVENT_TABLE()
173 wxFoldWindowItemArray _items
;
175 void OnSize(wxSizeEvent
&event
);
176 void OnPressCaption(wxCaptionBarEvent
&event
);
177 void OnPaint(wxPaintEvent
&event
);
180 // constructors and destructors
181 wxFoldPanelItem( wxWindow
*parent
, const wxString
&caption
, wxImageList
*icons
= 0, bool collapsedInitially
= false,
182 const wxCaptionBarStyle
&style
= wxEmptyCaptionBarStyle
);
183 virtual ~wxFoldPanelItem();
185 /** Add a window item to the list of items on this panel. The flags are wxFPB_ALIGN_LEFT for a non sizing
186 window element, and wxFPB_ALIGN_WIDTH for a width alligned item. The ySpacing parameter reserves a number
187 of pixels before the window element, and leftSpacing is an indent. rightSpacing is only relevant when the
188 style wxFPB_ALIGN_WIDTH is chosen. */
189 void AddWindow(wxWindow
*window
, int flags
, int ySpacing
, int leftSpacing
, int rightSpacing
);
191 void AddSeparator(const wxColour
&color
, int ySpacing
, int leftSpacing
, int rightSpacing
);
193 /** Repositions this wxFoldPanelBar and reports the height occupied for the next wxFoldPanelBar in the
195 int Reposition(int y
);
199 /** Return expanded or collapsed status. If the panel is expanded, true is returned */
200 bool IsExpanded() const {
201 return !_captionBar
->IsCollapsed();
210 // this should not be called by the user, because it doesn't trigger the parent
211 // to tell it that we are collapsed or expanded, it only changes visual state
213 _captionBar
->Collapse();
217 // this should not be called by the user, because it doesn't trigger the parent
218 // to tell it that we are collapsed or expanded, it only changes visual state
220 _captionBar
->Expand();
224 /* Return size of panel */
226 int GetPanelHeight() const {
227 if(_captionBar
->IsCollapsed())
228 return GetCaptionHeight();
234 // returns height of caption only. This is for folding calulation
237 int GetCaptionHeight() const {
238 wxSize size
= _captionBar
->GetSize();
239 return size
.GetHeight();
242 void ApplyCaptionStyle(const wxCaptionBarStyle
&style
) {
243 wxCHECK2(_captionBar
, return);
244 _captionBar
->SetCaptionStyle(false, style
);
247 wxCaptionBarStyle
GetCaptionStyle() {
248 wxCHECK(_captionBar
, wxEmptyCaptionBarStyle
);
249 return _captionBar
->GetCaptionStyle();
254 #endif // _NO_DOXYGEN_
256 #endif // __WXFOLDPANELITEM_H__