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_
19 #include "wx/bookctrl.h"
20 #include "wx/choice.h"
22 class WXDLLEXPORT wxChoice
;
24 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED
;
25 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING
;
28 #define wxCHB_DEFAULT wxBK_DEFAULT
29 #define wxCHB_TOP wxBK_TOP
30 #define wxCHB_BOTTOM wxBK_BOTTOM
31 #define wxCHB_LEFT wxBK_LEFT
32 #define wxCHB_RIGHT wxBK_RIGHT
33 #define wxCHB_ALIGN_MASK wxBK_ALIGN_MASK
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 class WXDLLEXPORT wxChoicebook
: public wxBookCtrlBase
47 wxChoicebook(wxWindow
*parent
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
52 const wxString
& name
= wxEmptyString
)
56 (void)Create(parent
, id
, pos
, size
, style
, name
);
60 bool Create(wxWindow
*parent
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
,
65 const wxString
& name
= wxEmptyString
);
68 virtual int GetSelection() const;
69 virtual bool SetPageText(size_t n
, const wxString
& strText
);
70 virtual wxString
GetPageText(size_t n
) const;
71 virtual int GetPageImage(size_t n
) const;
72 virtual bool SetPageImage(size_t n
, int imageId
);
73 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
74 virtual bool InsertPage(size_t n
,
79 virtual int SetSelection(size_t n
) { return DoSetSelection(n
, SetSelection_SendEvent
); }
80 virtual int ChangeSelection(size_t n
) { return DoSetSelection(n
); }
81 virtual void SetImageList(wxImageList
*imageList
);
83 virtual bool DeleteAllPages();
85 // returns the choice control
86 wxChoice
* GetChoiceCtrl() const { return (wxChoice
*)m_bookctrl
; }
89 virtual wxWindow
*DoRemovePage(size_t page
);
91 // get the size which the choice control should have
92 virtual wxSize
GetControllerSize() const;
94 void UpdateSelectedPage(size_t newsel
)
97 GetChoiceCtrl()->Select(newsel
);
100 wxBookCtrlBaseEvent
* CreatePageChangingEvent() const;
101 void MakeChangedEvent(wxBookCtrlBaseEvent
&event
);
104 void OnChoiceSelected(wxCommandEvent
& event
);
106 // the currently selected page or wxNOT_FOUND if none
110 // common part of all constructors
113 DECLARE_EVENT_TABLE()
114 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook
)
117 // ----------------------------------------------------------------------------
118 // choicebook event class and related stuff
119 // ----------------------------------------------------------------------------
121 class WXDLLEXPORT wxChoicebookEvent
: public wxBookCtrlBaseEvent
124 wxChoicebookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
125 int nSel
= -1, int nOldSel
= -1)
126 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
130 wxChoicebookEvent(const wxChoicebookEvent
& event
)
131 : wxBookCtrlBaseEvent(event
)
135 virtual wxEvent
*Clone() const { return new wxChoicebookEvent(*this); }
138 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent
)
141 typedef void (wxEvtHandler::*wxChoicebookEventFunction
)(wxChoicebookEvent
&);
143 #define wxChoicebookEventHandler(func) \
144 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func)
146 #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
147 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn))
149 #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
150 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn))
152 #endif // wxUSE_CHOICEBOOK
154 #endif // _WX_CHOICEBOOK_H_