X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e421922f90186d0619a806d277a0a2182e61b5fb..c0b8a8b9cc0c2bfd56426c9a6b6c946ea1031c55:/src/msw/notebook.cpp diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index dc4f4d5d4c..36e50c706b 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -110,7 +110,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) // common part of all ctors void wxNotebook::Init() { - m_bOwnsImageList = FALSE; m_imageList = NULL; m_nSelection = -1; } @@ -142,67 +141,53 @@ bool wxNotebook::Create(wxWindow *parent, long style, const wxString& name) { - // base init - if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) - return FALSE; - - // colors and font - m_backgroundColour = wxColour(GetSysColor(COLOR_BTNFACE)); - m_foregroundColour = *wxBLACK; - - // style - m_windowStyle = style | wxTAB_TRAVERSAL; - - long tabStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | TCS_TABS; - - if ( m_windowStyle & wxCLIP_SIBLINGS ) - tabStyle |= WS_CLIPSIBLINGS; - 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 ; - if (m_windowStyle & wxNB_BOTTOM) - tabStyle |= TCS_RIGHT; - if (m_windowStyle & wxNB_LEFT) - 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, - tabStyle, NULL, 0) ) - { - return FALSE; - } + // base init + if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) + return FALSE; - // Not all compilers recognise SetWindowFont - ::SendMessage(GetHwnd(), WM_SETFONT, - (WPARAM)::GetStockObject(DEFAULT_GUI_FONT), TRUE); + // notebook, so explicitly specify 0 as last parameter + if ( !MSWCreateControl(WC_TABCONTROL, _T(""), pos, size, + style | wxTAB_TRAVERSAL) ) + return FALSE; + SetBackgroundColour(wxColour(::GetSysColor(COLOR_BTNFACE))); - if ( parent != NULL ) - parent->AddChild(this); - - SubclassWin(m_hWnd); - - return TRUE; + return TRUE; } -// dtor -wxNotebook::~wxNotebook() +WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const { - if (m_bOwnsImageList) - delete m_imageList; + WXDWORD tabStyle = wxControl::MSWGetStyle(style, exstyle); + + tabStyle |= WS_TABSTOP | TCS_TABS; + + if ( style & wxTC_MULTILINE ) + tabStyle |= TCS_MULTILINE; + if ( style & wxNB_FIXEDWIDTH ) + tabStyle |= TCS_FIXEDWIDTH; + + if ( style & wxNB_BOTTOM ) + tabStyle |= TCS_RIGHT; + else if ( style & wxNB_LEFT ) + tabStyle |= TCS_VERTICAL; + else if ( style & wxNB_RIGHT ) + tabStyle |= TCS_VERTICAL | TCS_RIGHT; + + // ex style + if ( exstyle ) + { + // note that we never want to have the default WS_EX_CLIENTEDGE style + // as it looks too ugly for the notebooks + *exstyle = 0; + } + + return tabStyle; } // ---------------------------------------------------------------------------- // wxNotebook accessors // ---------------------------------------------------------------------------- + int wxNotebook::GetPageCount() const { // consistency check @@ -276,21 +261,12 @@ bool wxNotebook::SetPageImage(int nPage, int nImage) void wxNotebook::SetImageList(wxImageList* imageList) { - if ( m_bOwnsImageList ) + wxNotebookBase::SetImageList(imageList); + + if ( imageList ) { - delete m_imageList; + TabCtrl_SetImageList(m_hwnd, (HIMAGELIST)imageList->GetHIMAGELIST()); } - - m_bOwnsImageList = FALSE; - m_imageList = imageList; - - TabCtrl_SetImageList(m_hwnd, (HIMAGELIST)imageList->GetHIMAGELIST()); -} - -void wxNotebook::AssignImageList(wxImageList* imageList) -{ - SetImageList(imageList); - m_bOwnsImageList = TRUE; } // ---------------------------------------------------------------------------- @@ -342,7 +318,7 @@ bool wxNotebook::DeletePage(int nPage) TabCtrl_DeleteItem(m_hwnd, nPage); delete m_pages[nPage]; - m_pages.Remove(nPage); + m_pages.RemoveAt(nPage); if ( m_pages.IsEmpty() ) { // no selection if the notebook became empty @@ -358,13 +334,12 @@ bool wxNotebook::DeletePage(int nPage) // remove one page from the notebook, without deleting wxNotebookPage *wxNotebook::DoRemovePage(int nPage) { - wxCHECK_MSG( IS_VALID_PAGE(nPage), NULL, wxT("notebook page out of range") ); + wxNotebookPage *pageRemoved = wxNotebookBase::DoRemovePage(nPage); + if ( !pageRemoved ) + return NULL; TabCtrl_DeleteItem(m_hwnd, nPage); - wxNotebookPage *pageRemoved = m_pages[nPage]; - m_pages.Remove(nPage); - if ( m_pages.IsEmpty() ) m_nSelection = -1; else @@ -606,6 +581,21 @@ bool wxNotebook::DoPhase(int WXUNUSED(nPhase)) return TRUE; } +// ---------------------------------------------------------------------------- +// wxNotebook Windows message handlers +// ---------------------------------------------------------------------------- + +bool wxNotebook::MSWOnScroll(int orientation, WXWORD nSBCode, + WXWORD pos, WXHWND control) +{ + // don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the + // up-down control + if ( control ) + return FALSE; + + return wxNotebookBase::MSWOnScroll(orientation, nSBCode, pos, control); +} + bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result) { wxNotebookEvent event(wxEVT_NULL, m_windowId);