#include <windowsx.h> // for SetWindowFont
+#ifndef __TWIN32__
#ifdef __GNUWIN32__
#include "wx/msw/gnuwin32/extra.h"
-#else //!GnuWin32
+#endif
+#endif
+
+#if !defined(__GNUWIN32__) || defined(__TWIN32__)
#include <commctrl.h>
#endif
m_windowStyle = style | wxTAB_TRAVERSAL;
long tabStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | TCS_TABS;
+
+ if (m_windowStyle & wxCLIP_CHILDREN)
+ tabStyle |= WS_CLIPCHILDREN;
if ( m_windowStyle & wxTC_MULTILINE )
tabStyle |= TCS_MULTILINE;
if ( m_windowStyle & wxBORDER )
tabStyle &= WS_BORDER;
+ if (m_windowStyle & wxNB_FIXEDWIDTH)
+ tabStyle |= TCS_FIXEDWIDTH ;
// create the tab control.
m_hWnd = (WXHWND)CreateWindowEx
// add the tab to the control
TC_ITEM tcItem;
- tcItem.mask = TCIF_TEXT | TCIF_IMAGE;
- tcItem.pszText = (char *)strText.c_str();
- tcItem.iImage = imageId;
+ tcItem.mask = 0;
+
+ if (imageId != -1)
+ {
+ tcItem.mask |= TCIF_IMAGE;
+ tcItem.iImage = imageId;
+ }
+ else
+ tcItem.iImage = 0;
+
+ if (!strText.IsEmpty())
+ {
+ tcItem.mask |= TCIF_TEXT;
+ tcItem.pszText = (char *)strText.c_str();
+ }
+ else
+ tcItem.pszText = (char *) NULL;
if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 ) {
wxLogError("Can't create the notebook page '%s'.", strText.c_str());
void wxNotebook::OnSize(wxSizeEvent& event)
{
- // emulate page change (it's esp. important to do it first time because
- // otherwise our page would stay invisible)
- int nSel = m_nSelection;
- m_nSelection = -1;
- SetSelection(nSel);
+ // make sure the current page is shown and has focus (it's useful because all
+ // pages are created invisible initially)
+ if ( m_nSelection != -1 ) {
+ wxNotebookPage *pPage = m_aPages[m_nSelection];
+ pPage->Show(TRUE);
+ pPage->SetFocus();
+ }
// fit the notebook page to the tab control's display area
RECT rc;
wxFAIL_MSG("wxNotebook::Command not implemented");
}
-bool wxNotebook::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM* result)
+bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
{
wxNotebookEvent event(wxEVT_NULL, m_windowId);
break;
default:
- return wxControl::MSWNotify(wParam, lParam, result);
+ return wxControl::MSWOnNotify(idCtrl, lParam, result);
}
event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
event.SetOldSelection(m_nSelection);
event.SetEventObject(this);
- event.SetInt(LOWORD(wParam)); // ctrl id
+ event.SetInt(idCtrl);
bool processed = GetEventHandler()->ProcessEvent(event);
*result = !event.IsAllowed();
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));
+}
+