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_
14 #if defined(__GNUG__) && !defined(__APPLE__)
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 // Already defined in wx/notebook.h
36 // array of notebook pages
37 typedef wxWindow wxNotebookPage
; // so far, any window can be a page
38 WX_DEFINE_ARRAY(wxNotebookPage
*, wxArrayPages
);
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 class WXDLLEXPORT wxNotebook
;
47 // This reuses wxTabView to draw the tabs.
48 class WXDLLEXPORT wxNotebookTabView
: public wxTabView
50 DECLARE_DYNAMIC_CLASS(wxNotebookTabView
)
52 wxNotebookTabView(wxNotebook
* notebook
, long style
= wxTAB_STYLE_DRAW_BOX
| wxTAB_STYLE_COLOUR_INTERIOR
);
53 ~wxNotebookTabView(void);
55 // Called when a tab is activated
56 virtual void OnTabActivate(int activateId
, int deactivateId
);
58 virtual bool OnTabPreActivate(int activateId
, int deactivateId
);
61 wxNotebook
* m_notebook
;
64 class wxNotebook
: public wxNotebookBase
69 // default for dynamic class
71 // the same arguments as for wxControl (@@@ any special styles?)
72 wxNotebook(wxWindow
*parent
,
74 const wxPoint
& pos
= wxDefaultPosition
,
75 const wxSize
& size
= wxDefaultSize
,
77 const wxString
& name
= "notebook");
79 bool Create(wxWindow
*parent
,
81 const wxPoint
& pos
= wxDefaultPosition
,
82 const wxSize
& size
= wxDefaultSize
,
84 const wxString
& name
= "notebook");
90 // Find the position of the wxNotebookPage, -1 if not found.
91 int FindPagePosition(wxNotebookPage
* page
) const;
93 // set the currently selected page, return the index of the previously
94 // selected one (or -1 on error)
95 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
96 int SetSelection(int nPage
);
97 // cycle thru the tabs
98 // void AdvanceSelection(bool bForward = TRUE);
99 // get the currently selected page
100 int GetSelection() const { return m_nSelection
; }
102 // set/get the title of a page
103 bool SetPageText(int nPage
, const wxString
& strText
);
104 wxString
GetPageText(int nPage
) const;
106 // get the number of rows for a control with wxNB_MULTILINE style (not all
107 // versions support it - they will always return 1 then)
108 virtual int GetRowCount() const ;
110 // sets/returns item's image index in the current image list
111 int GetPageImage(int nPage
) const;
112 bool SetPageImage(int nPage
, int nImage
);
114 // control the appearance of the notebook pages
115 // set the size (the same for all pages)
116 void SetPageSize(const wxSize
& size
);
117 // set the padding between tabs (in pixels)
118 void SetPadding(const wxSize
& padding
);
120 // Sets the size of the tabs (assumes all tabs are the same size)
121 void SetTabSize(const wxSize
& sz
);
125 // remove one page from the notebook, and delete the page.
126 bool DeletePage(int nPage
);
127 bool DeletePage(wxNotebookPage
* page
);
128 // remove one page from the notebook, without deleting the page.
129 bool RemovePage(int nPage
);
130 bool RemovePage(wxNotebookPage
* page
);
132 bool DeleteAllPages();
133 // the same as AddPage(), but adds it at the specified position
134 bool InsertPage(int nPage
,
135 wxNotebookPage
*pPage
,
136 const wxString
& strText
,
137 bool bSelect
= FALSE
,
142 void OnSize(wxSizeEvent
& event
);
143 void OnIdle(wxIdleEvent
& event
);
144 void OnSelChange(wxNotebookEvent
& event
);
145 void OnSetFocus(wxFocusEvent
& event
);
146 void OnNavigationKey(wxNavigationKeyEvent
& event
);
148 // base class virtuals
149 // -------------------
150 virtual void Command(wxCommandEvent
& event
);
151 virtual void SetConstraintSizes(bool recurse
= TRUE
);
152 virtual bool DoPhase(int nPhase
);
156 // wxNotebook on Motif uses a generic wxTabView to implement itself.
157 wxTabView
*GetTabView() const { return m_tabView
; }
158 void SetTabView(wxTabView
*v
) { m_tabView
= v
; }
160 void OnMouseEvent(wxMouseEvent
& event
);
161 void OnPaint(wxPaintEvent
& event
);
163 virtual wxRect
GetAvailableClientSize();
165 // Implementation: calculate the layout of the view rect
166 // and resize the children if required
167 bool RefreshLayout(bool force
= TRUE
);
170 // common part of all ctors
174 void ChangePage(int nOldSel
, int nSel
); // change pages
177 wxImageList
*m_pImageList
; // we can have an associated image list
178 wxArrayPages m_aPages
; // array of pages
181 int m_nSelection
; // the current selection (-1 if none)
183 wxTabView
* m_tabView
;
185 DECLARE_DYNAMIC_CLASS(wxNotebook
)
186 DECLARE_EVENT_TABLE()
189 #endif // _WX_NOTEBOOK_H_