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"
21 #include "wx/containr.h"
23 class WXDLLIMPEXP_FWD_CORE wxChoice
;
25 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_CHOICEBOOK_PAGE_CHANGED
, wxBookCtrlEvent
);
26 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_CHOICEBOOK_PAGE_CHANGING
, wxBookCtrlEvent
);
29 #define wxCHB_DEFAULT wxBK_DEFAULT
30 #define wxCHB_TOP wxBK_TOP
31 #define wxCHB_BOTTOM wxBK_BOTTOM
32 #define wxCHB_LEFT wxBK_LEFT
33 #define wxCHB_RIGHT wxBK_RIGHT
34 #define wxCHB_ALIGN_MASK wxBK_ALIGN_MASK
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 class WXDLLIMPEXP_CORE wxChoicebook
: public wxNavigationEnabled
<wxBookCtrlBase
>
45 wxChoicebook(wxWindow
*parent
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
50 const wxString
& name
= wxEmptyString
)
52 (void)Create(parent
, id
, pos
, size
, style
, name
);
56 bool Create(wxWindow
*parent
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
61 const wxString
& name
= wxEmptyString
);
64 virtual bool SetPageText(size_t n
, const wxString
& strText
);
65 virtual wxString
GetPageText(size_t n
) const;
66 virtual int GetPageImage(size_t n
) const;
67 virtual bool SetPageImage(size_t n
, int imageId
);
68 virtual bool InsertPage(size_t n
,
72 int imageId
= NO_IMAGE
);
73 virtual int SetSelection(size_t n
)
74 { return DoSetSelection(n
, SetSelection_SendEvent
); }
75 virtual int ChangeSelection(size_t n
) { return DoSetSelection(n
); }
76 virtual void SetImageList(wxImageList
*imageList
);
78 virtual bool DeleteAllPages();
80 // returns the choice control
81 wxChoice
* GetChoiceCtrl() const { return (wxChoice
*)m_bookctrl
; }
83 // Override this to return true because the part of parent window
84 // background between our controlling wxChoice and the page area should
86 virtual bool HasTransparentBackground() { return true; }
89 virtual void DoSetWindowVariant(wxWindowVariant variant
);
91 virtual wxWindow
*DoRemovePage(size_t page
);
93 void UpdateSelectedPage(size_t newsel
)
95 m_selection
= static_cast<int>(newsel
);
96 GetChoiceCtrl()->Select(m_selection
);
99 wxBookCtrlEvent
* CreatePageChangingEvent() const;
100 void MakeChangedEvent(wxBookCtrlEvent
&event
);
103 void OnChoiceSelected(wxCommandEvent
& event
);
106 DECLARE_EVENT_TABLE()
107 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook
)
110 // ----------------------------------------------------------------------------
111 // choicebook event class and related stuff
112 // ----------------------------------------------------------------------------
114 // wxChoicebookEvent is obsolete and defined for compatibility only
115 #define wxChoicebookEvent wxBookCtrlEvent
116 typedef wxBookCtrlEventFunction wxChoicebookEventFunction
;
117 #define wxChoicebookEventHandler(func) wxBookCtrlEventHandler(func)
119 #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
120 wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
122 #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
123 wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
125 // old wxEVT_COMMAND_* constants
126 #define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED wxEVT_CHOICEBOOK_PAGE_CHANGED
127 #define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING wxEVT_CHOICEBOOK_PAGE_CHANGING
129 #endif // wxUSE_CHOICEBOOK
131 #endif // _WX_CHOICEBOOK_H_