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 WX_DEFINE_ARRAY(wxNotebookPage
*, wxArrayPages
);
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 // FIXME this class should really derive from wxTabCtrl, but the interface is not
43 // exactly the same, so I can't do it right now and instead we reimplement
44 // part of wxTabCtrl here
45 class WXDLLEXPORT wxNotebook
: public wxControl
50 // default for dynamic class
52 // the same arguments as for wxControl (@@@ any special styles?)
53 wxNotebook(wxWindow
*parent
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
58 const wxString
& name
= "notebook");
60 bool Create(wxWindow
*parent
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
,
65 const wxString
& name
= "notebook");
71 // get number of pages in the dialog
72 int GetPageCount() const;
74 // set the currently selected page, return the index of the previously
75 // selected one (or -1 on error)
76 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
77 int SetSelection(int nPage
);
78 // cycle thru the tabs
79 void AdvanceSelection(bool bForward
= TRUE
);
80 // get the currently selected page
81 int GetSelection() const { return m_nSelection
; }
83 // set/get the title of a page
84 bool SetPageText(int nPage
, const wxString
& strText
);
85 wxString
GetPageText(int nPage
) const;
87 // image list stuff: each page may have an image associated with it. All
88 // the images belong to an image list, so you have to
89 // 1) create an image list
90 // 2) associate it with the notebook
91 // 3) set for each page it's image
92 // associate image list with a control
93 void SetImageList(wxImageList
* imageList
);
94 // get pointer (may be NULL) to the associated image list
95 wxImageList
* GetImageList() const { return m_pImageList
; }
97 // sets/returns item's image index in the current image list
98 int GetPageImage(int nPage
) const;
99 bool SetPageImage(int nPage
, int nImage
);
101 // currently it's always 1 because wxGTK doesn't support multi-row
103 int GetRowCount() const;
105 // control the appearance of the notebook pages
106 // set the size (the same for all pages)
107 void SetPageSize(const wxSize
& size
);
108 // set the padding between tabs (in pixels)
109 void SetPadding(const wxSize
& padding
);
113 // remove one page from the notebook
114 bool DeletePage(int nPage
);
115 // remove one page from the notebook, without deleting
116 bool RemovePage(int nPage
);
118 bool DeleteAllPages();
119 // adds a new page to the notebook (it will be deleted ny the notebook,
120 // don't delete it yourself). If bSelect, this page becomes active.
121 bool AddPage(wxNotebookPage
*pPage
,
122 const wxString
& strText
,
123 bool bSelect
= FALSE
,
125 // the same as AddPage(), but adds it at the specified position
126 bool InsertPage(int nPage
,
127 wxNotebookPage
*pPage
,
128 const wxString
& strText
,
129 bool bSelect
= FALSE
,
131 // get the panel which represents the given page
132 wxNotebookPage
*GetPage(int nPage
) { return m_aPages
[nPage
]; }
134 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
136 void SetTabSize(const wxSize
& sz
);
140 void OnSize(wxSizeEvent
& event
);
141 void OnSelChange(wxNotebookEvent
& event
);
142 void OnSetFocus(wxFocusEvent
& event
);
143 void OnNavigationKey(wxNavigationKeyEvent
& event
);
145 // base class virtuals
146 // -------------------
147 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
148 virtual void SetConstraintSizes(bool recurse
= TRUE
);
149 virtual bool DoPhase(int nPhase
);
152 // common part of all ctors
156 void ChangePage(int nOldSel
, int nSel
); // change pages
158 wxImageList
*m_pImageList
; // we can have an associated image list
159 wxArrayPages m_aPages
; // array of pages
161 int m_nSelection
; // the current selection (-1 if none)
163 DECLARE_DYNAMIC_CLASS(wxNotebook
)
164 DECLARE_EVENT_TABLE()
167 #endif // _NOTEBOOK_H