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