1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxChoicebook: wxChoice and wxNotebook combination
4 // Author: Vadim Zeitlin
5 // Modified by: Wlodzimierz ABX Skiba from wx/listbook.h
8 // Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CHOICEBOOK_H_
13 #define _WX_CHOICEBOOK_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "choicebook.h"
23 #include "wx/bookctrl.h"
25 class WXDLLEXPORT wxChoice
;
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 // wxChoicebook styles
34 // default alignment: top everywhere
37 // put the choice control to the left/right/top/bottom of the page area
43 // the mask which can be used to extract the alignment from the style
44 wxCHB_ALIGN_MASK
= 0xf
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 class WXDLLEXPORT wxChoicebook
: public wxBookCtrl
59 wxChoicebook(wxWindow
*parent
,
61 const wxPoint
& pos
= wxDefaultPosition
,
62 const wxSize
& size
= wxDefaultSize
,
64 const wxString
& name
= wxEmptyString
)
68 (void)Create(parent
, id
, pos
, size
, style
, name
);
72 bool Create(wxWindow
*parent
,
74 const wxPoint
& pos
= wxDefaultPosition
,
75 const wxSize
& size
= wxDefaultSize
,
77 const wxString
& name
= wxEmptyString
);
80 virtual int GetSelection() const;
81 virtual bool SetPageText(size_t n
, const wxString
& strText
);
82 virtual wxString
GetPageText(size_t n
) const;
83 virtual int GetPageImage(size_t n
) const;
84 virtual bool SetPageImage(size_t n
, int imageId
);
85 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
86 virtual bool InsertPage(size_t n
,
91 virtual int SetSelection(size_t n
);
92 virtual void SetImageList(wxImageList
*imageList
);
94 // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
95 bool IsVertical() const { return HasFlag(wxCHB_BOTTOM
| wxCHB_TOP
); }
97 virtual bool DeleteAllPages();
100 virtual wxWindow
*DoRemovePage(size_t page
);
103 // common part of all constructors
106 // get the size which the choice control should have
107 wxSize
GetChoiceSize() const;
110 wxRect
GetPageRect() const;
113 void OnSize(wxSizeEvent
& event
);
114 void OnChoiceSelected(wxCommandEvent
& event
);
117 // the choice control we use for showing the pages index
120 // the currently selected page or wxNOT_FOUND if none
124 DECLARE_EVENT_TABLE()
125 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook
)
128 // ----------------------------------------------------------------------------
129 // choicebook event class and related stuff
130 // ----------------------------------------------------------------------------
132 class WXDLLEXPORT wxChoicebookEvent
: public wxBookCtrlEvent
135 wxChoicebookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
136 int nSel
= -1, int nOldSel
= -1)
137 : wxBookCtrlEvent(commandType
, id
, nSel
, nOldSel
)
142 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebookEvent
)
145 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED
;
146 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING
;
148 typedef void (wxEvtHandler::*wxChoicebookEventFunction
)(wxChoicebookEvent
&);
150 #define EVT_CHOICEBOOK_PAGE_CHANGED(id, fn) \
151 DECLARE_EVENT_TABLE_ENTRY( \
152 wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, \
155 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxChoicebookEventFunction, &fn ), \
159 #define EVT_CHOICEBOOK_PAGE_CHANGING(id, fn) \
160 DECLARE_EVENT_TABLE_ENTRY( \
161 wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, \
164 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxChoicebookEventFunction, &fn ), \
168 #endif // wxUSE_CHOICEBOOK
170 #endif // _WX_CHOICEBOOK_H_