Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: views/controls/label.h

Issue 8142026: Revert 104076 - Change std::wstring to string16 for views::Link (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/wrench_menu.cc ('k') | views/controls/label.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef VIEWS_CONTROLS_LABEL_H_ 5 #ifndef VIEWS_CONTROLS_LABEL_H_
6 #define VIEWS_CONTROLS_LABEL_H_ 6 #define VIEWS_CONTROLS_LABEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/string16.h"
13 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
14 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/gfx/font.h" 14 #include "ui/gfx/font.h"
16 #include "views/view.h" 15 #include "views/view.h"
17 16
18 namespace views { 17 namespace views {
19 18
20 ///////////////////////////////////////////////////////////////////////////// 19 /////////////////////////////////////////////////////////////////////////////
21 // 20 //
22 // Label class 21 // Label class
(...skipping 23 matching lines...) Expand all
46 AUTO_DETECT_ALIGNMENT 45 AUTO_DETECT_ALIGNMENT
47 }; 46 };
48 47
49 // The view class name. 48 // The view class name.
50 static const char kViewClassName[]; 49 static const char kViewClassName[];
51 50
52 // The padding for the focus border when rendering focused text. 51 // The padding for the focus border when rendering focused text.
53 static const int kFocusBorderPadding; 52 static const int kFocusBorderPadding;
54 53
55 Label(); 54 Label();
56 explicit Label(const string16& text); 55 explicit Label(const std::wstring& text);
57 Label(const string16& text, const gfx::Font& font); 56 Label(const std::wstring& text, const gfx::Font& font);
58 virtual ~Label(); 57 virtual ~Label();
59 58
60 // Set the font. 59 // Set the font.
61 virtual void SetFont(const gfx::Font& font); 60 virtual void SetFont(const gfx::Font& font);
62 61
63 // Set the label text. 62 // Set the label text.
64 void SetText(const string16& text); 63 void SetText(const std::wstring& text);
65 64
66 // Return the font used by this label. 65 // Return the font used by this label.
67 gfx::Font font() const { return font_; } 66 gfx::Font font() const { return font_; }
68 67
69 // Return the label text. 68 // Return the label text.
70 const string16 GetText() const; 69 const std::wstring GetText() const;
71 70
72 // Set URL Value - text_ is set to spec(). 71 // Set URL Value - text_ is set to spec().
73 void SetURL(const GURL& url); 72 void SetURL(const GURL& url);
74 73
75 // Return the label URL. 74 // Return the label URL.
76 const GURL GetURL() const; 75 const GURL GetURL() const;
77 76
78 // Set the color 77 // Set the color
79 virtual void SetColor(const SkColor& color); 78 virtual void SetColor(const SkColor& color);
80 79
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Gets the tooltip text for labels that are wider than their bounds, except 175 // Gets the tooltip text for labels that are wider than their bounds, except
177 // when the label is multiline, in which case it just returns false (no 176 // when the label is multiline, in which case it just returns false (no
178 // tooltip). If a custom tooltip has been specified with SetTooltipText() 177 // tooltip). If a custom tooltip has been specified with SetTooltipText()
179 // it is returned instead. 178 // it is returned instead.
180 virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE; 179 virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) OVERRIDE;
181 180
182 protected: 181 protected:
183 // Called by Paint to paint the text. Override this to change how 182 // Called by Paint to paint the text. Override this to change how
184 // text is painted. 183 // text is painted.
185 virtual void PaintText(gfx::Canvas* canvas, 184 virtual void PaintText(gfx::Canvas* canvas,
186 const string16& text, 185 const std::wstring& text,
187 const gfx::Rect& text_bounds, 186 const gfx::Rect& text_bounds,
188 int flags); 187 int flags);
189 188
190 void invalidate_text_size() { text_size_valid_ = false; } 189 void invalidate_text_size() { text_size_valid_ = false; }
191 190
192 virtual gfx::Size GetTextSize() const; 191 virtual gfx::Size GetTextSize() const;
193 192
194 // Overridden from View: 193 // Overridden from View:
195 // Overridden to dirty our text bounds if we're multi-line. 194 // Overridden to dirty our text bounds if we're multi-line.
196 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; 195 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
197 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 196 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
198 // If the mouse is over the label, and a mouse over background has been 197 // If the mouse is over the label, and a mouse over background has been
199 // specified, its used. Otherwise super's implementation is invoked. 198 // specified, its used. Otherwise super's implementation is invoked.
200 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; 199 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE;
201 200
202 private: 201 private:
203 // These tests call CalculateDrawStringParams in order to verify the 202 // These tests call CalculateDrawStringParams in order to verify the
204 // calculations done for drawing text. 203 // calculations done for drawing text.
205 FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawSingleLineString); 204 FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawSingleLineString);
206 FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawMultiLineString); 205 FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawMultiLineString);
207 FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawSingleLineStringInRTL); 206 FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawSingleLineStringInRTL);
208 FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawMultiLineStringInRTL); 207 FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawMultiLineStringInRTL);
209 208
210 static gfx::Font GetDefaultFont(); 209 static gfx::Font GetDefaultFont();
211 210
212 void Init(const string16& text, const gfx::Font& font); 211 void Init(const std::wstring& text, const gfx::Font& font);
213 212
214 // If the mouse is over the text, SetContainsMouse(true) is invoked, otherwise 213 // If the mouse is over the text, SetContainsMouse(true) is invoked, otherwise
215 // SetContainsMouse(false) is invoked. 214 // SetContainsMouse(false) is invoked.
216 void UpdateContainsMouse(const MouseEvent& event); 215 void UpdateContainsMouse(const MouseEvent& event);
217 216
218 // Updates whether the mouse is contained in the Label. If the new value 217 // Updates whether the mouse is contained in the Label. If the new value
219 // differs from the current value, and a mouse over background is specified, 218 // differs from the current value, and a mouse over background is specified,
220 // SchedulePaint is invoked. 219 // SchedulePaint is invoked.
221 void SetContainsMouse(bool contains_mouse); 220 void SetContainsMouse(bool contains_mouse);
222 221
223 // Returns where the text is drawn, in the receivers coordinate system. 222 // Returns where the text is drawn, in the receivers coordinate system.
224 gfx::Rect GetTextBounds() const; 223 gfx::Rect GetTextBounds() const;
225 224
226 int ComputeMultiLineFlags() const; 225 int ComputeMultiLineFlags() const;
227 226
228 gfx::Rect GetAvailableRect() const; 227 gfx::Rect GetAvailableRect() const;
229 228
230 // Returns parameters to be used for the DrawString call. 229 // Returns parameters to be used for the DrawString call.
231 void CalculateDrawStringParams(string16* paint_text, 230 void CalculateDrawStringParams(std::wstring* paint_text,
232 gfx::Rect* text_bounds, 231 gfx::Rect* text_bounds,
233 int* flags) const; 232 int* flags) const;
234 233
235 string16 text_; 234 string16 text_;
236 GURL url_; 235 GURL url_;
237 gfx::Font font_; 236 gfx::Font font_;
238 SkColor color_; 237 SkColor color_;
239 mutable gfx::Size text_size_; 238 mutable gfx::Size text_size_;
240 mutable bool text_size_valid_; 239 mutable bool text_size_valid_;
241 bool is_multi_line_; 240 bool is_multi_line_;
(...skipping 18 matching lines...) Expand all
260 // allows this view to reserve space for a focus border that it otherwise 259 // allows this view to reserve space for a focus border that it otherwise
261 // might not have because it is not itself focusable. 260 // might not have because it is not itself focusable.
262 bool has_focus_border_; 261 bool has_focus_border_;
263 262
264 DISALLOW_COPY_AND_ASSIGN(Label); 263 DISALLOW_COPY_AND_ASSIGN(Label);
265 }; 264 };
266 265
267 } // namespace views 266 } // namespace views
268 267
269 #endif // VIEWS_CONTROLS_LABEL_H_ 268 #endif // VIEWS_CONTROLS_LABEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/wrench_menu.cc ('k') | views/controls/label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698