]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/notebook.h
Removed unnecessary code from utilsunx.cpp
[wxWidgets.git] / include / wx / generic / notebook.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: notebook.h
3 // Purpose: wxNotebook class (a.k.a. property sheet, tabbed dialog)
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"
24 #include "wx/generic/tabg.h"
25
26 // ----------------------------------------------------------------------------
27 // types
28 // ----------------------------------------------------------------------------
29
30 // fwd declarations
31 class WXDLLEXPORT wxImageList;
32 class WXDLLEXPORT wxWindow;
33
34 // array of notebook pages
35 typedef wxWindow wxNotebookPage; // so far, any window can be a page
36 WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages);
37
38 // ----------------------------------------------------------------------------
39 // wxNotebook
40 // ----------------------------------------------------------------------------
41
42 class WXDLLEXPORT wxNotebook;
43
44 // This reuses wxTabView to draw the tabs.
45 class WXDLLEXPORT wxNotebookTabView: public wxTabView
46 {
47 DECLARE_DYNAMIC_CLASS(wxNotebookTabView)
48 public:
49 wxNotebookTabView(wxNotebook* notebook, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR);
50 ~wxNotebookTabView(void);
51
52 // Called when a tab is activated
53 virtual void OnTabActivate(int activateId, int deactivateId);
54
55 protected:
56 wxNotebook* m_notebook;
57 };
58
59 class wxNotebook : public wxControl
60 {
61 public:
62 // ctors
63 // -----
64 // default for dynamic class
65 wxNotebook();
66 // the same arguments as for wxControl (@@@ any special styles?)
67 wxNotebook(wxWindow *parent,
68 wxWindowID id,
69 const wxPoint& pos = wxDefaultPosition,
70 const wxSize& size = wxDefaultSize,
71 long style = 0,
72 const wxString& name = "notebook");
73 // Create() function
74 bool Create(wxWindow *parent,
75 wxWindowID id,
76 const wxPoint& pos = wxDefaultPosition,
77 const wxSize& size = wxDefaultSize,
78 long style = 0,
79 const wxString& name = "notebook");
80 // dtor
81 ~wxNotebook();
82
83 // accessors
84 // ---------
85 // get number of pages in the dialog
86 int GetPageCount() const;
87
88 // Find the position of the wxNotebookPage, -1 if not found.
89 int FindPagePosition(wxNotebookPage* page) const;
90
91 // set the currently selected page, return the index of the previously
92 // selected one (or -1 on error)
93 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
94 int SetSelection(int nPage);
95 // cycle thru the tabs
96 void AdvanceSelection(bool bForward = TRUE);
97 // get the currently selected page
98 int GetSelection() const { return m_nSelection; }
99
100 // set/get the title of a page
101 bool SetPageText(int nPage, const wxString& strText);
102 wxString GetPageText(int nPage) const;
103
104 // image list stuff: each page may have an image associated with it. All
105 // the images belong to an image list, so you have to
106 // 1) create an image list
107 // 2) associate it with the notebook
108 // 3) set for each page it's image
109 // associate image list with a control
110 void SetImageList(wxImageList* imageList);
111 // get pointer (may be NULL) to the associated image list
112 wxImageList* GetImageList() const { return m_pImageList; }
113
114 // sets/returns item's image index in the current image list
115 int GetPageImage(int nPage) const;
116 bool SetPageImage(int nPage, int nImage);
117
118 // currently it's always 1 because wxGTK doesn't support multi-row
119 // tab controls
120 int GetRowCount() const;
121
122 // control the appearance of the notebook pages
123 // set the size (the same for all pages)
124 void SetPageSize(const wxSize& size);
125 // set the padding between tabs (in pixels)
126 void SetPadding(const wxSize& padding);
127
128 // Sets the size of the tabs (assumes all tabs are the same size)
129 void SetTabSize(const wxSize& sz);
130
131 // operations
132 // ----------
133 // remove one page from the notebook, and delete the page.
134 bool DeletePage(int nPage);
135 bool DeletePage(wxNotebookPage* page);
136 // remove one page from the notebook, without deleting the page.
137 bool RemovePage(int nPage);
138 bool RemovePage(wxNotebookPage* page);
139 // remove all pages
140 bool DeleteAllPages();
141 // adds a new page to the notebook (it will be deleted ny the notebook,
142 // don't delete it yourself). If bSelect, this page becomes active.
143 bool AddPage(wxNotebookPage *pPage,
144 const wxString& strText,
145 bool bSelect = FALSE,
146 int imageId = -1);
147 // the same as AddPage(), but adds it at the specified position
148 bool InsertPage(int nPage,
149 wxNotebookPage *pPage,
150 const wxString& strText,
151 bool bSelect = FALSE,
152 int imageId = -1);
153 // get the panel which represents the given page
154 wxNotebookPage *GetPage(int nPage) { return m_aPages[nPage]; }
155
156 // callbacks
157 // ---------
158 void OnSize(wxSizeEvent& event);
159 void OnIdle(wxIdleEvent& event);
160 void OnSelChange(wxNotebookEvent& event);
161 void OnSetFocus(wxFocusEvent& event);
162 void OnNavigationKey(wxNavigationKeyEvent& event);
163
164 // base class virtuals
165 // -------------------
166 virtual void Command(wxCommandEvent& event);
167 virtual void SetConstraintSizes(bool recurse = TRUE);
168 virtual bool DoPhase(int nPhase);
169
170 // Implementation
171
172 // wxNotebook on Motif uses a generic wxTabView to implement itself.
173 wxTabView *GetTabView() const { return m_tabView; }
174 void SetTabView(wxTabView *v) { m_tabView = v; }
175
176 void OnMouseEvent(wxMouseEvent& event);
177 void OnPaint(wxPaintEvent& event);
178
179 virtual wxRect GetAvailableClientSize();
180
181 // Implementation: calculate the layout of the view rect
182 // and resize the children if required
183 bool RefreshLayout(bool force = TRUE);
184
185 protected:
186 // common part of all ctors
187 void Init();
188
189 // helper functions
190 void ChangePage(int nOldSel, int nSel); // change pages
191
192 wxImageList *m_pImageList; // we can have an associated image list
193 wxArrayPages m_aPages; // array of pages
194
195 int m_nSelection; // the current selection (-1 if none)
196
197 wxTabView* m_tabView;
198
199 DECLARE_DYNAMIC_CLASS(wxNotebook)
200 DECLARE_EVENT_TABLE()
201 };
202
203 #endif // _WX_NOTEBOOK_H_