| 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/label.h" | 5 #include "chrome/views/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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 if (url_set_) | 181 if (url_set_) |
| 182 return UTF8ToWide(url_.spec()); | 182 return UTF8ToWide(url_.spec()); |
| 183 else | 183 else |
| 184 return text_; | 184 return text_; |
| 185 } | 185 } |
| 186 | 186 |
| 187 const GURL Label::GetURL() const { | 187 const GURL Label::GetURL() const { |
| 188 if (url_set_) | 188 if (url_set_) |
| 189 return url_; | 189 return url_; |
| 190 else | 190 else |
| 191 return GURL(text_); | 191 return GURL(WideToUTF8(text_)); |
| 192 } | 192 } |
| 193 | 193 |
| 194 gfx::Size Label::GetTextSize() { | 194 gfx::Size Label::GetTextSize() { |
| 195 if (!text_size_valid_) { | 195 if (!text_size_valid_) { |
| 196 text_size_.SetSize(font_.GetStringWidth(text_), font_.height()); | 196 text_size_.SetSize(font_.GetStringWidth(text_), font_.height()); |
| 197 text_size_valid_ = true; | 197 text_size_valid_ = true; |
| 198 } | 198 } |
| 199 | 199 |
| 200 if (text_size_valid_) | 200 if (text_size_valid_) |
| 201 return text_size_; | 201 return text_size_; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 gfx::Insets insets = GetInsets(); | 365 gfx::Insets insets = GetInsets(); |
| 366 label_width += insets.width(); | 366 label_width += insets.width(); |
| 367 | 367 |
| 368 if (max_width > 0) | 368 if (max_width > 0) |
| 369 label_width = std::min(label_width, max_width); | 369 label_width = std::min(label_width, max_width); |
| 370 | 370 |
| 371 SetBounds(x(), y(), label_width, 0); | 371 SetBounds(x(), y(), label_width, 0); |
| 372 SizeToPreferredSize(); | 372 SizeToPreferredSize(); |
| 373 } | 373 } |
| 374 | 374 |
| 375 #if defined(OS_WIN) |
| 375 bool Label::GetAccessibleRole(VARIANT* role) { | 376 bool Label::GetAccessibleRole(VARIANT* role) { |
| 376 DCHECK(role); | 377 DCHECK(role); |
| 377 | 378 |
| 378 role->vt = VT_I4; | 379 role->vt = VT_I4; |
| 379 role->lVal = ROLE_SYSTEM_TEXT; | 380 role->lVal = ROLE_SYSTEM_TEXT; |
| 380 return true; | 381 return true; |
| 381 } | 382 } |
| 382 | 383 |
| 383 bool Label::GetAccessibleName(std::wstring* name) { | 384 bool Label::GetAccessibleName(std::wstring* name) { |
| 384 *name = GetText(); | 385 *name = GetText(); |
| 385 return true; | 386 return true; |
| 386 } | 387 } |
| 387 | 388 |
| 388 bool Label::GetAccessibleState(VARIANT* state) { | 389 bool Label::GetAccessibleState(VARIANT* state) { |
| 389 DCHECK(state); | 390 DCHECK(state); |
| 390 | 391 |
| 391 state->lVal |= STATE_SYSTEM_READONLY; | 392 state->lVal |= STATE_SYSTEM_READONLY; |
| 392 return true; | 393 return true; |
| 393 } | 394 } |
| 395 #endif // defined(OS_WIN) |
| 394 | 396 |
| 395 } // namespace views | 397 } // namespace views |
| OLD | NEW |