1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxNotebook class (a.k.a. property sheet, tabbed dialog)
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_NOTEBOOK_H_
12 #define _WX_NOTEBOOK_H_
15 #pragma interface "notebook.h"
18 // ----------------------------------------------------------------------------
20 // ----------------------------------------------------------------------------
21 #include "wx/dynarray.h"
23 #include "wx/control.h"
24 #include "wx/generic/tabg.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
31 class WXDLLEXPORT wxImageList
;
32 class WXDLLEXPORT wxWindow
;
34 // array of notebook pages
35 typedef wxWindow wxNotebookPage
; // so far, any window can be a page
36 WX_DEFINE_ARRAY(wxNotebookPage
*, wxArrayPages
);
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 class WXDLLEXPORT wxNotebook
;
44 // This reuses wxTabView to draw the tabs.
45 class WXDLLEXPORT wxNotebookTabView
: public wxTabView
47 DECLARE_DYNAMIC_CLASS(wxNotebookTabView
)
49 wxNotebookTabView(wxNotebook
* notebook
, long style
= wxTAB_STYLE_DRAW_BOX
| wxTAB_STYLE_COLOUR_INTERIOR
);
50 ~wxNotebookTabView(void);
52 // Called when a tab is activated
53 virtual void OnTabActivate(int activateId
, int deactivateId
);
56 wxNotebook
* m_notebook
;
59 class wxNotebook
: public wxControl
64 // default for dynamic class
66 // the same arguments as for wxControl (@@@ any special styles?)
67 wxNotebook(wxWindow
*parent
,
69 const wxPoint
& pos
= wxDefaultPosition
,
70 const wxSize
& size
= wxDefaultSize
,
72 const wxString
& name
= "notebook");
74 bool Create(wxWindow
*parent
,
76 const wxPoint
& pos
= wxDefaultPosition
,
77 const wxSize
& size
= wxDefaultSize
,
79 const wxString
& name
= "notebook");
85 // get number of pages in the dialog
86 int GetPageCount() const;
88 // Find the position of the wxNotebookPage, -1 if not found.
89 int FindPagePosition(wxNotebookPage
* page
) const;
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
; }
100 // set/get the title of a page
101 bool SetPageText(int nPage
, const wxString
& strText
);
102 wxString
GetPageText(int nPage
) const;
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
; }
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
);
118 // currently it's always 1 because wxGTK doesn't support multi-row
120 int GetRowCount() const;
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
);
128 // Sets the size of the tabs (assumes all tabs are the same size)
129 void SetTabSize(const wxSize
& sz
);
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
);
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
,
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
,
153 // get the panel which represents the given page
154 wxNotebookPage
*GetPage(int nPage
) { return m_aPages
[nPage
]; }
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
);
164 // base class virtuals
165 // -------------------
166 virtual void Command(wxCommandEvent
& event
);
167 virtual void SetConstraintSizes(bool recurse
= TRUE
);
168 virtual bool DoPhase(int nPhase
);
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
; }
176 void OnMouseEvent(wxMouseEvent
& event
);
177 void OnPaint(wxPaintEvent
& event
);
179 virtual wxRect
GetAvailableClientSize();
181 // Implementation: calculate the layout of the view rect
182 // and resize the children if required
183 bool RefreshLayout(bool force
= TRUE
);
186 // common part of all ctors
190 void ChangePage(int nOldSel
, int nSel
); // change pages
192 wxImageList
*m_pImageList
; // we can have an associated image list
193 wxArrayPages m_aPages
; // array of pages
195 int m_nSelection
; // the current selection (-1 if none)
197 wxTabView
* m_tabView
;
199 DECLARE_DYNAMIC_CLASS(wxNotebook
)
200 DECLARE_EVENT_TABLE()
203 #endif // _WX_NOTEBOOK_H_