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

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

Issue 8359029: ui/gfx: Convert Canvas::DrawFocusRect() to use gfx::Rect. (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
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 #include "views/controls/label.h" 5 #include "views/controls/label.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <vector> 10 #include <vector>
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 const gfx::Rect& text_bounds, 268 const gfx::Rect& text_bounds,
269 int flags) { 269 int flags) {
270 canvas->DrawStringInt(text, font_, 270 canvas->DrawStringInt(text, font_,
271 IsEnabled() ? actual_enabled_color_ : actual_disabled_color_, 271 IsEnabled() ? actual_enabled_color_ : actual_disabled_color_,
272 text_bounds.x(), text_bounds.y(), text_bounds.width(), 272 text_bounds.x(), text_bounds.y(), text_bounds.width(),
273 text_bounds.height(), flags); 273 text_bounds.height(), flags);
274 274
275 if (HasFocus() || paint_as_focused_) { 275 if (HasFocus() || paint_as_focused_) {
276 gfx::Rect focus_bounds = text_bounds; 276 gfx::Rect focus_bounds = text_bounds;
277 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); 277 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding);
278 canvas->DrawFocusRect(focus_bounds.x(), focus_bounds.y(), 278 canvas->DrawFocusRect(focus_bounds);
279 focus_bounds.width(), focus_bounds.height());
280 } 279 }
281 } 280 }
282 281
283 gfx::Size Label::GetTextSize() const { 282 gfx::Size Label::GetTextSize() const {
284 if (!text_size_valid_) { 283 if (!text_size_valid_) {
285 // For single-line strings, we supply the largest possible width, because 284 // For single-line strings, we supply the largest possible width, because
286 // while adding NO_ELLIPSIS to the flags works on Windows for forcing 285 // while adding NO_ELLIPSIS to the flags works on Windows for forcing
287 // SizeStringInt() to calculate the desired width, it doesn't seem to work 286 // SizeStringInt() to calculate the desired width, it doesn't seem to work
288 // on Linux. 287 // on Linux.
289 int w = is_multi_line_ ? 288 int w = is_multi_line_ ?
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // it is right aligned. Otherwise, its directionality is forced to be LTR. 494 // it is right aligned. Otherwise, its directionality is forced to be LTR.
496 if (rtl_alignment_mode_ == AUTO_DETECT_ALIGNMENT) { 495 if (rtl_alignment_mode_ == AUTO_DETECT_ALIGNMENT) {
497 if (horiz_alignment_ == ALIGN_RIGHT) 496 if (horiz_alignment_ == ALIGN_RIGHT)
498 *flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; 497 *flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY;
499 else 498 else
500 *flags |= gfx::Canvas::FORCE_LTR_DIRECTIONALITY; 499 *flags |= gfx::Canvas::FORCE_LTR_DIRECTIONALITY;
501 } 500 }
502 } 501 }
503 502
504 } // namespace views 503 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698