]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: notebook.h | |
3 | // Purpose: wxNotebook class (a.k.a. property sheet, tabbed dialog) | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) Julian Smart | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_NOTEBOOK_H_ | |
12 | #define _WX_NOTEBOOK_H_ | |
13 | ||
14 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
15 | #pragma interface "notebook.h" | |
16 | #endif | |
17 | ||
18 | // ---------------------------------------------------------------------------- | |
19 | // headers | |
20 | // ---------------------------------------------------------------------------- | |
21 | #include "wx/event.h" | |
22 | #include "wx/control.h" | |
23 | ||
24 | // ---------------------------------------------------------------------------- | |
25 | // types | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
28 | // fwd declarations | |
29 | class WXDLLEXPORT wxImageList; | |
30 | class WXDLLEXPORT wxWindow; | |
31 | class WXDLLEXPORT wxTabView; | |
32 | ||
33 | // ---------------------------------------------------------------------------- | |
34 | // wxNotebook | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
37 | class wxNotebook : public wxNotebookBase | |
38 | { | |
39 | public: | |
40 | // ctors | |
41 | // ----- | |
42 | // default for dynamic class | |
43 | wxNotebook(); | |
44 | // the same arguments as for wxControl (@@@ any special styles?) | |
45 | wxNotebook(wxWindow *parent, | |
46 | wxWindowID id, | |
47 | const wxPoint& pos = wxDefaultPosition, | |
48 | const wxSize& size = wxDefaultSize, | |
49 | long style = 0, | |
50 | const wxString& name = wxT("notebook")); | |
51 | // Create() function | |
52 | bool Create(wxWindow *parent, | |
53 | wxWindowID id, | |
54 | const wxPoint& pos = wxDefaultPosition, | |
55 | const wxSize& size = wxDefaultSize, | |
56 | long style = 0, | |
57 | const wxString& name = wxT("notebook")); | |
58 | // dtor | |
59 | ~wxNotebook(); | |
60 | ||
61 | // accessors | |
62 | // --------- | |
63 | // Find the position of the wxNotebookPage, -1 if not found. | |
64 | int FindPagePosition(wxNotebookPage* page) const; | |
65 | ||
66 | // set the currently selected page, return the index of the previously | |
67 | // selected one (or -1 on error) | |
68 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events | |
69 | int SetSelection(size_t nPage); | |
70 | // cycle thru the tabs | |
71 | // void AdvanceSelection(bool bForward = true); | |
72 | // get the currently selected page | |
73 | int GetSelection() const { return m_nSelection; } | |
74 | ||
75 | // set/get the title of a page | |
76 | bool SetPageText(size_t nPage, const wxString& strText); | |
77 | wxString GetPageText(size_t nPage) const; | |
78 | ||
79 | // get the number of rows for a control with wxNB_MULTILINE style (not all | |
80 | // versions support it - they will always return 1 then) | |
81 | virtual int GetRowCount() const ; | |
82 | ||
83 | // sets/returns item's image index in the current image list | |
84 | int GetPageImage(size_t nPage) const; | |
85 | bool SetPageImage(size_t nPage, int nImage); | |
86 | ||
87 | // control the appearance of the notebook pages | |
88 | // set the size (the same for all pages) | |
89 | void SetPageSize(const wxSize& size); | |
90 | // set the padding between tabs (in pixels) | |
91 | void SetPadding(const wxSize& padding); | |
92 | ||
93 | // Sets the size of the tabs (assumes all tabs are the same size) | |
94 | void SetTabSize(const wxSize& sz); | |
95 | ||
96 | // operations | |
97 | // ---------- | |
98 | // remove one page from the notebook, and delete the page. | |
99 | bool DeletePage(size_t nPage); | |
100 | bool DeletePage(wxNotebookPage* page); | |
101 | // remove one page from the notebook, without deleting the page. | |
102 | bool RemovePage(size_t nPage); | |
103 | bool RemovePage(wxNotebookPage* page); | |
104 | virtual wxWindow* DoRemovePage(size_t nPage); | |
105 | ||
106 | // remove all pages | |
107 | bool DeleteAllPages(); | |
108 | // the same as AddPage(), but adds it at the specified position | |
109 | bool InsertPage(size_t nPage, | |
110 | wxNotebookPage *pPage, | |
111 | const wxString& strText, | |
112 | bool bSelect = false, | |
113 | int imageId = -1); | |
114 | ||
115 | // callbacks | |
116 | // --------- | |
117 | void OnSize(wxSizeEvent& event); | |
118 | void OnInternalIdle(); | |
119 | void OnSelChange(wxNotebookEvent& event); | |
120 | void OnSetFocus(wxFocusEvent& event); | |
121 | void OnNavigationKey(wxNavigationKeyEvent& event); | |
122 | ||
123 | // base class virtuals | |
124 | // ------------------- | |
125 | virtual void Command(wxCommandEvent& event); | |
126 | virtual void SetConstraintSizes(bool recurse = true); | |
127 | virtual bool DoPhase(int nPhase); | |
128 | ||
129 | // Implementation | |
130 | ||
131 | // wxNotebook on Motif uses a generic wxTabView to implement itself. | |
132 | wxTabView *GetTabView() const { return m_tabView; } | |
133 | void SetTabView(wxTabView *v) { m_tabView = v; } | |
134 | ||
135 | void OnMouseEvent(wxMouseEvent& event); | |
136 | void OnPaint(wxPaintEvent& event); | |
137 | ||
138 | virtual wxRect GetAvailableClientSize(); | |
139 | ||
140 | // Implementation: calculate the layout of the view rect | |
141 | // and resize the children if required | |
142 | bool RefreshLayout(bool force = true); | |
143 | ||
144 | protected: | |
145 | // common part of all ctors | |
146 | void Init(); | |
147 | ||
148 | // helper functions | |
149 | void ChangePage(int nOldSel, int nSel); // change pages | |
150 | ||
151 | int m_nSelection; // the current selection (-1 if none) | |
152 | ||
153 | wxTabView* m_tabView; | |
154 | ||
155 | DECLARE_DYNAMIC_CLASS(wxNotebook) | |
156 | DECLARE_EVENT_TABLE() | |
157 | }; | |
158 | ||
159 | #endif // _WX_NOTEBOOK_H_ |