///////////////////////////////////////////////////////////////////////////////
-// Name: notebook.cpp
+// Name: src/os2/notebook.cpp
// Purpose: implementation of wxNotebook
// Author: David Webster
// Modified by:
#if wxUSE_NOTEBOOK
+#include "wx/notebook.h"
+
// wxWidgets
#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/dcclient.h"
- #include "wx/string.h"
- #include "wx/settings.h"
+ #include "wx/app.h"
+ #include "wx/dcclient.h"
+ #include "wx/string.h"
+ #include "wx/settings.h"
+ #include "wx/log.h"
+ #include "wx/event.h"
+ #include "wx/control.h"
#endif // WX_PRECOMP
-#include "wx/log.h"
#include "wx/imaglist.h"
-#include "wx/event.h"
-#include "wx/control.h"
-#include "wx/notebook.h"
#include "wx/os2/private.h"
// event table
// ----------------------------------------------------------------------------
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
-
-BEGIN_EVENT_TABLE(wxNotebook, wxControl)
- EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
+BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
+ EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
EVT_SIZE(wxNotebook::OnSize)
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
END_EVENT_TABLE()
-IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
// ============================================================================
// implementation
long lStyle,
const wxString& rsName )
{
+ if ( (lStyle & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
+ lStyle |= wxBK_TOP;
//
// Base init
//
dwTabStyle |= WS_TABSTOP | BKS_SOLIDBIND | BKS_ROUNDEDTABS | BKS_TABTEXTCENTER | BKS_TABBEDDIALOG;
- if (lStyle & wxNB_BOTTOM)
+ if (lStyle & wxBK_BOTTOM)
dwTabStyle |= BKS_MAJORTABBOTTOM | BKS_BACKPAGESBL;
- else if (lStyle & wxNB_RIGHT)
+ else if (lStyle & wxBK_RIGHT)
dwTabStyle |= BKS_MAJORTABRIGHT | BKS_BACKPAGESBR;
- else if (lStyle & wxNB_LEFT)
+ else if (lStyle & wxBK_LEFT)
dwTabStyle |= BKS_MAJORTABLEFT | BKS_BACKPAGESTL;
else // default to top
dwTabStyle |= BKS_MAJORTABTOP | BKS_BACKPAGESTR;
int wxNotebook::SetSelection( size_t nPage )
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
if (nPage != (size_t)m_nSelection)
{
- wxNotebookEvent vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
+ wxBookCtrlEvent vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
,m_windowId
);
vEvent.SetSelection(nPage);
vEvent.SetOldSelection(m_nSelection);
vEvent.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(vEvent) || vEvent.IsAllowed())
+ if (!HandleWindowEvent(vEvent) || vEvent.IsAllowed())
{
//
// Program allows the page change
//
vEvent.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
- GetEventHandler()->ProcessEvent(vEvent);
+ HandleWindowEvent(vEvent);
::WinSendMsg( GetHWND()
,BKM_TURNTOPAGE
return nPage;
} // end of wxNotebook::SetSelection
+int wxNotebook::ChangeSelection( size_t nPage )
+{
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
+
+ if (nPage != (size_t)m_nSelection)
+ {
+ ::WinSendMsg( GetHWND()
+ ,BKM_TURNTOPAGE
+ ,MPFROMLONG((ULONG)m_alPageId[nPage])
+ ,(MPARAM)0
+ );
+ }
+ m_nSelection = nPage;
+ return nPage;
+}
+
bool wxNotebook::SetPageText( size_t nPage,
const wxString& rsStrText )
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") );
return (bool)::WinSendMsg( m_hWnd
,BKM_SETTABTEXT
,MPFROMLONG((ULONG)m_alPageId[nPage])
- ,MPFROMP((PSZ)rsStrText.c_str())
+ ,MPFROMP((const char*)rsStrText.c_str())
);
} // end of wxNotebook::SetPageText
wxString sStr;
ULONG ulRc;
- wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), wxT("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") );
memset(&vBookText, '\0', sizeof(BOOKTEXT));
vBookText.textLen = 0; // This will get the length
int wxNotebook::GetPageImage ( size_t nPage ) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
//
// For OS/2 just return the page
return (bool)::WinSendMsg( GetHWND()
,BKM_SETTABBITMAP
,MPFROMLONG((ULONG)m_alPageId[nPage])
- ,(MPARAM)vBitmap.GetHBITMAP()
+ ,(MPARAM)wxCopyBmp(vBitmap.GetHBITMAP(), true)
);
} // end of wxNotebook::SetPageImage
ULONG ulApiPage;
wxASSERT( pPage != NULL );
- wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
+ wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false );
//
// Under OS/2 we can only insert FIRST, LAST, NEXT or PREV. Requires
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
- return FALSE;
+ return false;
}
m_alPageId.Insert((long)ulApiPage, nPage);
}
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
- return FALSE;
+ return false;
}
m_alPageId.Insert((long)ulApiPage, nPage);
}
,MPFROMLONG((ULONG)m_alPageId[nPage])
,MPFROMHWND(pPage->GetHWND())
))
- return FALSE;
+ return false;
}
//
// If the inserted page is before the selected one, we must update the
if (!SetPageText( nPage
,rsStrText
))
- return FALSE;
+ return false;
}
//
if (!SetPageImage( nPage
,nImageId
))
- return FALSE;
+ return false;
}
if (pPage)
//
// Don't show pages by default (we'll need to adjust their size first)
//
- HWND hWnd = GetWinHwnd(pPage);
+ HWND hWnd = GetWinHwnd(pPage);
WinSetWindowULong( hWnd
,QWL_STYLE
//
// This updates internal flag too - otherwise it will get out of sync
//
- pPage->Show(FALSE);
+ pPage->Show(false);
}
//
// Some page should be selected: either this one or the first one if there is
// still no selection
//
- int nSelNew = -1;
+ int nSelNew = -1;
if (bSelect)
nSelNew = nPage;
InvalidateBestSize();
- return TRUE;
+ return true;
} // end of wxNotebook::InsertPage
// ----------------------------------------------------------------------------
} // end of wxNotebook::OnSize
void wxNotebook::OnSelChange (
- wxNotebookEvent& rEvent
+ wxBookCtrlEvent& rEvent
)
{
//
//
if (rEvent.GetEventObject() == this)
{
- int nPageCount = GetPageCount();
- int nSel;
- ULONG ulOS2Sel = (ULONG)rEvent.GetOldSelection();
- bool bFound = FALSE;
+ int nPageCount = GetPageCount();
+ int nSel;
+ ULONG ulOS2Sel = (ULONG)rEvent.GetOldSelection();
+ bool bFound = false;
for (nSel = 0; nSel < nPageCount; nSel++)
{
if (ulOS2Sel == (ULONG)m_alPageId[nSel])
{
- bFound = TRUE;
+ bFound = true;
break;
}
}
if (!bFound)
return;
- m_pages[nSel]->Show(FALSE);
+ m_pages[nSel]->Show(false);
ulOS2Sel = (ULONG)rEvent.GetSelection();
- bFound = FALSE;
+ bFound = false;
for (nSel = 0; nSel < nPageCount; nSel++)
{
if (ulOS2Sel == (ULONG)m_alPageId[nSel])
{
- bFound = TRUE;
+ bFound = true;
break;
}
}
wxNotebookPage* pPage = m_pages[nSel];
- pPage->Show(TRUE);
+ pPage->Show(true);
m_nSelection = nSel;
}
wxWindow* pPage = m_pages[m_nSelection];
- if (!pPage->GetEventHandler()->ProcessEvent(rEvent))
+ if (!pPage->HandleWindowEvent(rEvent))
{
pPage->SetFocus();
}
if (pParent)
{
rEvent.SetCurrentFocus(this);
- pParent->GetEventHandler()->ProcessEvent(rEvent);
+ pParent->HandleWindowEvent(rEvent);
}
}
}
//
// Override these 2 functions to do nothing: everything is done in OnSize
//
-void wxNotebook::SetConstraintSizes(
- bool WXUNUSED(bRecurse)
-)
+void wxNotebook::SetConstraintSizes( bool WXUNUSED(bRecurse) )
{
//
// Don't set the sizes of the pages - their correct size is not yet known
//
- wxControl::SetConstraintSizes(FALSE);
+ wxControl::SetConstraintSizes(false);
} // end of wxNotebook::SetConstraintSizes
-bool wxNotebook::DoPhase (
- int WXUNUSED(nPhase)
-)
+bool wxNotebook::DoPhase ( int WXUNUSED(nPhase) )
{
- return TRUE;
+ return true;
} // end of wxNotebook::DoPhase
// ----------------------------------------------------------------------------
// up-down control
//
if (wControl)
- return FALSE;
+ return false;
return wxNotebookBase::OS2OnScroll( nOrientation
,wSBCode
,wPos