]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/gtk1/notebook.h | |
3 | // Purpose: wxNotebook class | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // Copyright: (c) Julian Smart and Robert Roebling | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef __GTKNOTEBOOKH__ | |
11 | #define __GTKNOTEBOOKH__ | |
12 | ||
13 | //----------------------------------------------------------------------------- | |
14 | // internal class | |
15 | //----------------------------------------------------------------------------- | |
16 | ||
17 | class WXDLLIMPEXP_FWD_CORE wxGtkNotebookPage; | |
18 | ||
19 | #include "wx/list.h" | |
20 | WX_DECLARE_LIST(wxGtkNotebookPage, wxGtkNotebookPagesList); | |
21 | ||
22 | //----------------------------------------------------------------------------- | |
23 | // wxNotebook | |
24 | //----------------------------------------------------------------------------- | |
25 | ||
26 | class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase | |
27 | { | |
28 | public: | |
29 | // default for dynamic class | |
30 | wxNotebook(); | |
31 | // the same arguments as for wxControl | |
32 | wxNotebook(wxWindow *parent, | |
33 | wxWindowID id, | |
34 | const wxPoint& pos = wxDefaultPosition, | |
35 | const wxSize& size = wxDefaultSize, | |
36 | long style = 0, | |
37 | const wxString& name = wxNotebookNameStr); | |
38 | // Create() function | |
39 | bool Create(wxWindow *parent, | |
40 | wxWindowID id, | |
41 | const wxPoint& pos = wxDefaultPosition, | |
42 | const wxSize& size = wxDefaultSize, | |
43 | long style = 0, | |
44 | const wxString& name = wxNotebookNameStr); | |
45 | // dtor | |
46 | virtual ~wxNotebook(); | |
47 | ||
48 | // accessors | |
49 | // --------- | |
50 | ||
51 | // set the currently selected page, return the index of the previously | |
52 | // selected one (or wxNOT_FOUND on error) | |
53 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events | |
54 | int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); } | |
55 | // get the currently selected page | |
56 | int GetSelection() const; | |
57 | ||
58 | // changes selected page without sending events | |
59 | int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); } | |
60 | ||
61 | // set/get the title of a page | |
62 | bool SetPageText(size_t nPage, const wxString& strText); | |
63 | wxString GetPageText(size_t nPage) const; | |
64 | ||
65 | // sets/returns item's image index in the current image list | |
66 | int GetPageImage(size_t nPage) const; | |
67 | bool SetPageImage(size_t nPage, int nImage); | |
68 | ||
69 | // control the appearance of the notebook pages | |
70 | // set the size (the same for all pages) | |
71 | void SetPageSize(const wxSize& size); | |
72 | // set the padding between tabs (in pixels) | |
73 | void SetPadding(const wxSize& padding); | |
74 | // sets the size of the tabs (assumes all tabs are the same size) | |
75 | void SetTabSize(const wxSize& sz); | |
76 | ||
77 | virtual int HitTest(const wxPoint& pt, long *flags = NULL) const; | |
78 | ||
79 | // operations | |
80 | // ---------- | |
81 | // remove all pages | |
82 | bool DeleteAllPages(); | |
83 | ||
84 | // adds a new page to the notebook (it will be deleted by the notebook, | |
85 | // don't delete it yourself). If bSelect, this page becomes active. | |
86 | // the same as AddPage(), but adds it at the specified position | |
87 | bool InsertPage( size_t position, | |
88 | wxNotebookPage *win, | |
89 | const wxString& strText, | |
90 | bool bSelect = false, | |
91 | int imageId = NO_IMAGE ); | |
92 | ||
93 | // handler for tab navigation | |
94 | // -------------------------- | |
95 | void OnNavigationKey(wxNavigationKeyEvent& event); | |
96 | ||
97 | ||
98 | static wxVisualAttributes | |
99 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
100 | ||
101 | // implementation | |
102 | // -------------- | |
103 | ||
104 | #if wxUSE_CONSTRAINTS | |
105 | void SetConstraintSizes(bool recurse); | |
106 | bool DoPhase(int phase); | |
107 | #endif | |
108 | ||
109 | // set all page's attributes | |
110 | void DoApplyWidgetStyle(GtkRcStyle *style); | |
111 | ||
112 | // report if window belongs to notebook | |
113 | bool IsOwnGtkWindow( GdkWindow *window ); | |
114 | ||
115 | // common part of all ctors | |
116 | void Init(); | |
117 | ||
118 | // helper function | |
119 | wxGtkNotebookPage* GetNotebookPage(int page) const; | |
120 | ||
121 | // the additional page data (the pages themselves are in m_pages array) | |
122 | wxGtkNotebookPagesList m_pagesData; | |
123 | ||
124 | // for reasons explained in gtk/notebook.cpp we store the current | |
125 | // selection internally instead of querying the notebook for it | |
126 | int m_selection; | |
127 | ||
128 | // flag set to true while we're inside "switch_page" callback | |
129 | bool m_inSwitchPage; | |
130 | ||
131 | // flag set to true when the switch-page signal has been programmatically generated | |
132 | bool m_skipNextPageChangeEvent; | |
133 | ||
134 | protected: | |
135 | // remove one page from the notebook but do not destroy it | |
136 | virtual wxNotebookPage *DoRemovePage(size_t nPage); | |
137 | ||
138 | int DoSetSelection(size_t nPage, int flags = 0); | |
139 | ||
140 | private: | |
141 | // the padding set by SetPadding() | |
142 | int m_padding; | |
143 | ||
144 | DECLARE_DYNAMIC_CLASS(wxNotebook) | |
145 | DECLARE_EVENT_TABLE() | |
146 | }; | |
147 | ||
148 | #endif | |
149 | // __GTKNOTEBOOKH__ |