]> git.saurik.com Git - wxWidgets.git/blame - include/wx/choicebk.h
fixed gcc warnings about not calling base class ctor explicitly in copy ctors (patch...
[wxWidgets.git] / include / wx / choicebk.h
CommitLineData
f5e0b4bc
WS
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#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "choicebook.h"
17#endif
18
19#include "wx/defs.h"
20
21#if wxUSE_CHOICEBOOK
22
23#include "wx/bookctrl.h"
24
25class WXDLLEXPORT wxChoice;
26
27// ----------------------------------------------------------------------------
28// constants
29// ----------------------------------------------------------------------------
30
31// wxChoicebook styles
32enum
33{
34 // default alignment: top everywhere
35 wxCHB_DEFAULT = 0,
36
37 // put the choice control to the left/right/top/bottom of the page area
38 wxCHB_TOP = 0x1,
39 wxCHB_BOTTOM = 0x2,
40 wxCHB_LEFT = 0x4,
41 wxCHB_RIGHT = 0x8,
42
43 // the mask which can be used to extract the alignment from the style
44 wxCHB_ALIGN_MASK = 0xf
45};
46
47// ----------------------------------------------------------------------------
48// wxChoicebook
49// ----------------------------------------------------------------------------
50
51class WXDLLEXPORT wxChoicebook : public wxBookCtrl
52{
53public:
54 wxChoicebook()
55 {
56 Init();
57 }
58
59 wxChoicebook(wxWindow *parent,
60 wxWindowID id,
61 const wxPoint& pos = wxDefaultPosition,
62 const wxSize& size = wxDefaultSize,
63 long style = 0,
64 const wxString& name = wxEmptyString)
65 {
66 Init();
67
68 (void)Create(parent, id, pos, size, style, name);
69 }
70
71 // quasi ctor
72 bool Create(wxWindow *parent,
73 wxWindowID id,
74 const wxPoint& pos = wxDefaultPosition,
75 const wxSize& size = wxDefaultSize,
76 long style = 0,
77 const wxString& name = wxEmptyString);
78
79
80 virtual int GetSelection() const;
81 virtual bool SetPageText(size_t n, const wxString& strText);
82 virtual wxString GetPageText(size_t n) const;
83 virtual int GetPageImage(size_t n) const;
84 virtual bool SetPageImage(size_t n, int imageId);
85 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
86 virtual bool InsertPage(size_t n,
87 wxWindow *page,
88 const wxString& text,
89 bool bSelect = false,
90 int imageId = -1);
91 virtual int SetSelection(size_t n);
92 virtual void SetImageList(wxImageList *imageList);
93
94 // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
95 bool IsVertical() const { return HasFlag(wxCHB_BOTTOM | wxCHB_TOP); }
96
97 virtual bool DeleteAllPages();
98
99protected:
100 virtual wxWindow *DoRemovePage(size_t page);
101
102private:
103 // common part of all constructors
104 void Init();
105
106 // get the size which the choice control should have
107 wxSize GetChoiceSize() const;
108
109 // get the page area
110 wxRect GetPageRect() const;
111
112 // event handlers
113 void OnSize(wxSizeEvent& event);
114 void OnChoiceSelected(wxCommandEvent& event);
115
116
117 // the choice control we use for showing the pages index
118 wxChoice *m_choice;
119
120 // the currently selected page or wxNOT_FOUND if none
121 int m_selection;
122
123
124 DECLARE_EVENT_TABLE()
125 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
126};
127
128// ----------------------------------------------------------------------------
129// choicebook event class and related stuff
130// ----------------------------------------------------------------------------
131
132class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlEvent
133{
134public:
135 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
136 int nSel = -1, int nOldSel = -1)
137 : wxBookCtrlEvent(commandType, id, nSel, nOldSel)
138 {
139 }
140
141private:
142 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebookEvent)
143};
144
145extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
146extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
147
148typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&);
149
150#define EVT_CHOICEBOOK_PAGE_CHANGED(id, fn) \
151 DECLARE_EVENT_TABLE_ENTRY( \
152 wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, \
153 id, \
154 -1, \
155 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxChoicebookEventFunction, &fn ), \
156 NULL \
157 ),
158
159#define EVT_CHOICEBOOK_PAGE_CHANGING(id, fn) \
160 DECLARE_EVENT_TABLE_ENTRY( \
161 wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, \
162 id, \
163 -1, \
164 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxChoicebookEventFunction, &fn ), \
165 NULL \
166 ),
167
168#endif // wxUSE_CHOICEBOOK
169
170#endif // _WX_CHOICEBOOK_H_