]> git.saurik.com Git - wxWidgets.git/blob - include/wx/choicebk.h
avoid conflict between wxBookCtrlBase::DoSetSelection() and the derived classes;...
[wxWidgets.git] / include / wx / choicebk.h
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
15 #include "wx/defs.h"
16
17 #if wxUSE_CHOICEBOOK
18
19 #include "wx/bookctrl.h"
20 #include "wx/choice.h"
21
22 class WXDLLEXPORT wxChoice;
23
24 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
25 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
26
27
28 // ----------------------------------------------------------------------------
29 // wxChoicebook
30 // ----------------------------------------------------------------------------
31
32 class WXDLLEXPORT wxChoicebook : public wxBookCtrlBase
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);
72 virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
73 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
74 virtual void SetImageList(wxImageList *imageList);
75
76 virtual bool DeleteAllPages();
77
78 // returns the choice control
79 wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; }
80
81 protected:
82 virtual wxWindow *DoRemovePage(size_t page);
83
84 // get the size which the choice control should have
85 virtual wxSize GetControllerSize() const;
86
87 void UpdateSelectedPage(size_t newsel)
88 {
89 m_selection = newsel;
90 GetChoiceCtrl()->Select(newsel);
91 }
92
93 wxBookCtrlBaseEvent* CreatePageChangingEvent() const;
94 void MakeChangedEvent(wxBookCtrlBaseEvent &event);
95
96 // event handlers
97 void OnChoiceSelected(wxCommandEvent& event);
98
99 // the currently selected page or wxNOT_FOUND if none
100 int m_selection;
101
102 private:
103 // common part of all constructors
104 void Init();
105
106 DECLARE_EVENT_TABLE()
107 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
108 };
109
110 // ----------------------------------------------------------------------------
111 // choicebook event class and related stuff
112 // ----------------------------------------------------------------------------
113
114 class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlBaseEvent
115 {
116 public:
117 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
118 int nSel = -1, int nOldSel = -1)
119 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
120 {
121 }
122
123 wxChoicebookEvent(const wxChoicebookEvent& event)
124 : wxBookCtrlBaseEvent(event)
125 {
126 }
127
128 virtual wxEvent *Clone() const { return new wxChoicebookEvent(*this); }
129
130 private:
131 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent)
132 };
133
134 typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&);
135
136 #define wxChoicebookEventHandler(func) \
137 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func)
138
139 #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
140 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn))
141
142 #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
143 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn))
144
145 #endif // wxUSE_CHOICEBOOK
146
147 #endif // _WX_CHOICEBOOK_H_