1fb07ece0SStephan Aßmus /* 2*325a6253SAxel 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 20*325a6253SAxel Dörfler #include <GraphicsDefs.h> 21*325a6253SAxel Dörfler 22*325a6253SAxel Dörfler #include <agg_color_rgba.h> 23*325a6253SAxel Dörfler 24*325a6253SAxel Dörfler 25*325a6253SAxel Dörfler namespace BPrivate { 26*325a6253SAxel Dörfler namespace Icon { 27*325a6253SAxel Dörfler 28fb07ece0SStephan Aßmus class Gradient; 29fb07ece0SStephan Aßmus 30fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 31fb07ece0SStephan Aßmus class Style : public IconObject, 32fb07ece0SStephan Aßmus public Observer { 33fb07ece0SStephan Aßmus #else 34fb07ece0SStephan Aßmus class Style { 35fb07ece0SStephan Aßmus #endif 36fb07ece0SStephan Aßmus public: 37fb07ece0SStephan Aßmus Style(); 38fb07ece0SStephan Aßmus Style(const Style& other); 39fb07ece0SStephan Aßmus Style(const rgb_color& color); 40fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 41fb07ece0SStephan Aßmus Style(BMessage* archive); 42fb07ece0SStephan Aßmus #endif 43fb07ece0SStephan Aßmus virtual ~Style(); 44fb07ece0SStephan Aßmus 45fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 46fb07ece0SStephan Aßmus // Observer interface 47fb07ece0SStephan Aßmus virtual void ObjectChanged(const Observable* object); 48fb07ece0SStephan Aßmus 49fb07ece0SStephan Aßmus // Style 50fb07ece0SStephan Aßmus status_t Archive(BMessage* into, 51fb07ece0SStephan Aßmus bool deep = true) const; 526e3b3b09SStephan Aßmus 536e3b3b09SStephan Aßmus bool operator==(const Style& other) const; 54fb07ece0SStephan Aßmus #else 55fb07ece0SStephan Aßmus inline void Notify() {} 56fb07ece0SStephan Aßmus #endif // ICON_O_MATIC 57fb07ece0SStephan Aßmus 58fb07ece0SStephan Aßmus void SetColor(const rgb_color& color); 59fb07ece0SStephan Aßmus inline rgb_color Color() const 60fb07ece0SStephan Aßmus { return fColor; } 61fb07ece0SStephan Aßmus 62*325a6253SAxel Dörfler void SetGradient(const BPrivate::Icon::Gradient* 63*325a6253SAxel Dörfler gradient); 64*325a6253SAxel Dörfler BPrivate::Icon::Gradient* Gradient() const 65fb07ece0SStephan Aßmus { return fGradient; } 66fb07ece0SStephan Aßmus 67fb07ece0SStephan Aßmus const agg::rgba8* Colors() const 68fb07ece0SStephan Aßmus { return fColors; } 69fb07ece0SStephan Aßmus 70fb07ece0SStephan Aßmus const agg::rgba8* GammaCorrectedColors( 71fb07ece0SStephan Aßmus const GammaTable& table) const; 72fb07ece0SStephan Aßmus 73fb07ece0SStephan Aßmus private: 74fb07ece0SStephan Aßmus rgb_color fColor; 75*325a6253SAxel Dörfler BPrivate::Icon::Gradient* fGradient; 76fb07ece0SStephan Aßmus 77fb07ece0SStephan Aßmus // hold gradient color array 78fb07ece0SStephan Aßmus agg::rgba8* fColors; 79fb07ece0SStephan Aßmus 80fb07ece0SStephan Aßmus // for caching gamma corrected gradient color array 81fb07ece0SStephan Aßmus mutable agg::rgba8* fGammaCorrectedColors; 82fb07ece0SStephan Aßmus mutable bool fGammaCorrectedColorsValid; 83fb07ece0SStephan Aßmus }; 84fb07ece0SStephan Aßmus 85*325a6253SAxel Dörfler } // namespace Icon 86*325a6253SAxel Dörfler } // namespace BPrivate 87*325a6253SAxel Dörfler 88*325a6253SAxel Dörfler using namespace BPrivate::Icon; 89*325a6253SAxel Dörfler 90fb07ece0SStephan Aßmus #endif // STYLE_H 91