1fb07ece0SStephan Aßmus /* 2fb07ece0SStephan Aßmus * Copyright 2006, 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 9fb07ece0SStephan Aßmus #ifndef STYLE_H 10fb07ece0SStephan Aßmus #define STYLE_H 11fb07ece0SStephan Aßmus 12fb07ece0SStephan Aßmus #include <GraphicsDefs.h> 13fb07ece0SStephan Aßmus 14fb07ece0SStephan Aßmus #include <agg_color_rgba.h> 15fb07ece0SStephan Aßmus 16fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 17fb07ece0SStephan Aßmus # include "IconObject.h" 18fb07ece0SStephan Aßmus # include "Observer.h" 19fb07ece0SStephan Aßmus #endif 20fb07ece0SStephan Aßmus 21fb07ece0SStephan Aßmus #include "IconRenderer.h" 22fb07ece0SStephan Aßmus // TODO: put GammaTable into its own file 23fb07ece0SStephan Aßmus 24fb07ece0SStephan Aßmus class Gradient; 25fb07ece0SStephan Aßmus 26fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 27fb07ece0SStephan Aßmus class Style : public IconObject, 28fb07ece0SStephan Aßmus public Observer { 29fb07ece0SStephan Aßmus #else 30fb07ece0SStephan Aßmus class Style { 31fb07ece0SStephan Aßmus #endif 32fb07ece0SStephan Aßmus public: 33fb07ece0SStephan Aßmus Style(); 34fb07ece0SStephan Aßmus Style(const Style& other); 35fb07ece0SStephan Aßmus Style(const rgb_color& color); 36fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 37fb07ece0SStephan Aßmus Style(BMessage* archive); 38fb07ece0SStephan Aßmus #endif 39fb07ece0SStephan Aßmus virtual ~Style(); 40fb07ece0SStephan Aßmus 41fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC 42fb07ece0SStephan Aßmus // Observer interface 43fb07ece0SStephan Aßmus virtual void ObjectChanged(const Observable* object); 44fb07ece0SStephan Aßmus 45fb07ece0SStephan Aßmus // Style 46fb07ece0SStephan Aßmus status_t Archive(BMessage* into, 47fb07ece0SStephan Aßmus bool deep = true) const; 48*6e3b3b09SStephan Aßmus 49*6e3b3b09SStephan Aßmus bool operator==(const Style& other) const; 50fb07ece0SStephan Aßmus #else 51fb07ece0SStephan Aßmus inline void Notify() {} 52fb07ece0SStephan Aßmus #endif // ICON_O_MATIC 53fb07ece0SStephan Aßmus 54fb07ece0SStephan Aßmus void SetColor(const rgb_color& color); 55fb07ece0SStephan Aßmus inline rgb_color Color() const 56fb07ece0SStephan Aßmus { return fColor; } 57fb07ece0SStephan Aßmus 58fb07ece0SStephan Aßmus void SetGradient(const ::Gradient* gradient); 59fb07ece0SStephan Aßmus ::Gradient* Gradient() const 60fb07ece0SStephan Aßmus { return fGradient; } 61fb07ece0SStephan Aßmus 62fb07ece0SStephan Aßmus const agg::rgba8* Colors() const 63fb07ece0SStephan Aßmus { return fColors; } 64fb07ece0SStephan Aßmus 65fb07ece0SStephan Aßmus const agg::rgba8* GammaCorrectedColors( 66fb07ece0SStephan Aßmus const GammaTable& table) const; 67fb07ece0SStephan Aßmus 68fb07ece0SStephan Aßmus private: 69fb07ece0SStephan Aßmus rgb_color fColor; 70fb07ece0SStephan Aßmus ::Gradient* fGradient; 71fb07ece0SStephan Aßmus 72fb07ece0SStephan Aßmus // hold gradient color array 73fb07ece0SStephan Aßmus agg::rgba8* fColors; 74fb07ece0SStephan Aßmus 75fb07ece0SStephan Aßmus // for caching gamma corrected gradient color array 76fb07ece0SStephan Aßmus mutable agg::rgba8* fGammaCorrectedColors; 77fb07ece0SStephan Aßmus mutable bool fGammaCorrectedColorsValid; 78fb07ece0SStephan Aßmus }; 79fb07ece0SStephan Aßmus 80fb07ece0SStephan Aßmus #endif // STYLE_H 81