]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/notebook.h
Remove calls to a couple of deprecated methods, fix wxMotif build with
[wxWidgets.git] / include / wx / generic / notebook.h
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(__APPLE__)
15 #pragma interface "notebook.h"
16 #endif
17
18 // ----------------------------------------------------------------------------
19 // headers
20 // ----------------------------------------------------------------------------
21 #include "wx/dynarray.h"
22 #include "wx/event.h"
23 #include "wx/control.h"
24 #include "wx/generic/tabg.h"
25
26 // ----------------------------------------------------------------------------
27 // types
28 // ----------------------------------------------------------------------------
29
30 // fwd declarations
31 class WXDLLEXPORT wxImageList;
32 class WXDLLEXPORT wxWindow;
33
34 // ----------------------------------------------------------------------------
35 // wxNotebook
36 // ----------------------------------------------------------------------------
37
38 class WXDLLEXPORT wxNotebook;
39
40 // This reuses wxTabView to draw the tabs.
41 class WXDLLEXPORT wxNotebookTabView: public wxTabView
42 {
43 DECLARE_DYNAMIC_CLASS(wxNotebookTabView)
44 public:
45 wxNotebookTabView(wxNotebook* notebook, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR);
46 ~wxNotebookTabView(void);
47
48 // Called when a tab is activated
49 virtual void OnTabActivate(int activateId, int deactivateId);
50 // Allows vetoing
51 virtual bool OnTabPreActivate(int activateId, int deactivateId);
52
53 protected:
54 wxNotebook* m_notebook;
55 };
56
57 class wxNotebook : public wxNotebookBase
58 {
59 public:
60 // ctors
61 // -----
62 // default for dynamic class
63 wxNotebook();
64 // the same arguments as for wxControl (@@@ any special styles?)
65 wxNotebook(wxWindow *parent,
66 wxWindowID id,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize,
69 long style = 0,
70 const wxString& name = "notebook");
71 // Create() function
72 bool Create(wxWindow *parent,
73 wxWindowID id,
74 const wxPoint& pos = wxDefaultPosition,
75 const wxSize& size = wxDefaultSize,
76 long style = 0,
77 const wxString& name = "notebook");
78 // dtor
79 ~wxNotebook();
80
81 // accessors
82 // ---------
83 // Find the position of the wxNotebookPage, -1 if not found.
84 int FindPagePosition(wxNotebookPage* page) const;
85
86 // set the currently selected page, return the index of the previously
87 // selected one (or -1 on error)
88 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
89 int SetSelection(int nPage);
90 // cycle thru the tabs
91 // void AdvanceSelection(bool bForward = TRUE);
92 // get the currently selected page
93 int GetSelection() const { return m_nSelection; }
94
95 // set/get the title of a page
96 bool SetPageText(int nPage, const wxString& strText);
97 wxString GetPageText(int nPage) const;
98
99 // get the number of rows for a control with wxNB_MULTILINE style (not all
100 // versions support it - they will always return 1 then)
101 virtual int GetRowCount() const ;
102
103 // sets/returns item's image index in the current image list
104 int GetPageImage(int nPage) const;
105 bool SetPageImage(int nPage, int nImage);
106
107 // control the appearance of the notebook pages
108 // set the size (the same for all pages)
109 void SetPageSize(const wxSize& size);
110 // set the padding between tabs (in pixels)
111 void SetPadding(const wxSize& padding);
112
113 // Sets the size of the tabs (assumes all tabs are the same size)
114 void SetTabSize(const wxSize& sz);
115
116 // operations
117 // ----------
118 // remove one page from the notebook, and delete the page.
119 bool DeletePage(int nPage);
120 bool DeletePage(wxNotebookPage* page);
121 // remove one page from the notebook, without deleting the page.
122 bool RemovePage(int nPage);
123 bool RemovePage(wxNotebookPage* page);
124 // remove all pages
125 bool DeleteAllPages();
126 // the same as AddPage(), but adds it at the specified position
127 bool InsertPage(int nPage,
128 wxNotebookPage *pPage,
129 const wxString& strText,
130 bool bSelect = FALSE,
131 int imageId = -1);
132
133 // callbacks
134 // ---------
135 void OnSize(wxSizeEvent& event);
136 void OnIdle(wxIdleEvent& event);
137 void OnSelChange(wxNotebookEvent& event);
138 void OnSetFocus(wxFocusEvent& event);
139 void OnNavigationKey(wxNavigationKeyEvent& event);
140
141 // base class virtuals
142 // -------------------
143 virtual void Command(wxCommandEvent& event);
144 virtual void SetConstraintSizes(bool recurse = TRUE);
145 virtual bool DoPhase(int nPhase);
146
147 // Implementation
148
149 // wxNotebook on Motif uses a generic wxTabView to implement itself.
150 wxTabView *GetTabView() const { return m_tabView; }
151 void SetTabView(wxTabView *v) { m_tabView = v; }
152
153 void OnMouseEvent(wxMouseEvent& event);
154 void OnPaint(wxPaintEvent& event);
155
156 virtual wxRect GetAvailableClientSize();
157
158 // Implementation: calculate the layout of the view rect
159 // and resize the children if required
160 bool RefreshLayout(bool force = TRUE);
161
162 protected:
163 // common part of all ctors
164 void Init();
165
166 // helper functions
167 void ChangePage(int nOldSel, int nSel); // change pages
168
169 int m_nSelection; // the current selection (-1 if none)
170
171 wxTabView* m_tabView;
172
173 DECLARE_DYNAMIC_CLASS(wxNotebook)
174 DECLARE_EVENT_TABLE()
175 };
176
177 #endif // _WX_NOTEBOOK_H_