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

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

Issue 113441: ChromeFont->gfx::Font... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Created 11 years, 7 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
« no previous file with comments | « views/controls/combo_box.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 7
8 #include "app/gfx/chrome_font.h" 8 #include "app/gfx/chrome_font.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 // The view class name. 45 // The view class name.
46 static const char kViewClassName[]; 46 static const char kViewClassName[];
47 47
48 // Create a new label with a default font and empty value 48 // Create a new label with a default font and empty value
49 Label(); 49 Label();
50 50
51 // Create a new label with a default font 51 // Create a new label with a default font
52 explicit Label(const std::wstring& text); 52 explicit Label(const std::wstring& text);
53 53
54 Label(const std::wstring& text, const ChromeFont& font); 54 Label(const std::wstring& text, const gfx::Font& font);
55 55
56 virtual ~Label(); 56 virtual ~Label();
57 57
58 // Overridden to compute the size required to display this label 58 // Overridden to compute the size required to display this label
59 virtual gfx::Size GetPreferredSize(); 59 virtual gfx::Size GetPreferredSize();
60 60
61 // Return the height necessary to display this label with the provided width. 61 // Return the height necessary to display this label with the provided width.
62 // This method is used to layout multi-line labels. It is equivalent to 62 // This method is used to layout multi-line labels. It is equivalent to
63 // GetPreferredSize().height() if the receiver is not multi-line 63 // GetPreferredSize().height() if the receiver is not multi-line
64 virtual int GetHeightForWidth(int w); 64 virtual int GetHeightForWidth(int w);
65 65
66 // Returns views/Label. 66 // Returns views/Label.
67 virtual std::string GetClassName() const; 67 virtual std::string GetClassName() const;
68 68
69 // Overridden to paint 69 // Overridden to paint
70 virtual void Paint(ChromeCanvas* canvas); 70 virtual void Paint(ChromeCanvas* canvas);
71 71
72 // If the mouse is over the label, and a mouse over background has been 72 // If the mouse is over the label, and a mouse over background has been
73 // specified, its used. Otherwise super's implementation is invoked 73 // specified, its used. Otherwise super's implementation is invoked
74 virtual void PaintBackground(ChromeCanvas* canvas); 74 virtual void PaintBackground(ChromeCanvas* canvas);
75 75
76 // Set the font. 76 // Set the font.
77 void SetFont(const ChromeFont& font); 77 void SetFont(const gfx::Font& font);
78 78
79 // Return the font used by this label 79 // Return the font used by this label
80 ChromeFont GetFont() const; 80 gfx::Font GetFont() const;
81 81
82 // Set the label text. 82 // Set the label text.
83 void SetText(const std::wstring& text); 83 void SetText(const std::wstring& text);
84 84
85 // Return the label text. 85 // Return the label text.
86 const std::wstring GetText() const; 86 const std::wstring GetText() const;
87 87
88 // Set URL Value - text_ is set to spec(). 88 // Set URL Value - text_ is set to spec().
89 void SetURL(const GURL& url); 89 void SetURL(const GURL& url);
90 90
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 void set_has_focus_border(bool has_focus_border) { 185 void set_has_focus_border(bool has_focus_border) {
186 has_focus_border_ = has_focus_border; 186 has_focus_border_ = has_focus_border;
187 } 187 }
188 188
189 private: 189 private:
190 // These tests call CalculateDrawStringParams in order to verify the 190 // These tests call CalculateDrawStringParams in order to verify the
191 // calculations done for drawing text. 191 // calculations done for drawing text.
192 FRIEND_TEST(LabelTest, DrawSingleLineString); 192 FRIEND_TEST(LabelTest, DrawSingleLineString);
193 FRIEND_TEST(LabelTest, DrawMultiLineString); 193 FRIEND_TEST(LabelTest, DrawMultiLineString);
194 194
195 static ChromeFont GetDefaultFont(); 195 static gfx::Font GetDefaultFont();
196 196
197 // Returns parameters to be used for the DrawString call. 197 // Returns parameters to be used for the DrawString call.
198 void CalculateDrawStringParams(std::wstring* paint_text, 198 void CalculateDrawStringParams(std::wstring* paint_text,
199 gfx::Rect* text_bounds, 199 gfx::Rect* text_bounds,
200 int* flags); 200 int* flags);
201 201
202 // If the mouse is over the text, SetContainsMouse(true) is invoked, otherwise 202 // If the mouse is over the text, SetContainsMouse(true) is invoked, otherwise
203 // SetContainsMouse(false) is invoked. 203 // SetContainsMouse(false) is invoked.
204 void UpdateContainsMouse(const MouseEvent& event); 204 void UpdateContainsMouse(const MouseEvent& event);
205 205
206 // Updates whether the mouse is contained in the Label. If the new value 206 // Updates whether the mouse is contained in the Label. If the new value
207 // differs from the current value, and a mouse over background is specified, 207 // differs from the current value, and a mouse over background is specified,
208 // SchedulePaint is invoked. 208 // SchedulePaint is invoked.
209 void SetContainsMouse(bool contains_mouse); 209 void SetContainsMouse(bool contains_mouse);
210 210
211 // Returns where the text is drawn, in the receivers coordinate system. 211 // Returns where the text is drawn, in the receivers coordinate system.
212 gfx::Rect GetTextBounds(); 212 gfx::Rect GetTextBounds();
213 213
214 int ComputeMultiLineFlags(); 214 int ComputeMultiLineFlags();
215 gfx::Size GetTextSize(); 215 gfx::Size GetTextSize();
216 void Init(const std::wstring& text, const ChromeFont& font); 216 void Init(const std::wstring& text, const gfx::Font& font);
217 std::wstring text_; 217 std::wstring text_;
218 GURL url_; 218 GURL url_;
219 ChromeFont font_; 219 gfx::Font font_;
220 SkColor color_; 220 SkColor color_;
221 gfx::Size text_size_; 221 gfx::Size text_size_;
222 bool text_size_valid_; 222 bool text_size_valid_;
223 bool is_multi_line_; 223 bool is_multi_line_;
224 bool allow_character_break_; 224 bool allow_character_break_;
225 bool url_set_; 225 bool url_set_;
226 Alignment horiz_alignment_; 226 Alignment horiz_alignment_;
227 std::wstring tooltip_text_; 227 std::wstring tooltip_text_;
228 // Whether the mouse is over this label. 228 // Whether the mouse is over this label.
229 bool contains_mouse_; 229 bool contains_mouse_;
(...skipping 11 matching lines...) Expand all
241 // allows this view to reserve space for a focus border that it otherwise 241 // allows this view to reserve space for a focus border that it otherwise
242 // might not have because it is not itself focusable. 242 // might not have because it is not itself focusable.
243 bool has_focus_border_; 243 bool has_focus_border_;
244 244
245 DISALLOW_COPY_AND_ASSIGN(Label); 245 DISALLOW_COPY_AND_ASSIGN(Label);
246 }; 246 };
247 247
248 } // namespace views 248 } // namespace views
249 249
250 #endif // VIEWS_CONTROLS_LABEL_H_ 250 #endif // VIEWS_CONTROLS_LABEL_H_
OLDNEW
« no previous file with comments | « views/controls/combo_box.cc ('k') | views/controls/label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698