1 /////////////////////////////////////////////////////////////////////////////
2 // Name: foldpanelitem.h
3 // Purpose: wxFoldPanel
4 // Author: Jorgen Bodde
8 // Copyright: (c) Jorgen Bodde
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __WXFOLDPANELITEM_H__
13 #define __WXFOLDPANELITEM_H__
19 #include "captionbar.h"
21 #define wxFPB_ALIGN_LEFT 0
22 #define wxFPB_ALIGN_WIDTH 1
24 #define wxFPB_DEFAULT_LEFTSPACING 5
25 #define wxFPB_DEFAULT_RIGHTSPACING 10
26 #define wxFPB_DEFAULT_YSPACING 8
28 #define wxFPB_DEFAULT_LEFTLINESPACING 2
29 #define wxFPB_DEFAULT_RIGHTLINESPACING 2
31 class wxFoldWindowItem
39 int _lineWidth
, _lineY
;
40 wxColour _sepLineColour
;
49 // wxWindow constructor. This initialises the class as a wxWindow type
50 wxFoldWindowItem(wxWindow
*wnd
, int flags
= wxFPB_ALIGN_WIDTH
, int ySpacing
= wxFPB_DEFAULT_YSPACING
,
51 int leftSpacing
= wxFPB_DEFAULT_LEFTSPACING
, int rightSpacing
= wxFPB_DEFAULT_RIGHTSPACING
)
55 , _leftSpacing(leftSpacing
)
56 , _rightSpacing(rightSpacing
)
63 // separator constructor. This initialises the class as a separator type
64 wxFoldWindowItem(int y
, const wxColour
&lineColor
= *wxBLACK
, int ySpacing
= wxFPB_DEFAULT_YSPACING
,
65 int leftSpacing
= wxFPB_DEFAULT_LEFTLINESPACING
,
66 int rightSpacing
= wxFPB_DEFAULT_RIGHTLINESPACING
)
69 , _flags(wxFPB_ALIGN_WIDTH
)
70 , _leftSpacing(leftSpacing
)
71 , _rightSpacing(rightSpacing
)
75 , _sepLineColour(lineColor
)
79 // TODO: Make a c'tor for a captioned splitter
85 int GetLineY() const {
89 int GetLineWidth() const {
93 const wxColour
&GetLineColour() const {
94 return _sepLineColour
;
97 int GetLeftSpacing() const {
101 int GetRightSpacing() const {
102 return _rightSpacing
;
105 int GetYSpacing() const {
109 // returns the window height if type is wxFoldWindowItem::WINDOW
110 // and returns the total size plus the extra spacing
112 int GetWindowHeight() const {
117 wxSize size
= _wnd
->GetSize();
118 value
= size
.GetHeight() + _ySpacing
;
120 else if(_type
== SEPARATOR
)
121 value
= 1 + _ySpacing
;
126 // resize the element, whatever it is. A separator or
127 // line will be always alligned by width
129 void ResizeItem(int width
) {
130 if((_flags
& wxFPB_ALIGN_WIDTH
))
132 // allign by taking full width
133 int myWidth
= width
- _leftSpacing
- _rightSpacing
;
136 myWidth
= 10; // can't have negative width
138 if(_type
== SEPARATOR
)
139 _lineWidth
= myWidth
;
142 wxCHECK2(_wnd
, return);
143 _wnd
->SetSize(wxSize(myWidth
, wxDefaultCoord
));
150 #include <wx/dynarray.h>
151 WX_DECLARE_OBJARRAY(wxFoldWindowItem
, wxFoldWindowItemArray
);
156 This class is a child sibling of the wxFoldPanelBar class. It will be containing a wxCaptionBar class
157 for receiving of events, and a the rest of the area can be populated by a wxPanel derived class.
160 class WXDLLIMPEXP_FOLDBAR wxFoldPanelItem
: public wxPanel
163 wxCaptionBar
*_captionBar
;
165 bool _controlCreated
;
173 DECLARE_CLASS( wxFoldPanelItem
)
174 DECLARE_EVENT_TABLE()
177 wxFoldWindowItemArray _items
;
179 void OnSize(wxSizeEvent
&event
);
180 void OnPressCaption(wxCaptionBarEvent
&event
);
181 void OnPaint(wxPaintEvent
&event
);
184 // constructors and destructors
185 wxFoldPanelItem( wxWindow
*parent
, const wxString
&caption
, wxImageList
*icons
= 0, bool collapsedInitially
= false,
186 const wxCaptionBarStyle
&style
= wxEmptyCaptionBarStyle
);
187 virtual ~wxFoldPanelItem();
189 /** Add a window item to the list of items on this panel. The flags are wxFPB_ALIGN_LEFT for a non sizing
190 window element, and wxFPB_ALIGN_WIDTH for a width alligned item. The ySpacing parameter reserves a number
191 of pixels before the window element, and leftSpacing is an indent. rightSpacing is only relevant when the
192 style wxFPB_ALIGN_WIDTH is chosen. */
193 void AddWindow(wxWindow
*window
, int flags
, int ySpacing
, int leftSpacing
, int rightSpacing
);
195 void AddSeparator(const wxColour
&color
, int ySpacing
, int leftSpacing
, int rightSpacing
);
197 /** Repositions this wxFoldPanelBar and reports the height occupied for the next wxFoldPanelBar in the
199 int Reposition(int y
);
203 /** Return expanded or collapsed status. If the panel is expanded, true is returned */
204 bool IsExpanded() const {
205 return !_captionBar
->IsCollapsed();
214 // this should not be called by the user, because it doesn't trigger the parent
215 // to tell it that we are collapsed or expanded, it only changes visual state
217 _captionBar
->Collapse();
221 // this should not be called by the user, because it doesn't trigger the parent
222 // to tell it that we are collapsed or expanded, it only changes visual state
224 _captionBar
->Expand();
228 /* Return size of panel */
230 int GetPanelHeight() const {
231 if(_captionBar
->IsCollapsed())
232 return GetCaptionHeight();
238 // returns height of caption only. This is for folding calulation
241 int GetCaptionHeight() const {
242 wxSize size
= _captionBar
->GetSize();
243 return size
.GetHeight();
246 void ApplyCaptionStyle(const wxCaptionBarStyle
&style
) {
247 wxCHECK2(_captionBar
, return);
248 _captionBar
->SetCaptionStyle(false, style
);
251 wxCaptionBarStyle
GetCaptionStyle() {
252 wxCHECK(_captionBar
, wxEmptyCaptionBarStyle
);
253 return _captionBar
->GetCaptionStyle();
258 #endif // _NO_DOXYGEN_
260 #endif // __WXFOLDPANELITEM_H__