Commit | Line | Data |
---|---|---|
b5f2afe5 | 1 | ///////////////////////////////////////////////////////////////////////////// |
bc8793f4 | 2 | // Name: wx/msw/notebook.h |
b5f2afe5 VZ |
3 | // Purpose: MSW/GTK compatible notebook (a.k.a. property sheet) |
4 | // Author: Robert Roebling | |
5 | // Modified by: Vadim Zeitlin for Windows version | |
6 | // RCS-ID: $Id$ | |
371a5b4e | 7 | // Copyright: (c) Julian Smart |
65571936 | 8 | // Licence: wxWindows licence |
b5f2afe5 VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _NOTEBOOK_H | |
12 | #define _NOTEBOOK_H | |
13 | ||
1e6feb95 VZ |
14 | #if wxUSE_NOTEBOOK |
15 | ||
b5f2afe5 VZ |
16 | // ---------------------------------------------------------------------------- |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
74b31181 | 19 | |
7c0ea335 | 20 | #include "wx/control.h" |
b5f2afe5 | 21 | |
b5f2afe5 VZ |
22 | // ---------------------------------------------------------------------------- |
23 | // wxNotebook | |
24 | // ---------------------------------------------------------------------------- | |
25 | ||
53a2db12 | 26 | class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase |
b5f2afe5 VZ |
27 | { |
28 | public: | |
29 | // ctors | |
30 | // ----- | |
31 | // default for dynamic class | |
32 | wxNotebook(); | |
33 | // the same arguments as for wxControl (@@@ any special styles?) | |
34 | wxNotebook(wxWindow *parent, | |
35eca07c | 35 | wxWindowID id, |
b5f2afe5 VZ |
36 | const wxPoint& pos = wxDefaultPosition, |
37 | const wxSize& size = wxDefaultSize, | |
debe6624 | 38 | long style = 0, |
630ad6c6 | 39 | const wxString& name = wxNotebookNameStr); |
b5f2afe5 VZ |
40 | // Create() function |
41 | bool Create(wxWindow *parent, | |
35eca07c | 42 | wxWindowID id, |
b5f2afe5 VZ |
43 | const wxPoint& pos = wxDefaultPosition, |
44 | const wxSize& size = wxDefaultSize, | |
debe6624 | 45 | long style = 0, |
630ad6c6 | 46 | const wxString& name = wxNotebookNameStr); |
caf95d2a | 47 | virtual ~wxNotebook(); |
b5f2afe5 VZ |
48 | |
49 | // accessors | |
50 | // --------- | |
51 | // get number of pages in the dialog | |
8d34bf5c | 52 | virtual size_t GetPageCount() const; |
b5f2afe5 VZ |
53 | |
54 | // set the currently selected page, return the index of the previously | |
7e837615 | 55 | // selected one (or wxNOT_FOUND on error) |
b5f2afe5 | 56 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events |
15aad3b9 | 57 | int SetSelection(size_t nPage); |
b5f2afe5 | 58 | |
1d6fcbcc VZ |
59 | // changes selected page without sending events |
60 | int ChangeSelection(size_t nPage); | |
61 | ||
b5f2afe5 | 62 | // set/get the title of a page |
15aad3b9 VZ |
63 | bool SetPageText(size_t nPage, const wxString& strText); |
64 | wxString GetPageText(size_t nPage) const; | |
b5f2afe5 VZ |
65 | |
66 | // image list stuff: each page may have an image associated with it. All | |
67 | // the images belong to an image list, so you have to | |
68 | // 1) create an image list | |
69 | // 2) associate it with the notebook | |
70 | // 3) set for each page it's image | |
71 | // associate image list with a control | |
72 | void SetImageList(wxImageList* imageList); | |
b5f2afe5 VZ |
73 | |
74 | // sets/returns item's image index in the current image list | |
15aad3b9 VZ |
75 | int GetPageImage(size_t nPage) const; |
76 | bool SetPageImage(size_t nPage, int nImage); | |
b5f2afe5 | 77 | |
b5f2afe5 VZ |
78 | // currently it's always 1 because wxGTK doesn't support multi-row |
79 | // tab controls | |
80 | int GetRowCount() const; | |
81 | ||
82 | // control the appearance of the notebook pages | |
83 | // set the size (the same for all pages) | |
84 | void SetPageSize(const wxSize& size); | |
85 | // set the padding between tabs (in pixels) | |
86 | void SetPadding(const wxSize& padding); | |
87 | ||
88 | // operations | |
89 | // ---------- | |
b5f2afe5 VZ |
90 | // remove all pages |
91 | bool DeleteAllPages(); | |
e450aa69 | 92 | |
efa14cf2 | 93 | // inserts a new page to the notebook (it will be deleted ny the notebook, |
b5f2afe5 | 94 | // don't delete it yourself). If bSelect, this page becomes active. |
15aad3b9 | 95 | bool InsertPage(size_t nPage, |
b5f2afe5 VZ |
96 | wxNotebookPage *pPage, |
97 | const wxString& strText, | |
078cf5cb | 98 | bool bSelect = false, |
1871b9fa | 99 | int imageId = NO_IMAGE); |
b5f2afe5 | 100 | |
58a8ab88 JS |
101 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH |
102 | // style. | |
103 | void SetTabSize(const wxSize& sz); | |
104 | ||
e450aa69 VZ |
105 | // hit test |
106 | virtual int HitTest(const wxPoint& pt, long *flags = NULL) const; | |
107 | ||
108 | // calculate the size of the notebook from the size of its page | |
2ce7af35 JS |
109 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; |
110 | ||
b5f2afe5 VZ |
111 | // callbacks |
112 | // --------- | |
9026ad85 | 113 | void OnSize(wxSizeEvent& event); |
8a33ea62 | 114 | void OnNavigationKey(wxNavigationKeyEvent& event); |
35eca07c | 115 | |
b5f2afe5 VZ |
116 | // base class virtuals |
117 | // ------------------- | |
0b481c72 | 118 | |
a23fd0e1 | 119 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
0df3fbd7 VZ |
120 | virtual bool MSWOnScroll(int orientation, WXWORD nSBCode, |
121 | WXWORD pos, WXHWND control); | |
0b481c72 VZ |
122 | |
123 | #if wxUSE_CONSTRAINTS | |
078cf5cb | 124 | virtual void SetConstraintSizes(bool recurse = true); |
5475b960 | 125 | virtual bool DoPhase(int nPhase); |
0b481c72 | 126 | #endif // wxUSE_CONSTRAINTS |
b5f2afe5 | 127 | |
25057aba JS |
128 | // Attempts to get colour for UX theme page background |
129 | wxColour GetThemeBackgroundColour() const; | |
caf95d2a VZ |
130 | |
131 | // implementation only | |
132 | // ------------------- | |
133 | ||
134 | #if wxUSE_UXTHEME | |
c4a95f6f VZ |
135 | virtual bool SetBackgroundColour(const wxColour& colour) |
136 | { | |
137 | if ( !wxNotebookBase::SetBackgroundColour(colour) ) | |
138 | return false; | |
caf95d2a | 139 | |
c4a95f6f | 140 | UpdateBgBrush(); |
9b7d2b81 | 141 | |
c4a95f6f VZ |
142 | return true; |
143 | } | |
6f02a879 | 144 | |
6f02a879 VZ |
145 | // draw child background |
146 | virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win); | |
d9317033 VZ |
147 | |
148 | virtual bool MSWHasInheritableBackground() const { return true; } | |
bc8793f4 WS |
149 | #endif // wxUSE_UXTHEME |
150 | ||
151 | // translate wxWin styles to the Windows ones | |
152 | virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; | |
6f02a879 | 153 | |
b5f2afe5 VZ |
154 | protected: |
155 | // common part of all ctors | |
156 | void Init(); | |
157 | ||
5482ee07 | 158 | // hides the currently shown page and shows the given one (if not -1) and |
681be2ef | 159 | // updates m_selection accordingly |
5482ee07 | 160 | void UpdateSelection(int selNew); |
1d6fcbcc | 161 | |
1e6feb95 | 162 | // remove one page from the notebook, without deleting |
15aad3b9 | 163 | virtual wxNotebookPage *DoRemovePage(size_t nPage); |
1e6feb95 | 164 | |
c3732409 VZ |
165 | // get the page rectangle for the current notebook size |
166 | // | |
167 | // returns empty rectangle if an error occurs, do test for it | |
168 | wxRect GetPageSize() const; | |
169 | ||
2015f2b3 VZ |
170 | // set the size of the given page to fit in the notebook |
171 | void AdjustPageSize(wxNotebookPage *page); | |
172 | ||
ffafd8a5 | 173 | #if wxUSE_UXTHEME |
0a81f130 VZ |
174 | // return the themed brush for painting our children |
175 | virtual WXHBRUSH MSWGetCustomBgBrush() { return m_hbrBackground; } | |
176 | ||
de359565 VZ |
177 | // gets the bitmap of notebook background and returns a brush from it |
178 | WXHBRUSH QueryBgBitmap(); | |
c4a95f6f | 179 | |
caf95d2a VZ |
180 | // creates the brush to be used for drawing the tab control background |
181 | void UpdateBgBrush(); | |
07c19327 | 182 | |
c3732409 VZ |
183 | // common part of QueryBgBitmap() and MSWPrintChild() |
184 | // | |
185 | // if child == NULL, draw background for the entire notebook itself | |
186 | bool DoDrawBackground(WXHDC hDC, wxWindow *child = NULL); | |
caf95d2a | 187 | #endif // wxUSE_UXTHEME |
2015f2b3 | 188 | |
dfb47d83 VZ |
189 | // these function are only used for reducing flicker on notebook resize and |
190 | // we don't need to do this for WinCE | |
191 | #ifndef __WXWINCE__ | |
192 | void OnEraseBackground(wxEraseEvent& event); | |
193 | void OnPaint(wxPaintEvent& event); | |
194 | ||
195 | // true if we have already subclassed our updown control | |
196 | bool m_hasSubclassedUpdown; | |
feb32e31 VZ |
197 | |
198 | // true if we already refreshed the current page after showing the window | |
199 | bool m_doneUpdateHack; | |
dfb47d83 VZ |
200 | #endif // __WXWINCE__ |
201 | ||
caf95d2a VZ |
202 | #if wxUSE_UXTHEME |
203 | // background brush used to paint the tab control | |
204 | WXHBRUSH m_hbrBackground; | |
205 | #endif // wxUSE_UXTHEME | |
8acd402f | 206 | |
2015f2b3 | 207 | |
fc7a2a60 | 208 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook) |
b5f2afe5 VZ |
209 | DECLARE_EVENT_TABLE() |
210 | }; | |
211 | ||
1e6feb95 VZ |
212 | #endif // wxUSE_NOTEBOOK |
213 | ||
b5f2afe5 | 214 | #endif // _NOTEBOOK_H |