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 "views/controls/scrollbar/bitmap_scroll_bar.h" | 5 #include "views/controls/scrollbar/bitmap_scroll_bar.h" |
6 | 6 |
7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
8 #include "views/screen.h" | 8 #include "views/screen.h" |
9 #endif | 9 #endif |
10 | 10 |
11 #include "app/keyboard_codes.h" | |
12 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
13 #include "base/callback.h" | 12 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
15 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
16 #include "base/string16.h" | 15 #include "base/string16.h" |
17 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
18 #include "gfx/canvas.h" | 17 #include "gfx/canvas.h" |
19 #include "grit/app_strings.h" | 18 #include "grit/app_strings.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 #include "ui/base/keycodes/keyboard_codes.h" |
21 #include "views/controls/menu/menu.h" | 21 #include "views/controls/menu/menu.h" |
22 #include "views/controls/scroll_view.h" | 22 #include "views/controls/scroll_view.h" |
23 #include "views/widget/widget.h" | 23 #include "views/widget/widget.h" |
24 #include "views/window/window.h" | 24 #include "views/window/window.h" |
25 | 25 |
26 #undef min | 26 #undef min |
27 #undef max | 27 #undef max |
28 | 28 |
29 namespace views { | 29 namespace views { |
30 | 30 |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 491 } |
492 | 492 |
493 bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) { | 493 bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) { |
494 ScrollByContentsOffset(event.GetOffset()); | 494 ScrollByContentsOffset(event.GetOffset()); |
495 return true; | 495 return true; |
496 } | 496 } |
497 | 497 |
498 bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) { | 498 bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) { |
499 ScrollAmount amount = SCROLL_NONE; | 499 ScrollAmount amount = SCROLL_NONE; |
500 switch (event.GetKeyCode()) { | 500 switch (event.GetKeyCode()) { |
501 case app::VKEY_UP: | 501 case ui::VKEY_UP: |
502 if (!IsHorizontal()) | 502 if (!IsHorizontal()) |
503 amount = SCROLL_PREV_LINE; | 503 amount = SCROLL_PREV_LINE; |
504 break; | 504 break; |
505 case app::VKEY_DOWN: | 505 case ui::VKEY_DOWN: |
506 if (!IsHorizontal()) | 506 if (!IsHorizontal()) |
507 amount = SCROLL_NEXT_LINE; | 507 amount = SCROLL_NEXT_LINE; |
508 break; | 508 break; |
509 case app::VKEY_LEFT: | 509 case ui::VKEY_LEFT: |
510 if (IsHorizontal()) | 510 if (IsHorizontal()) |
511 amount = SCROLL_PREV_LINE; | 511 amount = SCROLL_PREV_LINE; |
512 break; | 512 break; |
513 case app::VKEY_RIGHT: | 513 case ui::VKEY_RIGHT: |
514 if (IsHorizontal()) | 514 if (IsHorizontal()) |
515 amount = SCROLL_NEXT_LINE; | 515 amount = SCROLL_NEXT_LINE; |
516 break; | 516 break; |
517 case app::VKEY_PRIOR: | 517 case ui::VKEY_PRIOR: |
518 amount = SCROLL_PREV_PAGE; | 518 amount = SCROLL_PREV_PAGE; |
519 break; | 519 break; |
520 case app::VKEY_NEXT: | 520 case ui::VKEY_NEXT: |
521 amount = SCROLL_NEXT_PAGE; | 521 amount = SCROLL_NEXT_PAGE; |
522 break; | 522 break; |
523 case app::VKEY_HOME: | 523 case ui::VKEY_HOME: |
524 amount = SCROLL_START; | 524 amount = SCROLL_START; |
525 break; | 525 break; |
526 case app::VKEY_END: | 526 case ui::VKEY_END: |
527 amount = SCROLL_END; | 527 amount = SCROLL_END; |
528 break; | 528 break; |
529 } | 529 } |
530 if (amount != SCROLL_NONE) { | 530 if (amount != SCROLL_NONE) { |
531 ScrollByAmount(amount); | 531 ScrollByAmount(amount); |
532 return true; | 532 return true; |
533 } | 533 } |
534 return false; | 534 return false; |
535 } | 535 } |
536 | 536 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 thumb_position = thumb_position - (thumb_->GetSize() / 2); | 717 thumb_position = thumb_position - (thumb_->GetSize() / 2); |
718 return (thumb_position * contents_size_) / GetTrackSize(); | 718 return (thumb_position * contents_size_) / GetTrackSize(); |
719 } | 719 } |
720 | 720 |
721 void BitmapScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { | 721 void BitmapScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { |
722 thumb_track_state_ = state; | 722 thumb_track_state_ = state; |
723 SchedulePaint(); | 723 SchedulePaint(); |
724 } | 724 } |
725 | 725 |
726 } // namespace views | 726 } // namespace views |
OLD | NEW |