]> git.saurik.com Git - wxWidgets.git/blame - src/msw/notebook.cpp
Fixed compilation for GCC 3.4 when wxUSE_STL == 1.
[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>
65571936 9// Licence: wxWindows licence
88310e2e
VZ
10///////////////////////////////////////////////////////////////////////////////
11
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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
77ffb593 25// wxWidgets
88310e2e 26#ifndef WX_PRECOMP
3096bd2f 27 #include "wx/string.h"
bb180f90 28 #include "wx/dc.h"
88310e2e
VZ
29#endif // WX_PRECOMP
30
3096bd2f
VZ
31#include "wx/log.h"
32#include "wx/imaglist.h"
33#include "wx/event.h"
34#include "wx/control.h"
35#include "wx/notebook.h"
04eb05b0 36#include "wx/app.h"
25057aba 37#include "wx/sysopt.h"
88310e2e 38
3096bd2f 39#include "wx/msw/private.h"
88310e2e 40
c1f3a149 41#include <windowsx.h>
aaab7c01 42
b39dbf34
JS
43#ifdef __GNUWIN32_OLD__
44 #include "wx/msw/gnuwin32/extra.h"
65fd5cb0 45#endif
57c208c5 46
c1f3a149 47#if !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
c42404a5 48 #include <commctrl.h>
88310e2e
VZ
49#endif
50
85b43fbf
JS
51#include "wx/msw/winundef.h"
52
53#if wxUSE_UXTHEME
caf95d2a 54 #include "wx/msw/uxtheme.h"
85b43fbf
JS
55#endif
56
88310e2e
VZ
57// ----------------------------------------------------------------------------
58// macros
59// ----------------------------------------------------------------------------
60
61// check that the page index is valid
8d34bf5c 62#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
88310e2e
VZ
63
64// hide the ugly cast
65#define m_hwnd (HWND)GetHWND()
66
74b31181
VZ
67// ----------------------------------------------------------------------------
68// constants
69// ----------------------------------------------------------------------------
70
71// This is a work-around for missing defines in gcc-2.95 headers
72#ifndef TCS_RIGHT
73 #define TCS_RIGHT 0x0002
74#endif
75
76#ifndef TCS_VERTICAL
77 #define TCS_VERTICAL 0x0080
78#endif
79
80#ifndef TCS_BOTTOM
81 #define TCS_BOTTOM TCS_RIGHT
82#endif
83
88310e2e
VZ
84// ----------------------------------------------------------------------------
85// event table
86// ----------------------------------------------------------------------------
87
51741307
SC
88#include <wx/listimpl.cpp>
89
90WX_DEFINE_LIST( wxNotebookPageInfoList ) ;
91
2e4df4bf
VZ
92DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
93DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
94
d9317fd4 95BEGIN_EVENT_TABLE(wxNotebook, wxControl)
88310e2e 96 EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
9026ad85 97 EVT_SIZE(wxNotebook::OnSize)
88310e2e 98 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
d9317fd4 99END_EVENT_TABLE()
88310e2e 100
51596bcb 101#if wxUSE_EXTENDED_RTTI
bc9fb572
JS
102WX_DEFINE_FLAGS( wxNotebookStyle )
103
3ff066a4 104wxBEGIN_FLAGS( wxNotebookStyle )
bc9fb572
JS
105 // new style border flags, we put them first to
106 // use them for streaming out
3ff066a4
SC
107 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
108 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
109 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
110 wxFLAGS_MEMBER(wxBORDER_RAISED)
111 wxFLAGS_MEMBER(wxBORDER_STATIC)
112 wxFLAGS_MEMBER(wxBORDER_NONE)
078cf5cb 113
bc9fb572 114 // old style border flags
3ff066a4
SC
115 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
116 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
117 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
118 wxFLAGS_MEMBER(wxRAISED_BORDER)
119 wxFLAGS_MEMBER(wxSTATIC_BORDER)
cb0afb26 120 wxFLAGS_MEMBER(wxBORDER)
bc9fb572
JS
121
122 // standard window styles
3ff066a4
SC
123 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
124 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
125 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
126 wxFLAGS_MEMBER(wxWANTS_CHARS)
cb0afb26 127 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
3ff066a4
SC
128 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
129 wxFLAGS_MEMBER(wxVSCROLL)
130 wxFLAGS_MEMBER(wxHSCROLL)
131
132 wxFLAGS_MEMBER(wxNB_FIXEDWIDTH)
133 wxFLAGS_MEMBER(wxNB_LEFT)
134 wxFLAGS_MEMBER(wxNB_RIGHT)
135 wxFLAGS_MEMBER(wxNB_BOTTOM)
136
137wxEND_FLAGS( wxNotebookStyle )
51741307 138
51596bcb 139IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook, wxControl,"wx/notebook.h")
51741307
SC
140IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo, wxObject , "wx/notebook.h" )
141
3ff066a4 142wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo * , wxNotebookPageInfoList ) ;
51596bcb 143
f0a126fe
SC
144template<> void wxCollectionToVariantArray( wxNotebookPageInfoList const &theList, wxxVariantArray &value)
145{
0c6b0084 146 wxListCollectionToVariantArray<wxNotebookPageInfoList::compatibility_iterator>( theList , value ) ;
f0a126fe
SC
147}
148
3ff066a4
SC
149wxBEGIN_PROPERTIES_TABLE(wxNotebook)
150 wxEVENT_PROPERTY( PageChanging , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING , wxNotebookEvent )
151 wxEVENT_PROPERTY( PageChanged , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , wxNotebookEvent )
c5ca409b 152
3ff066a4 153 wxPROPERTY_COLLECTION( PageInfos , wxNotebookPageInfoList , wxNotebookPageInfo* , AddPageInfo , GetPageInfos , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
af498247 154 wxPROPERTY_FLAGS( WindowStyle , wxNotebookStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
3ff066a4 155wxEND_PROPERTIES_TABLE()
51596bcb 156
3ff066a4
SC
157wxBEGIN_HANDLERS_TABLE(wxNotebook)
158wxEND_HANDLERS_TABLE()
51596bcb 159
078cf5cb 160wxCONSTRUCTOR_5( wxNotebook , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle)
51596bcb 161
51741307 162
3ff066a4 163wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo)
af498247 164 wxREADONLY_PROPERTY( Page , wxNotebookPage* , GetPage , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
3ff066a4
SC
165 wxREADONLY_PROPERTY( Text , wxString , GetText , wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
166 wxREADONLY_PROPERTY( Selected , bool , GetSelected , false, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
167 wxREADONLY_PROPERTY( ImageId , int , GetImageId , -1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
168wxEND_PROPERTIES_TABLE()
51741307 169
3ff066a4
SC
170wxBEGIN_HANDLERS_TABLE(wxNotebookPageInfo)
171wxEND_HANDLERS_TABLE()
51741307 172
078cf5cb 173wxCONSTRUCTOR_4( wxNotebookPageInfo , wxNotebookPage* , Page , wxString , Text , bool , Selected , int , ImageId )
51741307 174
51596bcb 175#else
d9317fd4 176IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
51741307 177IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo, wxObject )
51596bcb 178#endif
d9317fd4 179IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
88310e2e
VZ
180
181// ============================================================================
182// implementation
183// ============================================================================
184
185// ----------------------------------------------------------------------------
186// wxNotebook construction
187// ----------------------------------------------------------------------------
188
51741307
SC
189const wxNotebookPageInfoList& wxNotebook::GetPageInfos() const
190{
191 wxNotebookPageInfoList* list = const_cast< wxNotebookPageInfoList* >( &m_pageInfos ) ;
192 WX_CLEAR_LIST( wxNotebookPageInfoList , *list ) ;
34a0c9f4 193 for( size_t i = 0 ; i < GetPageCount() ; ++i )
51741307
SC
194 {
195 wxNotebookPageInfo *info = new wxNotebookPageInfo() ;
34a0c9f4 196 info->Create( const_cast<wxNotebook*>(this)->GetPage(i) , GetPageText(i) , GetSelection() == int(i) , GetPageImage(i) ) ;
51741307
SC
197 list->Append( info ) ;
198 }
199 return m_pageInfos ;
200}
201
88310e2e
VZ
202// common part of all ctors
203void wxNotebook::Init()
204{
1e6feb95 205 m_imageList = NULL;
88310e2e 206 m_nSelection = -1;
caf95d2a
VZ
207
208#if wxUSE_UXTHEME
209 m_hbrBackground = NULL;
210#endif // wxUSE_UXTHEME
88310e2e
VZ
211}
212
213// default for dynamic class
214wxNotebook::wxNotebook()
215{
216 Init();
217}
218
219// the same arguments as for wxControl
220wxNotebook::wxNotebook(wxWindow *parent,
8b9518ee 221 wxWindowID id,
88310e2e
VZ
222 const wxPoint& pos,
223 const wxSize& size,
8b9518ee 224 long style,
88310e2e
VZ
225 const wxString& name)
226{
227 Init();
228
229 Create(parent, id, pos, size, style, name);
230}
231
232// Create() function
233bool wxNotebook::Create(wxWindow *parent,
8b9518ee 234 wxWindowID id,
88310e2e
VZ
235 const wxPoint& pos,
236 const wxSize& size,
8b9518ee 237 long style,
88310e2e
VZ
238 const wxString& name)
239{
df10208f
VZ
240 // comctl32.dll 6.0 doesn't support non-top tabs with visual styles (the
241 // control is simply not rendered correctly), so disable them in this case
242 const int verComCtl32 = wxApp::GetComCtl32Version();
243 if ( verComCtl32 == 600 )
04eb05b0 244 {
df10208f
VZ
245 // check if we use themes at all -- if we don't, we're still ok
246#if wxUSE_UXTHEME
247 if ( wxUxThemeEngine::GetIfActive() )
248#endif
249 {
250 style &= ~(wxNB_BOTTOM | wxNB_LEFT | wxNB_RIGHT);
251 }
04eb05b0 252 }
078cf5cb 253
c1637c89
VZ
254 LPCTSTR className = WC_TABCONTROL;
255
256 // SysTabCtl32 class has natively CS_HREDRAW and CS_VREDRAW enabled and it
257 // causes horrible flicker when resizing notebook, so get rid of it by
258 // using a class without these styles (but otherwise identical to it)
259 if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) )
260 {
261 static ClassRegistrar s_clsNotebook;
262 if ( !s_clsNotebook.IsInitialized() )
263 {
264 // get a copy of standard class and modify it
265 WNDCLASS wc;
266
267 if ( ::GetClassInfo(::GetModuleHandle(NULL), WC_TABCONTROL, &wc) )
268 {
269 wc.lpszClassName = wxT("_wx_SysTabCtl32");
270 wc.style &= ~(CS_HREDRAW | CS_VREDRAW);
271
272 s_clsNotebook.Register(wc);
273 }
274 else
275 {
276 wxLogLastError(_T("GetClassInfoEx(SysTabCtl32)"));
277 }
278 }
279
280 // use our custom class if available but fall back to the standard
281 // notebook if we failed to register it
282 if ( s_clsNotebook.IsRegistered() )
283 {
284 // it's ok to use c_str() here as the static s_clsNotebook object
285 // has sufficiently long lifetime
286 className = s_clsNotebook.GetName().c_str();
287 }
288 }
289
6dd16e4f
VZ
290 if ( !CreateControl(parent, id, pos, size, style | wxTAB_TRAVERSAL,
291 wxDefaultValidator, name) )
b8bdaa7c 292 return false;
88310e2e 293
c1637c89 294 if ( !MSWCreateControl(className, wxEmptyString, pos, size) )
b8bdaa7c 295 return false;
907f37b3 296
f2b7be7a
JS
297 if (HasFlag(wxNB_NOPAGETHEME) || (wxSystemOptions::HasOption(wxT("msw.notebook.themed-background")) &&
298 wxSystemOptions::GetOptionInt(wxT("msw.notebook.themed-background")) == 0))
299 {
300 wxColour col = GetThemeBackgroundColour();
301 if (col.Ok())
302 {
303 SetBackgroundColour(col);
304 }
305 }
b8bdaa7c 306 return true;
0df3fbd7
VZ
307}
308
309WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const
310{
311 WXDWORD tabStyle = wxControl::MSWGetStyle(style, exstyle);
312
313 tabStyle |= WS_TABSTOP | TCS_TABS;
314
2b5f62a0 315 if ( style & wxNB_MULTILINE )
0df3fbd7
VZ
316 tabStyle |= TCS_MULTILINE;
317 if ( style & wxNB_FIXEDWIDTH )
318 tabStyle |= TCS_FIXEDWIDTH;
319
320 if ( style & wxNB_BOTTOM )
321 tabStyle |= TCS_RIGHT;
322 else if ( style & wxNB_LEFT )
323 tabStyle |= TCS_VERTICAL;
324 else if ( style & wxNB_RIGHT )
325 tabStyle |= TCS_VERTICAL | TCS_RIGHT;
326
327 // ex style
328 if ( exstyle )
329 {
330 // note that we never want to have the default WS_EX_CLIENTEDGE style
331 // as it looks too ugly for the notebooks
332 *exstyle = 0;
333 }
334
335 return tabStyle;
88310e2e
VZ
336}
337
caf95d2a
VZ
338wxNotebook::~wxNotebook()
339{
340#if wxUSE_UXTHEME
341 if ( m_hbrBackground )
342 ::DeleteObject((HBRUSH)m_hbrBackground);
343#endif // wxUSE_UXTHEME
344}
345
88310e2e
VZ
346// ----------------------------------------------------------------------------
347// wxNotebook accessors
348// ----------------------------------------------------------------------------
07b8d7ec 349
8d34bf5c 350size_t wxNotebook::GetPageCount() const
88310e2e
VZ
351{
352 // consistency check
1e6feb95 353 wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(m_hwnd) );
88310e2e 354
1e6feb95 355 return m_pages.Count();
88310e2e
VZ
356}
357
358int wxNotebook::GetRowCount() const
359{
360 return TabCtrl_GetRowCount(m_hwnd);
361}
362
8d34bf5c 363int wxNotebook::SetSelection(size_t nPage)
88310e2e 364{
078cf5cb 365 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
88310e2e 366
34a0c9f4 367 if ( int(nPage) != m_nSelection )
2b5f62a0
VZ
368 {
369 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
370 event.SetSelection(nPage);
371 event.SetOldSelection(m_nSelection);
372 event.SetEventObject(this);
373 if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
374 {
375 // program allows the page change
376 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
377 (void)GetEventHandler()->ProcessEvent(event);
378
379 TabCtrl_SetCurSel(m_hwnd, nPage);
380 }
381 }
88310e2e 382
2b5f62a0 383 return m_nSelection;
88310e2e
VZ
384}
385
8d34bf5c 386bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
88310e2e 387{
b8bdaa7c 388 wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") );
88310e2e
VZ
389
390 TC_ITEM tcItem;
391 tcItem.mask = TCIF_TEXT;
837e5743 392 tcItem.pszText = (wxChar *)strText.c_str();
88310e2e
VZ
393
394 return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0;
395}
396
8d34bf5c 397wxString wxNotebook::GetPageText(size_t nPage) const
88310e2e 398{
fda7962d 399 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") );
88310e2e 400
837e5743 401 wxChar buf[256];
88310e2e
VZ
402 TC_ITEM tcItem;
403 tcItem.mask = TCIF_TEXT;
404 tcItem.pszText = buf;
405 tcItem.cchTextMax = WXSIZEOF(buf);
406
407 wxString str;
408 if ( TabCtrl_GetItem(m_hwnd, nPage, &tcItem) )
409 str = tcItem.pszText;
410
411 return str;
412}
413
8d34bf5c 414int wxNotebook::GetPageImage(size_t nPage) const
88310e2e 415{
223d09f6 416 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
88310e2e
VZ
417
418 TC_ITEM tcItem;
419 tcItem.mask = TCIF_IMAGE;
420
421 return TabCtrl_GetItem(m_hwnd, nPage, &tcItem) ? tcItem.iImage : -1;
422}
423
8d34bf5c 424bool wxNotebook::SetPageImage(size_t nPage, int nImage)
88310e2e 425{
b8bdaa7c 426 wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") );
88310e2e
VZ
427
428 TC_ITEM tcItem;
429 tcItem.mask = TCIF_IMAGE;
430 tcItem.iImage = nImage;
431
432 return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0;
433}
434
435void wxNotebook::SetImageList(wxImageList* imageList)
907f37b3 436{
07b8d7ec
VZ
437 wxNotebookBase::SetImageList(imageList);
438
439 if ( imageList )
1e6feb95 440 {
07b8d7ec 441 TabCtrl_SetImageList(m_hwnd, (HIMAGELIST)imageList->GetHIMAGELIST());
1e6feb95 442 }
b656febd
VS
443}
444
d9506e77
VZ
445// ----------------------------------------------------------------------------
446// wxNotebook size settings
447// ----------------------------------------------------------------------------
448
449void wxNotebook::SetPageSize(const wxSize& size)
450{
451 // transform the page size into the notebook size
452 RECT rc;
453 rc.left =
454 rc.top = 0;
455 rc.right = size.x;
456 rc.bottom = size.y;
457
b8bdaa7c 458 TabCtrl_AdjustRect(GetHwnd(), true, &rc);
d9506e77
VZ
459
460 // and now set it
461 SetSize(rc.right - rc.left, rc.bottom - rc.top);
462}
463
464void wxNotebook::SetPadding(const wxSize& padding)
465{
466 TabCtrl_SetPadding(GetHwnd(), padding.x, padding.y);
467}
42e69d6b
VZ
468
469// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
470// style.
471void wxNotebook::SetTabSize(const wxSize& sz)
472{
473 ::SendMessage(GetHwnd(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y));
474}
475
2ce7af35
JS
476wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
477{
478 wxSize sizeTotal = sizePage;
078cf5cb 479
77ffb593 480 // We need to make getting tab size part of the wxWidgets API.
8b5d5223 481 wxSize tabSize;
2ce7af35
JS
482 if (GetPageCount() > 0)
483 {
484 RECT rect;
485 TabCtrl_GetItemRect((HWND) GetHWND(), 0, & rect);
486 tabSize.x = rect.right - rect.left;
487 tabSize.y = rect.bottom - rect.top;
488 }
489 if ( HasFlag(wxNB_LEFT) || HasFlag(wxNB_RIGHT) )
490 {
491 sizeTotal.x += tabSize.x + 7;
492 sizeTotal.y += 7;
493 }
494 else
495 {
496 sizeTotal.x += 7;
497 sizeTotal.y += tabSize.y + 7;
498 }
499
500 return sizeTotal;
501}
502
2015f2b3
VZ
503void wxNotebook::AdjustPageSize(wxNotebookPage *page)
504{
505 wxCHECK_RET( page, _T("NULL page in wxNotebook::AdjustPageSize") );
506
507 RECT rc;
508 rc.left =
509 rc.top = 0;
510
511 // get the page size from the notebook size
512 GetSize((int *)&rc.right, (int *)&rc.bottom);
2015f2b3 513
14a6b6e5
RD
514 // This check is to work around a bug in TabCtrl_AdjustRect which will
515 // cause a crash on win2k, or on XP with themes disabled, if the
516 // wxNB_MULTILINE style is used and the rectangle is very small, (such as
517 // when the notebook is first created.) The value of 20 is just
518 // arbitrarily chosen, if there is a better way to determine this value
519 // then please do so. --RD
520 if (rc.right > 20 && rc.bottom > 20)
521 {
522 TabCtrl_AdjustRect(m_hwnd, false, &rc);
523 page->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
524 }
2015f2b3
VZ
525}
526
88310e2e
VZ
527// ----------------------------------------------------------------------------
528// wxNotebook operations
529// ----------------------------------------------------------------------------
530
621793f4 531// remove one page from the notebook, without deleting
8d34bf5c 532wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
621793f4 533{
df7145da
VZ
534 wxNotebookPage *pageRemoved = wxNotebookBase::DoRemovePage(nPage);
535 if ( !pageRemoved )
536 return NULL;
621793f4 537
df7145da 538 TabCtrl_DeleteItem(m_hwnd, nPage);
621793f4 539
df7145da
VZ
540 if ( m_pages.IsEmpty() )
541 {
542 // no selection any more, the notebook becamse empty
543 m_nSelection = -1;
544 }
545 else // notebook still not empty
546 {
623f5f70
JS
547 int selNew = TabCtrl_GetCurSel(m_hwnd);
548 if (selNew != -1)
df7145da 549 {
623f5f70 550 // No selection change, just refresh the current selection.
078cf5cb
WS
551 // Because it could be that the slection index changed
552 // we need to update it.
623f5f70
JS
553 // Note: this does not mean the selection it self changed.
554 m_nSelection = selNew;
555 m_pages[m_nSelection]->Refresh();
df7145da 556 }
623f5f70 557 else if (int(nPage) == m_nSelection)
43a997b6 558 {
623f5f70 559 // The selection was deleted.
078cf5cb 560
623f5f70
JS
561 // Determine new selection.
562 if (m_nSelection == int(GetPageCount()))
563 selNew = m_nSelection - 1;
564 else
565 selNew = m_nSelection;
078cf5cb 566
43a997b6
VZ
567 // m_nSelection must be always valid so reset it before calling
568 // SetSelection()
569 m_nSelection = -1;
570 SetSelection(selNew);
571 }
623f5f70
JS
572 else
573 {
574 wxFAIL; // Windows did not behave ok.
575 }
df7145da 576 }
47f12f58 577
df7145da 578 return pageRemoved;
621793f4
JS
579}
580
88310e2e
VZ
581// remove all pages
582bool wxNotebook::DeleteAllPages()
583{
8d34bf5c
VZ
584 size_t nPageCount = GetPageCount();
585 size_t nPage;
88310e2e 586 for ( nPage = 0; nPage < nPageCount; nPage++ )
1e6feb95 587 delete m_pages[nPage];
88310e2e 588
1e6feb95 589 m_pages.Clear();
88310e2e 590
907f37b3
VZ
591 TabCtrl_DeleteAllItems(m_hwnd);
592
47f12f58
JS
593 m_nSelection = -1;
594
37144cf0 595 InvalidateBestSize();
b8bdaa7c 596 return true;
88310e2e
VZ
597}
598
88310e2e 599// same as AddPage() but does it at given position
8d34bf5c 600bool wxNotebook::InsertPage(size_t nPage,
88310e2e
VZ
601 wxNotebookPage *pPage,
602 const wxString& strText,
603 bool bSelect,
604 int imageId)
605{
b8bdaa7c
VZ
606 wxCHECK_MSG( pPage != NULL, false, _T("NULL page in wxNotebook::InsertPage") );
607 wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false,
22f3361e 608 _T("invalid index in wxNotebook::InsertPage") );
88310e2e 609
efa14cf2
VZ
610 wxASSERT_MSG( pPage->GetParent() == this,
611 _T("notebook pages must have notebook as parent") );
43427087 612
22f3361e
VZ
613 // add a new tab to the control
614 // ----------------------------
58a8ab88 615
22f3361e
VZ
616 // init all fields to 0
617 TC_ITEM tcItem;
618 wxZeroMemory(tcItem);
58a8ab88 619
22f3361e
VZ
620 // set the image, if any
621 if ( imageId != -1 )
622 {
623 tcItem.mask |= TCIF_IMAGE;
624 tcItem.iImage = imageId;
625 }
88310e2e 626
22f3361e 627 // and the text
8b5d5223 628 if ( !strText.empty() )
22f3361e
VZ
629 {
630 tcItem.mask |= TCIF_TEXT;
631 tcItem.pszText = (wxChar *)strText.c_str(); // const_cast
632 }
43427087 633
e830a6a6
RD
634 // hide the page: unless it is selected, it shouldn't be shown (and if it
635 // is selected it will be shown later)
636 HWND hwnd = GetWinHwnd(pPage);
637 SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE);
638
639 // this updates internal flag too -- otherwise it would get out of sync
640 // with the real state
641 pPage->Show(false);
642
643
22f3361e
VZ
644 // fit the notebook page to the tab control's display area: this should be
645 // done before adding it to the notebook or TabCtrl_InsertItem() will
646 // change the notebooks size itself!
2015f2b3 647 AdjustPageSize(pPage);
43427087 648
22f3361e 649 // finally do insert it
2015f2b3
VZ
650 if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 )
651 {
22f3361e 652 wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str());
88310e2e 653
b8bdaa7c 654 return false;
22f3361e 655 }
88310e2e 656
22f3361e
VZ
657 // succeeded: save the pointer to the page
658 m_pages.Insert(pPage, nPage);
42e69d6b 659
56b9925b
VZ
660 // we may need to adjust the size again if the notebook size changed:
661 // normally this only happens for the first page we add (the tabs which
662 // hadn't been there before are now shown) but for a multiline notebook it
663 // can happen for any page at all as a new row could have been started
664 if ( m_pages.GetCount() == 1 || HasFlag(wxNB_MULTILINE) )
2015f2b3
VZ
665 {
666 AdjustPageSize(pPage);
667 }
668
22f3361e
VZ
669 // now deal with the selection
670 // ---------------------------
671
672 // if the inserted page is before the selected one, we must update the
673 // index of the selected page
34a0c9f4 674 if ( int(nPage) <= m_nSelection )
22f3361e
VZ
675 {
676 // one extra page added
677 m_nSelection++;
678 }
679
680 // some page should be selected: either this one or the first one if there
681 // is still no selection
682 int selNew = -1;
683 if ( bSelect )
684 selNew = nPage;
685 else if ( m_nSelection == -1 )
686 selNew = 0;
687
688 if ( selNew != -1 )
689 SetSelection(selNew);
690
37144cf0 691 InvalidateBestSize();
25057aba 692
b8bdaa7c 693 return true;
88310e2e
VZ
694}
695
e450aa69 696int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
ef094fa0
JS
697{
698 TC_HITTESTINFO hitTestInfo;
699 hitTestInfo.pt.x = pt.x;
700 hitTestInfo.pt.y = pt.y;
e450aa69 701 int item = TabCtrl_HitTest(GetHwnd(), &hitTestInfo);
ef094fa0 702
e450aa69
VZ
703 if ( flags )
704 {
705 *flags = 0;
706
707 if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE)
708 *flags |= wxNB_HITTEST_NOWHERE;
709 if ((hitTestInfo.flags & TCHT_ONITEM) == TCHT_ONITEM)
710 *flags |= wxNB_HITTEST_ONITEM;
711 if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON)
712 *flags |= wxNB_HITTEST_ONICON;
713 if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL)
714 *flags |= wxNB_HITTEST_ONLABEL;
715 }
ef094fa0
JS
716
717 return item;
718}
719
e450aa69 720
88310e2e
VZ
721// ----------------------------------------------------------------------------
722// wxNotebook callbacks
723// ----------------------------------------------------------------------------
724
9026ad85 725void wxNotebook::OnSize(wxSizeEvent& event)
88310e2e 726{
c1637c89 727 // update the background brush
de371316 728#if wxUSE_UXTHEME
c1637c89 729 UpdateBgBrush();
de371316
VZ
730#endif // wxUSE_UXTHEME
731
c1637c89 732 // fit all the notebook pages to the tab control's display area
56b9925b 733
c1637c89
VZ
734 RECT rc;
735 rc.left = rc.top = 0;
736 GetSize((int *)&rc.right, (int *)&rc.bottom);
56b9925b 737
c1637c89
VZ
738 // save the total size, we'll use it below
739 int widthNbook = rc.right - rc.left,
740 heightNbook = rc.bottom - rc.top;
741
742 // there seems to be a bug in the implementation of TabCtrl_AdjustRect(): it
743 // returns completely false values for multiline tab controls after the tabs
744 // are added but before getting the first WM_SIZE (off by ~50 pixels, see
745 //
746 // http://sf.net/tracker/index.php?func=detail&aid=645323&group_id=9863&atid=109863
747 //
748 // and the only work around I could find was this ugly hack... without it
749 // simply toggling the "multiline" checkbox in the notebook sample resulted
750 // in a noticeable page displacement
751 if ( HasFlag(wxNB_MULTILINE) )
752 {
753 // avoid an infinite recursion: we get another notification too!
754 static bool s_isInOnSize = false;
4b7f2165 755
c1637c89
VZ
756 if ( !s_isInOnSize )
757 {
758 s_isInOnSize = true;
759 SendMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED,
760 MAKELPARAM(rc.right, rc.bottom));
761 s_isInOnSize = false;
762 }
763 }
b5c3b538 764
c1637c89
VZ
765 TabCtrl_AdjustRect(m_hwnd, false, &rc);
766
767 int width = rc.right - rc.left,
768 height = rc.bottom - rc.top;
769 size_t nCount = m_pages.Count();
770 for ( size_t nPage = 0; nPage < nCount; nPage++ ) {
771 wxNotebookPage *pPage = m_pages[nPage];
772 pPage->SetSize(rc.left, rc.top, width, height);
773 }
774
775
776 // unless we had already repainted everything, we now need to refresh
777 if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) )
778 {
779 // invalidate areas not covered by pages
780 RefreshRect(wxRect(0, 0, widthNbook, rc.top), false);
781 RefreshRect(wxRect(0, rc.top, rc.left, height), false);
782 RefreshRect(wxRect(0, rc.bottom, widthNbook, heightNbook - rc.bottom),
783 false);
784 RefreshRect(wxRect(rc.right, rc.top, widthNbook - rc.bottom, height),
785 false);
786 }
787
788 event.Skip();
88310e2e
VZ
789}
790
791void wxNotebook::OnSelChange(wxNotebookEvent& event)
792{
793 // is it our tab control?
794 if ( event.GetEventObject() == this )
5d1d2d46 795 {
5d1d2d46
VZ
796 int sel = event.GetOldSelection();
797 if ( sel != -1 )
b8bdaa7c 798 m_pages[sel]->Show(false);
0398b1d6 799
5d1d2d46
VZ
800 sel = event.GetSelection();
801 if ( sel != -1 )
802 {
1e6feb95 803 wxNotebookPage *pPage = m_pages[sel];
b8bdaa7c 804 pPage->Show(true);
1d5b3bf0
VZ
805 pPage->SetFocus();
806
807 // If the newly focused window is not a child of the new page,
808 // SetFocus was not successful and the notebook itself should be
809 // focused
810 wxWindow *currentFocus = FindFocus();
811 wxWindow *startFocus = currentFocus;
812 while ( currentFocus && currentFocus != pPage && currentFocus != this )
813 currentFocus = currentFocus->GetParent();
814
815 if ( startFocus == pPage || currentFocus != pPage )
816 SetFocus();
817
818 }
819 else // no pages in the notebook, give the focus to itself
820 {
821 SetFocus();
5d1d2d46 822 }
0398b1d6 823
5d1d2d46
VZ
824 m_nSelection = sel;
825 }
88310e2e
VZ
826
827 // we want to give others a chance to process this message as well
828 event.Skip();
829}
830
b8bdaa7c 831bool wxNotebook::MSWTranslateMessage(WXMSG *wxmsg)
88310e2e 832{
b8bdaa7c 833 const MSG * const msg = (MSG *)wxmsg;
88310e2e 834
1d5b3bf0
VZ
835 // intercept TAB, CTRL+TAB and CTRL+SHIFT+TAB for processing by wxNotebook.
836 // TAB will be passed to the currently selected page, CTRL+TAB and
837 // CTRL+SHIFT+TAB will be processed by the notebook itself. do not
838 // intercept SHIFT+TAB. This goes to the parent of the notebook which will
839 // process it.
b8bdaa7c
VZ
840 if ( msg->message == WM_KEYDOWN && msg->wParam == VK_TAB &&
841 msg->hwnd == m_hwnd &&
1d5b3bf0 842 (wxIsCtrlDown() || !wxIsShiftDown()) )
b8bdaa7c
VZ
843 {
844 return MSWProcessMessage(wxmsg);
845 }
d9506e77 846
b8bdaa7c 847 return false;
88310e2e
VZ
848}
849
850void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
851{
d9506e77
VZ
852 if ( event.IsWindowChange() ) {
853 // change pages
854 AdvanceSelection(event.GetDirection());
855 }
856 else {
b8bdaa7c 857 // we get this event in 3 cases
d9506e77
VZ
858 //
859 // a) one of our pages might have generated it because the user TABbed
860 // out from it in which case we should propagate the event upwards and
861 // our parent will take care of setting the focus to prev/next sibling
862 //
863 // or
864 //
865 // b) the parent panel wants to give the focus to us so that we
866 // forward it to our selected page. We can't deal with this in
867 // OnSetFocus() because we don't know which direction the focus came
868 // from in this case and so can't choose between setting the focus to
869 // first or last panel child
b8bdaa7c
VZ
870 //
871 // or
872 //
873 // c) we ourselves (see MSWTranslateMessage) generated the event
874 //
875 wxWindow * const parent = GetParent();
876
877 const bool isFromParent = event.GetEventObject() == parent;
878 const bool isFromSelf = event.GetEventObject() == this;
879
880 if ( isFromParent || isFromSelf )
d9506e77 881 {
b8bdaa7c
VZ
882 // no, it doesn't come from child, case (b) or (c): forward to a
883 // page but only if direction is backwards (TAB) or from ourselves,
884 if ( m_nSelection != -1 &&
885 (!event.GetDirection() || isFromSelf) )
d9506e77
VZ
886 {
887 // so that the page knows that the event comes from it's parent
888 // and is being propagated downwards
889 event.SetEventObject(this);
890
1e6feb95 891 wxWindow *page = m_pages[m_nSelection];
d9506e77
VZ
892 if ( !page->GetEventHandler()->ProcessEvent(event) )
893 {
894 page->SetFocus();
895 }
896 //else: page manages focus inside it itself
897 }
b8bdaa7c 898 else // otherwise set the focus to the notebook itself
d9506e77 899 {
d9506e77
VZ
900 SetFocus();
901 }
902 }
903 else
904 {
b8bdaa7c
VZ
905 // it comes from our child, case (a), pass to the parent, but only
906 // if the direction is forwards. Otherwise set the focus to the
907 // notebook itself. The notebook is always the 'first' control of a
908 // page.
909 if ( !event.GetDirection() )
910 {
911 SetFocus();
912 }
913 else if ( parent )
914 {
d9506e77
VZ
915 event.SetCurrentFocus(this);
916 parent->GetEventHandler()->ProcessEvent(event);
917 }
918 }
88310e2e 919 }
88310e2e
VZ
920}
921
caf95d2a
VZ
922#if wxUSE_UXTHEME
923
c4a95f6f 924WXHANDLE wxNotebook::QueryBgBitmap(wxWindow *win)
caf95d2a 925{
c4a95f6f
VZ
926 RECT rc;
927 GetWindowRect(GetHwnd(), &rc);
928
929 WindowHDC hDC(GetHwnd());
930 MemoryHDC hDCMem(hDC);
931 CompatibleBitmap hBmp(hDC, rc.right - rc.left, rc.bottom - rc.top);
932
933 SelectInHDC selectBmp(hDCMem, hBmp);
caf95d2a 934
c4a95f6f 935 ::SendMessage(GetHwnd(), WM_PRINTCLIENT,
c1637c89 936 (WPARAM)(HDC)hDCMem,
c4a95f6f
VZ
937 PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT);
938
939 if ( win )
caf95d2a 940 {
c4a95f6f
VZ
941 RECT rc2;
942 ::GetWindowRect(GetHwndOf(win), &rc2);
caf95d2a 943
c4a95f6f 944 COLORREF c = ::GetPixel(hDCMem, rc2.left - rc.left, rc2.top - rc.top);
caf95d2a 945
c4a95f6f
VZ
946 return (WXHANDLE)c;
947 }
c1637c89 948 //else: we are asked to create the brush
0f770734 949
0f770734 950 return (WXHANDLE)::CreatePatternBrush(hBmp);
c4a95f6f 951}
caf95d2a 952
c4a95f6f
VZ
953void wxNotebook::UpdateBgBrush()
954{
955 if ( m_hbrBackground )
956 ::DeleteObject((HBRUSH)m_hbrBackground);
caf95d2a 957
c4a95f6f
VZ
958 if ( !m_hasBgCol && wxUxThemeEngine::GetIfActive() )
959 {
960 m_hbrBackground = (WXHBRUSH)QueryBgBitmap();
caf95d2a
VZ
961 }
962 else // no themes
963 {
964 m_hbrBackground = NULL;
965 }
966}
967
c4a95f6f 968WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, wxWindow *win)
caf95d2a 969{
caf95d2a
VZ
970 if ( m_hbrBackground )
971 {
972 // before drawing with the background brush, we need to position it
973 // correctly
caf95d2a
VZ
974 RECT rc;
975 ::GetWindowRect(GetHwndOf(win), &rc);
976
977 ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1);
978
5c836c46 979 if ( !::SetBrushOrgEx((HDC)hDC, -rc.left, -rc.top, NULL) )
caf95d2a
VZ
980 {
981 wxLogLastError(_T("SetBrushOrgEx(notebook bg brush)"));
982 }
c4a95f6f
VZ
983
984 return m_hbrBackground;
5c836c46
VZ
985 }
986
c4a95f6f 987 return wxNotebookBase::MSWGetBgBrushForChild(hDC, win);
5c836c46 988}
caf95d2a 989
c4a95f6f 990wxColour wxNotebook::MSWGetBgColourForChild(wxWindow *win)
9b7d2b81 991{
c4a95f6f
VZ
992 if ( m_hasBgCol )
993 return GetBackgroundColour();
9b7d2b81 994
c4a95f6f
VZ
995 if ( !wxUxThemeEngine::GetIfActive() )
996 return wxNullColour;
997
998 COLORREF c = (COLORREF)QueryBgBitmap(win);
999
1000 return c == CLR_INVALID ? wxNullColour : wxRGBToColour(c);
caf95d2a
VZ
1001}
1002
07c19327
VZ
1003bool
1004wxNotebook::MSWPrintChild(wxWindow *win,
1005 WXWPARAM wParam,
1006 WXLPARAM WXUNUSED(lParam))
1007{
3534fc20
JS
1008 // Don't paint the theme for the child if we have a solid
1009 // background
1010 if (m_hasBgCol || HasFlag(wxNB_NOPAGETHEME) || (wxSystemOptions::HasOption(wxT("msw.notebook.themed-background")) &&
1011 wxSystemOptions::GetOptionInt(wxT("msw.notebook.themed-background")) == 0))
1012 return false;
1013
07c19327
VZ
1014 RECT rc;
1015 ::GetClientRect(GetHwnd(), &rc);
1016 TabCtrl_AdjustRect(GetHwnd(), true, &rc);
1017 ::MapWindowPoints(GetHwnd(), GetHwndOf(win), (POINT *)&rc, 2);
1018
1019 wxUxThemeHandle theme(win, L"TAB");
1020 if ( theme )
1021 {
1022 wxUxThemeEngine::Get()->DrawThemeBackground
1023 (
1024 theme,
1025 (WXHDC)wParam,
1026 9 /* TABP_PANE */,
1027 0,
1028 &rc,
1029 NULL
1030 );
1031 }
1032
1033 return true;
1034}
1035
caf95d2a
VZ
1036#endif // wxUSE_UXTHEME
1037
25057aba
JS
1038// Windows only: attempts to get colour for UX theme page background
1039wxColour wxNotebook::GetThemeBackgroundColour() const
1040{
1041#if wxUSE_UXTHEME
1042 if (wxUxThemeEngine::Get())
1043 {
1044 wxUxThemeHandle hTheme((wxNotebook*) this, L"TAB");
1045 if (hTheme)
1046 {
1047 // This is total guesswork.
1048 // See PlatformSDK\Include\Tmschema.h for values
1049 COLORREF themeColor;
1050 wxUxThemeEngine::Get()->GetThemeColor(
1051 hTheme,
1052 10 /* TABP_BODY */,
1053 1 /* NORMAL */,
1054 3821 /* FILLCOLORHINT */,
1055 &themeColor);
1056
1057 /*
1058 [DS] Workaround for WindowBlinds:
1059 Some themes return a near black theme color using FILLCOLORHINT,
1060 this makes notebook pages have an ugly black background and makes
1061 text (usually black) unreadable. Retry again with FILLCOLOR.
1062
1063 This workaround potentially breaks appearance of some themes,
1064 but in practice it already fixes some themes.
1065 */
1066 if (themeColor == 1)
1067 {
1068 wxUxThemeEngine::Get()->GetThemeColor(
1069 hTheme,
1070 10 /* TABP_BODY */,
1071 1 /* NORMAL */,
1072 3802 /* FILLCOLOR */,
1073 &themeColor);
1074 }
1075
1076 wxColour colour(GetRValue(themeColor), GetGValue(themeColor), GetBValue(themeColor));
1077 return colour;
1078 }
1079 }
1080#endif // wxUSE_UXTHEME
1081
1082 return GetBackgroundColour();
1083}
1084
88310e2e
VZ
1085// ----------------------------------------------------------------------------
1086// wxNotebook base class virtuals
1087// ----------------------------------------------------------------------------
b5c3b538 1088
0b481c72
VZ
1089#if wxUSE_CONSTRAINTS
1090
b5c3b538
VZ
1091// override these 2 functions to do nothing: everything is done in OnSize
1092
4b7f2165 1093void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
b5c3b538
VZ
1094{
1095 // don't set the sizes of the pages - their correct size is not yet known
b8bdaa7c 1096 wxControl::SetConstraintSizes(false);
b5c3b538
VZ
1097}
1098
4b7f2165 1099bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
b5c3b538 1100{
b8bdaa7c 1101 return true;
b5c3b538
VZ
1102}
1103
0b481c72
VZ
1104#endif // wxUSE_CONSTRAINTS
1105
0df3fbd7
VZ
1106// ----------------------------------------------------------------------------
1107// wxNotebook Windows message handlers
1108// ----------------------------------------------------------------------------
1109
1110bool wxNotebook::MSWOnScroll(int orientation, WXWORD nSBCode,
1111 WXWORD pos, WXHWND control)
1112{
1113 // don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the
1114 // up-down control
1115 if ( control )
b8bdaa7c 1116 return false;
0df3fbd7
VZ
1117
1118 return wxNotebookBase::MSWOnScroll(orientation, nSBCode, pos, control);
1119}
1120
a23fd0e1 1121bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
88310e2e 1122{
93a19f17 1123 wxNotebookEvent event(wxEVT_NULL, m_windowId);
88310e2e
VZ
1124
1125 NMHDR* hdr = (NMHDR *)lParam;
1126 switch ( hdr->code ) {
1127 case TCN_SELCHANGE:
1128 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
1129 break;
1130
1131 case TCN_SELCHANGING:
1132 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING);
1133 break;
1134
fd3f686c 1135 default:
a23fd0e1 1136 return wxControl::MSWOnNotify(idCtrl, lParam, result);
88310e2e
VZ
1137 }
1138
93a19f17
VZ
1139 event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
1140 event.SetOldSelection(m_nSelection);
88310e2e 1141 event.SetEventObject(this);
a23fd0e1 1142 event.SetInt(idCtrl);
88310e2e 1143
fd3f686c
VZ
1144 bool processed = GetEventHandler()->ProcessEvent(event);
1145 *result = !event.IsAllowed();
1146 return processed;
88310e2e
VZ
1147}
1148
1e6feb95 1149#endif // wxUSE_NOTEBOOK