xref: /haiku/src/libs/icon/style/Style.h (revision b30304acc8c37e678a1bf66976d15bdab103f931)
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 			bool				HasTransparency() const;
59 
60 			void				SetColor(const rgb_color& color);
61 	inline	rgb_color			Color() const
62 									{ return fColor; }
63 
64 			void				SetGradient(const BPrivate::Icon::Gradient*
65 											gradient);
66 			BPrivate::Icon::Gradient* Gradient() const
67 									{ return fGradient; }
68 
69 			const agg::rgba8*	Colors() const
70 									{ return fColors; }
71 
72 			const agg::rgba8*	GammaCorrectedColors(
73 									const GammaTable& table) const;
74 
75  private:
76 			rgb_color			fColor;
77 			BPrivate::Icon::Gradient* fGradient;
78 
79 			// hold gradient color array
80 			agg::rgba8*			fColors;
81 
82 			// for caching gamma corrected gradient color array
83 	mutable	agg::rgba8*			fGammaCorrectedColors;
84 	mutable	bool				fGammaCorrectedColorsValid;
85 };
86 
87 }	// namespace Icon
88 }	// namespace BPrivate
89 
90 using namespace BPrivate::Icon;
91 
92 #endif	// STYLE_H
93