// wxWindows
#ifndef WX_PRECOMP
- #include <wx/string.h>
+ #include "wx/string.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/log.h"
+#include "wx/imaglist.h"
+#include "wx/event.h"
+#include "wx/control.h"
+#include "wx/notebook.h"
-#include <wx/msw/private.h>
+#include "wx/msw/private.h"
// Windows standard headers
#ifndef __WIN95__
// hide the ugly cast
#define m_hwnd (HWND)GetHWND()
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// This is a work-around for missing defines in gcc-2.95 headers
+#ifndef TCS_RIGHT
+ #define TCS_RIGHT 0x0002
+#endif
+
+#ifndef TCS_VERTICAL
+ #define TCS_VERTICAL 0x0080
+#endif
+
+#ifndef TCS_BOTTOM
+ #define TCS_BOTTOM TCS_RIGHT
+#endif
+
// ----------------------------------------------------------------------------
// event table
// ----------------------------------------------------------------------------
tabStyle |= TCS_VERTICAL;
if (m_windowStyle & wxNB_RIGHT)
tabStyle |= TCS_VERTICAL|TCS_RIGHT;
-
+
if ( !MSWCreate(GetId(), GetParent(), WC_TABCONTROL,
this, NULL, pos.x, pos.y, size.x, size.y,
int wxNotebook::SetSelection(int nPage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
ChangePage(m_nSelection, nPage);
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
TC_ITEM tcItem;
tcItem.mask = TCIF_TEXT;
wxString wxNotebook::GetPageText(int nPage) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), _T(""), _T("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), wxT("notebook page out of range") );
wxChar buf[256];
TC_ITEM tcItem;
int wxNotebook::GetPageImage(int nPage) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("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, _T("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
TC_ITEM tcItem;
tcItem.mask = TCIF_IMAGE;
// remove one page from the notebook
bool wxNotebook::DeletePage(int nPage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
if ( m_nSelection == nPage ) {
// advance selection backwards - the page being deleted shouldn't be left
// remove one page from the notebook, without deleting
bool wxNotebook::RemovePage(int nPage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
TabCtrl_DeleteItem(m_hwnd, nPage);
m_aPages.Remove(nPage);
+ if ( m_aPages.IsEmpty() )
+ m_nSelection = -1;
+
return TRUE;
}
TabCtrl_DeleteAllItems(m_hwnd);
+ m_nSelection = -1;
+
return TRUE;
}
}
if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 ) {
- wxLogError(_T("Can't create the notebook page '%s'."), strText.c_str());
+ wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str());
return FALSE;
}
// this updates internal flag too - otherwise it will get out of sync
pPage->Show(FALSE);
+ // fit the notebook page to the tab control's display area
+ RECT rc;
+ rc.left = rc.top = 0;
+ GetSize((int *)&rc.right, (int *)&rc.bottom);
+ TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
+ pPage->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
+
+
// some page should be selected: either this one or the first one if there is
// still no selection
int selNew = -1;
for ( size_t nPage = 0; nPage < nCount; nPage++ ) {
wxNotebookPage *pPage = m_aPages[nPage];
pPage->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
- if ( pPage->GetAutoLayout() )
- pPage->Layout();
}
event.Skip();
int sel = event.GetOldSelection();
if ( sel != -1 )
m_aPages[sel]->Show(FALSE);
-
+
sel = event.GetSelection();
if ( sel != -1 )
{
pPage->Show(TRUE);
pPage->SetFocus();
}
-
+
m_nSelection = sel;
}