OLD | NEW |
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 "chrome/browser/ui/views/wrench_menu.h" | 5 #include "chrome/browser/ui/views/wrench_menu.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // A View subclass that forces SchedulePaint to paint all. Normally when the | 225 // A View subclass that forces SchedulePaint to paint all. Normally when the |
226 // mouse enters/exits a button the buttons invokes SchedulePaint. As part of the | 226 // mouse enters/exits a button the buttons invokes SchedulePaint. As part of the |
227 // button border (MenuButtonBackground) is rendered by the button to the | 227 // button border (MenuButtonBackground) is rendered by the button to the |
228 // left/right of it SchedulePaint on the the button may not be enough, so this | 228 // left/right of it SchedulePaint on the the button may not be enough, so this |
229 // forces a paint all. | 229 // forces a paint all. |
230 class ScheduleAllView : public views::View { | 230 class ScheduleAllView : public views::View { |
231 public: | 231 public: |
232 ScheduleAllView() {} | 232 ScheduleAllView() {} |
233 | 233 |
234 virtual void SchedulePaintInRect(const gfx::Rect& r) { | 234 virtual void SchedulePaintInRect(const gfx::Rect& r) { |
235 if (!IsVisible()) | 235 if (!visible()) |
236 return; | 236 return; |
237 | 237 |
238 if (parent()) | 238 if (parent()) |
239 parent()->SchedulePaintInRect(GetMirroredBounds()); | 239 parent()->SchedulePaintInRect(GetMirroredBounds()); |
240 } | 240 } |
241 | 241 |
242 private: | 242 private: |
243 DISALLOW_COPY_AND_ASSIGN(ScheduleAllView); | 243 DISALLOW_COPY_AND_ASSIGN(ScheduleAllView); |
244 }; | 244 }; |
245 | 245 |
(...skipping 29 matching lines...) Expand all Loading... |
275 | 275 |
276 TextButton* CreateButtonWithAccName(int string_id, | 276 TextButton* CreateButtonWithAccName(int string_id, |
277 MenuButtonBackground::ButtonType type, | 277 MenuButtonBackground::ButtonType type, |
278 int index, | 278 int index, |
279 MenuButtonBackground** background, | 279 MenuButtonBackground** background, |
280 int acc_string_id) { | 280 int acc_string_id) { |
281 TextButton* button = | 281 TextButton* button = |
282 new TextButton(this, UTF16ToWide(l10n_util::GetStringUTF16(string_id))); | 282 new TextButton(this, UTF16ToWide(l10n_util::GetStringUTF16(string_id))); |
283 button->SetAccessibleName( | 283 button->SetAccessibleName( |
284 GetAccessibleNameForWrenchMenuItem(menu_model_, index, acc_string_id)); | 284 GetAccessibleNameForWrenchMenuItem(menu_model_, index, acc_string_id)); |
285 button->SetFocusable(true); | 285 button->set_focusable(true); |
286 button->set_request_focus_on_press(false); | 286 button->set_request_focus_on_press(false); |
287 button->set_tag(index); | 287 button->set_tag(index); |
288 button->SetEnabled(menu_model_->IsEnabledAt(index)); | 288 button->SetEnabled(menu_model_->IsEnabledAt(index)); |
289 button->set_prefix_type(TextButton::PREFIX_HIDE); | 289 button->set_prefix_type(TextButton::PREFIX_HIDE); |
290 MenuButtonBackground* bg = new MenuButtonBackground(type); | 290 MenuButtonBackground* bg = new MenuButtonBackground(type); |
291 button->set_background(bg); | 291 button->set_background(bg); |
292 button->SetEnabledColor(MenuConfig::instance().text_color); | 292 button->SetEnabledColor(MenuConfig::instance().text_color); |
293 if (background) | 293 if (background) |
294 *background = bg; | 294 *background = bg; |
295 button->set_border(new MenuButtonBorder()); | 295 button->set_border(new MenuButtonBorder()); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 IDS_ZOOM_PLUS2, MenuButtonBackground::RIGHT_BUTTON, increment_index, | 412 IDS_ZOOM_PLUS2, MenuButtonBackground::RIGHT_BUTTON, increment_index, |
413 NULL, IDS_ACCNAME_ZOOM_PLUS2); | 413 NULL, IDS_ACCNAME_ZOOM_PLUS2); |
414 | 414 |
415 center_bg->SetOtherButtons(decrement_button_, increment_button_); | 415 center_bg->SetOtherButtons(decrement_button_, increment_button_); |
416 | 416 |
417 fullscreen_button_ = new FullscreenButton(this); | 417 fullscreen_button_ = new FullscreenButton(this); |
418 fullscreen_button_->SetImage( | 418 fullscreen_button_->SetImage( |
419 ImageButton::BS_NORMAL, | 419 ImageButton::BS_NORMAL, |
420 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 420 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
421 IDR_FULLSCREEN_MENU_BUTTON)); | 421 IDR_FULLSCREEN_MENU_BUTTON)); |
422 fullscreen_button_->SetFocusable(true); | 422 fullscreen_button_->set_focusable(true); |
423 fullscreen_button_->set_request_focus_on_press(false); | 423 fullscreen_button_->set_request_focus_on_press(false); |
424 fullscreen_button_->set_tag(fullscreen_index); | 424 fullscreen_button_->set_tag(fullscreen_index); |
425 fullscreen_button_->SetImageAlignment( | 425 fullscreen_button_->SetImageAlignment( |
426 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); | 426 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); |
427 fullscreen_button_->set_border(views::Border::CreateEmptyBorder( | 427 fullscreen_button_->set_border(views::Border::CreateEmptyBorder( |
428 0, kHorizontalPadding, 0, kHorizontalPadding)); | 428 0, kHorizontalPadding, 0, kHorizontalPadding)); |
429 fullscreen_button_->set_background( | 429 fullscreen_button_->set_background( |
430 new MenuButtonBackground(MenuButtonBackground::SINGLE_BUTTON)); | 430 new MenuButtonBackground(MenuButtonBackground::SINGLE_BUTTON)); |
431 fullscreen_button_->SetAccessibleName( | 431 fullscreen_button_->SetAccessibleName( |
432 GetAccessibleNameForWrenchMenuItem( | 432 GetAccessibleNameForWrenchMenuItem( |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 } | 701 } |
702 | 702 |
703 return menu_item; | 703 return menu_item; |
704 } | 704 } |
705 | 705 |
706 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { | 706 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { |
707 selected_menu_model_ = model; | 707 selected_menu_model_ = model; |
708 selected_index_ = index; | 708 selected_index_ = index; |
709 root_->Cancel(); | 709 root_->Cancel(); |
710 } | 710 } |
OLD | NEW |