]>
Commit | Line | Data |
---|---|---|
1e6d9499 JS |
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 | |
af0bb3b1 | 8 | // Licence: wxWindows licence |
1e6d9499 JS |
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 | ||
45f22d48 JS |
34 | // Already defined in wx/notebook.h |
35 | #if 0 | |
1e6d9499 JS |
36 | // array of notebook pages |
37 | typedef wxWindow wxNotebookPage; // so far, any window can be a page | |
38 | WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages); | |
45f22d48 | 39 | #endif |
1e6d9499 | 40 | |
1e6d9499 JS |
41 | // ---------------------------------------------------------------------------- |
42 | // wxNotebook | |
43 | // ---------------------------------------------------------------------------- | |
44 | ||
45 | class WXDLLEXPORT wxNotebook; | |
46 | ||
47 | // This reuses wxTabView to draw the tabs. | |
48 | class WXDLLEXPORT wxNotebookTabView: public wxTabView | |
49 | { | |
50 | DECLARE_DYNAMIC_CLASS(wxNotebookTabView) | |
51 | public: | |
52 | wxNotebookTabView(wxNotebook* notebook, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR); | |
53 | ~wxNotebookTabView(void); | |
54 | ||
55 | // Called when a tab is activated | |
56 | virtual void OnTabActivate(int activateId, int deactivateId); | |
57 | ||
58 | protected: | |
59 | wxNotebook* m_notebook; | |
60 | }; | |
61 | ||
45f22d48 | 62 | class wxNotebook : public wxNotebookBase |
1e6d9499 JS |
63 | { |
64 | public: | |
65 | // ctors | |
66 | // ----- | |
67 | // default for dynamic class | |
68 | wxNotebook(); | |
69 | // the same arguments as for wxControl (@@@ any special styles?) | |
70 | wxNotebook(wxWindow *parent, | |
af0bb3b1 | 71 | wxWindowID id, |
1e6d9499 JS |
72 | const wxPoint& pos = wxDefaultPosition, |
73 | const wxSize& size = wxDefaultSize, | |
74 | long style = 0, | |
75 | const wxString& name = "notebook"); | |
76 | // Create() function | |
77 | bool Create(wxWindow *parent, | |
af0bb3b1 | 78 | wxWindowID id, |
1e6d9499 JS |
79 | const wxPoint& pos = wxDefaultPosition, |
80 | const wxSize& size = wxDefaultSize, | |
81 | long style = 0, | |
82 | const wxString& name = "notebook"); | |
83 | // dtor | |
84 | ~wxNotebook(); | |
85 | ||
86 | // accessors | |
87 | // --------- | |
1e6d9499 JS |
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 | |
45f22d48 | 96 | // void AdvanceSelection(bool bForward = TRUE); |
1e6d9499 JS |
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 | ||
45f22d48 JS |
104 | // get the number of rows for a control with wxNB_MULTILINE style (not all |
105 | // versions support it - they will always return 1 then) | |
106 | virtual int GetRowCount() const ; | |
1e6d9499 JS |
107 | |
108 | // sets/returns item's image index in the current image list | |
109 | int GetPageImage(int nPage) const; | |
110 | bool SetPageImage(int nPage, int nImage); | |
111 | ||
1e6d9499 JS |
112 | // control the appearance of the notebook pages |
113 | // set the size (the same for all pages) | |
114 | void SetPageSize(const wxSize& size); | |
115 | // set the padding between tabs (in pixels) | |
116 | void SetPadding(const wxSize& padding); | |
117 | ||
ca8b28f2 JS |
118 | // Sets the size of the tabs (assumes all tabs are the same size) |
119 | void SetTabSize(const wxSize& sz); | |
120 | ||
1e6d9499 JS |
121 | // operations |
122 | // ---------- | |
123 | // remove one page from the notebook, and delete the page. | |
124 | bool DeletePage(int nPage); | |
125 | bool DeletePage(wxNotebookPage* page); | |
126 | // remove one page from the notebook, without deleting the page. | |
127 | bool RemovePage(int nPage); | |
128 | bool RemovePage(wxNotebookPage* page); | |
129 | // remove all pages | |
130 | bool DeleteAllPages(); | |
1e6d9499 JS |
131 | // the same as AddPage(), but adds it at the specified position |
132 | bool InsertPage(int nPage, | |
133 | wxNotebookPage *pPage, | |
134 | const wxString& strText, | |
135 | bool bSelect = FALSE, | |
136 | int imageId = -1); | |
1e6d9499 JS |
137 | |
138 | // callbacks | |
139 | // --------- | |
140 | void OnSize(wxSizeEvent& event); | |
141 | void OnIdle(wxIdleEvent& event); | |
142 | void OnSelChange(wxNotebookEvent& event); | |
143 | void OnSetFocus(wxFocusEvent& event); | |
144 | void OnNavigationKey(wxNavigationKeyEvent& event); | |
af0bb3b1 | 145 | |
1e6d9499 JS |
146 | // base class virtuals |
147 | // ------------------- | |
148 | virtual void Command(wxCommandEvent& event); | |
149 | virtual void SetConstraintSizes(bool recurse = TRUE); | |
150 | virtual bool DoPhase(int nPhase); | |
151 | ||
af0bb3b1 | 152 | // Implementation |
1e6d9499 JS |
153 | |
154 | // wxNotebook on Motif uses a generic wxTabView to implement itself. | |
af0bb3b1 VZ |
155 | wxTabView *GetTabView() const { return m_tabView; } |
156 | void SetTabView(wxTabView *v) { m_tabView = v; } | |
157 | ||
1e6d9499 JS |
158 | void OnMouseEvent(wxMouseEvent& event); |
159 | void OnPaint(wxPaintEvent& event); | |
160 | ||
161 | virtual wxRect GetAvailableClientSize(); | |
162 | ||
163 | // Implementation: calculate the layout of the view rect | |
164 | // and resize the children if required | |
165 | bool RefreshLayout(bool force = TRUE); | |
166 | ||
167 | protected: | |
168 | // common part of all ctors | |
169 | void Init(); | |
170 | ||
171 | // helper functions | |
172 | void ChangePage(int nOldSel, int nSel); // change pages | |
173 | ||
45f22d48 | 174 | #if 0 |
1e6d9499 JS |
175 | wxImageList *m_pImageList; // we can have an associated image list |
176 | wxArrayPages m_aPages; // array of pages | |
45f22d48 JS |
177 | #endif |
178 | ||
1e6d9499 JS |
179 | int m_nSelection; // the current selection (-1 if none) |
180 | ||
181 | wxTabView* m_tabView; | |
182 | ||
183 | DECLARE_DYNAMIC_CLASS(wxNotebook) | |
184 | DECLARE_EVENT_TABLE() | |
185 | }; | |
186 | ||
1e6d9499 | 187 | #endif // _WX_NOTEBOOK_H_ |