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