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