1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/notebook.h
3 // Purpose: MSW/GTK compatible notebook (a.k.a. property sheet)
4 // Author: Robert Roebling
5 // Modified by: Vadim Zeitlin for Windows version
7 // Copyright: (c) Julian Smart and Markus Holzem
8 // Licence: wxWindows license
9 /////////////////////////////////////////////////////////////////////////////
15 #pragma interface "notebook.h"
18 // ----------------------------------------------------------------------------
20 // ----------------------------------------------------------------------------
22 #include <wx/dynarray.h>
25 // ----------------------------------------------------------------------------
27 // ----------------------------------------------------------------------------
30 class WXDLLEXPORT wxImageList
;
31 class WXDLLEXPORT wxWindow
;
33 // array of notebook pages
34 typedef wxWindow WXDLLEXPORT wxNotebookPage
; // so far, any window can be a page
36 #undef WXDLLEXPORTLOCAL
37 #define WXDLLEXPORTLOCAL WXDLLEXPORT
39 WX_DEFINE_ARRAY(wxNotebookPage
*, wxArrayPages
);
41 #undef WXDLLEXPORTLOCAL
42 #define WXDLLEXPORTLOCAL
44 // ----------------------------------------------------------------------------
46 // ----------------------------------------------------------------------------
48 // FIXME this class should really derive from wxTabCtrl, but the interface is not
49 // exactly the same, so I can't do it right now and instead we reimplement
50 // part of wxTabCtrl here
51 class WXDLLEXPORT wxNotebook
: public wxControl
56 // default for dynamic class
58 // the same arguments as for wxControl (@@@ any special styles?)
59 wxNotebook(wxWindow
*parent
,
61 const wxPoint
& pos
= wxDefaultPosition
,
62 const wxSize
& size
= wxDefaultSize
,
64 const wxString
& name
= "notebook");
66 bool Create(wxWindow
*parent
,
68 const wxPoint
& pos
= wxDefaultPosition
,
69 const wxSize
& size
= wxDefaultSize
,
71 const wxString
& name
= "notebook");
77 // get number of pages in the dialog
78 int GetPageCount() const;
80 // set the currently selected page, return the index of the previously
81 // selected one (or -1 on error)
82 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
83 int SetSelection(int nPage
);
84 // cycle thru the tabs
85 void AdvanceSelection(bool bForward
= TRUE
);
86 // get the currently selected page
87 int GetSelection() const { return m_nSelection
; }
89 // set/get the title of a page
90 bool SetPageText(int nPage
, const wxString
& strText
);
91 wxString
GetPageText(int nPage
) const;
93 // image list stuff: each page may have an image associated with it. All
94 // the images belong to an image list, so you have to
95 // 1) create an image list
96 // 2) associate it with the notebook
97 // 3) set for each page it's image
98 // associate image list with a control
99 void SetImageList(wxImageList
* imageList
);
100 // get pointer (may be NULL) to the associated image list
101 wxImageList
* GetImageList() const { return m_pImageList
; }
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 // currently it's always 1 because wxGTK doesn't support multi-row
109 int GetRowCount() const;
111 // control the appearance of the notebook pages
112 // set the size (the same for all pages)
113 void SetPageSize(const wxSize
& size
);
114 // set the padding between tabs (in pixels)
115 void SetPadding(const wxSize
& padding
);
119 // remove one page from the notebook
120 bool DeletePage(int nPage
);
121 // remove one page from the notebook, without deleting
122 bool RemovePage(int nPage
);
124 bool DeleteAllPages();
125 // adds a new page to the notebook (it will be deleted ny the notebook,
126 // don't delete it yourself). If bSelect, this page becomes active.
127 bool AddPage(wxNotebookPage
*pPage
,
128 const wxString
& strText
,
129 bool bSelect
= FALSE
,
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
,
137 // get the panel which represents the given page
138 wxNotebookPage
*GetPage(int nPage
) { return m_aPages
[nPage
]; }
140 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
142 void SetTabSize(const wxSize
& sz
);
146 void OnWindowCreate(wxWindowCreateEvent
& event
);
147 void OnSelChange(wxNotebookEvent
& event
);
148 void OnSetFocus(wxFocusEvent
& event
);
149 void OnNavigationKey(wxNavigationKeyEvent
& event
);
151 // base class virtuals
152 // -------------------
153 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
154 virtual void SetConstraintSizes(bool recurse
= TRUE
);
155 virtual bool DoPhase(int nPhase
);
158 // common part of all ctors
162 void ChangePage(int nOldSel
, int nSel
); // change pages
164 wxImageList
*m_pImageList
; // we can have an associated image list
165 wxArrayPages m_aPages
; // array of pages
167 int m_nSelection
; // the current selection (-1 if none)
169 DECLARE_DYNAMIC_CLASS(wxNotebook
)
170 DECLARE_EVENT_TABLE()
173 #endif // _NOTEBOOK_H