Author: anevilyak Date: 2011-11-01 22:10:24 +0100 (Tue, 01 Nov 2011) New Revision: 43081 Changeset: https://dev.haiku-os.org/changeset/43081 Modified: haiku/trunk/src/apps/debugger/settings/generic/Setting.cpp haiku/trunk/src/apps/debugger/settings/generic/Setting.h Log: Extend the generic Settings classes to support float and rect settings. Modified: haiku/trunk/src/apps/debugger/settings/generic/Setting.cpp =================================================================== --- haiku/trunk/src/apps/debugger/settings/generic/Setting.cpp 2011-11-01 20:57:31 UTC (rev 43080) +++ haiku/trunk/src/apps/debugger/settings/generic/Setting.cpp 2011-11-01 21:10:24 UTC (rev 43081) @@ -34,6 +34,23 @@ } +// #pragma mark - FloatSetting + + +setting_type +FloatSetting::Type() const +{ + return SETTING_TYPE_FLOAT; +} + + +BVariant +FloatSetting::DefaultValue() const +{ + return DefaultFloatValue(); +} + + // #pragma mark - SettingsOption @@ -71,6 +88,22 @@ } +// #pragma mark - RectSetting + +setting_type +RectSetting::Type() const +{ + return SETTING_TYPE_RECT; +} + + +BVariant +RectSetting::DefaultValue() const +{ + return DefaultRectValue(); +} + + // #pragma mark - AbstractSetting @@ -115,6 +148,25 @@ } +// #pragma mark - FloatSettingImpl + + +FloatSettingImpl::FloatSettingImpl(const BString& id, const BString& name, + float defaultValue) + : + AbstractSetting(id, name), + fDefaultValue(defaultValue) +{ +} + + +float +FloatSettingImpl::DefaultFloatValue() const +{ + return fDefaultValue; +} + + // #pragma mark - OptionsSettingImpl @@ -263,3 +315,22 @@ { return fUpperBound; } + + +// #pragma mark - RectSettingImpl + + +RectSettingImpl::RectSettingImpl(const BString& id, const BString& name, + const BRect& defaultValue) + : + AbstractSetting(id, name), + fDefaultValue(defaultValue) +{ +} + + +BRect +RectSettingImpl::DefaultRectValue() const +{ + return fDefaultValue; +} Modified: haiku/trunk/src/apps/debugger/settings/generic/Setting.h =================================================================== --- haiku/trunk/src/apps/debugger/settings/generic/Setting.h 2011-11-01 20:57:31 UTC (rev 43080) +++ haiku/trunk/src/apps/debugger/settings/generic/Setting.h 2011-11-01 21:10:24 UTC (rev 43081) @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxxx + * Copyright 2011, Rene Gollent, rene@xxxxxxxxxxxx * Distributed under the terms of the MIT License. */ #ifndef SETTING_H @@ -15,8 +16,10 @@ enum setting_type { SETTING_TYPE_BOOL, + SETTING_TYPE_FLOAT, SETTING_TYPE_OPTIONS, - SETTING_TYPE_RANGE + SETTING_TYPE_RANGE, + SETTING_TYPE_RECT }; @@ -42,6 +45,16 @@ }; +class FloatSetting : public virtual Setting { +public: + virtual setting_type Type() const; + + virtual BVariant DefaultValue() const; + + virtual float DefaultFloatValue() const = 0; +}; + + class SettingsOption : public BReferenceable { public: virtual ~SettingsOption(); @@ -74,6 +87,16 @@ }; +class RectSetting : public virtual Setting { +public: + virtual setting_type Type() const; + + virtual BVariant DefaultValue() const; + + virtual BRect DefaultRectValue() const = 0; +}; + + class AbstractSetting : public virtual Setting { public: AbstractSetting(const BString& id, @@ -100,6 +123,18 @@ }; +class FloatSettingImpl : public AbstractSetting, public FloatSetting { +public: + FloatSettingImpl(const BString& id, + const BString& name, float defaultValue); + + virtual float DefaultFloatValue() const; + +private: + float fDefaultValue; +}; + + class OptionsSettingImpl : public AbstractSetting, public OptionsSetting { public: OptionsSettingImpl(const BString& id, @@ -149,4 +184,17 @@ }; +class RectSettingImpl : public AbstractSetting, public RectSetting { +public: + RectSettingImpl(const BString& id, + const BString& name, + const BRect& defaultValue); + + virtual BRect DefaultRectValue() const; + +private: + BRect fDefaultValue; +}; + + #endif // SETTING_H