]> git.saurik.com Git - wxWidgets.git/blob - include/wx/choicebk.h
Don't duplicate event sending code in wxGTK wxListBox.
[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 WXDLLIMPEXP_FWD_CORE wxChoice;
23
24 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, wxBookCtrlEvent );
25 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, wxBookCtrlEvent );
26
27 // wxChoicebook flags
28 #define wxCHB_DEFAULT wxBK_DEFAULT
29 #define wxCHB_TOP wxBK_TOP
30 #define wxCHB_BOTTOM wxBK_BOTTOM
31 #define wxCHB_LEFT wxBK_LEFT
32 #define wxCHB_RIGHT wxBK_RIGHT
33 #define wxCHB_ALIGN_MASK wxBK_ALIGN_MASK
34
35 // ----------------------------------------------------------------------------
36 // wxChoicebook
37 // ----------------------------------------------------------------------------
38
39 class WXDLLIMPEXP_CORE wxChoicebook : public wxBookCtrlBase
40 {
41 public:
42 wxChoicebook() { }
43
44 wxChoicebook(wxWindow *parent,
45 wxWindowID id,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 long style = 0,
49 const wxString& name = wxEmptyString)
50 {
51 (void)Create(parent, id, pos, size, style, name);
52 }
53
54 // quasi ctor
55 bool Create(wxWindow *parent,
56 wxWindowID id,
57 const wxPoint& pos = wxDefaultPosition,
58 const wxSize& size = wxDefaultSize,
59 long style = 0,
60 const wxString& name = wxEmptyString);
61
62
63 virtual bool SetPageText(size_t n, const wxString& strText);
64 virtual wxString GetPageText(size_t n) const;
65 virtual int GetPageImage(size_t n) const;
66 virtual bool SetPageImage(size_t n, int imageId);
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)
73 { return DoSetSelection(n, SetSelection_SendEvent); }
74 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
75 virtual void SetImageList(wxImageList *imageList);
76
77 virtual bool DeleteAllPages();
78
79 // returns the choice control
80 wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; }
81
82 protected:
83 virtual void DoSetWindowVariant(wxWindowVariant variant);
84
85 virtual wxWindow *DoRemovePage(size_t page);
86
87 void UpdateSelectedPage(size_t newsel)
88 {
89 m_selection = static_cast<int>(newsel);
90 GetChoiceCtrl()->Select(m_selection);
91 }
92
93 wxBookCtrlEvent* CreatePageChangingEvent() const;
94 void MakeChangedEvent(wxBookCtrlEvent &event);
95
96 // event handlers
97 void OnChoiceSelected(wxCommandEvent& event);
98
99 private:
100 DECLARE_EVENT_TABLE()
101 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
102 };
103
104 // ----------------------------------------------------------------------------
105 // choicebook event class and related stuff
106 // ----------------------------------------------------------------------------
107
108 // wxChoicebookEvent is obsolete and defined for compatibility only
109 typedef wxBookCtrlEvent wxChoicebookEvent;
110 typedef wxBookCtrlEventFunction wxChoicebookEventFunction;
111 #define wxChoicebookEventHandler(func) wxBookCtrlEventHandler(func)
112
113 #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
114 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
115
116 #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
117 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
118
119 #endif // wxUSE_CHOICEBOOK
120
121 #endif // _WX_CHOICEBOOK_H_