]>
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" | |
20 | ||
21 | class WXDLLEXPORT wxChoice; | |
22 | ||
f5e0b4bc WS |
23 | // ---------------------------------------------------------------------------- |
24 | // wxChoicebook | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
61c083e7 | 27 | class WXDLLEXPORT wxChoicebook : public wxBookCtrlBase |
f5e0b4bc WS |
28 | { |
29 | public: | |
30 | wxChoicebook() | |
31 | { | |
32 | Init(); | |
33 | } | |
34 | ||
35 | wxChoicebook(wxWindow *parent, | |
36 | wxWindowID id, | |
37 | const wxPoint& pos = wxDefaultPosition, | |
38 | const wxSize& size = wxDefaultSize, | |
39 | long style = 0, | |
40 | const wxString& name = wxEmptyString) | |
41 | { | |
42 | Init(); | |
43 | ||
44 | (void)Create(parent, id, pos, size, style, name); | |
45 | } | |
46 | ||
47 | // quasi ctor | |
48 | bool Create(wxWindow *parent, | |
49 | wxWindowID id, | |
50 | const wxPoint& pos = wxDefaultPosition, | |
51 | const wxSize& size = wxDefaultSize, | |
52 | long style = 0, | |
53 | const wxString& name = wxEmptyString); | |
54 | ||
55 | ||
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, | |
63 | wxWindow *page, | |
64 | const wxString& text, | |
65 | bool bSelect = false, | |
66 | int imageId = -1); | |
67 | virtual int SetSelection(size_t n); | |
68 | virtual void SetImageList(wxImageList *imageList); | |
69 | ||
70 | // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style | |
71 | bool IsVertical() const { return HasFlag(wxCHB_BOTTOM | wxCHB_TOP); } | |
72 | ||
73 | virtual bool DeleteAllPages(); | |
74 | ||
c9ab63f4 JS |
75 | // returns the choice control |
76 | wxChoice* GetChoiceCtrl() const { return m_choice; } | |
77 | ||
f5e0b4bc WS |
78 | protected: |
79 | virtual wxWindow *DoRemovePage(size_t page); | |
80 | ||
f5e0b4bc WS |
81 | // get the size which the choice control should have |
82 | wxSize GetChoiceSize() const; | |
83 | ||
84 | // get the page area | |
85 | wxRect GetPageRect() const; | |
86 | ||
87 | // event handlers | |
88 | void OnSize(wxSizeEvent& event); | |
89 | void OnChoiceSelected(wxCommandEvent& event); | |
90 | ||
f5e0b4bc WS |
91 | // the choice control we use for showing the pages index |
92 | wxChoice *m_choice; | |
93 | ||
94 | // the currently selected page or wxNOT_FOUND if none | |
95 | int m_selection; | |
96 | ||
bb08a4a1 WS |
97 | private: |
98 | // common part of all constructors | |
99 | void Init(); | |
f5e0b4bc WS |
100 | |
101 | DECLARE_EVENT_TABLE() | |
102 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook) | |
103 | }; | |
104 | ||
105 | // ---------------------------------------------------------------------------- | |
106 | // choicebook event class and related stuff | |
107 | // ---------------------------------------------------------------------------- | |
108 | ||
61c083e7 | 109 | class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlBaseEvent |
f5e0b4bc WS |
110 | { |
111 | public: | |
112 | wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
113 | int nSel = -1, int nOldSel = -1) | |
61c083e7 | 114 | : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel) |
f5e0b4bc WS |
115 | { |
116 | } | |
117 | ||
118 | private: | |
119 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebookEvent) | |
120 | }; | |
121 | ||
122 | extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED; | |
123 | extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING; | |
124 | ||
125 | typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&); | |
126 | ||
7fa03f04 | 127 | #define wxChoicebookEventHandler(func) \ |
d94c09cd | 128 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func) |
7fa03f04 | 129 | |
d94c09cd WS |
130 | #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \ |
131 | wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn)) | |
7fa03f04 | 132 | |
d94c09cd WS |
133 | #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \ |
134 | wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn)) | |
f5e0b4bc WS |
135 | |
136 | #endif // wxUSE_CHOICEBOOK | |
137 | ||
138 | #endif // _WX_CHOICEBOOK_H_ |