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 // This is a work-around for missing defines in gcc-2.95 headers
27 #define TCS_RIGHT 0x0002
30 #define TCS_VERTICAL 0x0080
33 #define TCS_BOTTOM TCS_RIGHT
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
40 class WXDLLEXPORT wxImageList
;
41 class WXDLLEXPORT wxWindow
;
43 // array of notebook pages
44 typedef wxWindow WXDLLEXPORT wxNotebookPage
; // so far, any window can be a page
46 WX_DEFINE_ARRAY(wxNotebookPage
*, wxArrayPages
);
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 // FIXME this class should really derive from wxTabCtrl, but the interface is not
53 // exactly the same, so I can't do it right now and instead we reimplement
54 // part of wxTabCtrl here
55 class WXDLLEXPORT wxNotebook
: public wxControl
60 // default for dynamic class
62 // the same arguments as for wxControl (@@@ any special styles?)
63 wxNotebook(wxWindow
*parent
,
65 const wxPoint
& pos
= wxDefaultPosition
,
66 const wxSize
& size
= wxDefaultSize
,
68 const wxString
& name
= "notebook");
70 bool Create(wxWindow
*parent
,
72 const wxPoint
& pos
= wxDefaultPosition
,
73 const wxSize
& size
= wxDefaultSize
,
75 const wxString
& name
= "notebook");
81 // get number of pages in the dialog
82 int GetPageCount() const;
84 // set the currently selected page, return the index of the previously
85 // selected one (or -1 on error)
86 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
87 int SetSelection(int nPage
);
88 // cycle thru the tabs
89 void AdvanceSelection(bool bForward
= TRUE
);
90 // get the currently selected page
91 int GetSelection() const { return m_nSelection
; }
93 // set/get the title of a page
94 bool SetPageText(int nPage
, const wxString
& strText
);
95 wxString
GetPageText(int nPage
) const;
97 // image list stuff: each page may have an image associated with it. All
98 // the images belong to an image list, so you have to
99 // 1) create an image list
100 // 2) associate it with the notebook
101 // 3) set for each page it's image
102 // associate image list with a control
103 void SetImageList(wxImageList
* imageList
);
104 // get pointer (may be NULL) to the associated image list
105 wxImageList
* GetImageList() const { return m_pImageList
; }
107 // sets/returns item's image index in the current image list
108 int GetPageImage(int nPage
) const;
109 bool SetPageImage(int nPage
, int nImage
);
111 // currently it's always 1 because wxGTK doesn't support multi-row
113 int GetRowCount() const;
115 // control the appearance of the notebook pages
116 // set the size (the same for all pages)
117 void SetPageSize(const wxSize
& size
);
118 // set the padding between tabs (in pixels)
119 void SetPadding(const wxSize
& padding
);
123 // remove one page from the notebook
124 bool DeletePage(int nPage
);
125 // remove one page from the notebook, without deleting
126 bool RemovePage(int nPage
);
128 bool DeleteAllPages();
129 // adds a new page to the notebook (it will be deleted ny the notebook,
130 // don't delete it yourself). If bSelect, this page becomes active.
131 bool AddPage(wxNotebookPage
*pPage
,
132 const wxString
& strText
,
133 bool bSelect
= FALSE
,
135 // the same as AddPage(), but adds it at the specified position
136 bool InsertPage(int nPage
,
137 wxNotebookPage
*pPage
,
138 const wxString
& strText
,
139 bool bSelect
= FALSE
,
141 // get the panel which represents the given page
142 wxNotebookPage
*GetPage(int nPage
) { return m_aPages
[nPage
]; }
144 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
146 void SetTabSize(const wxSize
& sz
);
150 void OnSize(wxSizeEvent
& event
);
151 void OnSelChange(wxNotebookEvent
& event
);
152 void OnSetFocus(wxFocusEvent
& event
);
153 void OnNavigationKey(wxNavigationKeyEvent
& event
);
155 // base class virtuals
156 // -------------------
157 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
158 virtual void SetConstraintSizes(bool recurse
= TRUE
);
159 virtual bool DoPhase(int nPhase
);
162 // common part of all ctors
166 void ChangePage(int nOldSel
, int nSel
); // change pages
168 wxImageList
*m_pImageList
; // we can have an associated image list
169 wxArrayPages m_aPages
; // array of pages
171 int m_nSelection
; // the current selection (-1 if none)
173 DECLARE_DYNAMIC_CLASS(wxNotebook
)
174 DECLARE_EVENT_TABLE()
177 #endif // _NOTEBOOK_H