OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkWidgetViews.h" | 8 #include "SkWidgetViews.h" |
9 #include "SkTextBox.h" | 9 #include "SkTextBox.h" |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 if (fMode != mode) | 55 if (fMode != mode) |
56 { | 56 { |
57 fMode = SkToU8(mode); | 57 fMode = SkToU8(mode); |
58 this->computeSize(); | 58 this->computeSize(); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 void SkStaticTextView::setSpacingAlign(SkTextBox::SpacingAlign align) | 62 void SkStaticTextView::setSpacingAlign(SkTextBox::SpacingAlign align) |
63 { | 63 { |
64 fSpacingAlign = SkToU8(align); | 64 fSpacingAlign = SkToU8(align); |
65 this->inval(NULL); | 65 this->inval(nullptr); |
66 } | 66 } |
67 | 67 |
68 void SkStaticTextView::getMargin(SkPoint* margin) const | 68 void SkStaticTextView::getMargin(SkPoint* margin) const |
69 { | 69 { |
70 if (margin) | 70 if (margin) |
71 *margin = fMargin; | 71 *margin = fMargin; |
72 } | 72 } |
73 | 73 |
74 void SkStaticTextView::setMargin(SkScalar dx, SkScalar dy) | 74 void SkStaticTextView::setMargin(SkScalar dx, SkScalar dy) |
75 { | 75 { |
76 if (fMargin.fX != dx || fMargin.fY != dy) | 76 if (fMargin.fX != dx || fMargin.fY != dy) |
77 { | 77 { |
78 fMargin.set(dx, dy); | 78 fMargin.set(dx, dy); |
79 this->computeSize(); | 79 this->computeSize(); |
80 this->inval(NULL); | 80 this->inval(nullptr); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 size_t SkStaticTextView::getText(SkString* text) const | 84 size_t SkStaticTextView::getText(SkString* text) const |
85 { | 85 { |
86 if (text) | 86 if (text) |
87 *text = fText; | 87 *text = fText; |
88 return fText.size(); | 88 return fText.size(); |
89 } | 89 } |
90 | 90 |
91 size_t SkStaticTextView::getText(char text[]) const | 91 size_t SkStaticTextView::getText(char text[]) const |
92 { | 92 { |
93 if (text) | 93 if (text) |
94 memcpy(text, fText.c_str(), fText.size()); | 94 memcpy(text, fText.c_str(), fText.size()); |
95 return fText.size(); | 95 return fText.size(); |
96 } | 96 } |
97 | 97 |
98 void SkStaticTextView::setText(const SkString& text) | 98 void SkStaticTextView::setText(const SkString& text) |
99 { | 99 { |
100 this->setText(text.c_str(), text.size()); | 100 this->setText(text.c_str(), text.size()); |
101 } | 101 } |
102 | 102 |
103 void SkStaticTextView::setText(const char text[]) | 103 void SkStaticTextView::setText(const char text[]) |
104 { | 104 { |
105 if (text == NULL) | 105 if (text == nullptr) |
106 text = ""; | 106 text = ""; |
107 this->setText(text, strlen(text)); | 107 this->setText(text, strlen(text)); |
108 } | 108 } |
109 | 109 |
110 void SkStaticTextView::setText(const char text[], size_t len) | 110 void SkStaticTextView::setText(const char text[], size_t len) |
111 { | 111 { |
112 if (!fText.equals(text, len)) | 112 if (!fText.equals(text, len)) |
113 { | 113 { |
114 fText.set(text, len); | 114 fText.set(text, len); |
115 this->computeSize(); | 115 this->computeSize(); |
116 this->inval(NULL); | 116 this->inval(nullptr); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 void SkStaticTextView::getPaint(SkPaint* paint) const | 120 void SkStaticTextView::getPaint(SkPaint* paint) const |
121 { | 121 { |
122 if (paint) | 122 if (paint) |
123 *paint = fPaint; | 123 *paint = fPaint; |
124 } | 124 } |
125 | 125 |
126 void SkStaticTextView::setPaint(const SkPaint& paint) | 126 void SkStaticTextView::setPaint(const SkPaint& paint) |
127 { | 127 { |
128 if (fPaint != paint) | 128 if (fPaint != paint) |
129 { | 129 { |
130 fPaint = paint; | 130 fPaint = paint; |
131 this->computeSize(); | 131 this->computeSize(); |
132 this->inval(NULL); | 132 this->inval(nullptr); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 void SkStaticTextView::onDraw(SkCanvas* canvas) | 136 void SkStaticTextView::onDraw(SkCanvas* canvas) |
137 { | 137 { |
138 this->INHERITED::onDraw(canvas); | 138 this->INHERITED::onDraw(canvas); |
139 | 139 |
140 if (fText.isEmpty()) | 140 if (fText.isEmpty()) |
141 return; | 141 return; |
142 | 142 |
(...skipping 28 matching lines...) Expand all Loading... |
171 this->setMargin(s[0], s[1]); | 171 this->setMargin(s[0], s[1]); |
172 } else { | 172 } else { |
173 assert_no_attr(dom, node, "margin"); | 173 assert_no_attr(dom, node, "margin"); |
174 } | 174 } |
175 | 175 |
176 const char* text = dom.findAttr(node, "text"); | 176 const char* text = dom.findAttr(node, "text"); |
177 if (text) { | 177 if (text) { |
178 this->setText(text); | 178 this->setText(text); |
179 } | 179 } |
180 | 180 |
181 if ((node = dom.getFirstChild(node, "paint")) != NULL && | 181 if ((node = dom.getFirstChild(node, "paint")) != nullptr && |
182 (node = dom.getFirstChild(node, "screenplay")) != NULL) | 182 (node = dom.getFirstChild(node, "screenplay")) != nullptr) |
183 { | 183 { |
184 // FIXME: Including inflate_paint causes Windows build to fail -- it complains | 184 // FIXME: Including inflate_paint causes Windows build to fail -- it complains |
185 // that SKListView::SkListView is undefined. | 185 // that SKListView::SkListView is undefined. |
186 #if 0 | 186 #if 0 |
187 inflate_paint(dom, node, &fPaint); | 187 inflate_paint(dom, node, &fPaint); |
188 #endif | 188 #endif |
189 } | 189 } |
190 } | 190 } |
191 } | 191 } |
OLD | NEW |