/* ThemeMetric - Theme specific data. */ #ifndef THEME_METRIC_H #define THEME_METRIC_H #include "ThemeManager.h" class IThemeMetric { public: virtual ~IThemeMetric() { } virtual void Read() = 0; }; template class ThemeMetric : public IThemeMetric { private: CString m_sGroup; CString m_sName; T m_currentValue; public: /* Initializing with no group and name is allowed; if you do this, you must * call Load() to set them. This is done to allow initializing cached metrics * in one place for classes that don't receive their m_sName in the constructor * (everything except screens). */ ThemeMetric( const CString& sGroup = "", const CString& sName = "" ): m_sGroup( sGroup ), m_sName( sName ) { m_currentValue = T(); ThemeManager::Subscribe( this ); } ThemeMetric( const ThemeMetric &cpy ): IThemeMetric( cpy ), m_sGroup( cpy.m_sGroup ), m_sName( cpy.m_sName ), m_currentValue( cpy.m_currentValue ) { ThemeManager::Subscribe( this ); } ~ThemeMetric() { ThemeManager::Unsubscribe( this ); } void Load( const CString &sGroup, const CString& sName ) { m_sGroup = sGroup; m_sName = sName; Read(); } void ChangeGroup( const CString &sGroup ) { m_sGroup = sGroup; Read(); } void Read() { if( m_sName != "" && THEME && THEME->IsThemeLoaded() ) THEME->GetMetric( m_sGroup, m_sName, m_currentValue ); } const T& GetValue() const { ASSERT( m_sName != "" ); return m_currentValue; } operator const T& () const { return m_currentValue; } //Hacks for VC6 for all boolean operators. bool operator ! () const { return !m_currentValue; } bool operator && ( const T& input ) const { return m_currentValue && input; } bool operator || ( const T& input ) const { return m_currentValue || input; } bool operator == ( const T& input ) const { return m_currentValue == input; } }; typedef CString (*MetricName1D)(size_t N); template class ThemeMetric1D : public IThemeMetric { typedef ThemeMetric ThemeMetricT; vector m_metric; public: ThemeMetric1D( const CString& sGroup = "", MetricName1D pfn = NULL, size_t N = 0 ) { Load( sGroup, pfn, N ); } void Load( const CString& sGroup, MetricName1D pfn, size_t N ) { m_metric.resize( N ); for( unsigned i=0; i class ThemeMetric2D : public IThemeMetric { typedef ThemeMetric ThemeMetricT; typedef vector ThemeMetricTVector; vector m_metric; public: ThemeMetric2D( const CString& sGroup = "", MetricName2D pfn = NULL, size_t N = 0, size_t M = 0 ) { Load( sGroup, pfn, N, M ); } void Load( const CString& sGroup, MetricName2D pfn, size_t N, size_t M ) { m_metric.resize( N ); for( unsigned i=0; i