BEGIN_EVENT_TABLE(wxNotebook, wxControl)
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
- EVT_SIZE(wxNotebook::OnSize)
- EVT_ERASE_BACKGROUND(wxNotebook::OnEraseBackground)
+ // doesn't work yet EVT_WINDOW_CREATE(wxNotebook::OnWindowCreate)
+ EVT_SIZE(wxNotebook::OnWindowCreate)
+
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 )
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
// ----------------------------------------------------------------------------
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;
}
// wxNotebook callbacks
// ----------------------------------------------------------------------------
-void wxNotebook::OnSize(wxSizeEvent& event)
+void wxNotebook::OnWindowCreate(wxWindowCreateEvent& event)
{
// make sure the current page is shown and has focus (it's useful because all
// pages are created invisible initially)
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));
-}
-