xref: /haiku/src/libs/icon/style/Style.h (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
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 "IconBuild.h"
18 #include "IconRenderer.h"
19 	// TODO: put GammaTable into its own file
20 
21 #include <GraphicsDefs.h>
22 
23 #include <agg_color_rgba.h>
24 
25 
26 class BMessage;
27 
28 
29 _BEGIN_ICON_NAMESPACE
30 
31 
32 class Gradient;
33 
34 #ifdef ICON_O_MATIC
35 class Style : public IconObject,
36 			  public Observer {
37 #else
38 class Style {
39 #endif
40  public:
41 								Style();
42 								Style(const Style& other);
43 								Style(const rgb_color& color);
44 								Style(BMessage* archive);
45 
46 	virtual						~Style();
47 
48 #ifdef ICON_O_MATIC
49 	// Observer interface
50 	virtual	void				ObjectChanged(const Observable* object);
51 
52 	// Style
53 			status_t			Archive(BMessage* into,
54 										bool deep = true) const;
55 
56 			bool				operator==(const Style& other) const;
57 #else
58 	inline	void				Notify() {}
59 #endif // ICON_O_MATIC
60 
61 			bool				HasTransparency() const;
62 
63 			void				SetColor(const rgb_color& color);
64 	inline	rgb_color			Color() const
65 									{ return fColor; }
66 
67 			void				SetGradient(const _ICON_NAMESPACE Gradient*
68 											gradient);
69 			_ICON_NAMESPACE Gradient* Gradient() const
70 									{ return fGradient; }
71 
72 			const agg::rgba8*	Colors() const
73 									{ return fColors; }
74 
75 			const agg::rgba8*	GammaCorrectedColors(
76 									const GammaTable& table) const;
77 
78  private:
79 			rgb_color			fColor;
80 			_ICON_NAMESPACE Gradient* fGradient;
81 
82 			// hold gradient color array
83 			agg::rgba8*			fColors;
84 
85 			// for caching gamma corrected gradient color array
86 	mutable	agg::rgba8*			fGammaCorrectedColors;
87 	mutable	bool				fGammaCorrectedColorsValid;
88 };
89 
90 
91 _END_ICON_NAMESPACE
92 
93 
94 _USING_ICON_NAMESPACE
95 
96 
97 #endif	// STYLE_H
98