]> git.saurik.com Git - wxWidgets.git/blob - include/wx/choicebk.h
wxPropertyGrid validation failure was not (always) reset when a valid value was enter...
[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 Init();
45 }
46
47 wxChoicebook(wxWindow *parent,
48 wxWindowID id,
49 const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize,
51 long style = 0,
52 const wxString& name = wxEmptyString)
53 {
54 Init();
55
56 (void)Create(parent, id, pos, size, style, name);
57 }
58
59 // quasi ctor
60 bool Create(wxWindow *parent,
61 wxWindowID id,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = 0,
65 const wxString& name = wxEmptyString);
66
67
68 virtual int GetSelection() const;
69 virtual bool SetPageText(size_t n, const wxString& strText);
70 virtual wxString GetPageText(size_t n) const;
71 virtual int GetPageImage(size_t n) const;
72 virtual bool SetPageImage(size_t n, int imageId);
73 virtual bool InsertPage(size_t n,
74 wxWindow *page,
75 const wxString& text,
76 bool bSelect = false,
77 int imageId = -1);
78 virtual int SetSelection(size_t n)
79 { return DoSetSelection(n, SetSelection_SendEvent); }
80 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
81 virtual void SetImageList(wxImageList *imageList);
82
83 virtual bool DeleteAllPages();
84
85 // returns the choice control
86 wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; }
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 // the currently selected page or wxNOT_FOUND if none
106 int m_selection;
107
108 private:
109 // common part of all constructors
110 void Init();
111
112 DECLARE_EVENT_TABLE()
113 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
114 };
115
116 // ----------------------------------------------------------------------------
117 // choicebook event class and related stuff
118 // ----------------------------------------------------------------------------
119
120 // wxChoicebookEvent is obsolete and defined for compatibility only
121 typedef wxBookCtrlEvent wxChoicebookEvent;
122 typedef wxBookCtrlEventFunction wxChoicebookEventFunction;
123 #define wxChoicebookEventHandler(func) wxBookCtrlEventHandler(func)
124
125 #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
126 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
127
128 #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
129 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
130
131 #endif // wxUSE_CHOICEBOOK
132
133 #endif // _WX_CHOICEBOOK_H_