]> git.saurik.com Git - wxWidgets.git/blame - include/wx/qt/notebook.h
handle sizeof(int) correctly
[wxWidgets.git] / include / wx / qt / notebook.h
CommitLineData
7c78e7c7
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: notebook.h
01b2eeec
KB
3// Purpose: MSW/GTK compatible notebook (a.k.a. property sheet)
4// Author: AUTHOR
7c78e7c7
RR
5// Modified by:
6// RCS-ID: $Id$
01b2eeec
KB
7// Copyright: (c) AUTHOR
8// Licence: wxWindows licence
7c78e7c7
RR
9/////////////////////////////////////////////////////////////////////////////
10
01b2eeec
KB
11#ifndef _WX_NOTEBOOK_H_
12#define _WX_NOTEBOOK_H_
7c78e7c7
RR
13
14#ifdef __GNUG__
15#pragma interface "notebook.h"
16#endif
17
01b2eeec
KB
18// ----------------------------------------------------------------------------
19// headers
20// ----------------------------------------------------------------------------
21#include <wx/dynarray.h>
22
23// ----------------------------------------------------------------------------
24// types
25// ----------------------------------------------------------------------------
7c78e7c7 26
01b2eeec
KB
27// fwd declarations
28class WXDLLEXPORT wxImageList;
29class WXDLLEXPORT wxWindow;
7c78e7c7 30
01b2eeec
KB
31// array of notebook pages
32typedef wxWindow wxNotebookPage; // so far, any window can be a page
33WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages);
7c78e7c7
RR
34
35// ----------------------------------------------------------------------------
36// notebook events
37// ----------------------------------------------------------------------------
01b2eeec 38class WXDLLEXPORT wxNotebookEvent : public wxCommandEvent
7c78e7c7
RR
39{
40public:
01b2eeec 41 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
7c78e7c7
RR
42 int nSel = -1, int nOldSel = -1)
43 : wxCommandEvent(commandType, id) { m_nSel = nSel; m_nOldSel = nOldSel; }
44
45 // accessors
46 int GetSelection() const { return m_nSel; }
47 int GetOldSelection() const { return m_nOldSel; }
48
49private:
50 int m_nSel, // currently selected page
51 m_nOldSel; // previously selected page
52
53 DECLARE_DYNAMIC_CLASS(wxNotebookEvent)
54};
55
01b2eeec 56// ----------------------------------------------------------------------------
7c78e7c7 57// wxNotebook
01b2eeec 58// ----------------------------------------------------------------------------
7c78e7c7 59
01b2eeec
KB
60// @@@ this class should really derive from wxTabCtrl, but the interface is not
61// exactly the same, so I can't do it right now and instead we reimplement
62// part of wxTabCtrl here
7c78e7c7
RR
63class wxNotebook : public wxControl
64{
65public:
66 // ctors
67 // -----
68 // default for dynamic class
69 wxNotebook();
70 // the same arguments as for wxControl (@@@ any special styles?)
71 wxNotebook(wxWindow *parent,
01b2eeec 72 wxWindowID id,
7c78e7c7
RR
73 const wxPoint& pos = wxDefaultPosition,
74 const wxSize& size = wxDefaultSize,
75 long style = 0,
76 const wxString& name = "notebook");
77 // Create() function
78 bool Create(wxWindow *parent,
01b2eeec 79 wxWindowID id,
7c78e7c7
RR
80 const wxPoint& pos = wxDefaultPosition,
81 const wxSize& size = wxDefaultSize,
82 long style = 0,
83 const wxString& name = "notebook");
84 // dtor
85 ~wxNotebook();
86
87 // accessors
88 // ---------
89 // get number of pages in the dialog
90 int GetPageCount() const;
91
92 // set the currently selected page, return the index of the previously
93 // selected one (or -1 on error)
94 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
95 int SetSelection(int nPage);
96 // cycle thru the tabs
97 void AdvanceSelection(bool bForward = TRUE);
98 // get the currently selected page
01b2eeec 99 int GetSelection() const { return m_nSelection; }
7c78e7c7
RR
100
101 // set/get the title of a page
102 bool SetPageText(int nPage, const wxString& strText);
103 wxString GetPageText(int nPage) const;
104
105 // image list stuff: each page may have an image associated with it. All
106 // the images belong to an image list, so you have to
107 // 1) create an image list
108 // 2) associate it with the notebook
109 // 3) set for each page it's image
110 // associate image list with a control
111 void SetImageList(wxImageList* imageList);
112 // get pointer (may be NULL) to the associated image list
01b2eeec 113 wxImageList* GetImageList() const { return m_pImageList; }
7c78e7c7
RR
114
115 // sets/returns item's image index in the current image list
116 int GetPageImage(int nPage) const;
117 bool SetPageImage(int nPage, int nImage);
118
119 // currently it's always 1 because wxGTK doesn't support multi-row
120 // tab controls
121 int GetRowCount() const;
122
123 // control the appearance of the notebook pages
124 // set the size (the same for all pages)
125 void SetPageSize(const wxSize& size);
126 // set the padding between tabs (in pixels)
127 void SetPadding(const wxSize& padding);
128
129 // operations
130 // ----------
131 // remove one page from the notebook
132 bool DeletePage(int nPage);
133 // remove all pages
134 bool DeleteAllPages();
135 // adds a new page to the notebook (it will be deleted ny the notebook,
136 // don't delete it yourself). If bSelect, this page becomes active.
01b2eeec 137 bool AddPage(wxNotebookPage *pPage,
7c78e7c7
RR
138 const wxString& strText,
139 bool bSelect = FALSE,
140 int imageId = -1);
01b2eeec
KB
141 // the same as AddPage(), but adds it at the specified position
142 bool InsertPage(int nPage,
143 wxNotebookPage *pPage,
144 const wxString& strText,
145 bool bSelect = FALSE,
146 int imageId = -1);
7c78e7c7 147 // get the panel which represents the given page
01b2eeec 148 wxNotebookPage *GetPage(int nPage) { return m_aPages[nPage]; }
7c78e7c7 149
01b2eeec
KB
150 // callbacks
151 // ---------
152 void OnSize(wxSizeEvent& event);
153 void OnSelChange(wxNotebookEvent& event);
154 void OnSetFocus(wxFocusEvent& event);
155 void OnNavigationKey(wxNavigationKeyEvent& event);
156
157 // base class virtuals
158 // -------------------
159 virtual void Command(wxCommandEvent& event);
160 virtual void SetConstraintSizes(bool recurse = TRUE);
161 virtual bool DoPhase(int nPhase);
162
163protected:
7c78e7c7
RR
164 // common part of all ctors
165 void Init();
166
01b2eeec
KB
167 // helper functions
168 void ChangePage(int nOldSel, int nSel); // change pages
169
170 wxImageList *m_pImageList; // we can have an associated image list
171 wxArrayPages m_aPages; // array of pages
172
173 int m_nSelection; // the current selection (-1 if none)
7c78e7c7
RR
174
175 DECLARE_DYNAMIC_CLASS(wxNotebook)
01b2eeec 176 DECLARE_EVENT_TABLE()
7c78e7c7
RR
177};
178
179// ----------------------------------------------------------------------------
180// event macros
181// ----------------------------------------------------------------------------
182typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
183
184#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
185 { \
186 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \
187 id, \
188 -1, \
189 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
190 NULL \
191 },
192
193#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
194 { \
195 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \ \
196 id, \
197 -1, \
198 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
199 NULL \
200 },
201
01b2eeec 202#endif // _WX_NOTEBOOK_H_