Refactor: use wxBookCtrlBase::m_selection in all derived classes.
[wxWidgets.git] / src / os2 / notebook.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/notebook.cpp
3 // Purpose: implementation of wxNotebook
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/12/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #if wxUSE_NOTEBOOK
16
17 #include "wx/notebook.h"
18
19 // wxWidgets
20 #ifndef WX_PRECOMP
21 #include "wx/app.h"
22 #include "wx/dcclient.h"
23 #include "wx/string.h"
24 #include "wx/settings.h"
25 #include "wx/log.h"
26 #include "wx/event.h"
27 #include "wx/control.h"
28 #endif // WX_PRECOMP
29
30 #include "wx/imaglist.h"
31
32 #include "wx/os2/private.h"
33
34 // ----------------------------------------------------------------------------
35 // macros
36 // ----------------------------------------------------------------------------
37
38 // check that the page index is valid
39 #define IS_VALID_PAGE(nPage) ( \
40 /* size_t is _always_ >= 0 */ \
41 /* ((nPage) >= 0) && */ \
42 ((nPage) < GetPageCount()) \
43 )
44
45 // hide the ugly cast
46 #define m_hWnd (HWND)GetHWND()
47
48 // ----------------------------------------------------------------------------
49 // constants
50 // ----------------------------------------------------------------------------
51
52 // ----------------------------------------------------------------------------
53 // event table
54 // ----------------------------------------------------------------------------
55
56 BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
57 EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
58 EVT_SIZE(wxNotebook::OnSize)
59 EVT_SET_FOCUS(wxNotebook::OnSetFocus)
60 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
61 END_EVENT_TABLE()
62
63 IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
64
65 // ============================================================================
66 // implementation
67 // ============================================================================
68
69 // ----------------------------------------------------------------------------
70 // wxNotebook construction
71 // ----------------------------------------------------------------------------
72
73 //
74 // Common part of all ctors
75 //
76 void wxNotebook::Init()
77 {
78 m_imageList = NULL;
79 m_nTabSize = 0;
80 } // end of wxNotebook::Init
81
82 //
83 // Default for dynamic class
84 //
85 wxNotebook::wxNotebook()
86 {
87 Init();
88 } // end of wxNotebook::wxNotebook
89
90 //
91 // The same arguments as for wxControl
92 //
93 wxNotebook::wxNotebook(
94 wxWindow* pParent
95 , wxWindowID vId
96 , const wxPoint& rPos
97 , const wxSize& rSize
98 , long lStyle
99 , const wxString& rsName
100 )
101 {
102 Init();
103 Create( pParent
104 ,vId
105 ,rPos
106 ,rSize
107 ,lStyle
108 ,rsName
109 );
110 } // end of wxNotebook::wxNotebook
111
112 //
113 // Create() function
114 //
115 bool wxNotebook::Create( wxWindow* pParent,
116 wxWindowID vId,
117 const wxPoint& rPos,
118 const wxSize& rSize,
119 long lStyle,
120 const wxString& rsName )
121 {
122 if ( (lStyle & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
123 lStyle |= wxBK_TOP;
124 //
125 // Base init
126 //
127 if (!CreateControl( pParent
128 ,vId
129 ,rPos
130 ,rSize
131 ,lStyle
132 ,wxDefaultValidator
133 ,rsName
134 ))
135 return false;
136
137 //
138 // Notebook, so explicitly specify 0 as last parameter
139 //
140 if (!OS2CreateControl( wxT("NOTEBOOK")
141 ,wxEmptyString
142 ,rPos
143 ,rSize
144 ,lStyle | wxTAB_TRAVERSAL
145 ))
146 return false;
147
148 SetBackgroundColour(wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
149 return true;
150 } // end of wxNotebook::Create
151
152 WXDWORD wxNotebook::OS2GetStyle (
153 long lStyle
154 , WXDWORD* pdwExstyle
155 ) const
156 {
157 WXDWORD dwTabStyle = wxControl::OS2GetStyle( lStyle
158 ,pdwExstyle
159 );
160
161 dwTabStyle |= WS_TABSTOP | BKS_SOLIDBIND | BKS_ROUNDEDTABS | BKS_TABTEXTCENTER | BKS_TABBEDDIALOG;
162
163 if (lStyle & wxBK_BOTTOM)
164 dwTabStyle |= BKS_MAJORTABBOTTOM | BKS_BACKPAGESBL;
165 else if (lStyle & wxBK_RIGHT)
166 dwTabStyle |= BKS_MAJORTABRIGHT | BKS_BACKPAGESBR;
167 else if (lStyle & wxBK_LEFT)
168 dwTabStyle |= BKS_MAJORTABLEFT | BKS_BACKPAGESTL;
169 else // default to top
170 dwTabStyle |= BKS_MAJORTABTOP | BKS_BACKPAGESTR;
171
172 //
173 // Ex style
174 //
175 if (pdwExstyle )
176 {
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 //
181 *pdwExstyle = 0;
182 }
183 return dwTabStyle;
184 } // end of wxNotebook::OS2GetStyle
185
186 // ----------------------------------------------------------------------------
187 // wxNotebook accessors
188 // ----------------------------------------------------------------------------
189
190 size_t wxNotebook::GetPageCount() const
191 {
192 //
193 // Consistency check
194 //
195 wxASSERT((int)m_pages.Count() == (int)::WinSendMsg(GetHWND(), BKM_QUERYPAGECOUNT, (MPARAM)0, (MPARAM)BKA_END));
196 return m_pages.Count();
197 } // end of wxNotebook::GetPageCount
198
199 int wxNotebook::GetRowCount() const
200 {
201 return (int)::WinSendMsg( GetHWND()
202 ,BKM_QUERYPAGECOUNT
203 ,(MPARAM)0
204 ,(MPARAM)BKA_MAJOR
205 );
206 } // end of wxNotebook::GetRowCount
207
208 int wxNotebook::SetSelection( size_t nPage )
209 {
210 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
211
212 if (nPage != (size_t)m_selection)
213 {
214 wxBookCtrlEvent vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
215 ,m_windowId
216 );
217
218 vEvent.SetSelection(nPage);
219 vEvent.SetOldSelection(m_selection);
220 vEvent.SetEventObject(this);
221 if (!HandleWindowEvent(vEvent) || vEvent.IsAllowed())
222 {
223
224 //
225 // Program allows the page change
226 //
227 vEvent.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
228 HandleWindowEvent(vEvent);
229
230 ::WinSendMsg( GetHWND()
231 ,BKM_TURNTOPAGE
232 ,MPFROMLONG((ULONG)m_alPageId[nPage])
233 ,(MPARAM)0
234 );
235 }
236 }
237 m_selection = nPage;
238 return nPage;
239 } // end of wxNotebook::SetSelection
240
241 int wxNotebook::ChangeSelection( size_t nPage )
242 {
243 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
244
245 if (nPage != (size_t)m_selection)
246 {
247 ::WinSendMsg( GetHWND()
248 ,BKM_TURNTOPAGE
249 ,MPFROMLONG((ULONG)m_alPageId[nPage])
250 ,(MPARAM)0
251 );
252 }
253 m_selection = nPage;
254 return nPage;
255 }
256
257 bool wxNotebook::SetPageText( size_t nPage,
258 const wxString& rsStrText )
259 {
260 wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") );
261 return (bool)::WinSendMsg( m_hWnd
262 ,BKM_SETTABTEXT
263 ,MPFROMLONG((ULONG)m_alPageId[nPage])
264 ,MPFROMP((const char*)rsStrText.c_str())
265 );
266 } // end of wxNotebook::SetPageText
267
268 wxString wxNotebook::GetPageText ( size_t nPage ) const
269 {
270 BOOKTEXT vBookText;
271 wxChar zBuf[256];
272 wxString sStr;
273 ULONG ulRc;
274
275 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") );
276
277 memset(&vBookText, '\0', sizeof(BOOKTEXT));
278 vBookText.textLen = 0; // This will get the length
279 ulRc = LONGFROMMR(::WinSendMsg( m_hWnd
280 ,BKM_QUERYTABTEXT
281 ,MPFROMLONG((ULONG)m_alPageId[nPage])
282 ,MPFROMP(&vBookText)
283 ));
284 if (ulRc == (ULONG)BOOKERR_INVALID_PARAMETERS || ulRc == 0L)
285 {
286 if (ulRc == (ULONG)BOOKERR_INVALID_PARAMETERS)
287 {
288 wxLogError(wxT("Invalid Page Id for page text querry."));
289 }
290 return wxEmptyString;
291 }
292 vBookText.textLen = ulRc + 1; // To get the null terminator
293 vBookText.pString = (char*)zBuf;
294
295 //
296 // Now get the actual text
297 //
298 ulRc = LONGFROMMR(::WinSendMsg( m_hWnd
299 ,BKM_QUERYTABTEXT
300 ,MPFROMLONG((ULONG)m_alPageId[nPage])
301 ,MPFROMP(&vBookText)
302 ));
303 if (ulRc == (ULONG)BOOKERR_INVALID_PARAMETERS || ulRc == 0L)
304 {
305 return wxEmptyString;
306 }
307 if (ulRc > 255L)
308 ulRc = 255L;
309
310 vBookText.pString[ulRc] = '\0';
311 sStr = (wxChar*)vBookText.pString;
312 return sStr;
313 } // end of wxNotebook::GetPageText
314
315 int wxNotebook::GetPageImage ( size_t nPage ) const
316 {
317 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
318
319 //
320 // For OS/2 just return the page
321 //
322 return nPage;
323 } // end of wxNotebook::GetPageImage
324
325 bool wxNotebook::SetPageImage (
326 size_t nPage
327 , int nImage
328 )
329 {
330 wxBitmap vBitmap = (wxBitmap)m_imageList->GetBitmap(nImage);
331
332 return (bool)::WinSendMsg( GetHWND()
333 ,BKM_SETTABBITMAP
334 ,MPFROMLONG((ULONG)m_alPageId[nPage])
335 ,(MPARAM)wxCopyBmp(vBitmap.GetHBITMAP(), true)
336 );
337 } // end of wxNotebook::SetPageImage
338
339 void wxNotebook::SetImageList (
340 wxImageList* pImageList
341 )
342 {
343 //
344 // Does not really do anything yet, but at least we need to
345 // update the base class.
346 //
347 wxNotebookBase::SetImageList(pImageList);
348 } // end of wxNotebook::SetImageList
349
350 // ----------------------------------------------------------------------------
351 // wxNotebook size settings
352 // ----------------------------------------------------------------------------
353 void wxNotebook::SetPageSize (
354 const wxSize& rSize
355 )
356 {
357 SetSize(rSize);
358 } // end of wxNotebook::SetPageSize
359
360 void wxNotebook::SetPadding (
361 const wxSize& WXUNUSED(rPadding)
362 )
363 {
364 //
365 // No padding in OS/2
366 //
367 } // end of wxNotebook::SetPadding
368
369 void wxNotebook::SetTabSize (
370 const wxSize& rSize
371 )
372 {
373 ::WinSendMsg( GetHWND()
374 ,BKM_SETDIMENSIONS
375 ,MPFROM2SHORT( (USHORT)rSize.x
376 ,(USHORT)rSize.y
377 )
378 ,(MPARAM)BKA_MAJORTAB
379 );
380 } // end of wxNotebook::SetTabSize
381
382 // ----------------------------------------------------------------------------
383 // wxNotebook operations
384 // ----------------------------------------------------------------------------
385
386 //
387 // Remove one page from the notebook, without deleting
388 //
389 wxNotebookPage* wxNotebook::DoRemovePage ( size_t nPage )
390 {
391 wxNotebookPage* pPageRemoved = wxNotebookBase::DoRemovePage(nPage);
392
393 if (!pPageRemoved)
394 return NULL;
395
396 ::WinSendMsg( GetHWND()
397 ,BKM_DELETEPAGE
398 ,MPFROMLONG((ULONG)m_alPageId[nPage])
399 ,(MPARAM)BKA_TAB
400 );
401 if (m_pages.IsEmpty())
402 {
403 //
404 // No selection any more, the notebook becamse empty
405 //
406 m_selection = wxNOT_FOUND;
407 }
408 else // notebook still not empty
409 {
410 //
411 // Change the selected page if it was deleted or became invalid
412 //
413 int nSelNew;
414
415 if (m_selection == (int)GetPageCount())
416 {
417 //
418 // Last page deleted, make the new last page the new selection
419 //
420 nSelNew = m_selection - 1;
421 }
422 else if (nPage <= (size_t)m_selection)
423 {
424 //
425 // We must show another page, even if it has the same index
426 //
427 nSelNew = m_selection;
428 }
429 else // nothing changes for the currently selected page
430 {
431 nSelNew = wxNOT_FOUND;
432
433 //
434 // We still must refresh the current page: this needs to be done
435 // for some unknown reason if the tab control shows the up-down
436 // control (i.e. when there are too many pages) -- otherwise after
437 // deleting a page nothing at all is shown
438 //
439 m_pages[m_selection]->Refresh();
440 }
441
442 if (nSelNew != wxNOT_FOUND)
443 {
444 //
445 // m_selection must be always valid so reset it before calling
446 // SetSelection()
447 //
448 m_selection = wxNOT_FOUND;
449 SetSelection(nSelNew);
450 }
451 }
452 return pPageRemoved;
453 } // end of wxNotebook::DoRemovePage
454
455 //
456 // Remove all pages
457 //
458 bool wxNotebook::DeleteAllPages()
459 {
460 int nPageCount = GetPageCount();
461 int nPage;
462
463 for (nPage = 0; nPage < nPageCount; nPage++)
464 delete m_pages[nPage];
465 m_pages.Clear();
466 ::WinSendMsg( GetHWND()
467 ,BKM_DELETEPAGE
468 ,(MPARAM)0
469 ,(MPARAM)BKA_ALL
470 );
471 m_selection = wxNOT_FOUND;
472
473 return true;
474 } // end of wxNotebook::DeleteAllPages
475
476 //
477 // Add a page to the notebook
478 //
479 bool wxNotebook::AddPage (
480 wxNotebookPage* pPage
481 , const wxString& rStrText
482 , bool bSelect
483 , int nImageId
484 )
485 {
486 return InsertPage( GetPageCount()
487 ,pPage
488 ,rStrText
489 ,bSelect
490 ,nImageId
491 );
492 } // end of wxNotebook::AddPage
493
494 //
495 // Same as AddPage() but does it at given position
496 //
497 bool wxNotebook::InsertPage ( size_t nPage,
498 wxNotebookPage* pPage,
499 const wxString& rsStrText,
500 bool bSelect,
501 int nImageId )
502 {
503 ULONG ulApiPage;
504
505 wxASSERT( pPage != NULL );
506 wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false );
507
508 //
509 // Under OS/2 we can only insert FIRST, LAST, NEXT or PREV. Requires
510 // two different calls to the API. Page 1 uses the BKA_FIRST. Subsequent
511 // pages use the previous page ID coupled with a BKA_NEXT call. Unlike
512 // Windows, OS/2 uses an internal Page ID to ID the pages.
513 //
514 // OS/2 also has a nice auto-size feature that automatically sizes the
515 // the attached window so we don't have to worry about the size of the
516 // window on the page.
517 //
518 if (nPage == 0)
519 {
520 ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND()
521 ,BKM_INSERTPAGE
522 ,(MPARAM)0
523 ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_FIRST)
524 ));
525 if (ulApiPage == 0L)
526 {
527 ERRORID vError;
528 wxString sError;
529
530 vError = ::WinGetLastError(vHabmain);
531 sError = wxPMErrorToStr(vError);
532 return false;
533 }
534 m_alPageId.Insert((long)ulApiPage, nPage);
535 }
536 else
537 {
538 ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND()
539 ,BKM_INSERTPAGE
540 ,MPFROMLONG((ULONG)m_alPageId[nPage - 1])
541 ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_NEXT)
542 ));
543 if (ulApiPage == 0L)
544 {
545 ERRORID vError;
546 wxString sError;
547
548 vError = ::WinGetLastError(vHabmain);
549 sError = wxPMErrorToStr(vError);
550 return false;
551 }
552 m_alPageId.Insert((long)ulApiPage, nPage);
553 }
554
555 //
556 // Associate a window handle with the page
557 //
558 if (pPage)
559 {
560 if (!::WinSendMsg( GetHWND()
561 ,BKM_SETPAGEWINDOWHWND
562 ,MPFROMLONG((ULONG)m_alPageId[nPage])
563 ,MPFROMHWND(pPage->GetHWND())
564 ))
565 return false;
566 }
567 //
568 // If the inserted page is before the selected one, we must update the
569 // index of the selected page
570 //
571 if (nPage <= (size_t)m_selection)
572 {
573 //
574 // One extra page added
575 //
576 m_selection++;
577 }
578
579 if (pPage)
580 {
581 //
582 // Save the pointer to the page
583 //
584 m_pages.Insert( pPage
585 ,nPage
586 );
587 }
588
589 //
590 // Now set TAB dimenstions
591 //
592
593 wxWindowDC vDC(this);
594 wxCoord nTextX;
595 wxCoord nTextY;
596
597 vDC.GetTextExtent(rsStrText, &nTextX, &nTextY);
598 nTextY *= 2;
599 nTextX = (wxCoord)(nTextX * 1.3);
600 if (nTextX > m_nTabSize)
601 {
602 m_nTabSize = nTextX;
603 ::WinSendMsg( GetHWND()
604 ,BKM_SETDIMENSIONS
605 ,MPFROM2SHORT((USHORT)m_nTabSize, (USHORT)nTextY)
606 ,(MPARAM)BKA_MAJORTAB
607 );
608 }
609 //
610 // Now set any TAB text
611 //
612 if (!rsStrText.empty())
613 {
614 if (!SetPageText( nPage
615 ,rsStrText
616 ))
617 return false;
618 }
619
620 //
621 // Now set any TAB bitmap image
622 //
623 if (nImageId != -1)
624 {
625 if (!SetPageImage( nPage
626 ,nImageId
627 ))
628 return false;
629 }
630
631 if (pPage)
632 {
633 //
634 // Don't show pages by default (we'll need to adjust their size first)
635 //
636 HWND hWnd = GetWinHwnd(pPage);
637
638 WinSetWindowULong( hWnd
639 ,QWL_STYLE
640 ,WinQueryWindowULong( hWnd
641 ,QWL_STYLE
642 ) & ~WS_VISIBLE
643 );
644
645 //
646 // This updates internal flag too - otherwise it will get out of sync
647 //
648 pPage->Show(false);
649 }
650
651 //
652 // Some page should be selected: either this one or the first one if there is
653 // still no selection
654 //
655 int nSelNew = wxNOT_FOUND;
656
657 if (bSelect)
658 nSelNew = nPage;
659 else if ( m_selection == wxNOT_FOUND )
660 nSelNew = 0;
661
662 if (nSelNew != wxNOT_FOUND)
663 SetSelection(nSelNew);
664
665 InvalidateBestSize();
666
667 return true;
668 } // end of wxNotebook::InsertPage
669
670 // ----------------------------------------------------------------------------
671 // wxNotebook callbacks
672 // ----------------------------------------------------------------------------
673 void wxNotebook::OnSize(
674 wxSizeEvent& rEvent
675 )
676 {
677 rEvent.Skip();
678 } // end of wxNotebook::OnSize
679
680 void wxNotebook::OnSelChange (
681 wxBookCtrlEvent& rEvent
682 )
683 {
684 //
685 // Is it our tab control?
686 //
687 if (rEvent.GetEventObject() == this)
688 {
689 int nPageCount = GetPageCount();
690 int nSel;
691 ULONG ulOS2Sel = (ULONG)rEvent.GetOldSelection();
692 bool bFound = false;
693
694 for (nSel = 0; nSel < nPageCount; nSel++)
695 {
696 if (ulOS2Sel == (ULONG)m_alPageId[nSel])
697 {
698 bFound = true;
699 break;
700 }
701 }
702
703 if (!bFound)
704 return;
705
706 m_pages[nSel]->Show(false);
707
708 ulOS2Sel = (ULONG)rEvent.GetSelection();
709
710 bFound = false;
711
712 for (nSel = 0; nSel < nPageCount; nSel++)
713 {
714 if (ulOS2Sel == (ULONG)m_alPageId[nSel])
715 {
716 bFound = true;
717 break;
718 }
719 }
720
721 if (!bFound)
722 return;
723
724 wxNotebookPage* pPage = m_pages[nSel];
725
726 pPage->Show(true);
727 m_selection = nSel;
728 }
729
730 //
731 // We want to give others a chance to process this message as well
732 //
733 rEvent.Skip();
734 } // end of wxNotebook::OnSelChange
735
736 void wxNotebook::OnSetFocus (
737 wxFocusEvent& rEvent
738 )
739 {
740 //
741 // This function is only called when the focus is explicitly set (i.e. from
742 // the program) to the notebook - in this case we don't need the
743 // complicated OnNavigationKey() logic because the programmer knows better
744 // what [s]he wants
745 //
746 // set focus to the currently selected page if any
747 //
748 if (m_selection != wxNOT_FOUND)
749 m_pages[m_selection]->SetFocus();
750 rEvent.Skip();
751 } // end of wxNotebook::OnSetFocus
752
753 void wxNotebook::OnNavigationKey (
754 wxNavigationKeyEvent& rEvent
755 )
756 {
757 if (rEvent.IsWindowChange())
758 {
759 //
760 // Change pages
761 //
762 AdvanceSelection(rEvent.GetDirection());
763 }
764 else
765 {
766 //
767 // We get this event in 2 cases
768 //
769 // a) one of our pages might have generated it because the user TABbed
770 // out from it in which case we should propagate the event upwards and
771 // our parent will take care of setting the focus to prev/next sibling
772 //
773 // or
774 //
775 // b) the parent panel wants to give the focus to us so that we
776 // forward it to our selected page. We can't deal with this in
777 // OnSetFocus() because we don't know which direction the focus came
778 // from in this case and so can't choose between setting the focus to
779 // first or last panel child
780 //
781 wxWindow* pParent = GetParent();
782
783 if (rEvent.GetEventObject() == pParent)
784 {
785 //
786 // No, it doesn't come from child, case (b): forward to a page
787 //
788 if (m_selection != wxNOT_FOUND)
789 {
790 //
791 // So that the page knows that the event comes from it's parent
792 // and is being propagated downwards
793 //
794 rEvent.SetEventObject(this);
795
796 wxWindow* pPage = m_pages[m_selection];
797
798 if (!pPage->HandleWindowEvent(rEvent))
799 {
800 pPage->SetFocus();
801 }
802 //else: page manages focus inside it itself
803 }
804 else
805 {
806 //
807 // We have no pages - still have to give focus to _something_
808 //
809 SetFocus();
810 }
811 }
812 else
813 {
814 //
815 // It comes from our child, case (a), pass to the parent
816 //
817 if (pParent)
818 {
819 rEvent.SetCurrentFocus(this);
820 pParent->HandleWindowEvent(rEvent);
821 }
822 }
823 }
824 } // end of wxNotebook::OnNavigationKey
825
826 // ----------------------------------------------------------------------------
827 // wxNotebook base class virtuals
828 // ----------------------------------------------------------------------------
829
830 //
831 // Override these 2 functions to do nothing: everything is done in OnSize
832 //
833 void wxNotebook::SetConstraintSizes( bool WXUNUSED(bRecurse) )
834 {
835 //
836 // Don't set the sizes of the pages - their correct size is not yet known
837 //
838 wxControl::SetConstraintSizes(false);
839 } // end of wxNotebook::SetConstraintSizes
840
841 bool wxNotebook::DoPhase ( int WXUNUSED(nPhase) )
842 {
843 return true;
844 } // end of wxNotebook::DoPhase
845
846 // ----------------------------------------------------------------------------
847 // wxNotebook Windows message handlers
848 // ----------------------------------------------------------------------------
849 bool wxNotebook::OS2OnScroll ( int nOrientation,
850 WXWORD wSBCode,
851 WXWORD wPos,
852 WXHWND wControl )
853 {
854 //
855 // Don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the
856 // up-down control
857 //
858 if (wControl)
859 return false;
860 return wxNotebookBase::OS2OnScroll( nOrientation
861 ,wSBCode
862 ,wPos
863 ,wControl
864 );
865 } // end of wxNotebook::OS2OnScroll
866
867 #endif // wxUSE_NOTEBOOK