X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8ecd5de22748b434c085a3c2af8a57fc95607231..8e5ec129614e2473fd240f2a6e94ee56e3a9039b:/src/msw/notebook.cpp diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 3d4f37f452..f34fcbc97b 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -18,30 +18,30 @@ #if wxUSE_NOTEBOOK -// wxWidgets +#include "wx/notebook.h" + #ifndef WX_PRECOMP - #include "wx/string.h" - #include "wx/dc.h" + #include "wx/string.h" + #include "wx/dc.h" + #include "wx/log.h" + #include "wx/event.h" + #include "wx/app.h" + #include "wx/dcclient.h" + #include "wx/dcmemory.h" + #include "wx/control.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/app.h" #include "wx/sysopt.h" -#include "wx/dcclient.h" -#include "wx/dcmemory.h" #include "wx/msw/private.h" #include - -#include - #include "wx/msw/winundef.h" +// include "properly" +#include "wx/msw/wrapcctl.h" + #if wxUSE_UXTHEME #include "wx/msw/uxtheme.h" #endif @@ -268,6 +268,15 @@ bool wxNotebook::Create(wxWindow *parent, long style, const wxString& name) { + if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT ) + { +#if defined(__POCKETPC__) + style |= wxBK_BOTTOM | wxNB_FLAT; +#else + style |= wxBK_TOP; +#endif + } + #ifdef __WXWINCE__ // Not sure why, but without this style, there is no border // around the notebook tabs. @@ -275,19 +284,16 @@ bool wxNotebook::Create(wxWindow *parent, style |= wxBORDER_SUNKEN; #endif - // comctl32.dll 6.0 doesn't support non-top tabs with visual styles (the - // control is simply not rendered correctly), so disable them in this case +#if !wxUSE_UXTHEME + // ComCtl32 notebook tabs simply don't work unless they're on top if we have uxtheme, we can + // work around it later (after control creation), but if we don't have uxtheme, we have to clear + // those styles const int verComCtl32 = wxApp::GetComCtl32Version(); if ( verComCtl32 == 600 ) { - // check if we use themes at all -- if we don't, we're still ok -#if wxUSE_UXTHEME - if ( wxUxThemeEngine::GetIfActive() ) -#endif - { - style &= ~(wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT); - } + style &= ~(wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT); } +#endif //wxUSE_UXTHEME LPCTSTR className = WC_TABCONTROL; @@ -348,6 +354,22 @@ bool wxNotebook::Create(wxWindow *parent, // create backing store UpdateBgBrush(); } + + // comctl32.dll 6.0 doesn't support non-top tabs with visual styles (the + // control is simply not rendered correctly), so we disable themes + // if possible, otherwise we simply clear the styles. + // It's probably not possible to have UXTHEME without ComCtl32 6 or better, but lets + // check it anyway. + const int verComCtl32 = wxApp::GetComCtl32Version(); + if ( verComCtl32 == 600 ) + { + // check if we use themes at all -- if we don't, we're still okay + if ( wxUxThemeEngine::GetIfActive() && (style & (wxBK_BOTTOM|wxBK_LEFT|wxBK_RIGHT))) + { + wxUxThemeEngine::GetIfActive()->SetWindowTheme((HWND)this->GetHandle(), L"", L""); + SetBackgroundColour(GetThemeBackgroundColour()); //correct the background color for the new non-themed control + } + } #endif // wxUSE_UXTHEME // Undocumented hack to get flat notebook style @@ -450,7 +472,22 @@ bool wxNotebook::SetPageText(size_t nPage, const wxString& strText) tcItem.mask = TCIF_TEXT; tcItem.pszText = (wxChar *)strText.c_str(); - return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; + if ( !HasFlag(wxNB_MULTILINE) ) + return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; + + // multiline - we need to set new page size if a line is added or removed + int rows = GetRowCount(); + bool ret = TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; + + if ( ret && rows != GetRowCount() ) + { + const wxRect r = GetPageSize(); + const size_t count = m_pages.Count(); + for ( size_t page = 0; page < count; page++ ) + m_pages[page]->SetSize(r); + } + + return ret; } wxString wxNotebook::GetPageText(size_t nPage) const @@ -781,6 +818,8 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const *flags |= wxNB_HITTEST_ONICON; if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL) *flags |= wxNB_HITTEST_ONLABEL; + if ( item == wxNOT_FOUND && GetPageSize().Inside(pt) ) + *flags |= wxNB_HITTEST_ONPAGE; } return item; @@ -829,7 +868,11 @@ void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event)) memdc.SelectObject(bmp); // if there is no special brush just use the solid background colour +#if wxUSE_UXTHEME HBRUSH hbr = (HBRUSH)m_hbrBackground; +#else + HBRUSH hbr = 0; +#endif wxBrush brush; if ( !hbr ) {