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