]> git.saurik.com Git - wxWidgets.git/blame - include/wx/choicebk.h
make wxTmemchr() return (and take) char* instead of void* in ANSI build too
[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
f5e0b4bc
WS
15#include "wx/defs.h"
16
17#if wxUSE_CHOICEBOOK
18
19#include "wx/bookctrl.h"
cc66bf5a 20#include "wx/choice.h"
f5e0b4bc 21
b5dbe15d 22class WXDLLIMPEXP_FWD_CORE wxChoice;
f5e0b4bc 23
1d6fcbcc
VZ
24extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
25extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
26
90c0f63a
VZ
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
1d6fcbcc 34
f5e0b4bc
WS
35// ----------------------------------------------------------------------------
36// wxChoicebook
37// ----------------------------------------------------------------------------
38
61c083e7 39class WXDLLEXPORT wxChoicebook : public wxBookCtrlBase
f5e0b4bc
WS
40{
41public:
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 wxSize CalcSizeFromPage(const wxSize& sizePage) const;
74 virtual bool InsertPage(size_t n,
75 wxWindow *page,
76 const wxString& text,
77 bool bSelect = false,
78 int imageId = -1);
1d6fcbcc
VZ
79 virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
80 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
f5e0b4bc
WS
81 virtual void SetImageList(wxImageList *imageList);
82
f5e0b4bc
WS
83 virtual bool DeleteAllPages();
84
c9ab63f4 85 // returns the choice control
d8fd7acb 86 wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; }
c9ab63f4 87
f5e0b4bc
WS
88protected:
89 virtual wxWindow *DoRemovePage(size_t page);
90
f5e0b4bc 91 // get the size which the choice control should have
d8fd7acb 92 virtual wxSize GetControllerSize() const;
f5e0b4bc 93
1d6fcbcc
VZ
94 void UpdateSelectedPage(size_t newsel)
95 {
96 m_selection = newsel;
97 GetChoiceCtrl()->Select(newsel);
98 }
99
deb325e3
VZ
100 wxBookCtrlBaseEvent* CreatePageChangingEvent() const;
101 void MakeChangedEvent(wxBookCtrlBaseEvent &event);
1d6fcbcc 102
f5e0b4bc 103 // event handlers
f5e0b4bc
WS
104 void OnChoiceSelected(wxCommandEvent& event);
105
f5e0b4bc
WS
106 // the currently selected page or wxNOT_FOUND if none
107 int m_selection;
108
bb08a4a1
WS
109private:
110 // common part of all constructors
111 void Init();
f5e0b4bc
WS
112
113 DECLARE_EVENT_TABLE()
114 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
115};
116
117// ----------------------------------------------------------------------------
118// choicebook event class and related stuff
119// ----------------------------------------------------------------------------
120
61c083e7 121class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlBaseEvent
f5e0b4bc
WS
122{
123public:
124 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
125 int nSel = -1, int nOldSel = -1)
61c083e7 126 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
f5e0b4bc
WS
127 {
128 }
129
87355003
WS
130 wxChoicebookEvent(const wxChoicebookEvent& event)
131 : wxBookCtrlBaseEvent(event)
132 {
133 }
134
135 virtual wxEvent *Clone() const { return new wxChoicebookEvent(*this); }
136
f5e0b4bc 137private:
87355003 138 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent)
f5e0b4bc
WS
139};
140
f5e0b4bc
WS
141typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&);
142
7fa03f04 143#define wxChoicebookEventHandler(func) \
d94c09cd 144 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func)
7fa03f04 145
d94c09cd
WS
146#define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
147 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn))
7fa03f04 148
d94c09cd
WS
149#define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
150 wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn))
f5e0b4bc
WS
151
152#endif // wxUSE_CHOICEBOOK
153
154#endif // _WX_CHOICEBOOK_H_