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 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 class WXDLLEXPORT wxNotebook
;
40 // This reuses wxTabView to draw the tabs.
41 class WXDLLEXPORT wxNotebookTabView
: public wxTabView
43 DECLARE_DYNAMIC_CLASS(wxNotebookTabView
)
45 wxNotebookTabView(wxNotebook
* notebook
, long style
= wxTAB_STYLE_DRAW_BOX
| wxTAB_STYLE_COLOUR_INTERIOR
);
46 ~wxNotebookTabView(void);
48 // Called when a tab is activated
49 virtual void OnTabActivate(int activateId
, int deactivateId
);
51 virtual bool OnTabPreActivate(int activateId
, int deactivateId
);
54 wxNotebook
* m_notebook
;
57 class wxNotebook
: public wxNotebookBase
62 // default for dynamic class
64 // the same arguments as for wxControl (@@@ any special styles?)
65 wxNotebook(wxWindow
*parent
,
67 const wxPoint
& pos
= wxDefaultPosition
,
68 const wxSize
& size
= wxDefaultSize
,
70 const wxString
& name
= "notebook");
72 bool Create(wxWindow
*parent
,
74 const wxPoint
& pos
= wxDefaultPosition
,
75 const wxSize
& size
= wxDefaultSize
,
77 const wxString
& name
= "notebook");
83 // Find the position of the wxNotebookPage, -1 if not found.
84 int FindPagePosition(wxNotebookPage
* page
) const;
86 // set the currently selected page, return the index of the previously
87 // selected one (or -1 on error)
88 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
89 int SetSelection(int nPage
);
90 // cycle thru the tabs
91 // void AdvanceSelection(bool bForward = TRUE);
92 // get the currently selected page
93 int GetSelection() const { return m_nSelection
; }
95 // set/get the title of a page
96 bool SetPageText(int nPage
, const wxString
& strText
);
97 wxString
GetPageText(int nPage
) const;
99 // get the number of rows for a control with wxNB_MULTILINE style (not all
100 // versions support it - they will always return 1 then)
101 virtual int GetRowCount() const ;
103 // sets/returns item's image index in the current image list
104 int GetPageImage(int nPage
) const;
105 bool SetPageImage(int nPage
, int nImage
);
107 // control the appearance of the notebook pages
108 // set the size (the same for all pages)
109 void SetPageSize(const wxSize
& size
);
110 // set the padding between tabs (in pixels)
111 void SetPadding(const wxSize
& padding
);
113 // Sets the size of the tabs (assumes all tabs are the same size)
114 void SetTabSize(const wxSize
& sz
);
118 // remove one page from the notebook, and delete the page.
119 bool DeletePage(int nPage
);
120 bool DeletePage(wxNotebookPage
* page
);
121 // remove one page from the notebook, without deleting the page.
122 bool RemovePage(int nPage
);
123 bool RemovePage(wxNotebookPage
* page
);
125 bool DeleteAllPages();
126 // the same as AddPage(), but adds it at the specified position
127 bool InsertPage(int nPage
,
128 wxNotebookPage
*pPage
,
129 const wxString
& strText
,
130 bool bSelect
= FALSE
,
135 void OnSize(wxSizeEvent
& event
);
136 void OnIdle(wxIdleEvent
& event
);
137 void OnSelChange(wxNotebookEvent
& event
);
138 void OnSetFocus(wxFocusEvent
& event
);
139 void OnNavigationKey(wxNavigationKeyEvent
& event
);
141 // base class virtuals
142 // -------------------
143 virtual void Command(wxCommandEvent
& event
);
144 virtual void SetConstraintSizes(bool recurse
= TRUE
);
145 virtual bool DoPhase(int nPhase
);
149 // wxNotebook on Motif uses a generic wxTabView to implement itself.
150 wxTabView
*GetTabView() const { return m_tabView
; }
151 void SetTabView(wxTabView
*v
) { m_tabView
= v
; }
153 void OnMouseEvent(wxMouseEvent
& event
);
154 void OnPaint(wxPaintEvent
& event
);
156 virtual wxRect
GetAvailableClientSize();
158 // Implementation: calculate the layout of the view rect
159 // and resize the children if required
160 bool RefreshLayout(bool force
= TRUE
);
163 // common part of all ctors
167 void ChangePage(int nOldSel
, int nSel
); // change pages
169 int m_nSelection
; // the current selection (-1 if none)
171 wxTabView
* m_tabView
;
173 DECLARE_DYNAMIC_CLASS(wxNotebook
)
174 DECLARE_EVENT_TABLE()
177 #endif // _WX_NOTEBOOK_H_