vfs: check userland buffers before reading them.
[haiku.git] / src / apps / haikudepot / textview / CharacterStyleData.h
blob81439457f23970e72e7b885f46848e5864050514
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
8 #include <Font.h>
9 #include <Referenceable.h>
12 enum {
13 STRIKE_OUT_NONE = 0,
14 STRIKE_OUT_SINGLE = 1,
18 enum {
19 UNDERLINE_NONE = 0,
20 UNDERLINE_SINGLE = 1,
21 UNDERLINE_DOUBLE = 2,
22 UNDERLINE_WIGGLE = 3,
23 UNDERLINE_DOTTED = 4,
27 class CharacterStyleData;
28 typedef BReference<CharacterStyleData> CharacterStyleDataRef;
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.
36 class CharacterStyleData : public BReferenceable {
37 public:
38 CharacterStyleData();
39 CharacterStyleData(
40 const CharacterStyleData& other);
42 bool operator==(
43 const CharacterStyleData& other) const;
44 bool operator!=(
45 const CharacterStyleData& other) const;
47 CharacterStyleDataRef SetFont(const BFont& font);
48 inline const BFont& Font() const
49 { return fFont; }
51 CharacterStyleDataRef SetAscent(float ascent);
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;
57 CharacterStyleDataRef SetDescent(float descent);
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;
63 CharacterStyleDataRef SetWidth(float width);
64 inline float Width() const
65 { return fWidth; }
67 CharacterStyleDataRef SetGlyphSpacing(float glyphSpacing);
68 inline float GlyphSpacing() const
69 { return fGlyphSpacing; }
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; }
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; }
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; }
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; }
99 CharacterStyleDataRef SetStrikeOut(uint8 strikeOut);
100 inline uint8 StrikeOut() const
101 { return fStrikeOutStyle; }
103 CharacterStyleDataRef SetUnderline(uint8 underline);
104 inline uint8 Underline() const
105 { return fUnderlineStyle; }
108 private:
109 CharacterStyleData& operator=(const CharacterStyleData& other);
111 private:
112 BFont fFont;
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;
125 // Additional spacing to be applied between glyphs.
126 float fGlyphSpacing;
128 color_which fWhichFgColor;
129 color_which fWhichBgColor;
131 color_which fWhichStrikeOutColor;
132 color_which fWhichUnderlineColor;
134 rgb_color fFgColor;
135 rgb_color fBgColor;
137 rgb_color fStrikeOutColor;
138 rgb_color fUnderlineColor;
140 uint8 fStrikeOutStyle;
141 uint8 fUnderlineStyle;
145 #endif // CHARACTER_STYLE_DATA_H