]> git.saurik.com Git - iphone-api.git/blob - WebCore/TextRun.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / TextRun.h
1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007 Apple Computer, Inc.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24 #ifndef TextRun_h
25 #define TextRun_h
26
27 #include "PlatformString.h"
28
29 namespace WebCore {
30
31 class RenderObject;
32 class SVGPaintServer;
33
34 class TextRun {
35 public:
36 TextRun(const UChar* c, int len, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
37 bool applyRunRounding = true, bool applyWordRounding = true)
38 : m_characters(c)
39 , m_len(len)
40 , m_xpos(xpos)
41 , m_padding(padding)
42 , m_allowTabs(allowTabs)
43 , m_rtl(rtl)
44 , m_directionalOverride(directionalOverride)
45 , m_applyRunRounding(applyRunRounding)
46 , m_applyWordRounding(applyWordRounding)
47 , m_disableSpacing(false)
48 #if ENABLE(SVG_FONTS)
49 , m_referencingRenderObject(0)
50 , m_activePaintServer(0)
51 #endif
52 {
53 }
54
55 TextRun(const String& s, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
56 bool applyRunRounding = true, bool applyWordRounding = true)
57 : m_characters(s.characters())
58 , m_len(s.length())
59 , m_xpos(xpos)
60 , m_padding(padding)
61 , m_allowTabs(allowTabs)
62 , m_rtl(rtl)
63 , m_directionalOverride(directionalOverride)
64 , m_applyRunRounding(applyRunRounding)
65 , m_applyWordRounding(applyWordRounding)
66 , m_disableSpacing(false)
67 #if ENABLE(SVG_FONTS)
68 , m_referencingRenderObject(0)
69 , m_activePaintServer(0)
70 #endif
71 {
72 }
73
74 UChar operator[](int i) const { return m_characters[i]; }
75 const UChar* data(int i) const { return &m_characters[i]; }
76
77 const UChar* characters() const { return m_characters; }
78 int length() const { return m_len; }
79
80 void setText(const UChar* c, int len) { m_characters = c; m_len = len; }
81
82 bool allowTabs() const { return m_allowTabs; }
83 int xPos() const { return m_xpos; }
84 int padding() const { return m_padding; }
85 bool rtl() const { return m_rtl; }
86 bool ltr() const { return !m_rtl; }
87 bool directionalOverride() const { return m_directionalOverride; }
88 bool applyRunRounding() const { return m_applyRunRounding; }
89 bool applyWordRounding() const { return m_applyWordRounding; }
90 bool spacingDisabled() const { return m_disableSpacing; }
91
92 void disableSpacing() { m_disableSpacing = true; }
93 void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; }
94 void setRTL(bool b) { m_rtl = b; }
95 void setDirectionalOverride(bool override) { m_directionalOverride = override; }
96
97 #if ENABLE(SVG_FONTS)
98 RenderObject* referencingRenderObject() const { return m_referencingRenderObject; }
99 void setReferencingRenderObject(RenderObject* object) { m_referencingRenderObject = object; }
100
101 SVGPaintServer* activePaintServer() const { return m_activePaintServer; }
102 void setActivePaintServer(SVGPaintServer* object) { m_activePaintServer = object; }
103 #endif
104
105 private:
106 const UChar* m_characters;
107 int m_len;
108
109 int m_xpos;
110 int m_padding;
111 bool m_allowTabs;
112 bool m_rtl;
113 bool m_directionalOverride;
114 bool m_applyRunRounding;
115 bool m_applyWordRounding;
116 bool m_disableSpacing;
117
118 #if ENABLE(SVG_FONTS)
119 RenderObject* m_referencingRenderObject;
120 SVGPaintServer* m_activePaintServer;
121 #endif
122 };
123
124 }
125
126 #endif