// Name: msw/notebook.cpp
// Purpose: implementation of wxNotebook
// Author: Vadim Zeitlin
-// Modified by:
+// Modified by:
// Created: 11.06.98
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
EVT_SIZE(wxNotebook::OnSize)
- EVT_ERASE_BACKGROUND(wxNotebook::OnEraseBackground)
+
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
+
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
END_EVENT_TABLE()
const wxString& name)
{
// base init
- SetName(name);
- SetParent(parent);
-
- m_windowId = id == -1 ? NewControlId() : id;
+ CreateBase(parent, id, pos, size, style, name);
// colors and font
m_backgroundColour = wxColour(GetSysColor(COLOR_BTNFACE));
if (m_windowStyle & wxNB_FIXEDWIDTH)
tabStyle |= TCS_FIXEDWIDTH ;
- // create the tab control.
- m_hWnd = (WXHWND)CreateWindowEx
- (
- 0, // extended style
- WC_TABCONTROL, // class name for the tab control
- "", // no caption
- tabStyle, // style
- pos.x, pos.y, size.x, size.y, // size and position
- (HWND)parent->GetHWND(), // parent window
- (HMENU)m_windowId, // child id
- wxGetInstance(), // current instance
- NULL // no class data
- );
-
- if ( m_hWnd == 0 ) {
- wxLogSysError("Can't create the notebook control");
+ if ( !MSWCreate(GetId(), GetParent(), WC_TABCONTROL,
+ this, NULL, pos.x, pos.y, size.x, size.y,
+ tabStyle, NULL, 0) )
+ {
return FALSE;
}
// Not all compilers recognise SetWindowFont
-// SetWindowFont((HWND)m_hwnd, ::GetStockObject(DEFAULT_GUI_FONT), FALSE);
- ::SendMessage((HWND) m_hwnd, WM_SETFONT,
- (WPARAM)::GetStockObject(DEFAULT_GUI_FONT),TRUE);
+ ::SendMessage(GetHwnd(), WM_SETFONT,
+ (WPARAM)::GetStockObject(DEFAULT_GUI_FONT), TRUE);
- if ( parent != NULL )
+ if ( parent != NULL )
parent->AddChild(this);
-
+
SubclassWin(m_hWnd);
return TRUE;
int wxNotebook::SetSelection(int nPage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, "notebook page out of range" );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("notebook page out of range") );
ChangePage(m_nSelection, nPage);
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, "notebook page out of range" );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("notebook page out of range") );
TC_ITEM tcItem;
tcItem.mask = TCIF_TEXT;
- tcItem.pszText = (char *)strText.c_str();
+ tcItem.pszText = (wxChar *)strText.c_str();
return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0;
}
wxString wxNotebook::GetPageText(int nPage) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), "", "notebook page out of range" );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), _T(""), _T("notebook page out of range") );
- char buf[256];
+ wxChar buf[256];
TC_ITEM tcItem;
tcItem.mask = TCIF_TEXT;
tcItem.pszText = buf;
int wxNotebook::GetPageImage(int nPage) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, "notebook page out of range" );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("notebook page out of range") );
TC_ITEM tcItem;
tcItem.mask = TCIF_IMAGE;
bool wxNotebook::SetPageImage(int nPage, int nImage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, "notebook page out of range" );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("notebook page out of range") );
TC_ITEM tcItem;
tcItem.mask = TCIF_IMAGE;
}
void wxNotebook::SetImageList(wxImageList* imageList)
-{
+{
m_pImageList = imageList;
TabCtrl_SetImageList(m_hwnd, (HIMAGELIST)imageList->GetHIMAGELIST());
}
+
+// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
+// style.
+void wxNotebook::SetTabSize(const wxSize& sz)
+{
+ ::SendMessage(GetHwnd(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y));
+}
+
// ----------------------------------------------------------------------------
// wxNotebook operations
// ----------------------------------------------------------------------------
// remove one page from the notebook
bool wxNotebook::DeletePage(int nPage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, "notebook page out of range" );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("notebook page out of range") );
TabCtrl_DeleteItem(m_hwnd, nPage);
// remove one page from the notebook, without deleting
bool wxNotebook::RemovePage(int nPage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, "notebook page out of range" );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("notebook page out of range") );
TabCtrl_DeleteItem(m_hwnd, nPage);
// remove all pages
bool wxNotebook::DeleteAllPages()
{
- TabCtrl_DeleteAllItems(m_hwnd);
-
int nPageCount = GetPageCount();
int nPage;
for ( nPage = 0; nPage < nPageCount; nPage++ )
m_aPages.Clear();
+ TabCtrl_DeleteAllItems(m_hwnd);
+
return TRUE;
}
if (!strText.IsEmpty())
{
tcItem.mask |= TCIF_TEXT;
- tcItem.pszText = (char *)strText.c_str();
+ tcItem.pszText = (wxChar *)strText.c_str();
}
else
- tcItem.pszText = (char *) NULL;
+ tcItem.pszText = (wxChar *) NULL;
if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 ) {
- wxLogError("Can't create the notebook page '%s'.", strText.c_str());
+ wxLogError(_T("Can't create the notebook page '%s'."), strText.c_str());
return FALSE;
}
// save the pointer to the page
m_aPages.Insert(pPage, nPage);
- // some page must be selected: either this one or the first one if there is
+ // some page must be selected: either this one or the first one if there is
// still no selection
if ( bSelect )
m_nSelection = nPage;
m_nSelection = 0;
// don't show pages by default (we'll need to adjust their size first)
- HWND hwnd = (HWND)pPage->GetHWND();
+ HWND hwnd = GetWinHwnd(pPage);
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE);
+ // this updates internal flag too - otherwise it will get out of sync
+ pPage->Show(FALSE);
+
return TRUE;
}
return TRUE;
}
-void wxNotebook::Command(wxCommandEvent& event)
-{
- wxFAIL_MSG("wxNotebook::Command not implemented");
-}
-
bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
{
wxNotebookEvent event(wxEVT_NULL, m_windowId);
m_nSelection = nSel;
s_bInsideChangePage = FALSE;
}
-
-void wxNotebook::OnEraseBackground(wxEraseEvent& event)
-{
- Default();
-}
-
-// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
-// style.
-void wxNotebook::SetTabSize(const wxSize& sz)
-{
- ::SendMessage((HWND) GetHWND(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y));
-}
-