Use int instead of wxWindowID in wxNewId() and friends.
[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 #include "wx/containr.h"
22
23 class WXDLLIMPEXP_FWD_CORE wxChoice;
24
25 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGED, wxBookCtrlEvent );
26 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGING, wxBookCtrlEvent );
27
28 // wxChoicebook flags
29 #define wxCHB_DEFAULT wxBK_DEFAULT
30 #define wxCHB_TOP wxBK_TOP
31 #define wxCHB_BOTTOM wxBK_BOTTOM
32 #define wxCHB_LEFT wxBK_LEFT
33 #define wxCHB_RIGHT wxBK_RIGHT
34 #define wxCHB_ALIGN_MASK wxBK_ALIGN_MASK
35
36 // ----------------------------------------------------------------------------
37 // wxChoicebook
38 // ----------------------------------------------------------------------------
39
40 class WXDLLIMPEXP_CORE wxChoicebook : public wxNavigationEnabled<wxBookCtrlBase>
41 {
42 public:
43 wxChoicebook() { }
44
45 wxChoicebook(wxWindow *parent,
46 wxWindowID id,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 long style = 0,
50 const wxString& name = wxEmptyString)
51 {
52 (void)Create(parent, id, pos, size, style, name);
53 }
54
55 // quasi ctor
56 bool Create(wxWindow *parent,
57 wxWindowID id,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 long style = 0,
61 const wxString& name = wxEmptyString);
62
63
64 virtual bool SetPageText(size_t n, const wxString& strText);
65 virtual wxString GetPageText(size_t n) const;
66 virtual int GetPageImage(size_t n) const;
67 virtual bool SetPageImage(size_t n, int imageId);
68 virtual bool InsertPage(size_t n,
69 wxWindow *page,
70 const wxString& text,
71 bool bSelect = false,
72 int imageId = NO_IMAGE);
73 virtual int SetSelection(size_t n)
74 { return DoSetSelection(n, SetSelection_SendEvent); }
75 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
76 virtual void SetImageList(wxImageList *imageList);
77
78 virtual bool DeleteAllPages();
79
80 // returns the choice control
81 wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; }
82
83 // Override this to return true because the part of parent window
84 // background between our controlling wxChoice and the page area should
85 // show through.
86 virtual bool HasTransparentBackground() { return true; }
87
88 protected:
89 virtual void DoSetWindowVariant(wxWindowVariant variant);
90
91 virtual wxWindow *DoRemovePage(size_t page);
92
93 void UpdateSelectedPage(size_t newsel)
94 {
95 m_selection = static_cast<int>(newsel);
96 GetChoiceCtrl()->Select(m_selection);
97 }
98
99 wxBookCtrlEvent* CreatePageChangingEvent() const;
100 void MakeChangedEvent(wxBookCtrlEvent &event);
101
102 // event handlers
103 void OnChoiceSelected(wxCommandEvent& event);
104
105 private:
106 DECLARE_EVENT_TABLE()
107 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
108 };
109
110 // ----------------------------------------------------------------------------
111 // choicebook event class and related stuff
112 // ----------------------------------------------------------------------------
113
114 // wxChoicebookEvent is obsolete and defined for compatibility only
115 #define wxChoicebookEvent wxBookCtrlEvent
116 typedef wxBookCtrlEventFunction wxChoicebookEventFunction;
117 #define wxChoicebookEventHandler(func) wxBookCtrlEventHandler(func)
118
119 #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
120 wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
121
122 #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
123 wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
124
125 // old wxEVT_COMMAND_* constants
126 #define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED wxEVT_CHOICEBOOK_PAGE_CHANGED
127 #define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING wxEVT_CHOICEBOOK_PAGE_CHANGING
128
129 #endif // wxUSE_CHOICEBOOK
130
131 #endif // _WX_CHOICEBOOK_H_