]>
Commit | Line | Data |
---|---|---|
88310e2e | 1 | /////////////////////////////////////////////////////////////////////////////// |
2ddb4d13 | 2 | // Name: src/msw/notebook.cpp |
88310e2e VZ |
3 | // Purpose: implementation of wxNotebook |
4 | // Author: Vadim Zeitlin | |
907f37b3 | 5 | // Modified by: |
88310e2e VZ |
6 | // Created: 11.06.98 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
65571936 | 9 | // Licence: wxWindows licence |
88310e2e VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
88310e2e VZ |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
1e6feb95 | 16 | #pragma hdrstop |
88310e2e VZ |
17 | #endif |
18 | ||
1e6feb95 VZ |
19 | #if wxUSE_NOTEBOOK |
20 | ||
57bd4c60 | 21 | #include "wx/notebook.h" |
e4db172a | 22 | |
88310e2e | 23 | #ifndef WX_PRECOMP |
57bd4c60 WS |
24 | #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly" |
25 | #include "wx/string.h" | |
26 | #include "wx/dc.h" | |
27 | #include "wx/log.h" | |
28 | #include "wx/event.h" | |
29 | #include "wx/app.h" | |
30 | #include "wx/dcclient.h" | |
31 | #include "wx/dcmemory.h" | |
32 | #include "wx/control.h" | |
88310e2e VZ |
33 | #endif // WX_PRECOMP |
34 | ||
57bd4c60 WS |
35 | #include "wx/imaglist.h" |
36 | #include "wx/sysopt.h" | |
88310e2e | 37 | |
57bd4c60 | 38 | #include "wx/msw/private.h" |
88310e2e | 39 | |
57bd4c60 | 40 | #include <windowsx.h> |
85b43fbf JS |
41 | #include "wx/msw/winundef.h" |
42 | ||
43 | #if wxUSE_UXTHEME | |
caf95d2a | 44 | #include "wx/msw/uxtheme.h" |
85b43fbf JS |
45 | #endif |
46 | ||
88310e2e VZ |
47 | // ---------------------------------------------------------------------------- |
48 | // macros | |
49 | // ---------------------------------------------------------------------------- | |
50 | ||
51 | // check that the page index is valid | |
8d34bf5c | 52 | #define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount()) |
88310e2e | 53 | |
014ee083 VZ |
54 | // you can set USE_NOTEBOOK_ANTIFLICKER to 0 for desktop Windows versions too |
55 | // to disable code whih results in flicker-less notebook redrawing at the | |
56 | // expense of some extra GDI resource consumption | |
254fbd14 | 57 | #ifdef __WXWINCE__ |
014ee083 VZ |
58 | // notebooks are never resized under CE anyhow |
59 | #define USE_NOTEBOOK_ANTIFLICKER 0 | |
254fbd14 | 60 | #else |
014ee083 | 61 | #define USE_NOTEBOOK_ANTIFLICKER 1 |
254fbd14 JS |
62 | #endif |
63 | ||
74b31181 VZ |
64 | // ---------------------------------------------------------------------------- |
65 | // constants | |
66 | // ---------------------------------------------------------------------------- | |
67 | ||
68 | // This is a work-around for missing defines in gcc-2.95 headers | |
69 | #ifndef TCS_RIGHT | |
70 | #define TCS_RIGHT 0x0002 | |
71 | #endif | |
72 | ||
73 | #ifndef TCS_VERTICAL | |
74 | #define TCS_VERTICAL 0x0080 | |
75 | #endif | |
76 | ||
77 | #ifndef TCS_BOTTOM | |
78 | #define TCS_BOTTOM TCS_RIGHT | |
79 | #endif | |
80 | ||
014ee083 VZ |
81 | // ---------------------------------------------------------------------------- |
82 | // global variables | |
83 | // ---------------------------------------------------------------------------- | |
84 | ||
85 | #if USE_NOTEBOOK_ANTIFLICKER | |
86 | ||
87 | // the pointer to standard spin button wnd proc | |
88 | static WXFARPROC gs_wndprocNotebookSpinBtn = (WXFARPROC)NULL; | |
89 | ||
6143d3b6 | 90 | // the pointer to standard tab control wnd proc |
e1cffcd6 | 91 | static WXFARPROC gs_wndprocNotebook = (WXFARPROC)NULL; |
6143d3b6 VZ |
92 | |
93 | LRESULT APIENTRY _EXPORT wxNotebookWndProc(HWND hwnd, | |
94 | UINT message, | |
95 | WPARAM wParam, | |
96 | LPARAM lParam); | |
97 | ||
014ee083 VZ |
98 | #endif // USE_NOTEBOOK_ANTIFLICKER |
99 | ||
88310e2e VZ |
100 | // ---------------------------------------------------------------------------- |
101 | // event table | |
102 | // ---------------------------------------------------------------------------- | |
103 | ||
7ec69821 | 104 | #include "wx/listimpl.cpp" |
51741307 | 105 | |
259c43f6 | 106 | WX_DEFINE_LIST( wxNotebookPageInfoList ) |
51741307 | 107 | |
2e4df4bf VZ |
108 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED) |
109 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING) | |
110 | ||
d9317fd4 | 111 | BEGIN_EVENT_TABLE(wxNotebook, wxControl) |
7ec69821 | 112 | EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange) |
9026ad85 | 113 | EVT_SIZE(wxNotebook::OnSize) |
88310e2e | 114 | EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) |
014ee083 VZ |
115 | |
116 | #if USE_NOTEBOOK_ANTIFLICKER | |
117 | EVT_ERASE_BACKGROUND(wxNotebook::OnEraseBackground) | |
118 | EVT_PAINT(wxNotebook::OnPaint) | |
119 | #endif // USE_NOTEBOOK_ANTIFLICKER | |
d9317fd4 | 120 | END_EVENT_TABLE() |
88310e2e | 121 | |
51596bcb | 122 | #if wxUSE_EXTENDED_RTTI |
bc9fb572 JS |
123 | WX_DEFINE_FLAGS( wxNotebookStyle ) |
124 | ||
3ff066a4 | 125 | wxBEGIN_FLAGS( wxNotebookStyle ) |
bc9fb572 JS |
126 | // new style border flags, we put them first to |
127 | // use them for streaming out | |
3ff066a4 SC |
128 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
129 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
130 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
131 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
132 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
133 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
078cf5cb | 134 | |
bc9fb572 | 135 | // old style border flags |
3ff066a4 SC |
136 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
137 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
138 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
139 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
140 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
cb0afb26 | 141 | wxFLAGS_MEMBER(wxBORDER) |
bc9fb572 JS |
142 | |
143 | // standard window styles | |
3ff066a4 SC |
144 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
145 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
146 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
147 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
cb0afb26 | 148 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
3ff066a4 SC |
149 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
150 | wxFLAGS_MEMBER(wxVSCROLL) | |
151 | wxFLAGS_MEMBER(wxHSCROLL) | |
152 | ||
153 | wxFLAGS_MEMBER(wxNB_FIXEDWIDTH) | |
2ddb4d13 WS |
154 | wxFLAGS_MEMBER(wxBK_DEFAULT) |
155 | wxFLAGS_MEMBER(wxBK_TOP) | |
156 | wxFLAGS_MEMBER(wxBK_LEFT) | |
157 | wxFLAGS_MEMBER(wxBK_RIGHT) | |
158 | wxFLAGS_MEMBER(wxBK_BOTTOM) | |
b554cf63 JS |
159 | wxFLAGS_MEMBER(wxNB_NOPAGETHEME) |
160 | wxFLAGS_MEMBER(wxNB_FLAT) | |
3ff066a4 SC |
161 | |
162 | wxEND_FLAGS( wxNotebookStyle ) | |
51741307 | 163 | |
51596bcb | 164 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook, wxControl,"wx/notebook.h") |
51741307 SC |
165 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo, wxObject , "wx/notebook.h" ) |
166 | ||
3ff066a4 | 167 | wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo * , wxNotebookPageInfoList ) ; |
51596bcb | 168 | |
f0a126fe SC |
169 | template<> void wxCollectionToVariantArray( wxNotebookPageInfoList const &theList, wxxVariantArray &value) |
170 | { | |
0c6b0084 | 171 | wxListCollectionToVariantArray<wxNotebookPageInfoList::compatibility_iterator>( theList , value ) ; |
f0a126fe SC |
172 | } |
173 | ||
3ff066a4 SC |
174 | wxBEGIN_PROPERTIES_TABLE(wxNotebook) |
175 | wxEVENT_PROPERTY( PageChanging , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING , wxNotebookEvent ) | |
176 | wxEVENT_PROPERTY( PageChanged , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , wxNotebookEvent ) | |
c5ca409b | 177 | |
3ff066a4 | 178 | wxPROPERTY_COLLECTION( PageInfos , wxNotebookPageInfoList , wxNotebookPageInfo* , AddPageInfo , GetPageInfos , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
af498247 | 179 | wxPROPERTY_FLAGS( WindowStyle , wxNotebookStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
3ff066a4 | 180 | wxEND_PROPERTIES_TABLE() |
51596bcb | 181 | |
3ff066a4 SC |
182 | wxBEGIN_HANDLERS_TABLE(wxNotebook) |
183 | wxEND_HANDLERS_TABLE() | |
51596bcb | 184 | |
078cf5cb | 185 | wxCONSTRUCTOR_5( wxNotebook , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle) |
51596bcb | 186 | |
51741307 | 187 | |
3ff066a4 | 188 | wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo) |
af498247 | 189 | wxREADONLY_PROPERTY( Page , wxNotebookPage* , GetPage , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
3ff066a4 SC |
190 | wxREADONLY_PROPERTY( Text , wxString , GetText , wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
191 | wxREADONLY_PROPERTY( Selected , bool , GetSelected , false, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) | |
192 | wxREADONLY_PROPERTY( ImageId , int , GetImageId , -1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
193 | wxEND_PROPERTIES_TABLE() | |
51741307 | 194 | |
3ff066a4 SC |
195 | wxBEGIN_HANDLERS_TABLE(wxNotebookPageInfo) |
196 | wxEND_HANDLERS_TABLE() | |
51741307 | 197 | |
078cf5cb | 198 | wxCONSTRUCTOR_4( wxNotebookPageInfo , wxNotebookPage* , Page , wxString , Text , bool , Selected , int , ImageId ) |
51741307 | 199 | |
51596bcb | 200 | #else |
d9317fd4 | 201 | IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) |
51741307 | 202 | IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo, wxObject ) |
51596bcb | 203 | #endif |
d9317fd4 | 204 | IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) |
88310e2e VZ |
205 | |
206 | // ============================================================================ | |
207 | // implementation | |
208 | // ============================================================================ | |
209 | ||
210 | // ---------------------------------------------------------------------------- | |
211 | // wxNotebook construction | |
212 | // ---------------------------------------------------------------------------- | |
213 | ||
51741307 SC |
214 | const wxNotebookPageInfoList& wxNotebook::GetPageInfos() const |
215 | { | |
216 | wxNotebookPageInfoList* list = const_cast< wxNotebookPageInfoList* >( &m_pageInfos ) ; | |
217 | WX_CLEAR_LIST( wxNotebookPageInfoList , *list ) ; | |
34a0c9f4 | 218 | for( size_t i = 0 ; i < GetPageCount() ; ++i ) |
51741307 SC |
219 | { |
220 | wxNotebookPageInfo *info = new wxNotebookPageInfo() ; | |
34a0c9f4 | 221 | info->Create( const_cast<wxNotebook*>(this)->GetPage(i) , GetPageText(i) , GetSelection() == int(i) , GetPageImage(i) ) ; |
51741307 SC |
222 | list->Append( info ) ; |
223 | } | |
224 | return m_pageInfos ; | |
225 | } | |
226 | ||
88310e2e VZ |
227 | // common part of all ctors |
228 | void wxNotebook::Init() | |
229 | { | |
7ec69821 | 230 | m_imageList = NULL; |
5482ee07 | 231 | m_nSelection = wxNOT_FOUND; |
caf95d2a VZ |
232 | |
233 | #if wxUSE_UXTHEME | |
7ec69821 | 234 | m_hbrBackground = NULL; |
caf95d2a | 235 | #endif // wxUSE_UXTHEME |
dfb47d83 VZ |
236 | |
237 | #if USE_NOTEBOOK_ANTIFLICKER | |
7ec69821 | 238 | m_hasSubclassedUpdown = false; |
dfb47d83 | 239 | #endif // USE_NOTEBOOK_ANTIFLICKER |
88310e2e VZ |
240 | } |
241 | ||
242 | // default for dynamic class | |
243 | wxNotebook::wxNotebook() | |
244 | { | |
245 | Init(); | |
246 | } | |
247 | ||
248 | // the same arguments as for wxControl | |
249 | wxNotebook::wxNotebook(wxWindow *parent, | |
8b9518ee | 250 | wxWindowID id, |
88310e2e VZ |
251 | const wxPoint& pos, |
252 | const wxSize& size, | |
8b9518ee | 253 | long style, |
88310e2e VZ |
254 | const wxString& name) |
255 | { | |
256 | Init(); | |
257 | ||
258 | Create(parent, id, pos, size, style, name); | |
259 | } | |
260 | ||
261 | // Create() function | |
262 | bool wxNotebook::Create(wxWindow *parent, | |
8b9518ee | 263 | wxWindowID id, |
88310e2e VZ |
264 | const wxPoint& pos, |
265 | const wxSize& size, | |
8b9518ee | 266 | long style, |
88310e2e VZ |
267 | const wxString& name) |
268 | { | |
895cc205 WS |
269 | if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT ) |
270 | { | |
271 | #if defined(__POCKETPC__) | |
272 | style |= wxBK_BOTTOM | wxNB_FLAT; | |
273 | #else | |
274 | style |= wxBK_TOP; | |
275 | #endif | |
276 | } | |
277 | ||
45418059 JS |
278 | #ifdef __WXWINCE__ |
279 | // Not sure why, but without this style, there is no border | |
280 | // around the notebook tabs. | |
281 | if (style & wxNB_FLAT) | |
282 | style |= wxBORDER_SUNKEN; | |
283 | #endif | |
c3732409 | 284 | |
e4db172a | 285 | #if !wxUSE_UXTHEME |
7cc1ad29 JS |
286 | // ComCtl32 notebook tabs simply don't work unless they're on top if we have uxtheme, we can |
287 | // work around it later (after control creation), but if we don't have uxtheme, we have to clear | |
288 | // those styles | |
df10208f VZ |
289 | const int verComCtl32 = wxApp::GetComCtl32Version(); |
290 | if ( verComCtl32 == 600 ) | |
04eb05b0 | 291 | { |
5483756f | 292 | style &= ~(wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT); |
04eb05b0 | 293 | } |
7cc1ad29 | 294 | #endif //wxUSE_UXTHEME |
078cf5cb | 295 | |
82c51a8e JS |
296 | #if defined(__WINE__) && wxUSE_UNICODE |
297 | LPCTSTR className = L"SysTabControl32"; | |
298 | #else | |
c1637c89 | 299 | LPCTSTR className = WC_TABCONTROL; |
82c51a8e | 300 | #endif |
c1637c89 | 301 | |
6143d3b6 | 302 | #if USE_NOTEBOOK_ANTIFLICKER |
c1637c89 VZ |
303 | // SysTabCtl32 class has natively CS_HREDRAW and CS_VREDRAW enabled and it |
304 | // causes horrible flicker when resizing notebook, so get rid of it by | |
305 | // using a class without these styles (but otherwise identical to it) | |
306 | if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) | |
307 | { | |
308 | static ClassRegistrar s_clsNotebook; | |
309 | if ( !s_clsNotebook.IsInitialized() ) | |
310 | { | |
311 | // get a copy of standard class and modify it | |
312 | WNDCLASS wc; | |
313 | ||
6143d3b6 | 314 | if ( ::GetClassInfo(NULL, WC_TABCONTROL, &wc) ) |
c1637c89 | 315 | { |
6143d3b6 VZ |
316 | gs_wndprocNotebook = |
317 | wx_reinterpret_cast(WXFARPROC, wc.lpfnWndProc); | |
c1637c89 VZ |
318 | wc.lpszClassName = wxT("_wx_SysTabCtl32"); |
319 | wc.style &= ~(CS_HREDRAW | CS_VREDRAW); | |
6143d3b6 VZ |
320 | wc.hInstance = wxGetInstance(); |
321 | wc.lpfnWndProc = wxNotebookWndProc; | |
c1637c89 VZ |
322 | s_clsNotebook.Register(wc); |
323 | } | |
324 | else | |
325 | { | |
326 | wxLogLastError(_T("GetClassInfoEx(SysTabCtl32)")); | |
327 | } | |
328 | } | |
329 | ||
330 | // use our custom class if available but fall back to the standard | |
331 | // notebook if we failed to register it | |
332 | if ( s_clsNotebook.IsRegistered() ) | |
333 | { | |
334 | // it's ok to use c_str() here as the static s_clsNotebook object | |
335 | // has sufficiently long lifetime | |
336 | className = s_clsNotebook.GetName().c_str(); | |
337 | } | |
338 | } | |
6143d3b6 | 339 | #endif // USE_NOTEBOOK_ANTIFLICKER |
c1637c89 | 340 | |
6dd16e4f VZ |
341 | if ( !CreateControl(parent, id, pos, size, style | wxTAB_TRAVERSAL, |
342 | wxDefaultValidator, name) ) | |
b8bdaa7c | 343 | return false; |
88310e2e | 344 | |
c1637c89 | 345 | if ( !MSWCreateControl(className, wxEmptyString, pos, size) ) |
b8bdaa7c | 346 | return false; |
907f37b3 | 347 | |
7dccdf81 VZ |
348 | #if wxUSE_UXTHEME |
349 | if ( HasFlag(wxNB_NOPAGETHEME) || | |
350 | wxSystemOptions::IsFalse(wxT("msw.notebook.themed-background")) ) | |
f2b7be7a | 351 | { |
7dccdf81 | 352 | SetBackgroundColour(GetThemeBackgroundColour()); |
f2b7be7a | 353 | } |
30556182 VZ |
354 | else // use themed background by default |
355 | { | |
356 | // create backing store | |
357 | UpdateBgBrush(); | |
358 | } | |
e4db172a | 359 | |
7cc1ad29 JS |
360 | // comctl32.dll 6.0 doesn't support non-top tabs with visual styles (the |
361 | // control is simply not rendered correctly), so we disable themes | |
362 | // if possible, otherwise we simply clear the styles. | |
363 | // It's probably not possible to have UXTHEME without ComCtl32 6 or better, but lets | |
364 | // check it anyway. | |
365 | const int verComCtl32 = wxApp::GetComCtl32Version(); | |
e4db172a | 366 | if ( verComCtl32 == 600 ) |
7cc1ad29 JS |
367 | { |
368 | // check if we use themes at all -- if we don't, we're still okay | |
5483756f | 369 | if ( wxUxThemeEngine::GetIfActive() && (style & (wxBK_BOTTOM|wxBK_LEFT|wxBK_RIGHT))) |
7cc1ad29 JS |
370 | { |
371 | wxUxThemeEngine::GetIfActive()->SetWindowTheme((HWND)this->GetHandle(), L"", L""); | |
372 | SetBackgroundColour(GetThemeBackgroundColour()); //correct the background color for the new non-themed control | |
373 | } | |
374 | } | |
7dccdf81 | 375 | #endif // wxUSE_UXTHEME |
b554cf63 JS |
376 | |
377 | // Undocumented hack to get flat notebook style | |
378 | // In fact, we should probably only do this in some | |
379 | // curcumstances, i.e. if we know we will have a border | |
380 | // at the bottom (the tab control doesn't draw it itself) | |
381 | #if defined(__POCKETPC__) || defined(__SMARTPHONE__) | |
382 | if (HasFlag(wxNB_FLAT)) | |
383 | { | |
01c8cbf5 | 384 | SendMessage(GetHwnd(), CCM_SETVERSION, COMCTL32_VERSION, 0); |
b554cf63 JS |
385 | if (!m_hasBgCol) |
386 | SetBackgroundColour(*wxWHITE); | |
387 | } | |
388 | #endif | |
b8bdaa7c | 389 | return true; |
0df3fbd7 VZ |
390 | } |
391 | ||
392 | WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const | |
393 | { | |
394 | WXDWORD tabStyle = wxControl::MSWGetStyle(style, exstyle); | |
395 | ||
396 | tabStyle |= WS_TABSTOP | TCS_TABS; | |
397 | ||
2b5f62a0 | 398 | if ( style & wxNB_MULTILINE ) |
0df3fbd7 VZ |
399 | tabStyle |= TCS_MULTILINE; |
400 | if ( style & wxNB_FIXEDWIDTH ) | |
401 | tabStyle |= TCS_FIXEDWIDTH; | |
402 | ||
2ddb4d13 | 403 | if ( style & wxBK_BOTTOM ) |
0df3fbd7 | 404 | tabStyle |= TCS_RIGHT; |
2ddb4d13 | 405 | else if ( style & wxBK_LEFT ) |
0df3fbd7 | 406 | tabStyle |= TCS_VERTICAL; |
2ddb4d13 | 407 | else if ( style & wxBK_RIGHT ) |
c3732409 | 408 | tabStyle |= TCS_VERTICAL | TCS_RIGHT; |
0df3fbd7 VZ |
409 | |
410 | // ex style | |
411 | if ( exstyle ) | |
412 | { | |
413 | // note that we never want to have the default WS_EX_CLIENTEDGE style | |
414 | // as it looks too ugly for the notebooks | |
415 | *exstyle = 0; | |
416 | } | |
417 | ||
418 | return tabStyle; | |
88310e2e VZ |
419 | } |
420 | ||
caf95d2a VZ |
421 | wxNotebook::~wxNotebook() |
422 | { | |
423 | #if wxUSE_UXTHEME | |
424 | if ( m_hbrBackground ) | |
425 | ::DeleteObject((HBRUSH)m_hbrBackground); | |
426 | #endif // wxUSE_UXTHEME | |
427 | } | |
428 | ||
88310e2e VZ |
429 | // ---------------------------------------------------------------------------- |
430 | // wxNotebook accessors | |
431 | // ---------------------------------------------------------------------------- | |
07b8d7ec | 432 | |
8d34bf5c | 433 | size_t wxNotebook::GetPageCount() const |
88310e2e | 434 | { |
8ecd5de2 WS |
435 | // consistency check |
436 | wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(GetHwnd()) ); | |
88310e2e | 437 | |
8ecd5de2 | 438 | return m_pages.Count(); |
88310e2e VZ |
439 | } |
440 | ||
441 | int wxNotebook::GetRowCount() const | |
442 | { | |
8ecd5de2 | 443 | return TabCtrl_GetRowCount(GetHwnd()); |
88310e2e VZ |
444 | } |
445 | ||
8d34bf5c | 446 | int wxNotebook::SetSelection(size_t nPage) |
88310e2e | 447 | { |
8ecd5de2 WS |
448 | wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") ); |
449 | ||
a570e8f8 | 450 | if ( m_nSelection == wxNOT_FOUND || nPage != (size_t)m_nSelection ) |
2b5f62a0 | 451 | { |
a570e8f8 | 452 | if ( SendPageChangingEvent(nPage) ) |
8ecd5de2 WS |
453 | { |
454 | // program allows the page change | |
a570e8f8 | 455 | SendPageChangedEvent(m_nSelection, nPage); |
2b5f62a0 | 456 | |
a570e8f8 | 457 | TabCtrl_SetCurSel(GetHwnd(), nPage); |
8ecd5de2 | 458 | } |
2b5f62a0 | 459 | } |
88310e2e | 460 | |
8ecd5de2 | 461 | return m_nSelection; |
88310e2e VZ |
462 | } |
463 | ||
5482ee07 | 464 | void wxNotebook::UpdateSelection(int selNew) |
1d6fcbcc | 465 | { |
5482ee07 | 466 | if ( m_nSelection != wxNOT_FOUND ) |
1d6fcbcc VZ |
467 | m_pages[m_nSelection]->Show(false); |
468 | ||
5482ee07 | 469 | if ( selNew != wxNOT_FOUND ) |
1d6fcbcc | 470 | { |
5482ee07 | 471 | wxNotebookPage *pPage = m_pages[selNew]; |
1d6fcbcc VZ |
472 | pPage->Show(true); |
473 | } | |
474 | ||
475 | // Changing the page should give the focus to it but, as per bug report | |
476 | // http://sf.net/tracker/index.php?func=detail&aid=1150659&group_id=9863&atid=109863, | |
477 | // we should not set the focus to it directly since it erroneously | |
478 | // selects radio buttons and breaks keyboard handling for a notebook's | |
479 | // scroll buttons. So give focus to the notebook and not the page. | |
480 | ||
481 | // but don't do this is the notebook is hidden | |
482 | if ( ::IsWindowVisible(GetHwnd()) ) | |
483 | SetFocus(); | |
484 | ||
5482ee07 | 485 | m_nSelection = selNew; |
1d6fcbcc VZ |
486 | } |
487 | ||
488 | int wxNotebook::ChangeSelection(size_t nPage) | |
489 | { | |
490 | wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") ); | |
491 | ||
5482ee07 | 492 | if ( m_nSelection == wxNOT_FOUND || nPage != (size_t)m_nSelection ) |
1d6fcbcc VZ |
493 | { |
494 | TabCtrl_SetCurSel(GetHwnd(), nPage); | |
495 | ||
496 | UpdateSelection(nPage); | |
497 | } | |
498 | ||
499 | return m_nSelection; | |
500 | } | |
501 | ||
8d34bf5c | 502 | bool wxNotebook::SetPageText(size_t nPage, const wxString& strText) |
88310e2e | 503 | { |
8ecd5de2 | 504 | wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") ); |
88310e2e | 505 | |
8ecd5de2 WS |
506 | TC_ITEM tcItem; |
507 | tcItem.mask = TCIF_TEXT; | |
c9f78968 | 508 | tcItem.pszText = (wxChar *)strText.wx_str(); |
88310e2e | 509 | |
88a01064 JS |
510 | if ( !HasFlag(wxNB_MULTILINE) ) |
511 | return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; | |
512 | ||
513 | // multiline - we need to set new page size if a line is added or removed | |
514 | int rows = GetRowCount(); | |
515 | bool ret = TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; | |
516 | ||
517 | if ( ret && rows != GetRowCount() ) | |
518 | { | |
519 | const wxRect r = GetPageSize(); | |
520 | const size_t count = m_pages.Count(); | |
521 | for ( size_t page = 0; page < count; page++ ) | |
522 | m_pages[page]->SetSize(r); | |
523 | } | |
524 | ||
525 | return ret; | |
88310e2e VZ |
526 | } |
527 | ||
8d34bf5c | 528 | wxString wxNotebook::GetPageText(size_t nPage) const |
88310e2e | 529 | { |
8ecd5de2 | 530 | wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") ); |
88310e2e | 531 | |
8ecd5de2 WS |
532 | wxChar buf[256]; |
533 | TC_ITEM tcItem; | |
534 | tcItem.mask = TCIF_TEXT; | |
535 | tcItem.pszText = buf; | |
536 | tcItem.cchTextMax = WXSIZEOF(buf); | |
88310e2e | 537 | |
8ecd5de2 WS |
538 | wxString str; |
539 | if ( TabCtrl_GetItem(GetHwnd(), nPage, &tcItem) ) | |
540 | str = tcItem.pszText; | |
88310e2e | 541 | |
8ecd5de2 | 542 | return str; |
88310e2e VZ |
543 | } |
544 | ||
8d34bf5c | 545 | int wxNotebook::GetPageImage(size_t nPage) const |
88310e2e | 546 | { |
8ecd5de2 | 547 | wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") ); |
88310e2e | 548 | |
8ecd5de2 WS |
549 | TC_ITEM tcItem; |
550 | tcItem.mask = TCIF_IMAGE; | |
88310e2e | 551 | |
5482ee07 VZ |
552 | return TabCtrl_GetItem(GetHwnd(), nPage, &tcItem) ? tcItem.iImage |
553 | : wxNOT_FOUND; | |
88310e2e VZ |
554 | } |
555 | ||
8d34bf5c | 556 | bool wxNotebook::SetPageImage(size_t nPage, int nImage) |
88310e2e | 557 | { |
8ecd5de2 | 558 | wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") ); |
88310e2e | 559 | |
8ecd5de2 WS |
560 | TC_ITEM tcItem; |
561 | tcItem.mask = TCIF_IMAGE; | |
562 | tcItem.iImage = nImage; | |
88310e2e | 563 | |
8ecd5de2 | 564 | return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; |
88310e2e VZ |
565 | } |
566 | ||
567 | void wxNotebook::SetImageList(wxImageList* imageList) | |
907f37b3 | 568 | { |
8ecd5de2 | 569 | wxNotebookBase::SetImageList(imageList); |
07b8d7ec | 570 | |
8ecd5de2 WS |
571 | if ( imageList ) |
572 | { | |
5482ee07 | 573 | (void) TabCtrl_SetImageList(GetHwnd(), GetHimagelistOf(imageList)); |
8ecd5de2 | 574 | } |
b656febd VS |
575 | } |
576 | ||
d9506e77 VZ |
577 | // ---------------------------------------------------------------------------- |
578 | // wxNotebook size settings | |
579 | // ---------------------------------------------------------------------------- | |
580 | ||
c3732409 VZ |
581 | wxRect wxNotebook::GetPageSize() const |
582 | { | |
583 | wxRect r; | |
584 | ||
585 | RECT rc; | |
586 | ::GetClientRect(GetHwnd(), &rc); | |
587 | ||
588 | // This check is to work around a bug in TabCtrl_AdjustRect which will | |
628eae0b VZ |
589 | // cause a crash on win2k or on XP with themes disabled if either |
590 | // wxNB_MULTILINE is used or tabs are placed on a side, if the rectangle | |
591 | // is too small. | |
592 | // | |
593 | // The value of 20 is chosen arbitrarily but seems to work | |
594 | if ( rc.right > 20 && rc.bottom > 20 ) | |
c3732409 | 595 | { |
01c8cbf5 | 596 | TabCtrl_AdjustRect(GetHwnd(), false, &rc); |
c3732409 VZ |
597 | |
598 | wxCopyRECTToRect(rc, r); | |
599 | } | |
600 | ||
601 | return r; | |
602 | } | |
603 | ||
d9506e77 VZ |
604 | void wxNotebook::SetPageSize(const wxSize& size) |
605 | { | |
606 | // transform the page size into the notebook size | |
607 | RECT rc; | |
608 | rc.left = | |
609 | rc.top = 0; | |
610 | rc.right = size.x; | |
611 | rc.bottom = size.y; | |
612 | ||
b8bdaa7c | 613 | TabCtrl_AdjustRect(GetHwnd(), true, &rc); |
d9506e77 VZ |
614 | |
615 | // and now set it | |
616 | SetSize(rc.right - rc.left, rc.bottom - rc.top); | |
617 | } | |
618 | ||
619 | void wxNotebook::SetPadding(const wxSize& padding) | |
620 | { | |
621 | TabCtrl_SetPadding(GetHwnd(), padding.x, padding.y); | |
622 | } | |
42e69d6b VZ |
623 | |
624 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH | |
625 | // style. | |
626 | void wxNotebook::SetTabSize(const wxSize& sz) | |
627 | { | |
628 | ::SendMessage(GetHwnd(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y)); | |
629 | } | |
630 | ||
2ce7af35 JS |
631 | wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const |
632 | { | |
669c595d | 633 | // we can't use TabCtrl_AdjustRect here because it only works for wxNB_TOP |
2ce7af35 | 634 | wxSize sizeTotal = sizePage; |
078cf5cb | 635 | |
8b5d5223 | 636 | wxSize tabSize; |
669c595d | 637 | if ( GetPageCount() > 0 ) |
2ce7af35 JS |
638 | { |
639 | RECT rect; | |
669c595d | 640 | TabCtrl_GetItemRect(GetHwnd(), 0, &rect); |
2ce7af35 JS |
641 | tabSize.x = rect.right - rect.left; |
642 | tabSize.y = rect.bottom - rect.top; | |
643 | } | |
669c595d VZ |
644 | |
645 | // add an extra margin in both directions | |
646 | const int MARGIN = 8; | |
647 | if ( IsVertical() ) | |
2ce7af35 | 648 | { |
669c595d VZ |
649 | sizeTotal.x += MARGIN; |
650 | sizeTotal.y += tabSize.y + MARGIN; | |
2ce7af35 | 651 | } |
669c595d | 652 | else // horizontal layout |
2ce7af35 | 653 | { |
669c595d VZ |
654 | sizeTotal.x += tabSize.x + MARGIN; |
655 | sizeTotal.y += MARGIN; | |
2ce7af35 JS |
656 | } |
657 | ||
658 | return sizeTotal; | |
659 | } | |
660 | ||
2015f2b3 VZ |
661 | void wxNotebook::AdjustPageSize(wxNotebookPage *page) |
662 | { | |
663 | wxCHECK_RET( page, _T("NULL page in wxNotebook::AdjustPageSize") ); | |
664 | ||
c3732409 VZ |
665 | const wxRect r = GetPageSize(); |
666 | if ( !r.IsEmpty() ) | |
14a6b6e5 | 667 | { |
c3732409 | 668 | page->SetSize(r); |
14a6b6e5 | 669 | } |
2015f2b3 VZ |
670 | } |
671 | ||
88310e2e VZ |
672 | // ---------------------------------------------------------------------------- |
673 | // wxNotebook operations | |
674 | // ---------------------------------------------------------------------------- | |
675 | ||
621793f4 | 676 | // remove one page from the notebook, without deleting |
8d34bf5c | 677 | wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage) |
621793f4 | 678 | { |
df7145da VZ |
679 | wxNotebookPage *pageRemoved = wxNotebookBase::DoRemovePage(nPage); |
680 | if ( !pageRemoved ) | |
681 | return NULL; | |
621793f4 | 682 | |
01c8cbf5 | 683 | TabCtrl_DeleteItem(GetHwnd(), nPage); |
621793f4 | 684 | |
df7145da VZ |
685 | if ( m_pages.IsEmpty() ) |
686 | { | |
687 | // no selection any more, the notebook becamse empty | |
5482ee07 | 688 | m_nSelection = wxNOT_FOUND; |
df7145da VZ |
689 | } |
690 | else // notebook still not empty | |
691 | { | |
01c8cbf5 | 692 | int selNew = TabCtrl_GetCurSel(GetHwnd()); |
5482ee07 | 693 | if ( selNew != wxNOT_FOUND ) |
df7145da | 694 | { |
623f5f70 | 695 | // No selection change, just refresh the current selection. |
078cf5cb WS |
696 | // Because it could be that the slection index changed |
697 | // we need to update it. | |
623f5f70 JS |
698 | // Note: this does not mean the selection it self changed. |
699 | m_nSelection = selNew; | |
700 | m_pages[m_nSelection]->Refresh(); | |
df7145da | 701 | } |
623f5f70 | 702 | else if (int(nPage) == m_nSelection) |
43a997b6 | 703 | { |
623f5f70 | 704 | // The selection was deleted. |
078cf5cb | 705 | |
623f5f70 JS |
706 | // Determine new selection. |
707 | if (m_nSelection == int(GetPageCount())) | |
708 | selNew = m_nSelection - 1; | |
709 | else | |
710 | selNew = m_nSelection; | |
078cf5cb | 711 | |
43a997b6 VZ |
712 | // m_nSelection must be always valid so reset it before calling |
713 | // SetSelection() | |
5482ee07 | 714 | m_nSelection = wxNOT_FOUND; |
43a997b6 VZ |
715 | SetSelection(selNew); |
716 | } | |
623f5f70 JS |
717 | else |
718 | { | |
719 | wxFAIL; // Windows did not behave ok. | |
720 | } | |
df7145da | 721 | } |
47f12f58 | 722 | |
df7145da | 723 | return pageRemoved; |
621793f4 JS |
724 | } |
725 | ||
88310e2e VZ |
726 | // remove all pages |
727 | bool wxNotebook::DeleteAllPages() | |
728 | { | |
7ec69821 WS |
729 | size_t nPageCount = GetPageCount(); |
730 | size_t nPage; | |
731 | for ( nPage = 0; nPage < nPageCount; nPage++ ) | |
732 | delete m_pages[nPage]; | |
88310e2e | 733 | |
7ec69821 | 734 | m_pages.Clear(); |
88310e2e | 735 | |
7ec69821 | 736 | TabCtrl_DeleteAllItems(GetHwnd()); |
907f37b3 | 737 | |
5482ee07 | 738 | m_nSelection = wxNOT_FOUND; |
47f12f58 | 739 | |
7ec69821 WS |
740 | InvalidateBestSize(); |
741 | return true; | |
88310e2e VZ |
742 | } |
743 | ||
88310e2e | 744 | // same as AddPage() but does it at given position |
8d34bf5c | 745 | bool wxNotebook::InsertPage(size_t nPage, |
88310e2e VZ |
746 | wxNotebookPage *pPage, |
747 | const wxString& strText, | |
748 | bool bSelect, | |
749 | int imageId) | |
750 | { | |
b8bdaa7c VZ |
751 | wxCHECK_MSG( pPage != NULL, false, _T("NULL page in wxNotebook::InsertPage") ); |
752 | wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false, | |
22f3361e | 753 | _T("invalid index in wxNotebook::InsertPage") ); |
88310e2e | 754 | |
efa14cf2 VZ |
755 | wxASSERT_MSG( pPage->GetParent() == this, |
756 | _T("notebook pages must have notebook as parent") ); | |
43427087 | 757 | |
22f3361e VZ |
758 | // add a new tab to the control |
759 | // ---------------------------- | |
58a8ab88 | 760 | |
22f3361e VZ |
761 | // init all fields to 0 |
762 | TC_ITEM tcItem; | |
763 | wxZeroMemory(tcItem); | |
58a8ab88 | 764 | |
22f3361e VZ |
765 | // set the image, if any |
766 | if ( imageId != -1 ) | |
767 | { | |
768 | tcItem.mask |= TCIF_IMAGE; | |
769 | tcItem.iImage = imageId; | |
770 | } | |
88310e2e | 771 | |
22f3361e | 772 | // and the text |
8b5d5223 | 773 | if ( !strText.empty() ) |
22f3361e VZ |
774 | { |
775 | tcItem.mask |= TCIF_TEXT; | |
c9f78968 | 776 | tcItem.pszText = (wxChar *)strText.wx_str(); // const_cast |
22f3361e | 777 | } |
43427087 | 778 | |
e830a6a6 RD |
779 | // hide the page: unless it is selected, it shouldn't be shown (and if it |
780 | // is selected it will be shown later) | |
781 | HWND hwnd = GetWinHwnd(pPage); | |
782 | SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE); | |
783 | ||
784 | // this updates internal flag too -- otherwise it would get out of sync | |
785 | // with the real state | |
786 | pPage->Show(false); | |
787 | ||
788 | ||
22f3361e VZ |
789 | // fit the notebook page to the tab control's display area: this should be |
790 | // done before adding it to the notebook or TabCtrl_InsertItem() will | |
791 | // change the notebooks size itself! | |
2015f2b3 | 792 | AdjustPageSize(pPage); |
43427087 | 793 | |
22f3361e | 794 | // finally do insert it |
01c8cbf5 | 795 | if ( TabCtrl_InsertItem(GetHwnd(), nPage, &tcItem) == -1 ) |
2015f2b3 | 796 | { |
22f3361e | 797 | wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str()); |
88310e2e | 798 | |
b8bdaa7c | 799 | return false; |
22f3361e | 800 | } |
88310e2e | 801 | |
ebd9ec29 JG |
802 | // need to update the bg brush when the first page is added |
803 | // so the first panel gets the correct themed background | |
804 | if ( m_pages.empty() ) | |
805 | { | |
11e70ae6 | 806 | #if wxUSE_UXTHEME |
ebd9ec29 | 807 | UpdateBgBrush(); |
11e70ae6 | 808 | #endif // wxUSE_UXTHEME |
ebd9ec29 JG |
809 | } |
810 | ||
22f3361e VZ |
811 | // succeeded: save the pointer to the page |
812 | m_pages.Insert(pPage, nPage); | |
42e69d6b | 813 | |
56b9925b VZ |
814 | // we may need to adjust the size again if the notebook size changed: |
815 | // normally this only happens for the first page we add (the tabs which | |
816 | // hadn't been there before are now shown) but for a multiline notebook it | |
817 | // can happen for any page at all as a new row could have been started | |
818 | if ( m_pages.GetCount() == 1 || HasFlag(wxNB_MULTILINE) ) | |
2015f2b3 VZ |
819 | { |
820 | AdjustPageSize(pPage); | |
821 | } | |
822 | ||
22f3361e VZ |
823 | // now deal with the selection |
824 | // --------------------------- | |
825 | ||
826 | // if the inserted page is before the selected one, we must update the | |
827 | // index of the selected page | |
34a0c9f4 | 828 | if ( int(nPage) <= m_nSelection ) |
22f3361e VZ |
829 | { |
830 | // one extra page added | |
831 | m_nSelection++; | |
832 | } | |
833 | ||
834 | // some page should be selected: either this one or the first one if there | |
835 | // is still no selection | |
5482ee07 | 836 | int selNew = wxNOT_FOUND; |
22f3361e VZ |
837 | if ( bSelect ) |
838 | selNew = nPage; | |
5482ee07 | 839 | else if ( m_nSelection == wxNOT_FOUND ) |
22f3361e VZ |
840 | selNew = 0; |
841 | ||
5482ee07 | 842 | if ( selNew != wxNOT_FOUND ) |
22f3361e VZ |
843 | SetSelection(selNew); |
844 | ||
37144cf0 | 845 | InvalidateBestSize(); |
25057aba | 846 | |
b8bdaa7c | 847 | return true; |
88310e2e VZ |
848 | } |
849 | ||
e450aa69 | 850 | int wxNotebook::HitTest(const wxPoint& pt, long *flags) const |
ef094fa0 JS |
851 | { |
852 | TC_HITTESTINFO hitTestInfo; | |
853 | hitTestInfo.pt.x = pt.x; | |
854 | hitTestInfo.pt.y = pt.y; | |
e450aa69 | 855 | int item = TabCtrl_HitTest(GetHwnd(), &hitTestInfo); |
ef094fa0 | 856 | |
e450aa69 VZ |
857 | if ( flags ) |
858 | { | |
859 | *flags = 0; | |
860 | ||
861 | if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE) | |
9804d540 | 862 | *flags |= wxBK_HITTEST_NOWHERE; |
e450aa69 | 863 | if ((hitTestInfo.flags & TCHT_ONITEM) == TCHT_ONITEM) |
9804d540 | 864 | *flags |= wxBK_HITTEST_ONITEM; |
e450aa69 | 865 | if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON) |
9804d540 | 866 | *flags |= wxBK_HITTEST_ONICON; |
e450aa69 | 867 | if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL) |
9804d540 | 868 | *flags |= wxBK_HITTEST_ONLABEL; |
22a35096 | 869 | if ( item == wxNOT_FOUND && GetPageSize().Contains(pt) ) |
9804d540 | 870 | *flags |= wxBK_HITTEST_ONPAGE; |
e450aa69 | 871 | } |
ef094fa0 JS |
872 | |
873 | return item; | |
874 | } | |
875 | ||
014ee083 VZ |
876 | // ---------------------------------------------------------------------------- |
877 | // flicker-less notebook redraw | |
878 | // ---------------------------------------------------------------------------- | |
879 | ||
880 | #if USE_NOTEBOOK_ANTIFLICKER | |
881 | ||
882 | // wnd proc for the spin button | |
883 | LRESULT APIENTRY _EXPORT wxNotebookSpinBtnWndProc(HWND hwnd, | |
884 | UINT message, | |
885 | WPARAM wParam, | |
886 | LPARAM lParam) | |
887 | { | |
888 | if ( message == WM_ERASEBKGND ) | |
889 | return 0; | |
890 | ||
891 | return ::CallWindowProc(CASTWNDPROC gs_wndprocNotebookSpinBtn, | |
892 | hwnd, message, wParam, lParam); | |
893 | } | |
894 | ||
6143d3b6 VZ |
895 | LRESULT APIENTRY _EXPORT wxNotebookWndProc(HWND hwnd, |
896 | UINT message, | |
897 | WPARAM wParam, | |
898 | LPARAM lParam) | |
899 | { | |
900 | return ::CallWindowProc(CASTWNDPROC gs_wndprocNotebook, | |
901 | hwnd, message, wParam, lParam); | |
902 | } | |
903 | ||
014ee083 VZ |
904 | void wxNotebook::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) |
905 | { | |
906 | // do nothing here | |
907 | } | |
908 | ||
909 | void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event)) | |
910 | { | |
911 | wxPaintDC dc(this); | |
912 | wxMemoryDC memdc; | |
913 | RECT rc; | |
914 | ::GetClientRect(GetHwnd(), &rc); | |
915 | wxBitmap bmp(rc.right, rc.bottom); | |
916 | memdc.SelectObject(bmp); | |
917 | ||
6614aa49 VZ |
918 | const wxLayoutDirection dir = dc.GetLayoutDirection(); |
919 | memdc.SetLayoutDirection(dir); | |
920 | ||
014ee083 | 921 | // if there is no special brush just use the solid background colour |
64c288fa | 922 | #if wxUSE_UXTHEME |
014ee083 | 923 | HBRUSH hbr = (HBRUSH)m_hbrBackground; |
64c288fa JS |
924 | #else |
925 | HBRUSH hbr = 0; | |
e4db172a | 926 | #endif |
e32703a9 | 927 | wxBrush brush; |
014ee083 | 928 | if ( !hbr ) |
e32703a9 VZ |
929 | { |
930 | brush = wxBrush(GetBackgroundColour()); | |
931 | hbr = GetHbrushOf(brush); | |
932 | } | |
014ee083 VZ |
933 | |
934 | ::FillRect(GetHdcOf(memdc), &rc, hbr); | |
935 | ||
936 | MSWDefWindowProc(WM_PAINT, (WPARAM)memdc.GetHDC(), 0); | |
937 | ||
f4322df6 | 938 | // For some reason in RTL mode, source offset has to be -1, otherwise the |
6614aa49 VZ |
939 | // right border (physical) remains unpainted. |
940 | const wxCoord ofs = dir == wxLayout_RightToLeft ? -1 : 0; | |
941 | dc.Blit(ofs, 0, rc.right, rc.bottom, &memdc, ofs, 0); | |
014ee083 VZ |
942 | } |
943 | ||
944 | #endif // USE_NOTEBOOK_ANTIFLICKER | |
e450aa69 | 945 | |
88310e2e VZ |
946 | // ---------------------------------------------------------------------------- |
947 | // wxNotebook callbacks | |
948 | // ---------------------------------------------------------------------------- | |
949 | ||
9026ad85 | 950 | void wxNotebook::OnSize(wxSizeEvent& event) |
88310e2e | 951 | { |
7dccdf81 | 952 | if ( GetPageCount() == 0 ) |
f7eaa62f JS |
953 | { |
954 | // Prevents droppings on resize, but does cause some flicker | |
955 | // when there are no pages. | |
2aa24b60 | 956 | Refresh(); |
f7eaa62f JS |
957 | event.Skip(); |
958 | return; | |
959 | } | |
254fbd14 JS |
960 | #ifndef __WXWINCE__ |
961 | else | |
962 | { | |
963 | // Without this, we can sometimes get droppings at the edges | |
964 | // of a notebook, for example a notebook in a splitter window. | |
965 | // This needs to be reconciled with the RefreshRect calls | |
966 | // at the end of this function, which weren't enough to prevent | |
967 | // the droppings. | |
01c8cbf5 | 968 | |
254fbd14 JS |
969 | wxSize sz = GetClientSize(); |
970 | ||
971 | // Refresh right side | |
972 | wxRect rect(sz.x-4, 0, 4, sz.y); | |
973 | RefreshRect(rect); | |
01c8cbf5 | 974 | |
254fbd14 JS |
975 | // Refresh bottom side |
976 | rect = wxRect(0, sz.y-4, sz.x, 4); | |
977 | RefreshRect(rect); | |
01c8cbf5 | 978 | |
254fbd14 JS |
979 | // Refresh left side |
980 | rect = wxRect(0, 0, 4, sz.y); | |
981 | RefreshRect(rect); | |
982 | } | |
014ee083 | 983 | #endif // !__WXWINCE__ |
f7eaa62f | 984 | |
c1637c89 | 985 | // fit all the notebook pages to the tab control's display area |
56b9925b | 986 | |
c1637c89 VZ |
987 | RECT rc; |
988 | rc.left = rc.top = 0; | |
989 | GetSize((int *)&rc.right, (int *)&rc.bottom); | |
56b9925b | 990 | |
c1637c89 VZ |
991 | // save the total size, we'll use it below |
992 | int widthNbook = rc.right - rc.left, | |
993 | heightNbook = rc.bottom - rc.top; | |
994 | ||
995 | // there seems to be a bug in the implementation of TabCtrl_AdjustRect(): it | |
996 | // returns completely false values for multiline tab controls after the tabs | |
997 | // are added but before getting the first WM_SIZE (off by ~50 pixels, see | |
998 | // | |
999 | // http://sf.net/tracker/index.php?func=detail&aid=645323&group_id=9863&atid=109863 | |
1000 | // | |
1001 | // and the only work around I could find was this ugly hack... without it | |
1002 | // simply toggling the "multiline" checkbox in the notebook sample resulted | |
1003 | // in a noticeable page displacement | |
1004 | if ( HasFlag(wxNB_MULTILINE) ) | |
1005 | { | |
1006 | // avoid an infinite recursion: we get another notification too! | |
1007 | static bool s_isInOnSize = false; | |
4b7f2165 | 1008 | |
c1637c89 VZ |
1009 | if ( !s_isInOnSize ) |
1010 | { | |
1011 | s_isInOnSize = true; | |
1012 | SendMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, | |
1013 | MAKELPARAM(rc.right, rc.bottom)); | |
1014 | s_isInOnSize = false; | |
1015 | } | |
1016 | } | |
b5c3b538 | 1017 | |
e2f6f8da RD |
1018 | #if wxUSE_UXTHEME |
1019 | // background bitmap size has changed, update the brush using it too | |
1020 | UpdateBgBrush(); | |
1021 | #endif // wxUSE_UXTHEME | |
1022 | ||
01c8cbf5 | 1023 | TabCtrl_AdjustRect(GetHwnd(), false, &rc); |
c1637c89 VZ |
1024 | |
1025 | int width = rc.right - rc.left, | |
1026 | height = rc.bottom - rc.top; | |
1027 | size_t nCount = m_pages.Count(); | |
1028 | for ( size_t nPage = 0; nPage < nCount; nPage++ ) { | |
1029 | wxNotebookPage *pPage = m_pages[nPage]; | |
1030 | pPage->SetSize(rc.left, rc.top, width, height); | |
1031 | } | |
1032 | ||
1033 | ||
1034 | // unless we had already repainted everything, we now need to refresh | |
1035 | if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) | |
1036 | { | |
1037 | // invalidate areas not covered by pages | |
1038 | RefreshRect(wxRect(0, 0, widthNbook, rc.top), false); | |
1039 | RefreshRect(wxRect(0, rc.top, rc.left, height), false); | |
1040 | RefreshRect(wxRect(0, rc.bottom, widthNbook, heightNbook - rc.bottom), | |
1041 | false); | |
3550706d | 1042 | RefreshRect(wxRect(rc.right, rc.top, widthNbook - rc.right, height), |
c1637c89 VZ |
1043 | false); |
1044 | } | |
1045 | ||
014ee083 VZ |
1046 | #if USE_NOTEBOOK_ANTIFLICKER |
1047 | // subclass the spin control used by the notebook to scroll pages to | |
1048 | // prevent it from flickering on resize | |
dfb47d83 | 1049 | if ( !m_hasSubclassedUpdown ) |
014ee083 VZ |
1050 | { |
1051 | // iterate over all child windows to find spin button | |
1052 | for ( HWND child = ::GetWindow(GetHwnd(), GW_CHILD); | |
1053 | child; | |
1054 | child = ::GetWindow(child, GW_HWNDNEXT) ) | |
1055 | { | |
1056 | wxWindow *childWindow = wxFindWinFromHandle((WXHWND)child); | |
1057 | ||
1058 | // see if it exists, if no wxWindow found then assume it's the spin | |
1059 | // btn | |
1060 | if ( !childWindow ) | |
1061 | { | |
1062 | // subclass the spin button to override WM_ERASEBKGND | |
dfb47d83 VZ |
1063 | if ( !gs_wndprocNotebookSpinBtn ) |
1064 | gs_wndprocNotebookSpinBtn = (WXFARPROC)wxGetWindowProc(child); | |
014ee083 VZ |
1065 | |
1066 | wxSetWindowProc(child, wxNotebookSpinBtnWndProc); | |
dfb47d83 | 1067 | m_hasSubclassedUpdown = true; |
014ee083 VZ |
1068 | break; |
1069 | } | |
1070 | } | |
1071 | } | |
1072 | #endif // USE_NOTEBOOK_ANTIFLICKER | |
1073 | ||
c1637c89 | 1074 | event.Skip(); |
88310e2e VZ |
1075 | } |
1076 | ||
1077 | void wxNotebook::OnSelChange(wxNotebookEvent& event) | |
1078 | { | |
1d6fcbcc VZ |
1079 | // is it our tab control? |
1080 | if ( event.GetEventObject() == this ) | |
1081 | { | |
1082 | UpdateSelection(event.GetSelection()); | |
1083 | } | |
88310e2e | 1084 | |
1d6fcbcc VZ |
1085 | // we want to give others a chance to process this message as well |
1086 | event.Skip(); | |
88310e2e VZ |
1087 | } |
1088 | ||
88310e2e VZ |
1089 | void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) |
1090 | { | |
d9506e77 VZ |
1091 | if ( event.IsWindowChange() ) { |
1092 | // change pages | |
1093 | AdvanceSelection(event.GetDirection()); | |
1094 | } | |
1095 | else { | |
b8bdaa7c | 1096 | // we get this event in 3 cases |
d9506e77 VZ |
1097 | // |
1098 | // a) one of our pages might have generated it because the user TABbed | |
1099 | // out from it in which case we should propagate the event upwards and | |
1100 | // our parent will take care of setting the focus to prev/next sibling | |
1101 | // | |
1102 | // or | |
1103 | // | |
1104 | // b) the parent panel wants to give the focus to us so that we | |
1105 | // forward it to our selected page. We can't deal with this in | |
1106 | // OnSetFocus() because we don't know which direction the focus came | |
1107 | // from in this case and so can't choose between setting the focus to | |
1108 | // first or last panel child | |
b8bdaa7c VZ |
1109 | // |
1110 | // or | |
1111 | // | |
1112 | // c) we ourselves (see MSWTranslateMessage) generated the event | |
1113 | // | |
1114 | wxWindow * const parent = GetParent(); | |
1115 | ||
3c99602b MB |
1116 | // the wxObject* casts are required to avoid MinGW GCC 2.95.3 ICE |
1117 | const bool isFromParent = event.GetEventObject() == (wxObject*) parent; | |
1118 | const bool isFromSelf = event.GetEventObject() == (wxObject*) this; | |
b8bdaa7c VZ |
1119 | |
1120 | if ( isFromParent || isFromSelf ) | |
d9506e77 | 1121 | { |
b8bdaa7c VZ |
1122 | // no, it doesn't come from child, case (b) or (c): forward to a |
1123 | // page but only if direction is backwards (TAB) or from ourselves, | |
5482ee07 | 1124 | if ( m_nSelection != wxNOT_FOUND && |
b8bdaa7c | 1125 | (!event.GetDirection() || isFromSelf) ) |
d9506e77 VZ |
1126 | { |
1127 | // so that the page knows that the event comes from it's parent | |
1128 | // and is being propagated downwards | |
1129 | event.SetEventObject(this); | |
1130 | ||
1e6feb95 | 1131 | wxWindow *page = m_pages[m_nSelection]; |
d9506e77 VZ |
1132 | if ( !page->GetEventHandler()->ProcessEvent(event) ) |
1133 | { | |
1134 | page->SetFocus(); | |
1135 | } | |
1136 | //else: page manages focus inside it itself | |
1137 | } | |
b8bdaa7c | 1138 | else // otherwise set the focus to the notebook itself |
d9506e77 | 1139 | { |
d9506e77 VZ |
1140 | SetFocus(); |
1141 | } | |
1142 | } | |
1143 | else | |
1144 | { | |
b8bdaa7c VZ |
1145 | // it comes from our child, case (a), pass to the parent, but only |
1146 | // if the direction is forwards. Otherwise set the focus to the | |
1147 | // notebook itself. The notebook is always the 'first' control of a | |
1148 | // page. | |
1149 | if ( !event.GetDirection() ) | |
1150 | { | |
1151 | SetFocus(); | |
1152 | } | |
1153 | else if ( parent ) | |
1154 | { | |
d9506e77 VZ |
1155 | event.SetCurrentFocus(this); |
1156 | parent->GetEventHandler()->ProcessEvent(event); | |
1157 | } | |
1158 | } | |
88310e2e | 1159 | } |
88310e2e VZ |
1160 | } |
1161 | ||
caf95d2a VZ |
1162 | #if wxUSE_UXTHEME |
1163 | ||
c3732409 | 1164 | bool wxNotebook::DoDrawBackground(WXHDC hDC, wxWindow *child) |
caf95d2a | 1165 | { |
c3732409 VZ |
1166 | wxUxThemeHandle theme(child ? child : this, L"TAB"); |
1167 | if ( !theme ) | |
1168 | return false; | |
1169 | ||
1170 | // get the notebook client rect (we're not interested in drawing tabs | |
1171 | // themselves) | |
1172 | wxRect r = GetPageSize(); | |
1173 | if ( r.IsEmpty() ) | |
1174 | return false; | |
1175 | ||
c4a95f6f | 1176 | RECT rc; |
c3732409 VZ |
1177 | wxCopyRectToRECT(r, rc); |
1178 | ||
1179 | // map rect to the coords of the window we're drawing in | |
1180 | if ( child ) | |
1181 | ::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2); | |
1182 | ||
2ff53fd3 JS |
1183 | // we have the content area (page size), but we need to draw all of the |
1184 | // background for it to be aligned correctly | |
1185 | wxUxThemeEngine::Get()->GetThemeBackgroundExtent | |
1186 | ( | |
1187 | theme, | |
1188 | (HDC) hDC, | |
1189 | 9 /* TABP_PANE */, | |
1190 | 0, | |
1191 | &rc, | |
1192 | &rc | |
1193 | ); | |
c3732409 VZ |
1194 | wxUxThemeEngine::Get()->DrawThemeBackground |
1195 | ( | |
1196 | theme, | |
92199f4c | 1197 | (HDC) hDC, |
c3732409 VZ |
1198 | 9 /* TABP_PANE */, |
1199 | 0, | |
1200 | &rc, | |
1201 | NULL | |
1202 | ); | |
1203 | ||
1204 | return true; | |
1205 | } | |
de359565 | 1206 | |
c3732409 VZ |
1207 | WXHBRUSH wxNotebook::QueryBgBitmap() |
1208 | { | |
1209 | wxRect r = GetPageSize(); | |
1210 | if ( r.IsEmpty() ) | |
1211 | return 0; | |
c4a95f6f VZ |
1212 | |
1213 | WindowHDC hDC(GetHwnd()); | |
1214 | MemoryHDC hDCMem(hDC); | |
c3732409 | 1215 | CompatibleBitmap hBmp(hDC, r.x + r.width, r.y + r.height); |
c4a95f6f VZ |
1216 | |
1217 | SelectInHDC selectBmp(hDCMem, hBmp); | |
caf95d2a | 1218 | |
c3732409 VZ |
1219 | if ( !DoDrawBackground((WXHDC)(HDC)hDCMem) ) |
1220 | return 0; | |
0f770734 | 1221 | |
de359565 | 1222 | return (WXHBRUSH)::CreatePatternBrush(hBmp); |
c4a95f6f | 1223 | } |
caf95d2a | 1224 | |
c4a95f6f VZ |
1225 | void wxNotebook::UpdateBgBrush() |
1226 | { | |
1227 | if ( m_hbrBackground ) | |
1228 | ::DeleteObject((HBRUSH)m_hbrBackground); | |
caf95d2a | 1229 | |
c4a95f6f VZ |
1230 | if ( !m_hasBgCol && wxUxThemeEngine::GetIfActive() ) |
1231 | { | |
de359565 | 1232 | m_hbrBackground = QueryBgBitmap(); |
caf95d2a | 1233 | } |
c3732409 | 1234 | else // no themes or we've got user-defined solid colour |
caf95d2a VZ |
1235 | { |
1236 | m_hbrBackground = NULL; | |
1237 | } | |
1238 | } | |
1239 | ||
2bae4332 | 1240 | WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd) |
caf95d2a | 1241 | { |
caf95d2a VZ |
1242 | if ( m_hbrBackground ) |
1243 | { | |
1244 | // before drawing with the background brush, we need to position it | |
1245 | // correctly | |
caf95d2a | 1246 | RECT rc; |
2bae4332 | 1247 | ::GetWindowRect((HWND)hWnd, &rc); |
caf95d2a VZ |
1248 | |
1249 | ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1); | |
1250 | ||
5c836c46 | 1251 | if ( !::SetBrushOrgEx((HDC)hDC, -rc.left, -rc.top, NULL) ) |
caf95d2a VZ |
1252 | { |
1253 | wxLogLastError(_T("SetBrushOrgEx(notebook bg brush)")); | |
1254 | } | |
c4a95f6f VZ |
1255 | |
1256 | return m_hbrBackground; | |
5c836c46 VZ |
1257 | } |
1258 | ||
2bae4332 | 1259 | return wxNotebookBase::MSWGetBgBrushForChild(hDC, hWnd); |
5c836c46 | 1260 | } |
caf95d2a | 1261 | |
c3732409 | 1262 | bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child) |
07c19327 | 1263 | { |
c3732409 VZ |
1264 | // solid background colour overrides themed background drawing |
1265 | if ( !UseBgCol() && DoDrawBackground(hDC, child) ) | |
1266 | return true; | |
de359565 | 1267 | |
4dab5279 JS |
1268 | // If we're using a solid colour (for example if we've switched off |
1269 | // theming for this notebook), paint it | |
1270 | if (UseBgCol()) | |
1271 | { | |
1272 | wxRect r = GetPageSize(); | |
1273 | if ( r.IsEmpty() ) | |
1274 | return false; | |
1275 | ||
1276 | RECT rc; | |
1277 | wxCopyRectToRECT(r, rc); | |
1278 | ||
1279 | // map rect to the coords of the window we're drawing in | |
1280 | if ( child ) | |
1281 | ::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2); | |
1282 | ||
1283 | wxBrush brush(GetBackgroundColour()); | |
1284 | HBRUSH hbr = GetHbrushOf(brush); | |
01c8cbf5 | 1285 | |
4dab5279 JS |
1286 | ::FillRect((HDC) hDC, &rc, hbr); |
1287 | ||
1288 | return true; | |
1289 | } | |
1290 | ||
c3732409 | 1291 | return wxNotebookBase::MSWPrintChild(hDC, child); |
07c19327 VZ |
1292 | } |
1293 | ||
caf95d2a VZ |
1294 | #endif // wxUSE_UXTHEME |
1295 | ||
25057aba JS |
1296 | // Windows only: attempts to get colour for UX theme page background |
1297 | wxColour wxNotebook::GetThemeBackgroundColour() const | |
1298 | { | |
1299 | #if wxUSE_UXTHEME | |
1300 | if (wxUxThemeEngine::Get()) | |
1301 | { | |
1302 | wxUxThemeHandle hTheme((wxNotebook*) this, L"TAB"); | |
1303 | if (hTheme) | |
1304 | { | |
1305 | // This is total guesswork. | |
1306 | // See PlatformSDK\Include\Tmschema.h for values | |
1307 | COLORREF themeColor; | |
1308 | wxUxThemeEngine::Get()->GetThemeColor( | |
1309 | hTheme, | |
1310 | 10 /* TABP_BODY */, | |
1311 | 1 /* NORMAL */, | |
1312 | 3821 /* FILLCOLORHINT */, | |
1313 | &themeColor); | |
1314 | ||
1315 | /* | |
1316 | [DS] Workaround for WindowBlinds: | |
1317 | Some themes return a near black theme color using FILLCOLORHINT, | |
1318 | this makes notebook pages have an ugly black background and makes | |
1319 | text (usually black) unreadable. Retry again with FILLCOLOR. | |
1320 | ||
1321 | This workaround potentially breaks appearance of some themes, | |
1322 | but in practice it already fixes some themes. | |
1323 | */ | |
1324 | if (themeColor == 1) | |
1325 | { | |
1326 | wxUxThemeEngine::Get()->GetThemeColor( | |
1327 | hTheme, | |
1328 | 10 /* TABP_BODY */, | |
1329 | 1 /* NORMAL */, | |
1330 | 3802 /* FILLCOLOR */, | |
1331 | &themeColor); | |
1332 | } | |
1333 | ||
7dccdf81 | 1334 | return wxRGBToColour(themeColor); |
25057aba JS |
1335 | } |
1336 | } | |
1337 | #endif // wxUSE_UXTHEME | |
1338 | ||
1339 | return GetBackgroundColour(); | |
1340 | } | |
1341 | ||
88310e2e VZ |
1342 | // ---------------------------------------------------------------------------- |
1343 | // wxNotebook base class virtuals | |
1344 | // ---------------------------------------------------------------------------- | |
b5c3b538 | 1345 | |
0b481c72 VZ |
1346 | #if wxUSE_CONSTRAINTS |
1347 | ||
b5c3b538 VZ |
1348 | // override these 2 functions to do nothing: everything is done in OnSize |
1349 | ||
4b7f2165 | 1350 | void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse)) |
b5c3b538 VZ |
1351 | { |
1352 | // don't set the sizes of the pages - their correct size is not yet known | |
b8bdaa7c | 1353 | wxControl::SetConstraintSizes(false); |
b5c3b538 VZ |
1354 | } |
1355 | ||
4b7f2165 | 1356 | bool wxNotebook::DoPhase(int WXUNUSED(nPhase)) |
b5c3b538 | 1357 | { |
b8bdaa7c | 1358 | return true; |
b5c3b538 VZ |
1359 | } |
1360 | ||
0b481c72 VZ |
1361 | #endif // wxUSE_CONSTRAINTS |
1362 | ||
0df3fbd7 VZ |
1363 | // ---------------------------------------------------------------------------- |
1364 | // wxNotebook Windows message handlers | |
1365 | // ---------------------------------------------------------------------------- | |
1366 | ||
1367 | bool wxNotebook::MSWOnScroll(int orientation, WXWORD nSBCode, | |
1368 | WXWORD pos, WXHWND control) | |
1369 | { | |
1370 | // don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the | |
1371 | // up-down control | |
1372 | if ( control ) | |
b8bdaa7c | 1373 | return false; |
0df3fbd7 VZ |
1374 | |
1375 | return wxNotebookBase::MSWOnScroll(orientation, nSBCode, pos, control); | |
1376 | } | |
1377 | ||
a23fd0e1 | 1378 | bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result) |
88310e2e | 1379 | { |
93a19f17 | 1380 | wxNotebookEvent event(wxEVT_NULL, m_windowId); |
88310e2e VZ |
1381 | |
1382 | NMHDR* hdr = (NMHDR *)lParam; | |
1383 | switch ( hdr->code ) { | |
1384 | case TCN_SELCHANGE: | |
1385 | event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED); | |
1386 | break; | |
1387 | ||
1388 | case TCN_SELCHANGING: | |
1389 | event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING); | |
1390 | break; | |
1391 | ||
fd3f686c | 1392 | default: |
a23fd0e1 | 1393 | return wxControl::MSWOnNotify(idCtrl, lParam, result); |
88310e2e VZ |
1394 | } |
1395 | ||
01c8cbf5 | 1396 | event.SetSelection(TabCtrl_GetCurSel(GetHwnd())); |
93a19f17 | 1397 | event.SetOldSelection(m_nSelection); |
88310e2e | 1398 | event.SetEventObject(this); |
a23fd0e1 | 1399 | event.SetInt(idCtrl); |
88310e2e | 1400 | |
fd3f686c VZ |
1401 | bool processed = GetEventHandler()->ProcessEvent(event); |
1402 | *result = !event.IsAllowed(); | |
1403 | return processed; | |
88310e2e VZ |
1404 | } |
1405 | ||
1e6feb95 | 1406 | #endif // wxUSE_NOTEBOOK |