| OLD | NEW |
| 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 #include "chrome/views/controls/label.h" | 5 #include "chrome/views/controls/label.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 void Label::Init(const std::wstring& text, const ChromeFont& font) { | 39 void Label::Init(const std::wstring& text, const ChromeFont& font) { |
| 40 contains_mouse_ = false; | 40 contains_mouse_ = false; |
| 41 font_ = font; | 41 font_ = font; |
| 42 text_size_valid_ = false; | 42 text_size_valid_ = false; |
| 43 SetText(text); | 43 SetText(text); |
| 44 url_set_ = false; | 44 url_set_ = false; |
| 45 color_ = kEnabledColor; | 45 color_ = kEnabledColor; |
| 46 horiz_alignment_ = ALIGN_CENTER; | 46 horiz_alignment_ = ALIGN_CENTER; |
| 47 is_multi_line_ = false; | 47 is_multi_line_ = false; |
| 48 allow_character_break_ = false; |
| 48 collapse_when_hidden_ = false; | 49 collapse_when_hidden_ = false; |
| 49 rtl_alignment_mode_ = USE_UI_ALIGNMENT; | 50 rtl_alignment_mode_ = USE_UI_ALIGNMENT; |
| 50 paint_as_focused_ = false; | 51 paint_as_focused_ = false; |
| 51 has_focus_border_ = false; | 52 has_focus_border_ = false; |
| 52 } | 53 } |
| 53 | 54 |
| 54 Label::~Label() { | 55 Label::~Label() { |
| 55 } | 56 } |
| 56 | 57 |
| 57 gfx::Size Label::GetPreferredSize() { | 58 gfx::Size Label::GetPreferredSize() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 73 prefsize = GetTextSize(); | 74 prefsize = GetTextSize(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 gfx::Insets insets = GetInsets(); | 77 gfx::Insets insets = GetInsets(); |
| 77 prefsize.Enlarge(insets.width(), insets.height()); | 78 prefsize.Enlarge(insets.width(), insets.height()); |
| 78 return prefsize; | 79 return prefsize; |
| 79 } | 80 } |
| 80 | 81 |
| 81 int Label::ComputeMultiLineFlags() { | 82 int Label::ComputeMultiLineFlags() { |
| 82 int flags = ChromeCanvas::MULTI_LINE; | 83 int flags = ChromeCanvas::MULTI_LINE; |
| 84 if (allow_character_break_) |
| 85 flags |= ChromeCanvas::CHARACTER_BREAK; |
| 83 switch (horiz_alignment_) { | 86 switch (horiz_alignment_) { |
| 84 case ALIGN_LEFT: | 87 case ALIGN_LEFT: |
| 85 flags |= ChromeCanvas::TEXT_ALIGN_LEFT; | 88 flags |= ChromeCanvas::TEXT_ALIGN_LEFT; |
| 86 break; | 89 break; |
| 87 case ALIGN_CENTER: | 90 case ALIGN_CENTER: |
| 88 flags |= ChromeCanvas::TEXT_ALIGN_CENTER; | 91 flags |= ChromeCanvas::TEXT_ALIGN_CENTER; |
| 89 break; | 92 break; |
| 90 case ALIGN_RIGHT: | 93 case ALIGN_RIGHT: |
| 91 flags |= ChromeCanvas::TEXT_ALIGN_RIGHT; | 94 flags |= ChromeCanvas::TEXT_ALIGN_RIGHT; |
| 92 break; | 95 break; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return rtl_alignment_mode_; | 278 return rtl_alignment_mode_; |
| 276 } | 279 } |
| 277 | 280 |
| 278 void Label::SetMultiLine(bool f) { | 281 void Label::SetMultiLine(bool f) { |
| 279 if (f != is_multi_line_) { | 282 if (f != is_multi_line_) { |
| 280 is_multi_line_ = f; | 283 is_multi_line_ = f; |
| 281 SchedulePaint(); | 284 SchedulePaint(); |
| 282 } | 285 } |
| 283 } | 286 } |
| 284 | 287 |
| 288 void Label::SetAllowCharacterBreak(bool f) { |
| 289 if (f != allow_character_break_) { |
| 290 allow_character_break_ = f; |
| 291 SchedulePaint(); |
| 292 } |
| 293 } |
| 294 |
| 285 bool Label::IsMultiLine() { | 295 bool Label::IsMultiLine() { |
| 286 return is_multi_line_; | 296 return is_multi_line_; |
| 287 } | 297 } |
| 288 | 298 |
| 289 void Label::SetTooltipText(const std::wstring& tooltip_text) { | 299 void Label::SetTooltipText(const std::wstring& tooltip_text) { |
| 290 tooltip_text_ = tooltip_text; | 300 tooltip_text_ = tooltip_text; |
| 291 } | 301 } |
| 292 | 302 |
| 293 bool Label::GetTooltipText(int x, int y, std::wstring* tooltip) { | 303 bool Label::GetTooltipText(int x, int y, std::wstring* tooltip) { |
| 294 DCHECK(tooltip); | 304 DCHECK(tooltip); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 438 |
| 429 bool Label::GetAccessibleState(VARIANT* state) { | 439 bool Label::GetAccessibleState(VARIANT* state) { |
| 430 DCHECK(state); | 440 DCHECK(state); |
| 431 | 441 |
| 432 state->lVal |= STATE_SYSTEM_READONLY; | 442 state->lVal |= STATE_SYSTEM_READONLY; |
| 433 return true; | 443 return true; |
| 434 } | 444 } |
| 435 #endif // defined(OS_WIN) | 445 #endif // defined(OS_WIN) |
| 436 | 446 |
| 437 } // namespace views | 447 } // namespace views |
| OLD | NEW |