// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "notebook.h"
#endif
// event table
// ----------------------------------------------------------------------------
+#include <wx/listimpl.cpp>
+
+WX_DEFINE_LIST( wxNotebookPageInfoList ) ;
+
DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
END_EVENT_TABLE()
+#if wxUSE_EXTENDED_RTTI
+
+IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook, wxControl,"wx/notebook.h")
+IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo, wxObject , "wx/notebook.h" )
+
+template<> const wxTypeInfo* wxGetTypeInfo( wxNotebookPageInfoList * )
+{
+ static wxCollectionTypeInfo s_typeInfo( (wxTypeInfo*) wxGetTypeInfo( (wxNotebookPageInfo **) NULL) ) ;
+ return &s_typeInfo ;
+}
+
+WX_BEGIN_PROPERTIES_TABLE(wxNotebook)
+ WX_PROPERTY_COLLECTION( PageInfos , wxNotebookPageInfoList , wxNotebookPageInfo* , AddPageInfo , GetPageInfos )
+/*
+ notebookpage
+ object
+ object_ref
+ label
+ selected
+ style
+ usenotebooksizer
+*/
+WX_END_PROPERTIES_TABLE()
+
+WX_BEGIN_HANDLERS_TABLE(wxNotebook)
+WX_END_HANDLERS_TABLE()
+
+WX_CONSTRUCTOR_4( wxNotebook , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size )
+
+
+WX_BEGIN_PROPERTIES_TABLE(wxNotebookPageInfo)
+ WX_READONLY_PROPERTY( Page , wxNotebookPage* , GetPage , )
+ WX_READONLY_PROPERTY( Text , wxString , GetText , wxEmptyString )
+ WX_READONLY_PROPERTY( Selected , bool , GetSelected , false )
+ WX_READONLY_PROPERTY( ImageId , int , GetImageId , -1 )
+WX_END_PROPERTIES_TABLE()
+
+WX_BEGIN_HANDLERS_TABLE(wxNotebookPageInfo)
+WX_END_HANDLERS_TABLE()
+
+WX_CONSTRUCTOR_4( wxNotebookPageInfo , wxNotebookPage* , Page , wxString , Text , bool , Selected , int , ImageId )
+
+#else
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo, wxObject )
+#endif
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
// ============================================================================
// wxNotebook construction
// ----------------------------------------------------------------------------
+const wxNotebookPageInfoList& wxNotebook::GetPageInfos() const
+{
+ wxNotebookPageInfoList* list = const_cast< wxNotebookPageInfoList* >( &m_pageInfos ) ;
+ WX_CLEAR_LIST( wxNotebookPageInfoList , *list ) ;
+ for( int i = 0 ; i < GetPageCount() ; ++i )
+ {
+ wxNotebookPageInfo *info = new wxNotebookPageInfo() ;
+ info->Create( const_cast<wxNotebook*>(this)->GetPage(i) , GetPageText(i) , GetSelection() == i , GetPageImage(i) ) ;
+ list->Append( info ) ;
+ }
+ return m_pageInfos ;
+}
+
// common part of all ctors
void wxNotebook::Init()
{
wxDefaultValidator, name) )
return FALSE;
- if ( !MSWCreateControl(WC_TABCONTROL, _T(""), pos, size) )
+ if ( !MSWCreateControl(WC_TABCONTROL, wxEmptyString, pos, size) )
return FALSE;
SetBackgroundColour(wxColour(::GetSysColor(COLOR_BTNFACE)));
wxString wxNotebook::GetPageText(int nPage) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), 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;
// for some unknown reason if the tab control shows the up-down
// control (i.e. when there are too many pages) -- otherwise after
// deleting a page nothing at all is shown
- m_pages[m_nSelection]->Refresh();
+ if (m_nSelection >= 0)
+ m_pages[m_nSelection]->Refresh();
}
if ( selNew != -1 )
_T("notebook pages must have notebook as parent") );
#if wxUSE_UXTHEME && wxUSE_UXTHEME_AUTO
+ static bool g_TestedForTheme = FALSE;
+ static bool g_UseTheme = FALSE;
+ if (!g_TestedForTheme)
+ {
+ int commCtrlVersion = wxTheApp->GetComCtl32Version() ;
+
+ g_UseTheme = (commCtrlVersion >= 600);
+ g_TestedForTheme = TRUE;
+ }
+
// Automatically apply the theme background,
// changing the colour of the panel to match the
// tab page colour. This won't work well with all
// themes but it's a start.
- if (wxUxThemeEngine::Get() && pPage->IsKindOf(CLASSINFO(wxPanel)))
+ if (g_UseTheme && wxUxThemeEngine::Get() && pPage->IsKindOf(CLASSINFO(wxPanel)))
{
ApplyThemeBackground(pPage, GetThemeBackgroundColour());
}
return TRUE;
}
-// Hit test
-int wxNotebook::HitTest(const wxPoint& pt, long& flags)
+int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
{
TC_HITTESTINFO hitTestInfo;
hitTestInfo.pt.x = pt.x;
hitTestInfo.pt.y = pt.y;
- int item = TabCtrl_HitTest( (HWND) GetHWND(), & hitTestInfo ) ;
- flags = 0;
+ int item = TabCtrl_HitTest(GetHwnd(), &hitTestInfo);
- if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE)
- flags |= wxNB_HITTEST_NOWHERE;
- if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON)
- flags |= wxNB_HITTEST_ONICON;
- if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL)
- flags |= wxNB_HITTEST_ONLABEL;
+ if ( flags )
+ {
+ *flags = 0;
+
+ if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE)
+ *flags |= wxNB_HITTEST_NOWHERE;
+ if ((hitTestInfo.flags & TCHT_ONITEM) == TCHT_ONITEM)
+ *flags |= wxNB_HITTEST_ONITEM;
+ if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON)
+ *flags |= wxNB_HITTEST_ONICON;
+ if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL)
+ *flags |= wxNB_HITTEST_ONLABEL;
+ }
return item;
}
+
// ----------------------------------------------------------------------------
// wxNotebook callbacks
// ----------------------------------------------------------------------------
// OnSetFocus() because we don't know which direction the focus came
// from in this case and so can't choose between setting the focus to
// first or last panel child
-
wxWindow *parent = GetParent();
- if ( event.GetEventObject() == parent )
+ // the cast is here to fic a GCC ICE
+ if ( ((wxWindow*)event.GetEventObject()) == parent )
{
// no, it doesn't come from child, case (b): forward to a page
if ( m_nSelection != -1 )
#if wxUSE_UXTHEME
if (wxUxThemeEngine::Get())
{
- WXHTHEME hTheme = wxUxThemeEngine::Get()->m_pfnOpenThemeData(GetHWND(), L"TAB");
+ wxUxThemeHandle hTheme(this, L"TAB");
if (hTheme)
{
// This is total guesswork.
// See PlatformSDK\Include\Tmschema.h for values
COLORREF themeColor;
- wxUxThemeEngine::Get()->
- m_pfnGetThemeColor(hTheme,
- 10 /* TABP_BODY */,
- 1 /* NORMAL */,
- 3821, /* FILLCOLORHINT */
- & themeColor);
-
- wxUxThemeEngine::Get()->m_pfnCloseThemeData(hTheme);
+ wxUxThemeEngine::Get()->GetThemeColor
+ (
+ hTheme,
+ 10 /* TABP_BODY */,
+ 1 /* NORMAL */,
+ 3821, /* FILLCOLORHINT */
+ & themeColor
+ );
wxColour colour(GetRValue(themeColor), GetGValue(themeColor), GetBValue(themeColor));
return colour;
}
}
-#endif
+#endif // wxUSE_UXTHEME
+
return GetBackgroundColour();
}
// Windows only: attempts to apply the UX theme page background to this page
+#if wxUSE_UXTHEME
void wxNotebook::ApplyThemeBackground(wxWindow* window, const wxColour& colour)
+#else
+void wxNotebook::ApplyThemeBackground(wxWindow*, const wxColour&)
+#endif
{
#if wxUSE_UXTHEME
// Don't set the background for buttons since this will
window->SetBackgroundColour(colour);
}
- for ( wxWindowList::Node *node = window->GetChildren().GetFirst(); node; node = node->GetNext() )
+ for ( wxWindowList::compatibility_iterator node = window->GetChildren().GetFirst(); node; node = node->GetNext() )
{
wxWindow *child = node->GetData();
ApplyThemeBackground(child, colour);
#endif
}
+long wxNotebook::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+ static bool g_TestedForTheme = FALSE;
+ static bool g_UseTheme = FALSE;
+ switch ( nMsg )
+ {
+ case WM_ERASEBKGND:
+ {
+ if (!g_TestedForTheme)
+ {
+ int commCtrlVersion = wxTheApp->GetComCtl32Version() ;
+
+ g_UseTheme = (commCtrlVersion >= 600);
+ g_TestedForTheme = TRUE;
+ }
+
+ // If using XP themes, it seems we can get away
+ // with not drawing a background, which reduces flicker.
+ if (g_UseTheme)
+ return TRUE;
+ }
+ }
+
+ return wxControl::MSWWindowProc(nMsg, wParam, lParam);
+}
+
+
#endif // wxUSE_NOTEBOOK