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