]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/notebook.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxNotebook class
4 // Author: Robert Roebling
7 // Copyright: (c) Julian Smart and Robert Roebling
8 // Licence: wxWindows license
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __GTKNOTEBOOKH__
12 #define __GTKNOTEBOOKH__
19 #include "wx/object.h"
20 #include "wx/string.h"
21 #include "wx/control.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 class wxNotebookEvent
: public wxNotifyEvent
38 wxNotebookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
39 int nSel
= -1, int nOldSel
= -1)
40 : wxNotifyEvent(commandType
, id
)
48 int GetSelection() const { return m_nSel
; }
49 int GetOldSelection() const { return m_nOldSel
; }
51 // for wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING event this method may be called
52 // to disallow the page change
53 void Veto() { m_bAllow
= FALSE
; }
55 // implementation: for wxNotebook usage only
56 bool Allowed() const { return m_bAllow
; }
61 int m_nSel
, // currently selected page
62 m_nOldSel
; // previously selected page
64 DECLARE_DYNAMIC_CLASS(wxNotebookEvent
)
67 //-----------------------------------------------------------------------------
69 //-----------------------------------------------------------------------------
71 class wxNotebook
: public wxControl
76 // default for dynamic class
78 // the same arguments as for wxControl (@@@ any special styles?)
79 wxNotebook(wxWindow
*parent
,
81 const wxPoint
& pos
= wxDefaultPosition
,
82 const wxSize
& size
= wxDefaultSize
,
84 const wxString
& name
= "notebook");
86 bool Create(wxWindow
*parent
,
88 const wxPoint
& pos
= wxDefaultPosition
,
89 const wxSize
& size
= wxDefaultSize
,
91 const wxString
& name
= "notebook");
97 // get number of pages in the dialog
98 int GetPageCount() const;
100 // set the currently selected page, return the index of the previously
101 // selected one (or -1 on error)
102 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
103 int SetSelection(int nPage
);
104 // cycle thru the tabs
105 void AdvanceSelection(bool bForward
= TRUE
);
106 // get the currently selected page
107 int GetSelection() const;
109 // set/get the title of a page
110 bool SetPageText(int nPage
, const wxString
& strText
);
111 wxString
GetPageText(int nPage
) const;
113 // image list stuff: each page may have an image associated with it. All
114 // the images belong to an image list, so you have to
115 // 1) create an image list
116 // 2) associate it with the notebook
117 // 3) set for each page it's image
118 // associate image list with a control
119 void SetImageList(wxImageList
* imageList
);
120 // get pointer (may be NULL) to the associated image list
121 wxImageList
*GetImageList() const { return m_imageList
; }
123 // sets/returns item's image index in the current image list
124 int GetPageImage(int nPage
) const;
125 bool SetPageImage(int nPage
, int nImage
);
127 // currently it's always 1 because wxGTK doesn't support multi-row
129 int GetRowCount() const;
131 // control the appearance of the notebook pages
132 // set the size (the same for all pages)
133 void SetPageSize(const wxSize
& size
);
134 // set the padding between tabs (in pixels)
135 void SetPadding(const wxSize
& padding
);
136 // sets the size of the tabs (assumes all tabs are the same size)
137 void SetTabSize(const wxSize
& sz
);
141 // remove one page from the notebook but do not destroy it
142 bool RemovePage(int nPage
);
143 // remove one page from the notebook
144 bool DeletePage(int nPage
);
146 bool DeleteAllPages();
148 // adds a new page to the notebook (it will be deleted ny the notebook,
149 // don't delete it yourself). If bSelect, this page becomes active.
150 bool AddPage( wxWindow
*win
,
151 const wxString
& strText
,
154 // the same as AddPage(), but adds it at the specified position
155 bool InsertPage( int position
,
157 const wxString
& strText
,
158 bool bSelect
= FALSE
,
161 // get the panel which represents the given page
162 wxWindow
*GetPage(int nPage
) const;
164 void OnNavigationKey(wxNavigationKeyEvent
& event
);
168 void SetConstraintSizes(bool recurse
);
169 bool DoPhase(int phase
);
170 void ApplyWidgetStyle();
172 // report if window belongs to notebook
173 bool IsOwnGtkWindow( GdkWindow
*window
);
175 // common part of all ctors
179 wxNotebookPage
* GetNotebookPage(int page
) const;
181 wxImageList
* m_imageList
;
183 int m_lastSelection
; /* hack */
185 DECLARE_DYNAMIC_CLASS(wxNotebook
)
186 DECLARE_EVENT_TABLE()
189 // ----------------------------------------------------------------------------
191 // ----------------------------------------------------------------------------
192 typedef void (wxEvtHandler::*wxNotebookEventFunction
)(wxNotebookEvent
&);
194 #define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
196 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \
199 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
203 #define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
205 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \
208 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \