]>
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 | int DoSetSelection(size_t nPage, int flags = 0); |
88 | ||
89 | void UpdateSelectedPage(size_t newsel) | |
90 | { | |
91 | m_selection = newsel; | |
92 | GetChoiceCtrl()->Select(newsel); | |
93 | } | |
94 | ||
95 | void MakeChangedEvent(wxBookCtrlBaseEvent &event) | |
96 | { | |
97 | event.SetEventType(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED); | |
98 | } | |
99 | ||
f5e0b4bc | 100 | // event handlers |
f5e0b4bc WS |
101 | void OnChoiceSelected(wxCommandEvent& event); |
102 | ||
f5e0b4bc WS |
103 | // the currently selected page or wxNOT_FOUND if none |
104 | int m_selection; | |
105 | ||
bb08a4a1 WS |
106 | private: |
107 | // common part of all constructors | |
108 | void Init(); | |
f5e0b4bc WS |
109 | |
110 | DECLARE_EVENT_TABLE() | |
111 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook) | |
112 | }; | |
113 | ||
114 | // ---------------------------------------------------------------------------- | |
115 | // choicebook event class and related stuff | |
116 | // ---------------------------------------------------------------------------- | |
117 | ||
61c083e7 | 118 | class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlBaseEvent |
f5e0b4bc WS |
119 | { |
120 | public: | |
121 | wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
122 | int nSel = -1, int nOldSel = -1) | |
61c083e7 | 123 | : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel) |
f5e0b4bc WS |
124 | { |
125 | } | |
126 | ||
87355003 WS |
127 | wxChoicebookEvent(const wxChoicebookEvent& event) |
128 | : wxBookCtrlBaseEvent(event) | |
129 | { | |
130 | } | |
131 | ||
132 | virtual wxEvent *Clone() const { return new wxChoicebookEvent(*this); } | |
133 | ||
f5e0b4bc | 134 | private: |
87355003 | 135 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent) |
f5e0b4bc WS |
136 | }; |
137 | ||
f5e0b4bc WS |
138 | typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&); |
139 | ||
7fa03f04 | 140 | #define wxChoicebookEventHandler(func) \ |
d94c09cd | 141 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func) |
7fa03f04 | 142 | |
d94c09cd WS |
143 | #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \ |
144 | wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn)) | |
7fa03f04 | 145 | |
d94c09cd WS |
146 | #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \ |
147 | wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn)) | |
f5e0b4bc WS |
148 | |
149 | #endif // wxUSE_CHOICEBOOK | |
150 | ||
151 | #endif // _WX_CHOICEBOOK_H_ |