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 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 class WXDLLEXPORT wxChoicebook
: public wxBookCtrlBase
40 wxChoicebook(wxWindow
*parent
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
,
45 const wxString
& name
= wxEmptyString
)
49 (void)Create(parent
, id
, pos
, size
, style
, name
);
53 bool Create(wxWindow
*parent
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
58 const wxString
& name
= wxEmptyString
);
61 virtual int GetSelection() const;
62 virtual bool SetPageText(size_t n
, const wxString
& strText
);
63 virtual wxString
GetPageText(size_t n
) const;
64 virtual int GetPageImage(size_t n
) const;
65 virtual bool SetPageImage(size_t n
, int imageId
);
66 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
67 virtual bool InsertPage(size_t n
,
72 virtual int SetSelection(size_t n
) { return DoSetSelection(n
, SetSelection_SendEvent
); }
73 virtual int ChangeSelection(size_t n
) { return DoSetSelection(n
); }
74 virtual void SetImageList(wxImageList
*imageList
);
76 virtual bool DeleteAllPages();
78 // returns the choice control
79 wxChoice
* GetChoiceCtrl() const { return (wxChoice
*)m_bookctrl
; }
82 virtual wxWindow
*DoRemovePage(size_t page
);
84 // get the size which the choice control should have
85 virtual wxSize
GetControllerSize() const;
87 void UpdateSelectedPage(size_t newsel
)
90 GetChoiceCtrl()->Select(newsel
);
93 wxBookCtrlBaseEvent
* CreatePageChangingEvent() const;
94 void MakeChangedEvent(wxBookCtrlBaseEvent
&event
);
97 void OnChoiceSelected(wxCommandEvent
& event
);
99 // the currently selected page or wxNOT_FOUND if none
103 // common part of all constructors
106 DECLARE_EVENT_TABLE()
107 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook
)
110 // ----------------------------------------------------------------------------
111 // choicebook event class and related stuff
112 // ----------------------------------------------------------------------------
114 class WXDLLEXPORT wxChoicebookEvent
: public wxBookCtrlBaseEvent
117 wxChoicebookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
118 int nSel
= -1, int nOldSel
= -1)
119 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
123 wxChoicebookEvent(const wxChoicebookEvent
& event
)
124 : wxBookCtrlBaseEvent(event
)
128 virtual wxEvent
*Clone() const { return new wxChoicebookEvent(*this); }
131 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent
)
134 typedef void (wxEvtHandler::*wxChoicebookEventFunction
)(wxChoicebookEvent
&);
136 #define wxChoicebookEventHandler(func) \
137 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func)
139 #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
140 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn))
142 #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
143 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn))
145 #endif // wxUSE_CHOICEBOOK
147 #endif // _WX_CHOICEBOOK_H_