]>
Commit | Line | Data |
---|---|---|
f5e0b4bc WS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/choicebk.h | |
3 | // Purpose: wxChoicebook: wxChoice and wxNotebook combination | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: Wlodzimierz ABX Skiba from wx/listbook.h | |
6 | // Created: 15.09.04 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_CHOICEBOOK_H_ | |
13 | #define _WX_CHOICEBOOK_H_ | |
14 | ||
f5e0b4bc WS |
15 | #include "wx/defs.h" |
16 | ||
17 | #if wxUSE_CHOICEBOOK | |
18 | ||
19 | #include "wx/bookctrl.h" | |
cc66bf5a | 20 | #include "wx/choice.h" |
f5e0b4bc WS |
21 | |
22 | class WXDLLEXPORT wxChoice; | |
23 | ||
1d6fcbcc VZ |
24 | extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED; |
25 | extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING; | |
26 | ||
27 | ||
f5e0b4bc WS |
28 | // ---------------------------------------------------------------------------- |
29 | // wxChoicebook | |
30 | // ---------------------------------------------------------------------------- | |
31 | ||
61c083e7 | 32 | class WXDLLEXPORT wxChoicebook : public wxBookCtrlBase |
f5e0b4bc WS |
33 | { |
34 | public: | |
35 | wxChoicebook() | |
36 | { | |
37 | Init(); | |
38 | } | |
39 | ||
40 | wxChoicebook(wxWindow *parent, | |
41 | wxWindowID id, | |
42 | const wxPoint& pos = wxDefaultPosition, | |
43 | const wxSize& size = wxDefaultSize, | |
44 | long style = 0, | |
45 | const wxString& name = wxEmptyString) | |
46 | { | |
47 | Init(); | |
48 | ||
49 | (void)Create(parent, id, pos, size, style, name); | |
50 | } | |
51 | ||
52 | // quasi ctor | |
53 | bool Create(wxWindow *parent, | |
54 | wxWindowID id, | |
55 | const wxPoint& pos = wxDefaultPosition, | |
56 | const wxSize& size = wxDefaultSize, | |
57 | long style = 0, | |
58 | const wxString& name = wxEmptyString); | |
59 | ||
60 | ||
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, | |
68 | wxWindow *page, | |
69 | const wxString& text, | |
70 | bool bSelect = false, | |
71 | int imageId = -1); | |
1d6fcbcc VZ |
72 | virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); } |
73 | virtual int ChangeSelection(size_t n) { return DoSetSelection(n); } | |
f5e0b4bc WS |
74 | virtual void SetImageList(wxImageList *imageList); |
75 | ||
f5e0b4bc WS |
76 | virtual bool DeleteAllPages(); |
77 | ||
c9ab63f4 | 78 | // returns the choice control |
d8fd7acb | 79 | wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; } |
c9ab63f4 | 80 | |
f5e0b4bc WS |
81 | protected: |
82 | virtual wxWindow *DoRemovePage(size_t page); | |
83 | ||
f5e0b4bc | 84 | // get the size which the choice control should have |
d8fd7acb | 85 | virtual wxSize GetControllerSize() const; |
f5e0b4bc | 86 | |
1d6fcbcc VZ |
87 | void UpdateSelectedPage(size_t newsel) |
88 | { | |
89 | m_selection = newsel; | |
90 | GetChoiceCtrl()->Select(newsel); | |
91 | } | |
92 | ||
deb325e3 VZ |
93 | wxBookCtrlBaseEvent* CreatePageChangingEvent() const; |
94 | void MakeChangedEvent(wxBookCtrlBaseEvent &event); | |
1d6fcbcc | 95 | |
f5e0b4bc | 96 | // event handlers |
f5e0b4bc WS |
97 | void OnChoiceSelected(wxCommandEvent& event); |
98 | ||
f5e0b4bc WS |
99 | // the currently selected page or wxNOT_FOUND if none |
100 | int m_selection; | |
101 | ||
bb08a4a1 WS |
102 | private: |
103 | // common part of all constructors | |
104 | void Init(); | |
f5e0b4bc WS |
105 | |
106 | DECLARE_EVENT_TABLE() | |
107 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook) | |
108 | }; | |
109 | ||
110 | // ---------------------------------------------------------------------------- | |
111 | // choicebook event class and related stuff | |
112 | // ---------------------------------------------------------------------------- | |
113 | ||
61c083e7 | 114 | class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlBaseEvent |
f5e0b4bc WS |
115 | { |
116 | public: | |
117 | wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
118 | int nSel = -1, int nOldSel = -1) | |
61c083e7 | 119 | : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel) |
f5e0b4bc WS |
120 | { |
121 | } | |
122 | ||
87355003 WS |
123 | wxChoicebookEvent(const wxChoicebookEvent& event) |
124 | : wxBookCtrlBaseEvent(event) | |
125 | { | |
126 | } | |
127 | ||
128 | virtual wxEvent *Clone() const { return new wxChoicebookEvent(*this); } | |
129 | ||
f5e0b4bc | 130 | private: |
87355003 | 131 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent) |
f5e0b4bc WS |
132 | }; |
133 | ||
f5e0b4bc WS |
134 | typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&); |
135 | ||
7fa03f04 | 136 | #define wxChoicebookEventHandler(func) \ |
d94c09cd | 137 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func) |
7fa03f04 | 138 | |
d94c09cd WS |
139 | #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \ |
140 | wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn)) | |
7fa03f04 | 141 | |
d94c09cd WS |
142 | #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \ |
143 | wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn)) | |
f5e0b4bc WS |
144 | |
145 | #endif // wxUSE_CHOICEBOOK | |
146 | ||
147 | #endif // _WX_CHOICEBOOK_H_ |