+ //
+ // Under OS/2 we can only insert FIRST, LAST, NEXT or PREV. Requires
+ // two different calls to the API. Page 1 uses the BKA_FIRST. Subsequent
+ // pages use the previous page ID coupled with a BKA_NEXT call. Unlike
+ // Windows, OS/2 uses an internal Page ID to ID the pages.
+ //
+ // OS/2 also has a nice auto-size feature that automatically sizes the
+ // the attached window so we don't have to worry about the size of the
+ // window on the page.
+ //
+ if (nPage == 0)
+ {
+ ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND()
+ ,BKM_INSERTPAGE
+ ,(MPARAM)0
+ ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_FIRST)
+ ));
+ if (ulApiPage == 0L)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ return FALSE;
+ }
+ m_alPageId.Insert((long)ulApiPage, nPage);
+ }
+ else
+ {
+ ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND()
+ ,BKM_INSERTPAGE
+ ,MPFROMLONG((ULONG)m_alPageId[nPage - 1])
+ ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_NEXT)
+ ));
+ if (ulApiPage == 0L)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ return FALSE;
+ }
+ m_alPageId.Insert((long)ulApiPage, nPage);
+ }
+
+ //
+ // Associate a window handle with the page
+ //
+ if (pPage)
+ {
+ if (!::WinSendMsg( GetHWND()
+ ,BKM_SETPAGEWINDOWHWND
+ ,MPFROMLONG((ULONG)m_alPageId[nPage])
+ ,MPFROMHWND(pPage->GetHWND())
+ ))
+ return FALSE;
+ }
+ //
+ // If the inserted page is before the selected one, we must update the
+ // index of the selected page
+ //
+ if (nPage <= (size_t)m_nSelection)
+ {
+ //
+ // One extra page added
+ //
+ m_nSelection++;
+ }
+
+ if (pPage)
+ {
+ //
+ // Save the pointer to the page
+ //
+ m_pages.Insert( pPage
+ ,nPage
+ );
+ }
+
+ //
+ // Now set TAB dimenstions
+ //
+
+ wxWindowDC vDC(this);
+ wxCoord nTextX;
+ wxCoord nTextY;
+
+ vDC.GetTextExtent(rsStrText, &nTextX, &nTextY);
+ nTextY *= 2;
+ nTextX = (wxCoord)(nTextX * 1.3);
+ if (nTextX > m_nTabSize)
+ {
+ m_nTabSize = nTextX;
+ ::WinSendMsg( GetHWND()
+ ,BKM_SETDIMENSIONS
+ ,MPFROM2SHORT((USHORT)m_nTabSize, (USHORT)nTextY)
+ ,(MPARAM)BKA_MAJORTAB
+ );
+ }
+ //
+ // Now set any TAB text
+ //
+ if (!rsStrText.IsEmpty())
+ {
+ if (!SetPageText( nPage
+ ,rsStrText
+ ))
+ return FALSE;
+ }
+
+ //
+ // Now set any TAB bitmap image
+ //
+ if (nImageId != -1)
+ {
+ if (!SetPageImage( nPage
+ ,nImageId
+ ))
+ return FALSE;
+ }