]> git.saurik.com Git - wxWidgets.git/blame - src/msw/notebook.cpp
compilation fix
[wxWidgets.git] / src / msw / notebook.cpp
CommitLineData
88310e2e
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/notebook.cpp
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>
6c9a19aa 9// Licence: wxWindows licence
88310e2e
VZ
10///////////////////////////////////////////////////////////////////////////////
11
88310e2e 12#ifdef __GNUG__
a3b46648 13#pragma implementation "notebook.h"
88310e2e
VZ
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
1e6feb95 20 #pragma hdrstop
88310e2e
VZ
21#endif
22
1e6feb95
VZ
23#if wxUSE_NOTEBOOK
24
88310e2e
VZ
25// wxWindows
26#ifndef WX_PRECOMP
3096bd2f 27 #include "wx/string.h"
88310e2e
VZ
28#endif // WX_PRECOMP
29
3096bd2f
VZ
30#include "wx/log.h"
31#include "wx/imaglist.h"
32#include "wx/event.h"
33#include "wx/control.h"
34#include "wx/notebook.h"
88310e2e 35
3096bd2f 36#include "wx/msw/private.h"
88310e2e
VZ
37
38// Windows standard headers
39#ifndef __WIN95__
2432b92d 40 #error "wxNotebook is only supported Windows 95 and above"
88310e2e
VZ
41#endif //Win95
42
aaab7c01
VZ
43#include <windowsx.h> // for SetWindowFont
44
57c208c5 45#ifndef __TWIN32__
c42404a5
VZ
46 #ifdef __GNUWIN32_OLD__
47 #include "wx/msw/gnuwin32/extra.h"
48 #endif
65fd5cb0 49#endif
57c208c5 50
ae090fdb 51#if defined(__WIN95__) && !((defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) && !defined(__CYGWIN10__))
c42404a5 52 #include <commctrl.h>
88310e2e
VZ
53#endif
54
55// ----------------------------------------------------------------------------
56// macros
57// ----------------------------------------------------------------------------
58
59// check that the page index is valid
60#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount()))
61
62// hide the ugly cast
63#define m_hwnd (HWND)GetHWND()
64
74b31181
VZ
65// ----------------------------------------------------------------------------
66// constants
67// ----------------------------------------------------------------------------
68
69// This is a work-around for missing defines in gcc-2.95 headers
70#ifndef TCS_RIGHT
71 #define TCS_RIGHT 0x0002
72#endif
73
74#ifndef TCS_VERTICAL
75 #define TCS_VERTICAL 0x0080
76#endif
77
78#ifndef TCS_BOTTOM
79 #define TCS_BOTTOM TCS_RIGHT
80#endif
81
88310e2e
VZ
82// ----------------------------------------------------------------------------
83// event table
84// ----------------------------------------------------------------------------
85
2e4df4bf
VZ
86DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
87DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
88
d9317fd4 89BEGIN_EVENT_TABLE(wxNotebook, wxControl)
88310e2e
VZ
90 EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
91
9026ad85 92 EVT_SIZE(wxNotebook::OnSize)
42e69d6b 93
88310e2e 94 EVT_SET_FOCUS(wxNotebook::OnSetFocus)
42e69d6b 95
88310e2e 96 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
d9317fd4 97END_EVENT_TABLE()
88310e2e 98
d9317fd4
VZ
99IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
100IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
88310e2e
VZ
101
102// ============================================================================
103// implementation
104// ============================================================================
105
106// ----------------------------------------------------------------------------
107// wxNotebook construction
108// ----------------------------------------------------------------------------
109
110// common part of all ctors
111void wxNotebook::Init()
112{
1e6feb95 113 m_imageList = NULL;
88310e2e
VZ
114 m_nSelection = -1;
115}
116
117// default for dynamic class
118wxNotebook::wxNotebook()
119{
120 Init();
121}
122
123// the same arguments as for wxControl
124wxNotebook::wxNotebook(wxWindow *parent,
8b9518ee 125 wxWindowID id,
88310e2e
VZ
126 const wxPoint& pos,
127 const wxSize& size,
8b9518ee 128 long style,
88310e2e
VZ
129 const wxString& name)
130{
131 Init();
132
133 Create(parent, id, pos, size, style, name);
134}
135
136// Create() function
137bool wxNotebook::Create(wxWindow *parent,
8b9518ee 138 wxWindowID id,
88310e2e
VZ
139 const wxPoint& pos,
140 const wxSize& size,
8b9518ee 141 long style,
88310e2e
VZ
142 const wxString& name)
143{
0df3fbd7 144 // base init
6dd16e4f
VZ
145 if ( !CreateControl(parent, id, pos, size, style | wxTAB_TRAVERSAL,
146 wxDefaultValidator, name) )
0df3fbd7 147 return FALSE;
88310e2e 148
6dd16e4f 149 if ( !MSWCreateControl(WC_TABCONTROL, _T(""), pos, size) )
0df3fbd7 150 return FALSE;
907f37b3 151
0df3fbd7
VZ
152 SetBackgroundColour(wxColour(::GetSysColor(COLOR_BTNFACE)));
153
154 return TRUE;
155}
156
157WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const
158{
159 WXDWORD tabStyle = wxControl::MSWGetStyle(style, exstyle);
160
161 tabStyle |= WS_TABSTOP | TCS_TABS;
162
2b5f62a0 163 if ( style & wxNB_MULTILINE )
0df3fbd7
VZ
164 tabStyle |= TCS_MULTILINE;
165 if ( style & wxNB_FIXEDWIDTH )
166 tabStyle |= TCS_FIXEDWIDTH;
167
168 if ( style & wxNB_BOTTOM )
169 tabStyle |= TCS_RIGHT;
170 else if ( style & wxNB_LEFT )
171 tabStyle |= TCS_VERTICAL;
172 else if ( style & wxNB_RIGHT )
173 tabStyle |= TCS_VERTICAL | TCS_RIGHT;
174
175 // ex style
176 if ( exstyle )
177 {
178 // note that we never want to have the default WS_EX_CLIENTEDGE style
179 // as it looks too ugly for the notebooks
180 *exstyle = 0;
181 }
182
183 return tabStyle;
88310e2e
VZ
184}
185
88310e2e
VZ
186// ----------------------------------------------------------------------------
187// wxNotebook accessors
188// ----------------------------------------------------------------------------
07b8d7ec 189
88310e2e
VZ
190int wxNotebook::GetPageCount() const
191{
192 // consistency check
1e6feb95 193 wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(m_hwnd) );
88310e2e 194
1e6feb95 195 return m_pages.Count();
88310e2e
VZ
196}
197
198int wxNotebook::GetRowCount() const
199{
200 return TabCtrl_GetRowCount(m_hwnd);
201}
202
203int wxNotebook::SetSelection(int nPage)
204{
223d09f6 205 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
88310e2e 206
2b5f62a0
VZ
207 if ( nPage != m_nSelection )
208 {
209 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
210 event.SetSelection(nPage);
211 event.SetOldSelection(m_nSelection);
212 event.SetEventObject(this);
213 if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
214 {
215 // program allows the page change
216 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
217 (void)GetEventHandler()->ProcessEvent(event);
218
219 TabCtrl_SetCurSel(m_hwnd, nPage);
220 }
221 }
88310e2e 222
2b5f62a0 223 return m_nSelection;
88310e2e
VZ
224}
225
88310e2e
VZ
226bool wxNotebook::SetPageText(int nPage, const wxString& strText)
227{
223d09f6 228 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
88310e2e
VZ
229
230 TC_ITEM tcItem;
231 tcItem.mask = TCIF_TEXT;
837e5743 232 tcItem.pszText = (wxChar *)strText.c_str();
88310e2e
VZ
233
234 return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0;
235}
236
237wxString wxNotebook::GetPageText(int nPage) const
238{
223d09f6 239 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), wxT("notebook page out of range") );
88310e2e 240
837e5743 241 wxChar buf[256];
88310e2e
VZ
242 TC_ITEM tcItem;
243 tcItem.mask = TCIF_TEXT;
244 tcItem.pszText = buf;
245 tcItem.cchTextMax = WXSIZEOF(buf);
246
247 wxString str;
248 if ( TabCtrl_GetItem(m_hwnd, nPage, &tcItem) )
249 str = tcItem.pszText;
250
251 return str;
252}
253
254int wxNotebook::GetPageImage(int nPage) const
255{
223d09f6 256 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
88310e2e
VZ
257
258 TC_ITEM tcItem;
259 tcItem.mask = TCIF_IMAGE;
260
261 return TabCtrl_GetItem(m_hwnd, nPage, &tcItem) ? tcItem.iImage : -1;
262}
263
264bool wxNotebook::SetPageImage(int nPage, int nImage)
265{
223d09f6 266 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
88310e2e
VZ
267
268 TC_ITEM tcItem;
269 tcItem.mask = TCIF_IMAGE;
270 tcItem.iImage = nImage;
271
272 return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0;
273}
274
275void wxNotebook::SetImageList(wxImageList* imageList)
907f37b3 276{
07b8d7ec
VZ
277 wxNotebookBase::SetImageList(imageList);
278
279 if ( imageList )
1e6feb95 280 {
07b8d7ec 281 TabCtrl_SetImageList(m_hwnd, (HIMAGELIST)imageList->GetHIMAGELIST());
1e6feb95 282 }
b656febd
VS
283}
284
d9506e77
VZ
285// ----------------------------------------------------------------------------
286// wxNotebook size settings
287// ----------------------------------------------------------------------------
288
289void wxNotebook::SetPageSize(const wxSize& size)
290{
291 // transform the page size into the notebook size
292 RECT rc;
293 rc.left =
294 rc.top = 0;
295 rc.right = size.x;
296 rc.bottom = size.y;
297
298 TabCtrl_AdjustRect(GetHwnd(), TRUE, &rc);
299
300 // and now set it
301 SetSize(rc.right - rc.left, rc.bottom - rc.top);
302}
303
304void wxNotebook::SetPadding(const wxSize& padding)
305{
306 TabCtrl_SetPadding(GetHwnd(), padding.x, padding.y);
307}
42e69d6b
VZ
308
309// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
310// style.
311void wxNotebook::SetTabSize(const wxSize& sz)
312{
313 ::SendMessage(GetHwnd(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y));
314}
315
2015f2b3
VZ
316void wxNotebook::AdjustPageSize(wxNotebookPage *page)
317{
318 wxCHECK_RET( page, _T("NULL page in wxNotebook::AdjustPageSize") );
319
320 RECT rc;
321 rc.left =
322 rc.top = 0;
323
324 // get the page size from the notebook size
325 GetSize((int *)&rc.right, (int *)&rc.bottom);
326 TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
327
328 page->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
329}
330
88310e2e
VZ
331// ----------------------------------------------------------------------------
332// wxNotebook operations
333// ----------------------------------------------------------------------------
334
621793f4 335// remove one page from the notebook, without deleting
1e6feb95 336wxNotebookPage *wxNotebook::DoRemovePage(int nPage)
621793f4 337{
df7145da
VZ
338 wxNotebookPage *pageRemoved = wxNotebookBase::DoRemovePage(nPage);
339 if ( !pageRemoved )
340 return NULL;
621793f4 341
df7145da 342 TabCtrl_DeleteItem(m_hwnd, nPage);
621793f4 343
df7145da
VZ
344 if ( m_pages.IsEmpty() )
345 {
346 // no selection any more, the notebook becamse empty
347 m_nSelection = -1;
348 }
349 else // notebook still not empty
350 {
43a997b6
VZ
351 // change the selected page if it was deleted or became invalid
352 int selNew;
df7145da
VZ
353 if ( m_nSelection == GetPageCount() )
354 {
43a997b6
VZ
355 // last page deleted, make the new last page the new selection
356 selNew = m_nSelection - 1;
df7145da 357 }
43a997b6
VZ
358 else if ( nPage <= m_nSelection )
359 {
360 // we must show another page, even if it has the same index
361 selNew = m_nSelection;
362 }
363 else // nothing changes for the currently selected page
364 {
365 selNew = -1;
df7145da 366
43a997b6
VZ
367 // we still must refresh the current page: this needs to be done
368 // for some unknown reason if the tab control shows the up-down
369 // control (i.e. when there are too many pages) -- otherwise after
370 // deleting a page nothing at all is shown
371 m_pages[m_nSelection]->Refresh();
372 }
373
374 if ( selNew != -1 )
375 {
376 // m_nSelection must be always valid so reset it before calling
377 // SetSelection()
378 m_nSelection = -1;
379 SetSelection(selNew);
380 }
df7145da 381 }
47f12f58 382
df7145da 383 return pageRemoved;
621793f4
JS
384}
385
88310e2e
VZ
386// remove all pages
387bool wxNotebook::DeleteAllPages()
388{
88310e2e
VZ
389 int nPageCount = GetPageCount();
390 int nPage;
391 for ( nPage = 0; nPage < nPageCount; nPage++ )
1e6feb95 392 delete m_pages[nPage];
88310e2e 393
1e6feb95 394 m_pages.Clear();
88310e2e 395
907f37b3
VZ
396 TabCtrl_DeleteAllItems(m_hwnd);
397
47f12f58
JS
398 m_nSelection = -1;
399
88310e2e
VZ
400 return TRUE;
401}
402
88310e2e
VZ
403// same as AddPage() but does it at given position
404bool wxNotebook::InsertPage(int nPage,
405 wxNotebookPage *pPage,
406 const wxString& strText,
407 bool bSelect,
408 int imageId)
409{
22f3361e
VZ
410 wxCHECK_MSG( pPage != NULL, FALSE, _T("NULL page in wxNotebook::InsertPage") );
411 wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE,
412 _T("invalid index in wxNotebook::InsertPage") );
88310e2e 413
efa14cf2
VZ
414 wxASSERT_MSG( pPage->GetParent() == this,
415 _T("notebook pages must have notebook as parent") );
43427087 416
22f3361e
VZ
417 // add a new tab to the control
418 // ----------------------------
58a8ab88 419
22f3361e
VZ
420 // init all fields to 0
421 TC_ITEM tcItem;
422 wxZeroMemory(tcItem);
58a8ab88 423
22f3361e
VZ
424 // set the image, if any
425 if ( imageId != -1 )
426 {
427 tcItem.mask |= TCIF_IMAGE;
428 tcItem.iImage = imageId;
429 }
88310e2e 430
22f3361e
VZ
431 // and the text
432 if ( !strText.IsEmpty() )
433 {
434 tcItem.mask |= TCIF_TEXT;
435 tcItem.pszText = (wxChar *)strText.c_str(); // const_cast
436 }
43427087 437
22f3361e
VZ
438 // fit the notebook page to the tab control's display area: this should be
439 // done before adding it to the notebook or TabCtrl_InsertItem() will
440 // change the notebooks size itself!
2015f2b3 441 AdjustPageSize(pPage);
43427087 442
22f3361e 443 // finally do insert it
2015f2b3
VZ
444 if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 )
445 {
22f3361e 446 wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str());
88310e2e 447
22f3361e
VZ
448 return FALSE;
449 }
88310e2e 450
22f3361e
VZ
451 // succeeded: save the pointer to the page
452 m_pages.Insert(pPage, nPage);
42e69d6b 453
2015f2b3
VZ
454 // for the first page (only) we need to adjust the size again because the
455 // notebook size changed: the tabs which hadn't been there before are now
456 // shown
457 if ( m_pages.GetCount() == 1 )
458 {
459 AdjustPageSize(pPage);
460 }
461
22f3361e
VZ
462 // hide the page: unless it is selected, it shouldn't be shown (and if it
463 // is selected it will be shown later)
464 HWND hwnd = GetWinHwnd(pPage);
465 SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE);
0398b1d6 466
22f3361e
VZ
467 // this updates internal flag too -- otherwise it would get out of sync
468 // with the real state
469 pPage->Show(FALSE);
43427087 470
96d37807 471
22f3361e
VZ
472 // now deal with the selection
473 // ---------------------------
474
475 // if the inserted page is before the selected one, we must update the
476 // index of the selected page
477 if ( nPage <= m_nSelection )
478 {
479 // one extra page added
480 m_nSelection++;
481 }
482
483 // some page should be selected: either this one or the first one if there
484 // is still no selection
485 int selNew = -1;
486 if ( bSelect )
487 selNew = nPage;
488 else if ( m_nSelection == -1 )
489 selNew = 0;
490
491 if ( selNew != -1 )
492 SetSelection(selNew);
493
494 return TRUE;
88310e2e
VZ
495}
496
497// ----------------------------------------------------------------------------
498// wxNotebook callbacks
499// ----------------------------------------------------------------------------
500
9026ad85 501void wxNotebook::OnSize(wxSizeEvent& event)
88310e2e 502{
b5c3b538
VZ
503 // fit the notebook page to the tab control's display area
504 RECT rc;
505 rc.left = rc.top = 0;
506 GetSize((int *)&rc.right, (int *)&rc.bottom);
507
508 TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
4b7f2165
VZ
509
510 int width = rc.right - rc.left,
511 height = rc.bottom - rc.top;
1e6feb95 512 size_t nCount = m_pages.Count();
c86f1403 513 for ( size_t nPage = 0; nPage < nCount; nPage++ ) {
1e6feb95 514 wxNotebookPage *pPage = m_pages[nPage];
4b7f2165 515 pPage->SetSize(rc.left, rc.top, width, height);
b5c3b538
VZ
516 }
517
88310e2e
VZ
518 event.Skip();
519}
520
521void wxNotebook::OnSelChange(wxNotebookEvent& event)
522{
523 // is it our tab control?
524 if ( event.GetEventObject() == this )
5d1d2d46 525 {
5d1d2d46
VZ
526 int sel = event.GetOldSelection();
527 if ( sel != -1 )
1e6feb95 528 m_pages[sel]->Show(FALSE);
0398b1d6 529
5d1d2d46
VZ
530 sel = event.GetSelection();
531 if ( sel != -1 )
532 {
1e6feb95 533 wxNotebookPage *pPage = m_pages[sel];
5d1d2d46
VZ
534 pPage->Show(TRUE);
535 pPage->SetFocus();
536 }
0398b1d6 537
5d1d2d46
VZ
538 m_nSelection = sel;
539 }
88310e2e
VZ
540
541 // we want to give others a chance to process this message as well
542 event.Skip();
543}
544
545void wxNotebook::OnSetFocus(wxFocusEvent& event)
546{
d9506e77
VZ
547 // this function is only called when the focus is explicitly set (i.e. from
548 // the program) to the notebook - in this case we don't need the
549 // complicated OnNavigationKey() logic because the programmer knows better
550 // what [s]he wants
88310e2e 551
d9506e77
VZ
552 // set focus to the currently selected page if any
553 if ( m_nSelection != -1 )
1e6feb95 554 m_pages[m_nSelection]->SetFocus();
d9506e77
VZ
555
556 event.Skip();
88310e2e
VZ
557}
558
559void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
560{
d9506e77
VZ
561 if ( event.IsWindowChange() ) {
562 // change pages
563 AdvanceSelection(event.GetDirection());
564 }
565 else {
566 // we get this event in 2 cases
567 //
568 // a) one of our pages might have generated it because the user TABbed
569 // out from it in which case we should propagate the event upwards and
570 // our parent will take care of setting the focus to prev/next sibling
571 //
572 // or
573 //
574 // b) the parent panel wants to give the focus to us so that we
575 // forward it to our selected page. We can't deal with this in
576 // OnSetFocus() because we don't know which direction the focus came
577 // from in this case and so can't choose between setting the focus to
578 // first or last panel child
579
580 wxWindow *parent = GetParent();
581 if ( event.GetEventObject() == parent )
582 {
583 // no, it doesn't come from child, case (b): forward to a page
584 if ( m_nSelection != -1 )
585 {
586 // so that the page knows that the event comes from it's parent
587 // and is being propagated downwards
588 event.SetEventObject(this);
589
1e6feb95 590 wxWindow *page = m_pages[m_nSelection];
d9506e77
VZ
591 if ( !page->GetEventHandler()->ProcessEvent(event) )
592 {
593 page->SetFocus();
594 }
595 //else: page manages focus inside it itself
596 }
597 else
598 {
599 // we have no pages - still have to give focus to _something_
600 SetFocus();
601 }
602 }
603 else
604 {
605 // it comes from our child, case (a), pass to the parent
606 if ( parent ) {
607 event.SetCurrentFocus(this);
608 parent->GetEventHandler()->ProcessEvent(event);
609 }
610 }
88310e2e 611 }
88310e2e
VZ
612}
613
614// ----------------------------------------------------------------------------
615// wxNotebook base class virtuals
616// ----------------------------------------------------------------------------
b5c3b538 617
0b481c72
VZ
618#if wxUSE_CONSTRAINTS
619
b5c3b538
VZ
620// override these 2 functions to do nothing: everything is done in OnSize
621
4b7f2165 622void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
b5c3b538
VZ
623{
624 // don't set the sizes of the pages - their correct size is not yet known
625 wxControl::SetConstraintSizes(FALSE);
626}
627
4b7f2165 628bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
b5c3b538
VZ
629{
630 return TRUE;
631}
632
0b481c72
VZ
633#endif // wxUSE_CONSTRAINTS
634
0df3fbd7
VZ
635// ----------------------------------------------------------------------------
636// wxNotebook Windows message handlers
637// ----------------------------------------------------------------------------
638
639bool wxNotebook::MSWOnScroll(int orientation, WXWORD nSBCode,
640 WXWORD pos, WXHWND control)
641{
642 // don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the
643 // up-down control
644 if ( control )
645 return FALSE;
646
647 return wxNotebookBase::MSWOnScroll(orientation, nSBCode, pos, control);
648}
649
a23fd0e1 650bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
88310e2e 651{
93a19f17 652 wxNotebookEvent event(wxEVT_NULL, m_windowId);
88310e2e
VZ
653
654 NMHDR* hdr = (NMHDR *)lParam;
655 switch ( hdr->code ) {
656 case TCN_SELCHANGE:
657 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
658 break;
659
660 case TCN_SELCHANGING:
661 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING);
662 break;
663
fd3f686c 664 default:
a23fd0e1 665 return wxControl::MSWOnNotify(idCtrl, lParam, result);
88310e2e
VZ
666 }
667
93a19f17
VZ
668 event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
669 event.SetOldSelection(m_nSelection);
88310e2e 670 event.SetEventObject(this);
a23fd0e1 671 event.SetInt(idCtrl);
88310e2e 672
fd3f686c
VZ
673 bool processed = GetEventHandler()->ProcessEvent(event);
674 *result = !event.IsAllowed();
675 return processed;
88310e2e
VZ
676}
677
1e6feb95 678#endif // wxUSE_NOTEBOOK