/** * @file XTPGaugeMeterType.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #if !defined(__XTPGAUGEMETERTYPE_H__) # define __XTPGAUGEMETERTYPE_H__ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * Implements a Meter gauge type. This kind of gauges is supposed to reflect a potentially * unlimited number of numeric values in the specified value range. A clock or a numeric * display are simple examples of the meter gauges. Gauges of this type must have an initial * value set to a valid value within the given range. The currently reflected value can be * updated from both a user code and by the gauge itself in reaction to a certain user input or * time events. * * @see CXTPGaugeBaseType * @see CXTPGaugeStateType * @see CXTPGaugeCtrl */ class _XTP_EXT_CLASS CXTPGaugeMeterType : public CXTPGaugeBaseType { DECLARE_DYNCREATE(CXTPGaugeMeterType); private: CXTPGaugeMeterType(); public: /** * @brief * Handles meter gauge type destruction */ ~CXTPGaugeMeterType(); /** * @brief * Obtains implementation specified type name. * * @returns Type name string point. */ virtual LPCWSTR GetTypeName() const; /** * @brief * Gets the minimum acceptable value in the value range. * * @returns The current minimum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows * having all or selected dimensions to reflect a single global value in different * ways. The global value cannot be unset. * @see SetMin * @see UnsetMin */ double GetMin() const; /** * @brief * Gets the minimum acceptable value in the value range. * * @param nDimension Dimension index to get the value for. UINT_MAX is assumed by * default and can be used to access global value. * @returns The current minimum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows * having all or selected dimensions to reflect a single global value in different * ways. The global value cannot be unset. * @see SetMin * @see UnsetMin */ double GetMin(UINT nDimension) const; /** * @brief * Sets the minimum acceptable value in the value range. * * @param dValue New minimum value in the value range. * @returns The current minimum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows * having all or selected dimensions to reflect a single global value in different * ways. The global value cannot be unset. Returns TRUE if the new value * is different from the old one, thus the actual value change happened. * @see GetMin * @see UnsetMin */ BOOL SetMin(double dValue); /** * @brief * Sets the minimum acceptable value in the value range. * * @param dValue New minimum value in the value range. * @param nDimension Dimension index to set the value for. UINT_MAX is assumed by * default and can be used to access global value. * @returns The current minimum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows * having all or selected dimensions to reflect a single global value in different * ways. The global value cannot be unset. Returns TRUE if the new value * is different from the old one, thus the actual value change happened. * @see GetMin * @see UnsetMin */ BOOL SetMin(UINT nDimension, double dValue); /** * @brief * Clears the minimum acceptable value in the value range. * * @param nDimension Dimension index to set the value for. UINT_MAX is assumed by * default and can be used to access global value. * @returns The current minimum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows * having all or selected dimensions to reflect a single global value in different * ways. The global value cannot be unset. Returns TRUE if the new value * is different from the old one, thus the actual value change happened. * @see GetMin * @see SetMin */ BOOL UnsetMin(UINT nDimension); /** * @brief * Gets the maximum acceptable value in the value range. * * @returns The current maximum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows having all * or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. * @see SetMax * @see UnsetMax */ double GetMax() const; /** * @brief * Gets the maximum acceptable value in the value range. * * @param nDimension Dimension index to get the value for. UINT_MAX is assumed by * default and can be used to access global value. * * @returns The current maximum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows having all * or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. * @see SetMax * @see UnsetMax */ double GetMax(UINT nDimension) const; /** * @brief * Sets the maximum acceptable value in the value range. * * @param dValue New maximum value in the value range. * * @returns The current maximum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows having all * or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. Return TRUE if the new value is different from the old * one, thus the actual value change happened. * @see GetMax * @see UnsetMax */ BOOL SetMax(double dValue); /** * @brief * Sets the maximum acceptable value in the value range. * * @param dValue New maximum value in the value range. * @param nDimension Dimension index to set the value for. UINT_MAX is assumed by * default and can be used to access global value. * * @returns The current maximum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows having all * or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. Return TRUE if the new value is different from the old * one, thus the actual value change happened. * @see GetMax * @see UnsetMax */ BOOL SetMax(UINT nDimension, double dValue); /** * @brief * Clears the maximum acceptable value in the value range. * * @param nDimension Dimension index to set the value for. UINT_MAX is assumed by * default and can be used to access global value. * * @returns The current maximum value in the value range. If a dimension specific value is * unset then the respective global value is used for that dimension. This allows having all * or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. Return TRUE if the new value is different from the old * one, thus the actual value change happened. * @see GetMax * @see SetMax */ BOOL UnsetMax(UINT nDimension); /** * @brief * Gets the currently reflected value. * * @returns The currently reflected value in the value range. If a dimension specific value * is unset then the respective global value is used for that dimension. This allows having * all or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. * @see SetCurrent * @see UnsetCurrent */ double GetCurrent() const; /** * @brief * Gets the currently reflected value. * * @param nDimension Dimension index to get the value for. UINT_MAX is assumed by * default and can be used to access global value. * @returns The currently reflected value in the value range. If a dimension specific value * is unset then the respective global value is used for that dimension. This allows having * all or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. * @see SetCurrent * @see UnsetCurrent */ double GetCurrent(UINT nDimension) const; /** * @brief * Sets/clears the currently reflected value. * * @param dValue New currently reflected value in the value range. If the value provided * does not fit the current value range then it will be automatically * adjusted to the closest acceptable value. * @returns The currently reflected value in the value range. If a dimension specific value * is unset then the respective global value is used for that dimension. This allows having * all or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. Returns TRUE if the new value is different from the old * one, thus the actual value change happened. * @see GetCurrent * @see UnsetCurrent */ BOOL SetCurrent(double dValue); /** * @brief * Sets/clears the currently reflected value. * * @param dValue New currently reflected value in the value range. If the value provided * does not fit the current value range then it will be automatically * adjusted to the closest acceptable value. * @param nDimension Dimension index to set the value for. UINT_MAX is assumed by * default and can be used to access global value. * @returns The currently reflected value in the value range. If a dimension specific value * is unset then the respective global value is used for that dimension. This allows having * all or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. Returns TRUE if the new value is different from the old * one, thus the actual value change happened. * @see GetCurrent * @see UnsetCurrent */ BOOL SetCurrent(UINT nDimension, double dValue); /** * @brief * Clears the currently reflected value. * * @param nDimension Dimension index to set the value for. UINT_MAX is assumed by * default and can be used to access global value. * @returns The currently reflected value in the value range. If a dimension specific value * is unset then the respective global value is used for that dimension. This allows having * all or selected dimensions to reflect a single global value in different ways. The global * value cannot be unset. Returns TRUE if the new value is different from the old * one, thus the actual value change happened. * @see GetCurrent * @see SetCurrent */ BOOL UnsetCurrent(UINT nDimension); /** * @brief * Obtains the number of available dimensions. * * @returns The number of available dimensions. */ UINT GetDimensionCount() const; protected: /** @cond */ virtual void OnInit(); /** @endcond */ private: struct DimensionData { DimensionData(); double dMin; double dMax; double dCurrent; }; DimensionData* GetDimData(UINT nDim); const DimensionData* GetDimData(UINT nDim) const; static CString FormatJPath(UINT nDim, LPCTSTR pRelJPath); private: static const double m_dNan; CMap m_DimData; UINT m_nDimCount; }; AFX_INLINE double CXTPGaugeMeterType::GetMin() const { return GetMin(UINT_MAX); } AFX_INLINE BOOL CXTPGaugeMeterType::SetMin(double dValue) { return SetMin(UINT_MAX, dValue); } AFX_INLINE BOOL CXTPGaugeMeterType::UnsetMin(UINT nDimension) { return SetMin(nDimension, m_dNan); } AFX_INLINE double CXTPGaugeMeterType::GetMax() const { return GetMax(UINT_MAX); } AFX_INLINE BOOL CXTPGaugeMeterType::SetMax(double dValue) { return SetMax(UINT_MAX, dValue); } AFX_INLINE BOOL CXTPGaugeMeterType::UnsetMax(UINT nDimension) { return SetMax(nDimension, m_dNan); } AFX_INLINE double CXTPGaugeMeterType::GetCurrent() const { return GetCurrent(UINT_MAX); } AFX_INLINE BOOL CXTPGaugeMeterType::SetCurrent(double dValue) { return SetCurrent(UINT_MAX, dValue); } AFX_INLINE BOOL CXTPGaugeMeterType::UnsetCurrent(UINT nDimension) { return SetCurrent(nDimension, m_dNan); } AFX_INLINE const CXTPGaugeMeterType::DimensionData* CXTPGaugeMeterType::GetDimData(UINT nDim) const { return const_cast(this)->GetDimData(nDim); } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(__XTPGAUGEMETERTYPE_H__)