]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/notebook.h
Removed references to DEBUG and WXDEBUG; cured Motif font problem; removed
[wxWidgets.git] / include / wx / motif / notebook.h
CommitLineData
9b6dbb09
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: notebook.h
4b5f3fe6 3// Purpose: wxNotebook class (a.k.a. property sheet, tabbed dialog)
9b6dbb09
JS
4// Author: Julian Smart
5// Modified by:
6// RCS-ID: $Id$
7// Copyright: (c) Julian Smart
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#include "wx/event.h"
23#include "wx/control.h"
4b5f3fe6 24#include "wx/generic/tabg.h"
9b6dbb09
JS
25
26// ----------------------------------------------------------------------------
27// types
28// ----------------------------------------------------------------------------
29
30// fwd declarations
31class WXDLLEXPORT wxImageList;
32class WXDLLEXPORT wxWindow;
33
34// array of notebook pages
35typedef wxWindow wxNotebookPage; // so far, any window can be a page
36WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages);
37
38// ----------------------------------------------------------------------------
39// notebook events
40// ----------------------------------------------------------------------------
41class WXDLLEXPORT wxNotebookEvent : public wxCommandEvent
42{
43public:
44 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
45 int nSel = -1, int nOldSel = -1)
46 : wxCommandEvent(commandType, id) { m_nSel = nSel; m_nOldSel = nOldSel; }
47
48 // accessors
49 int GetSelection() const { return m_nSel; }
50 int GetOldSelection() const { return m_nOldSel; }
51
02800301
JS
52 void SetSelection(int sel) { m_nSel = sel; }
53 void SetOldSelection(int oldSel) { m_nOldSel = oldSel; }
54
9b6dbb09
JS
55private:
56 int m_nSel, // currently selected page
57 m_nOldSel; // previously selected page
58
59 DECLARE_DYNAMIC_CLASS(wxNotebookEvent)
60};
61
62// ----------------------------------------------------------------------------
63// wxNotebook
64// ----------------------------------------------------------------------------
65
4b5f3fe6
JS
66class WXDLLEXPORT wxNotebook;
67
68// This reuses wxTabView to draw the tabs.
69class WXDLLEXPORT wxNotebookTabView: public wxTabView
70{
71DECLARE_DYNAMIC_CLASS(wxNotebookTabView)
72public:
73 wxNotebookTabView(wxNotebook* notebook, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR);
74 ~wxNotebookTabView(void);
75
76 // Called when a tab is activated
77 virtual void OnTabActivate(int activateId, int deactivateId);
78
4b5f3fe6 79protected:
4b5f3fe6
JS
80 wxNotebook* m_notebook;
81};
82
9b6dbb09
JS
83class wxNotebook : public wxControl
84{
85public:
86 // ctors
87 // -----
88 // default for dynamic class
89 wxNotebook();
90 // the same arguments as for wxControl (@@@ any special styles?)
91 wxNotebook(wxWindow *parent,
92 wxWindowID id,
93 const wxPoint& pos = wxDefaultPosition,
94 const wxSize& size = wxDefaultSize,
95 long style = 0,
96 const wxString& name = "notebook");
97 // Create() function
98 bool Create(wxWindow *parent,
99 wxWindowID id,
100 const wxPoint& pos = wxDefaultPosition,
101 const wxSize& size = wxDefaultSize,
102 long style = 0,
103 const wxString& name = "notebook");
104 // dtor
105 ~wxNotebook();
106
107 // accessors
108 // ---------
109 // get number of pages in the dialog
110 int GetPageCount() const;
111
112 // set the currently selected page, return the index of the previously
113 // selected one (or -1 on error)
114 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
115 int SetSelection(int nPage);
116 // cycle thru the tabs
117 void AdvanceSelection(bool bForward = TRUE);
118 // get the currently selected page
119 int GetSelection() const { return m_nSelection; }
120
121 // set/get the title of a page
122 bool SetPageText(int nPage, const wxString& strText);
123 wxString GetPageText(int nPage) const;
124
125 // image list stuff: each page may have an image associated with it. All
126 // the images belong to an image list, so you have to
127 // 1) create an image list
128 // 2) associate it with the notebook
129 // 3) set for each page it's image
130 // associate image list with a control
131 void SetImageList(wxImageList* imageList);
132 // get pointer (may be NULL) to the associated image list
133 wxImageList* GetImageList() const { return m_pImageList; }
134
135 // sets/returns item's image index in the current image list
136 int GetPageImage(int nPage) const;
137 bool SetPageImage(int nPage, int nImage);
138
139 // currently it's always 1 because wxGTK doesn't support multi-row
140 // tab controls
141 int GetRowCount() const;
142
143 // control the appearance of the notebook pages
144 // set the size (the same for all pages)
145 void SetPageSize(const wxSize& size);
146 // set the padding between tabs (in pixels)
147 void SetPadding(const wxSize& padding);
148
149 // operations
150 // ----------
151 // remove one page from the notebook
152 bool DeletePage(int nPage);
153 // remove all pages
154 bool DeleteAllPages();
155 // adds a new page to the notebook (it will be deleted ny the notebook,
156 // don't delete it yourself). If bSelect, this page becomes active.
157 bool AddPage(wxNotebookPage *pPage,
158 const wxString& strText,
159 bool bSelect = FALSE,
160 int imageId = -1);
161 // the same as AddPage(), but adds it at the specified position
162 bool InsertPage(int nPage,
163 wxNotebookPage *pPage,
164 const wxString& strText,
165 bool bSelect = FALSE,
166 int imageId = -1);
167 // get the panel which represents the given page
168 wxNotebookPage *GetPage(int nPage) { return m_aPages[nPage]; }
169
170 // callbacks
171 // ---------
172 void OnSize(wxSizeEvent& event);
173 void OnSelChange(wxNotebookEvent& event);
174 void OnSetFocus(wxFocusEvent& event);
175 void OnNavigationKey(wxNavigationKeyEvent& event);
176
177 // base class virtuals
178 // -------------------
179 virtual void Command(wxCommandEvent& event);
180 virtual void SetConstraintSizes(bool recurse = TRUE);
181 virtual bool DoPhase(int nPhase);
182
0d57be45 183// Implementation
4b5f3fe6
JS
184
185 // wxNotebook on Motif uses a generic wxTabView to implement itself.
186 inline wxTabView *GetTabView() const { return m_tabView; }
187 inline void SetTabView(wxTabView *v) { m_tabView = v; }
188
189 void OnMouseEvent(wxMouseEvent& event);
190 void OnPaint(wxPaintEvent& event);
191
192 virtual void ChangeFont(bool keepOriginalSize = TRUE);
0d57be45
JS
193 virtual void ChangeBackgroundColour();
194 virtual void ChangeForegroundColour();
02800301 195 virtual wxRect GetAvailableClientSize();
0d57be45 196
9b6dbb09
JS
197protected:
198 // common part of all ctors
199 void Init();
200
201 // helper functions
202 void ChangePage(int nOldSel, int nSel); // change pages
203
204 wxImageList *m_pImageList; // we can have an associated image list
205 wxArrayPages m_aPages; // array of pages
206
207 int m_nSelection; // the current selection (-1 if none)
208
4b5f3fe6
JS
209 wxTabView* m_tabView;
210
9b6dbb09
JS
211 DECLARE_DYNAMIC_CLASS(wxNotebook)
212 DECLARE_EVENT_TABLE()
213};
214
215// ----------------------------------------------------------------------------
216// event macros
217// ----------------------------------------------------------------------------
218typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
219
220#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
221 { \
222 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \
223 id, \
224 -1, \
225 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
226 NULL \
227 },
228
229#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
230 { \
231 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \ \
232 id, \
233 -1, \
234 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
235 NULL \
236 },
237
238#endif // _WX_NOTEBOOK_H_