| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/chromeos/status/status_area_button.h" | 5 #include "chrome/browser/chromeos/status/status_area_button.h" |
| 6 | 6 |
| 7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
| 8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
| 9 #include "ui/gfx/skbitmap_operations.h" | 9 #include "ui/gfx/skbitmap_operations.h" |
| 10 #include "views/border.h" | 10 #include "views/border.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 gfx::Insets StatusAreaButton::GetInsets() const { | 74 gfx::Insets StatusAreaButton::GetInsets() const { |
| 75 return insets_; | 75 return insets_; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void StatusAreaButton::SetText(const std::wstring& text) { | 78 void StatusAreaButton::SetText(const std::wstring& text) { |
| 79 // TextButtons normally remember the max text size, so the button's preferred | 79 // TextButtons normally remember the max text size, so the button's preferred |
| 80 // size will always be as large as the largest text ever put in it. | 80 // size will always be as large as the largest text ever put in it. |
| 81 // We clear that max text size, so we can adjust the size to fit the text. | 81 // We clear that max text size, so we can adjust the size to fit the text. |
| 82 // The order is important. ClearMaxTextSize sets the size to that of the |
| 83 // current text, so it must be called after SetText. |
| 84 views::MenuButton::SetText(text); |
| 82 ClearMaxTextSize(); | 85 ClearMaxTextSize(); |
| 83 views::MenuButton::SetText(text); | 86 PreferredSizeChanged(); |
| 84 } | 87 } |
| 85 | 88 |
| 86 void StatusAreaButton::DrawIcon(gfx::Canvas* canvas) { | 89 void StatusAreaButton::DrawIcon(gfx::Canvas* canvas) { |
| 87 canvas->DrawBitmapInt(icon(), horizontal_padding(), 0); | 90 canvas->DrawBitmapInt(icon(), horizontal_padding(), 0); |
| 88 } | 91 } |
| 89 | 92 |
| 90 bool StatusAreaButton::Activate() { | 93 bool StatusAreaButton::Activate() { |
| 91 if (active_) { | 94 if (active_) { |
| 92 return views::MenuButton::Activate(); | 95 return views::MenuButton::Activate(); |
| 93 } else { | 96 } else { |
| 94 return true; | 97 return true; |
| 95 } | 98 } |
| 96 } | 99 } |
| 97 | 100 |
| 98 } // namespace chromeos | 101 } // namespace chromeos |
| OLD | NEW |