1fb07ece0SStephan Aßmus /* 2325a6253SAxel Dörfler * Copyright 2006-2007, Haiku. 3fb07ece0SStephan Aßmus * Distributed under the terms of the MIT License. 4fb07ece0SStephan Aßmus * 5fb07ece0SStephan Aßmus * Authors: 6fb07ece0SStephan Aßmus * Stephan Aßmus <superstippi@gmx.de> 7fb07ece0SStephan Aßmus */ 8fb07ece0SStephan Aßmus #ifndef STYLE_H 9fb07ece0SStephan Aßmus #define STYLE_H 10fb07ece0SStephan Aßmus 11fb07ece0SStephan Aßmus 12fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 13fb07ece0SStephan Aßmus # include "IconObject.h" 14fb07ece0SStephan Aßmus # include "Observer.h" 15fb07ece0SStephan Aßmus #endif 16fb07ece0SStephan Aßmus 17fb07ece0SStephan Aßmus #include "IconRenderer.h" 18fb07ece0SStephan Aßmus // TODO: put GammaTable into its own file 19fb07ece0SStephan Aßmus 20325a6253SAxel Dörfler #include <GraphicsDefs.h> 21325a6253SAxel Dörfler 22325a6253SAxel Dörfler #include <agg_color_rgba.h> 23325a6253SAxel Dörfler 24325a6253SAxel Dörfler 25*8b8d44bfSMichael Lotz class BMessage; 26*8b8d44bfSMichael Lotz 27325a6253SAxel Dörfler namespace BPrivate { 28325a6253SAxel Dörfler namespace Icon { 29325a6253SAxel Dörfler 30fb07ece0SStephan Aßmus class Gradient; 31fb07ece0SStephan Aßmus 32fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 33fb07ece0SStephan Aßmus class Style : public IconObject, 34fb07ece0SStephan Aßmus public Observer { 35fb07ece0SStephan Aßmus #else 36fb07ece0SStephan Aßmus class Style { 37fb07ece0SStephan Aßmus #endif 38fb07ece0SStephan Aßmus public: 39fb07ece0SStephan Aßmus Style(); 40fb07ece0SStephan Aßmus Style(const Style& other); 41fb07ece0SStephan Aßmus Style(const rgb_color& color); 42fb07ece0SStephan Aßmus Style(BMessage* archive); 43*8b8d44bfSMichael Lotz 44fb07ece0SStephan Aßmus virtual ~Style(); 45fb07ece0SStephan Aßmus 46fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 47fb07ece0SStephan Aßmus // Observer interface 48fb07ece0SStephan Aßmus virtual void ObjectChanged(const Observable* object); 49fb07ece0SStephan Aßmus 50fb07ece0SStephan Aßmus // Style 51fb07ece0SStephan Aßmus status_t Archive(BMessage* into, 52fb07ece0SStephan Aßmus bool deep = true) const; 536e3b3b09SStephan Aßmus 546e3b3b09SStephan Aßmus bool operator==(const Style& other) const; 55fb07ece0SStephan Aßmus #else 56fb07ece0SStephan Aßmus inline void Notify() {} 57fb07ece0SStephan Aßmus #endif // ICON_O_MATIC 58fb07ece0SStephan Aßmus 59112d6155SStephan Aßmus bool HasTransparency() const; 60112d6155SStephan Aßmus 61fb07ece0SStephan Aßmus void SetColor(const rgb_color& color); 62fb07ece0SStephan Aßmus inline rgb_color Color() const 63fb07ece0SStephan Aßmus { return fColor; } 64fb07ece0SStephan Aßmus 65325a6253SAxel Dörfler void SetGradient(const BPrivate::Icon::Gradient* 66325a6253SAxel Dörfler gradient); 67325a6253SAxel Dörfler BPrivate::Icon::Gradient* Gradient() const 68fb07ece0SStephan Aßmus { return fGradient; } 69fb07ece0SStephan Aßmus 70fb07ece0SStephan Aßmus const agg::rgba8* Colors() const 71fb07ece0SStephan Aßmus { return fColors; } 72fb07ece0SStephan Aßmus 73fb07ece0SStephan Aßmus const agg::rgba8* GammaCorrectedColors( 74fb07ece0SStephan Aßmus const GammaTable& table) const; 75fb07ece0SStephan Aßmus 76fb07ece0SStephan Aßmus private: 77fb07ece0SStephan Aßmus rgb_color fColor; 78325a6253SAxel Dörfler BPrivate::Icon::Gradient* fGradient; 79fb07ece0SStephan Aßmus 80fb07ece0SStephan Aßmus // hold gradient color array 81fb07ece0SStephan Aßmus agg::rgba8* fColors; 82fb07ece0SStephan Aßmus 83fb07ece0SStephan Aßmus // for caching gamma corrected gradient color array 84fb07ece0SStephan Aßmus mutable agg::rgba8* fGammaCorrectedColors; 85fb07ece0SStephan Aßmus mutable bool fGammaCorrectedColorsValid; 86fb07ece0SStephan Aßmus }; 87fb07ece0SStephan Aßmus 88325a6253SAxel Dörfler } // namespace Icon 89325a6253SAxel Dörfler } // namespace BPrivate 90325a6253SAxel Dörfler 91325a6253SAxel Dörfler using namespace BPrivate::Icon; 92325a6253SAxel Dörfler 93fb07ece0SStephan Aßmus #endif // STYLE_H 94