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/text_button.h" | 5 #include "chrome/views/text_button.h" |
6 | 6 |
7 #include "chrome/common/gfx/chrome_canvas.h" | 7 #include "chrome/common/gfx/chrome_canvas.h" |
8 #include "chrome/common/l10n_util.h" | 8 #include "chrome/common/l10n_util.h" |
9 #include "chrome/common/resource_bundle.h" | 9 #include "chrome/common/resource_bundle.h" |
10 #include "chrome/common/throb_animation.h" | 10 #include "chrome/common/throb_animation.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (state == TextButton::BS_PUSHED) | 79 if (state == TextButton::BS_PUSHED) |
80 set = &pushed_set_; | 80 set = &pushed_set_; |
81 | 81 |
82 if (set) { | 82 if (set) { |
83 gfx::Rect bounds = view.bounds(); | 83 gfx::Rect bounds = view.bounds(); |
84 | 84 |
85 // Draw the top left image | 85 // Draw the top left image |
86 canvas->DrawBitmapInt(*set->top_left, 0, 0); | 86 canvas->DrawBitmapInt(*set->top_left, 0, 0); |
87 | 87 |
88 // Tile the top image | 88 // Tile the top image |
89 canvas->TileImageInt(*set->top, | 89 canvas->TileImageInt( |
90 set->top_left->width(), 0, | 90 *set->top, |
91 bounds.width() - set->top_right->width() - set->top_le
ft->width(), | 91 set->top_left->width(), |
92 set->top->height()); | 92 0, |
| 93 bounds.width() - set->top_right->width() - set->top_left->width(), |
| 94 set->top->height()); |
93 | 95 |
94 // Draw the top right image | 96 // Draw the top right image |
95 canvas->DrawBitmapInt(*set->top_right, | 97 canvas->DrawBitmapInt(*set->top_right, |
96 bounds.width() - set->top_right->width(), 0); | 98 bounds.width() - set->top_right->width(), 0); |
97 | 99 |
98 // Tile the left image | 100 // Tile the left image |
99 canvas->TileImageInt(*set->left, | 101 canvas->TileImageInt( |
100 0, set->top_left->height(), | 102 *set->left, |
101 set->top_left->width(), | 103 0, |
102 bounds.height() - set->top->height() - set->bottom_left
->height()); | 104 set->top_left->height(), |
| 105 set->top_left->width(), |
| 106 bounds.height() - set->top->height() - set->bottom_left->height()); |
103 | 107 |
104 // Tile the center image | 108 // Tile the center image |
105 canvas->TileImageInt(*set->center, | 109 canvas->TileImageInt( |
106 set->left->width(), set->top->height(), | 110 *set->center, |
107 bounds.width() - set->right->width() - set->left->width
(), | 111 set->left->width(), |
108 bounds.height() - set->bottom->height() - set->top->hei
ght()); | 112 set->top->height(), |
| 113 bounds.width() - set->right->width() - set->left->width(), |
| 114 bounds.height() - set->bottom->height() - set->top->height()); |
109 | 115 |
110 // Tile the right image | 116 // Tile the right image |
111 canvas->TileImageInt(*set->right, | 117 canvas->TileImageInt( |
112 bounds.width() - set->right->width(), set->top_right->h
eight(), | 118 *set->right, |
113 bounds.width(), bounds.height() - set->bottom_right->he
ight() - set->top_right->height()); | 119 bounds.width() - set->right->width(), |
| 120 set->top_right->height(), |
| 121 bounds.width(), |
| 122 bounds.height() - set->bottom_right->height() - |
| 123 set->top_right->height()); |
114 | 124 |
115 // Draw the bottom left image | 125 // Draw the bottom left image |
116 canvas->DrawBitmapInt(*set->bottom_left, 0, bounds.height() - set->bottom_le
ft->height()); | 126 canvas->DrawBitmapInt(*set->bottom_left, |
| 127 0, |
| 128 bounds.height() - set->bottom_left->height()); |
117 | 129 |
118 // Tile the bottom image | 130 // Tile the bottom image |
119 canvas->TileImageInt(*set->bottom, | 131 canvas->TileImageInt( |
120 set->bottom_left->width(), bounds.height() - set->bott
om->height(), | 132 *set->bottom, |
121 bounds.width() - set->bottom_right->width() - set->bot
tom_left->width(), | 133 set->bottom_left->width(), |
122 set->bottom->height()); | 134 bounds.height() - set->bottom->height(), |
| 135 bounds.width() - set->bottom_right->width() - |
| 136 set->bottom_left->width(), |
| 137 set->bottom->height()); |
123 | 138 |
124 // Draw the bottom right image | 139 // Draw the bottom right image |
125 canvas->DrawBitmapInt(*set->bottom_right, | 140 canvas->DrawBitmapInt(*set->bottom_right, |
126 bounds.width() - set->bottom_right->width(), | 141 bounds.width() - set->bottom_right->width(), |
127 bounds.height() - set->bottom_right->height()); | 142 bounds.height() - set->bottom_right->height()); |
128 } else { | 143 } else { |
129 // Do nothing | 144 // Do nothing |
130 } | 145 } |
131 } | 146 } |
132 | 147 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 void TextButton::SetEnabled(bool enabled) { | 316 void TextButton::SetEnabled(bool enabled) { |
302 if (enabled == IsEnabled()) | 317 if (enabled == IsEnabled()) |
303 return; | 318 return; |
304 BaseButton::SetEnabled(enabled); | 319 BaseButton::SetEnabled(enabled); |
305 color_ = enabled ? kEnabledColor : kDisabledColor; | 320 color_ = enabled ? kEnabledColor : kDisabledColor; |
306 SchedulePaint(); | 321 SchedulePaint(); |
307 } | 322 } |
308 | 323 |
309 } // namespace views | 324 } // namespace views |
310 | 325 |
OLD | NEW |