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 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 #include "wx/control.h"
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
25 class WXDLLIMPEXP_FWD_CORE wxImageList
;
26 class WXDLLIMPEXP_FWD_CORE wxWindow
;
27 class WXDLLIMPEXP_FWD_CORE wxTabView
;
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 class WXDLLIMPEXP_CORE wxNotebook
: public wxNotebookBase
38 // default for dynamic class
40 // the same arguments as for wxControl (@@@ any special styles?)
41 wxNotebook(wxWindow
*parent
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
46 const wxString
& name
= wxNotebookNameStr
);
48 bool Create(wxWindow
*parent
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
53 const wxString
& name
= wxNotebookNameStr
);
55 virtual ~wxNotebook();
59 // Find the position of the wxNotebookPage, -1 if not found.
60 int FindPagePosition(wxNotebookPage
* page
) const;
62 // set the currently selected page, return the index of the previously
63 // selected one (or -1 on error)
64 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
65 int SetSelection(size_t nPage
);
66 // cycle thru the tabs
67 // void AdvanceSelection(bool bForward = true);
68 // get the currently selected page
69 int GetSelection() const { return m_nSelection
; }
71 // changes selected page without sending events
72 int ChangeSelection(size_t nPage
);
74 // set/get the title of a page
75 bool SetPageText(size_t nPage
, const wxString
& strText
);
76 wxString
GetPageText(size_t nPage
) const;
78 // get the number of rows for a control with wxNB_MULTILINE style (not all
79 // versions support it - they will always return 1 then)
80 virtual int GetRowCount() const ;
82 // sets/returns item's image index in the current image list
83 int GetPageImage(size_t nPage
) const;
84 bool SetPageImage(size_t nPage
, int nImage
);
86 // control the appearance of the notebook pages
87 // set the size (the same for all pages)
88 void SetPageSize(const wxSize
& size
);
89 // set the padding between tabs (in pixels)
90 void SetPadding(const wxSize
& padding
);
92 // Sets the size of the tabs (assumes all tabs are the same size)
93 void SetTabSize(const wxSize
& sz
);
97 // remove one page from the notebook, and delete the page.
98 bool DeletePage(size_t nPage
);
99 bool DeletePage(wxNotebookPage
* page
);
100 // remove one page from the notebook, without deleting the page.
101 bool RemovePage(size_t nPage
);
102 bool RemovePage(wxNotebookPage
* page
);
103 virtual wxWindow
* DoRemovePage(size_t nPage
);
106 bool DeleteAllPages();
107 // the same as AddPage(), but adds it at the specified position
108 bool InsertPage(size_t nPage
,
109 wxNotebookPage
*pPage
,
110 const wxString
& strText
,
111 bool bSelect
= false,
116 void OnSize(wxSizeEvent
& event
);
117 void OnInternalIdle();
118 void OnSelChange(wxBookCtrlEvent
& event
);
119 void OnSetFocus(wxFocusEvent
& event
);
120 void OnNavigationKey(wxNavigationKeyEvent
& event
);
122 // base class virtuals
123 // -------------------
124 virtual void Command(wxCommandEvent
& event
);
125 virtual void SetConstraintSizes(bool recurse
= true);
126 virtual bool DoPhase(int nPhase
);
128 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
132 // wxNotebook on Motif uses a generic wxTabView to implement itself.
133 wxTabView
*GetTabView() const { return m_tabView
; }
134 void SetTabView(wxTabView
*v
) { m_tabView
= v
; }
136 void OnMouseEvent(wxMouseEvent
& event
);
137 void OnPaint(wxPaintEvent
& event
);
139 virtual wxRect
GetAvailableClientSize();
141 // Implementation: calculate the layout of the view rect
142 // and resize the children if required
143 bool RefreshLayout(bool force
= true);
146 // common part of all ctors
150 void ChangePage(int nOldSel
, int nSel
); // change pages
152 int m_nSelection
; // the current selection (-1 if none)
154 wxTabView
* m_tabView
;
156 DECLARE_DYNAMIC_CLASS(wxNotebook
)
157 DECLARE_EVENT_TABLE()
160 #endif // _WX_NOTEBOOK_H_