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 // 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
);
59 wxNotebook
* m_notebook
;
62 class wxNotebook
: public wxNotebookBase
67 // default for dynamic class
69 // the same arguments as for wxControl (@@@ any special styles?)
70 wxNotebook(wxWindow
*parent
,
72 const wxPoint
& pos
= wxDefaultPosition
,
73 const wxSize
& size
= wxDefaultSize
,
75 const wxString
& name
= "notebook");
77 bool Create(wxWindow
*parent
,
79 const wxPoint
& pos
= wxDefaultPosition
,
80 const wxSize
& size
= wxDefaultSize
,
82 const wxString
& name
= "notebook");
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 // 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 ;
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
);
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
);
118 // Sets the size of the tabs (assumes all tabs are the same size)
119 void SetTabSize(const wxSize
& sz
);
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
);
130 bool DeleteAllPages();
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
,
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
);
146 // base class virtuals
147 // -------------------
148 virtual void Command(wxCommandEvent
& event
);
149 virtual void SetConstraintSizes(bool recurse
= TRUE
);
150 virtual bool DoPhase(int nPhase
);
154 // wxNotebook on Motif uses a generic wxTabView to implement itself.
155 wxTabView
*GetTabView() const { return m_tabView
; }
156 void SetTabView(wxTabView
*v
) { m_tabView
= v
; }
158 void OnMouseEvent(wxMouseEvent
& event
);
159 void OnPaint(wxPaintEvent
& event
);
161 virtual wxRect
GetAvailableClientSize();
163 // Implementation: calculate the layout of the view rect
164 // and resize the children if required
165 bool RefreshLayout(bool force
= TRUE
);
168 // common part of all ctors
172 void ChangePage(int nOldSel
, int nSel
); // change pages
175 wxImageList
*m_pImageList
; // we can have an associated image list
176 wxArrayPages m_aPages
; // array of pages
179 int m_nSelection
; // the current selection (-1 if none)
181 wxTabView
* m_tabView
;
183 DECLARE_DYNAMIC_CLASS(wxNotebook
)
184 DECLARE_EVENT_TABLE()
187 #endif // _WX_NOTEBOOK_H_