]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/qt/notebook.h
Reworked Frame class
[wxWidgets.git] / include / wx / qt / notebook.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: notebook.h
3// Purpose: MSW/GTK compatible notebook (a.k.a. property sheet)
4// Author: AUTHOR
5// Modified by:
6// RCS-ID: $Id$
7// Copyright: (c) AUTHOR
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_NOTEBOOK_H_
12#define _WX_NOTEBOOK_H_
13
14#ifdef __GNUG__
15#pragma interface "notebook.h"
16#endif
17
18// ----------------------------------------------------------------------------
19// headers
20// ----------------------------------------------------------------------------
21#include <wx/dynarray.h>
22
23// ----------------------------------------------------------------------------
24// types
25// ----------------------------------------------------------------------------
26
27// fwd declarations
28class WXDLLEXPORT wxImageList;
29class WXDLLEXPORT wxWindow;
30
31// array of notebook pages
32typedef wxWindow wxNotebookPage; // so far, any window can be a page
33WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages);
34
35// ----------------------------------------------------------------------------
36// notebook events
37// ----------------------------------------------------------------------------
38class WXDLLEXPORT wxNotebookEvent : public wxCommandEvent
39{
40public:
41 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
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
56// ----------------------------------------------------------------------------
57// wxNotebook
58// ----------------------------------------------------------------------------
59
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
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,
72 wxWindowID id,
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,
79 wxWindowID id,
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
99 int GetSelection() const { return m_nSelection; }
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
113 wxImageList* GetImageList() const { return m_pImageList; }
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.
137 bool AddPage(wxNotebookPage *pPage,
138 const wxString& strText,
139 bool bSelect = FALSE,
140 int imageId = -1);
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);
147 // get the panel which represents the given page
148 wxNotebookPage *GetPage(int nPage) { return m_aPages[nPage]; }
149
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:
164 // common part of all ctors
165 void Init();
166
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)
174
175 DECLARE_DYNAMIC_CLASS(wxNotebook)
176 DECLARE_EVENT_TABLE()
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
202#endif // _WX_NOTEBOOK_H_