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