1/*
2 * Copyright 2013, Stephan A��mus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5#ifndef CHARACTER_STYLE_DATA_H
6#define CHARACTER_STYLE_DATA_H
7
8#include <Font.h>
9#include <Referenceable.h>
10
11
12enum {
13	STRIKE_OUT_NONE		= 0,
14	STRIKE_OUT_SINGLE	= 1,
15};
16
17
18enum {
19	UNDERLINE_NONE		= 0,
20	UNDERLINE_SINGLE	= 1,
21	UNDERLINE_DOUBLE	= 2,
22	UNDERLINE_WIGGLE	= 3,
23	UNDERLINE_DOTTED	= 4,
24};
25
26
27class CharacterStyleData;
28typedef BReference<CharacterStyleData>	CharacterStyleDataRef;
29
30
31// You cannot modify a CharacterStyleData object once it has been
32// created. Instead, the setter methods return a new object that equals
33// the object on which the method has been called, except for the changed
34// property. If the property already has the requested value, then a
35// reference to the same object is returned.
36class CharacterStyleData : public BReferenceable {
37public:
38								CharacterStyleData();
39								CharacterStyleData(
40									const CharacterStyleData& other);
41
42			bool				operator==(
43									const CharacterStyleData& other) const;
44			bool				operator!=(
45									const CharacterStyleData& other) const;
46
47			CharacterStyleDataRef SetFont(const BFont& font);
48	inline	const BFont&		Font() const
49									{ return fFont; }
50
51			CharacterStyleDataRef SetAscent(float ascent);
52
53			// Returns the ascent of the configured font, unless the ascent
54			// has been overridden by a fixed value with SetAscent().
55			float				Ascent() const;
56
57			CharacterStyleDataRef SetDescent(float descent);
58
59			// Returns the descent of the configured font, unless the descent
60			// has been overridden by a fixed value with SetDescent().
61			float				Descent() const;
62
63			CharacterStyleDataRef SetWidth(float width);
64	inline	float				Width() const
65									{ return fWidth; }
66
67			CharacterStyleDataRef SetGlyphSpacing(float glyphSpacing);
68	inline	float				GlyphSpacing() const
69									{ return fGlyphSpacing; }
70
71			CharacterStyleDataRef SetForegroundColor(color_which which);
72			CharacterStyleDataRef SetForegroundColor(rgb_color color);
73	inline	rgb_color			ForegroundColor() const
74									{ return fFgColor; }
75	inline	color_which			WhichForegroundColor() const
76									{ return fWhichFgColor; }
77
78			CharacterStyleDataRef SetBackgroundColor(color_which which);
79			CharacterStyleDataRef SetBackgroundColor(rgb_color color);
80	inline	rgb_color			BackgroundColor() const
81									{ return fBgColor; }
82	inline	color_which			WhichBackgroundColor() const
83									{ return fWhichBgColor; }
84
85			CharacterStyleDataRef SetStrikeOutColor(color_which which);
86			CharacterStyleDataRef SetStrikeOutColor(rgb_color color);
87	inline	rgb_color			StrikeOutColor() const
88									{ return fStrikeOutColor; }
89	inline	color_which			WhichStrikeOutColor() const
90									{ return fWhichStrikeOutColor; }
91
92			CharacterStyleDataRef SetUnderlineColor(color_which which);
93			CharacterStyleDataRef SetUnderlineColor(rgb_color color);
94	inline	rgb_color			UnderlineColor() const
95									{ return fUnderlineColor; }
96	inline	color_which			WhichUnderlineColor() const
97									{ return fWhichUnderlineColor; }
98
99			CharacterStyleDataRef SetStrikeOut(uint8 strikeOut);
100	inline	uint8				StrikeOut() const
101									{ return fStrikeOutStyle; }
102
103			CharacterStyleDataRef SetUnderline(uint8 underline);
104	inline	uint8				Underline() const
105									{ return fUnderlineStyle; }
106
107
108private:
109			CharacterStyleData&	operator=(const CharacterStyleData& other);
110
111private:
112			BFont				fFont;
113
114			// The following three values override glyph metrics unless -1
115			// This is useful when you want to have a place-holder character
116			// in the text. You would assign this character a CharacterStyle
117			// which defines ascent, descent and width to fixed values, thereby
118			// controlling the exact dimensions of the character, regardless of
119			// font size. Instead of the character, one could render an icon
120			// that is layouted within the text.
121			float				fAscent;
122			float				fDescent;
123			float				fWidth;
124
125			// Additional spacing to be applied between glyphs.
126			float				fGlyphSpacing;
127
128			color_which			fWhichFgColor;
129			color_which			fWhichBgColor;
130
131			color_which			fWhichStrikeOutColor;
132			color_which			fWhichUnderlineColor;
133
134			rgb_color			fFgColor;
135			rgb_color			fBgColor;
136
137			rgb_color			fStrikeOutColor;
138			rgb_color			fUnderlineColor;
139
140			uint8				fStrikeOutStyle;
141			uint8				fUnderlineStyle;
142};
143
144
145#endif // CHARACTER_STYLE_DATA_H
146