]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/choicebk.h
added CreateSeparatedButtonSizer(), changed signature and semantics of CreateButtonSi...
[wxWidgets.git] / include / wx / choicebk.h
... / ...
CommitLineData
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
22class WXDLLEXPORT wxChoice;
23
24extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
25extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
26
27
28// ----------------------------------------------------------------------------
29// wxChoicebook
30// ----------------------------------------------------------------------------
31
32class WXDLLEXPORT wxChoicebook : public wxBookCtrlBase
33{
34public:
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
81protected:
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 int DoSetSelection(size_t nPage, int flags = 0);
88
89 void UpdateSelectedPage(size_t newsel)
90 {
91 m_selection = newsel;
92 GetChoiceCtrl()->Select(newsel);
93 }
94
95 void MakeChangedEvent(wxBookCtrlBaseEvent &event)
96 {
97 event.SetEventType(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED);
98 }
99
100 // event handlers
101 void OnChoiceSelected(wxCommandEvent& event);
102
103 // the currently selected page or wxNOT_FOUND if none
104 int m_selection;
105
106private:
107 // common part of all constructors
108 void Init();
109
110 DECLARE_EVENT_TABLE()
111 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
112};
113
114// ----------------------------------------------------------------------------
115// choicebook event class and related stuff
116// ----------------------------------------------------------------------------
117
118class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlBaseEvent
119{
120public:
121 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
122 int nSel = -1, int nOldSel = -1)
123 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
124 {
125 }
126
127 wxChoicebookEvent(const wxChoicebookEvent& event)
128 : wxBookCtrlBaseEvent(event)
129 {
130 }
131
132 virtual wxEvent *Clone() const { return new wxChoicebookEvent(*this); }
133
134private:
135 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent)
136};
137
138typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&);
139
140#define wxChoicebookEventHandler(func) \
141 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func)
142
143#define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
144 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn))
145
146#define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
147 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn))
148
149#endif // wxUSE_CHOICEBOOK
150
151#endif // _WX_CHOICEBOOK_H_