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