// event table
// ----------------------------------------------------------------------------
-#include <wx/listimpl.cpp>
+#include "wx/listimpl.cpp"
WX_DEFINE_LIST( wxNotebookPageInfoList )
DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
- EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
+ EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
EVT_SIZE(wxNotebook::OnSize)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
// common part of all ctors
void wxNotebook::Init()
{
- m_imageList = NULL;
- m_nSelection = -1;
+ m_imageList = NULL;
+ m_nSelection = -1;
#if wxUSE_UXTHEME
- m_hbrBackground = NULL;
+ m_hbrBackground = NULL;
#endif // wxUSE_UXTHEME
#if USE_NOTEBOOK_ANTIFLICKER
- m_hasSubclassedUpdown = false;
+ m_hasSubclassedUpdown = false;
#endif // USE_NOTEBOOK_ANTIFLICKER
}
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;
// 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
size_t wxNotebook::GetPageCount() const
{
- // consistency check
- wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(GetHwnd()) );
+ // consistency check
+ wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(GetHwnd()) );
- return m_pages.Count();
+ return m_pages.Count();
}
int wxNotebook::GetRowCount() const
{
- return TabCtrl_GetRowCount(GetHwnd());
+ return TabCtrl_GetRowCount(GetHwnd());
}
int wxNotebook::SetSelection(size_t nPage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
- if ( int(nPage) != m_nSelection )
- {
- wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
- event.SetSelection(nPage);
- event.SetOldSelection(m_nSelection);
- event.SetEventObject(this);
- if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
+ if ( int(nPage) != m_nSelection )
{
- // program allows the page change
- event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
- (void)GetEventHandler()->ProcessEvent(event);
+ wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
+ event.SetSelection(nPage);
+ event.SetOldSelection(m_nSelection);
+ event.SetEventObject(this);
+ if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
+ {
+ // program allows the page change
+ event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
+ (void)GetEventHandler()->ProcessEvent(event);
- TabCtrl_SetCurSel(GetHwnd(), nPage);
+ TabCtrl_SetCurSel(GetHwnd(), nPage);
+ }
}
- }
- return m_nSelection;
+ return m_nSelection;
}
bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("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;
+ tcItem.pszText = (wxChar *)strText.c_str();
+
+ 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;
- TC_ITEM tcItem;
- tcItem.mask = TCIF_TEXT;
- tcItem.pszText = (wxChar *)strText.c_str();
+ 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 TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0;
+ return ret;
}
wxString wxNotebook::GetPageText(size_t nPage) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") );
- wxChar buf[256];
- TC_ITEM tcItem;
- tcItem.mask = TCIF_TEXT;
- tcItem.pszText = buf;
- tcItem.cchTextMax = WXSIZEOF(buf);
+ wxChar buf[256];
+ TC_ITEM tcItem;
+ tcItem.mask = TCIF_TEXT;
+ tcItem.pszText = buf;
+ tcItem.cchTextMax = WXSIZEOF(buf);
- wxString str;
- if ( TabCtrl_GetItem(GetHwnd(), nPage, &tcItem) )
- str = tcItem.pszText;
+ wxString str;
+ if ( TabCtrl_GetItem(GetHwnd(), nPage, &tcItem) )
+ str = tcItem.pszText;
- return str;
+ return str;
}
int wxNotebook::GetPageImage(size_t nPage) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
- TC_ITEM tcItem;
- tcItem.mask = TCIF_IMAGE;
+ TC_ITEM tcItem;
+ tcItem.mask = TCIF_IMAGE;
- return TabCtrl_GetItem(GetHwnd(), nPage, &tcItem) ? tcItem.iImage : -1;
+ return TabCtrl_GetItem(GetHwnd(), nPage, &tcItem) ? tcItem.iImage : wxNOT_FOUND;
}
bool wxNotebook::SetPageImage(size_t nPage, int nImage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("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;
- tcItem.iImage = nImage;
+ TC_ITEM tcItem;
+ tcItem.mask = TCIF_IMAGE;
+ tcItem.iImage = nImage;
- return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0;
+ return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0;
}
void wxNotebook::SetImageList(wxImageList* imageList)
{
- wxNotebookBase::SetImageList(imageList);
+ wxNotebookBase::SetImageList(imageList);
- if ( imageList )
- {
- TabCtrl_SetImageList(GetHwnd(), (HIMAGELIST)imageList->GetHIMAGELIST());
- }
+ if ( imageList )
+ {
+ (void) TabCtrl_SetImageList(GetHwnd(), (HIMAGELIST)imageList->GetHIMAGELIST());
+ }
}
// ----------------------------------------------------------------------------
// remove all pages
bool wxNotebook::DeleteAllPages()
{
- size_t nPageCount = GetPageCount();
- size_t nPage;
- for ( nPage = 0; nPage < nPageCount; nPage++ )
- delete m_pages[nPage];
+ size_t nPageCount = GetPageCount();
+ size_t nPage;
+ for ( nPage = 0; nPage < nPageCount; nPage++ )
+ delete m_pages[nPage];
- m_pages.Clear();
+ m_pages.Clear();
- TabCtrl_DeleteAllItems(GetHwnd());
+ TabCtrl_DeleteAllItems(GetHwnd());
- m_nSelection = -1;
+ m_nSelection = -1;
- InvalidateBestSize();
- return true;
+ InvalidateBestSize();
+ return true;
}
// same as AddPage() but does it at given position
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 )
{