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"
21 class WXDLLEXPORT wxChoice
;
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 class WXDLLEXPORT wxChoicebook
: public wxBookCtrlBase
35 wxChoicebook(wxWindow
*parent
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
,
40 const wxString
& name
= wxEmptyString
)
44 (void)Create(parent
, id
, pos
, size
, style
, name
);
48 bool Create(wxWindow
*parent
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
53 const wxString
& name
= wxEmptyString
);
56 virtual int GetSelection() const;
57 virtual bool SetPageText(size_t n
, const wxString
& strText
);
58 virtual wxString
GetPageText(size_t n
) const;
59 virtual int GetPageImage(size_t n
) const;
60 virtual bool SetPageImage(size_t n
, int imageId
);
61 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
62 virtual bool InsertPage(size_t n
,
67 virtual int SetSelection(size_t n
);
68 virtual void SetImageList(wxImageList
*imageList
);
70 // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
71 bool IsVertical() const { return HasFlag(wxCHB_BOTTOM
| wxCHB_TOP
); }
73 virtual bool DeleteAllPages();
75 // returns the choice control
76 wxChoice
* GetChoiceCtrl() const { return m_choice
; }
79 virtual wxWindow
*DoRemovePage(size_t page
);
81 // get the size which the choice control should have
82 wxSize
GetChoiceSize() const;
85 wxRect
GetPageRect() const;
88 void OnSize(wxSizeEvent
& event
);
89 void OnChoiceSelected(wxCommandEvent
& event
);
91 // the choice control we use for showing the pages index
94 // the currently selected page or wxNOT_FOUND if none
98 // common part of all constructors
101 DECLARE_EVENT_TABLE()
102 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook
)
105 // ----------------------------------------------------------------------------
106 // choicebook event class and related stuff
107 // ----------------------------------------------------------------------------
109 class WXDLLEXPORT wxChoicebookEvent
: public wxBookCtrlBaseEvent
112 wxChoicebookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
113 int nSel
= -1, int nOldSel
= -1)
114 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
119 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebookEvent
)
122 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED
;
123 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING
;
125 typedef void (wxEvtHandler::*wxChoicebookEventFunction
)(wxChoicebookEvent
&);
127 #define wxChoicebookEventHandler(func) \
128 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func)
130 #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
131 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn))
133 #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
134 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn))
136 #endif // wxUSE_CHOICEBOOK
138 #endif // _WX_CHOICEBOOK_H_