| 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" |
| 14 #include "base/keyboard_codes.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "gfx/canvas.h" | 16 #include "gfx/canvas.h" |
| 17 #include "grit/app_strings.h" | 17 #include "grit/app_strings.h" |
| 18 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
| 19 #include "views/controls/menu/menu.h" | 19 #include "views/controls/menu/menu.h" |
| 20 #include "views/controls/scroll_view.h" | 20 #include "views/controls/scroll_view.h" |
| 21 #include "views/widget/widget.h" | 21 #include "views/widget/widget.h" |
| 22 #include "views/window/window.h" | 22 #include "views/window/window.h" |
| 23 | 23 |
| 24 #undef min | 24 #undef min |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 } | 489 } |
| 490 | 490 |
| 491 bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) { | 491 bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) { |
| 492 ScrollByContentsOffset(event.GetOffset()); | 492 ScrollByContentsOffset(event.GetOffset()); |
| 493 return true; | 493 return true; |
| 494 } | 494 } |
| 495 | 495 |
| 496 bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) { | 496 bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) { |
| 497 ScrollAmount amount = SCROLL_NONE; | 497 ScrollAmount amount = SCROLL_NONE; |
| 498 switch (event.GetKeyCode()) { | 498 switch (event.GetKeyCode()) { |
| 499 case app::VKEY_UP: | 499 case base::VKEY_UP: |
| 500 if (!IsHorizontal()) | 500 if (!IsHorizontal()) |
| 501 amount = SCROLL_PREV_LINE; | 501 amount = SCROLL_PREV_LINE; |
| 502 break; | 502 break; |
| 503 case app::VKEY_DOWN: | 503 case base::VKEY_DOWN: |
| 504 if (!IsHorizontal()) | 504 if (!IsHorizontal()) |
| 505 amount = SCROLL_NEXT_LINE; | 505 amount = SCROLL_NEXT_LINE; |
| 506 break; | 506 break; |
| 507 case app::VKEY_LEFT: | 507 case base::VKEY_LEFT: |
| 508 if (IsHorizontal()) | 508 if (IsHorizontal()) |
| 509 amount = SCROLL_PREV_LINE; | 509 amount = SCROLL_PREV_LINE; |
| 510 break; | 510 break; |
| 511 case app::VKEY_RIGHT: | 511 case base::VKEY_RIGHT: |
| 512 if (IsHorizontal()) | 512 if (IsHorizontal()) |
| 513 amount = SCROLL_NEXT_LINE; | 513 amount = SCROLL_NEXT_LINE; |
| 514 break; | 514 break; |
| 515 case app::VKEY_PRIOR: | 515 case base::VKEY_PRIOR: |
| 516 amount = SCROLL_PREV_PAGE; | 516 amount = SCROLL_PREV_PAGE; |
| 517 break; | 517 break; |
| 518 case app::VKEY_NEXT: | 518 case base::VKEY_NEXT: |
| 519 amount = SCROLL_NEXT_PAGE; | 519 amount = SCROLL_NEXT_PAGE; |
| 520 break; | 520 break; |
| 521 case app::VKEY_HOME: | 521 case base::VKEY_HOME: |
| 522 amount = SCROLL_START; | 522 amount = SCROLL_START; |
| 523 break; | 523 break; |
| 524 case app::VKEY_END: | 524 case base::VKEY_END: |
| 525 amount = SCROLL_END; | 525 amount = SCROLL_END; |
| 526 break; | 526 break; |
| 527 } | 527 } |
| 528 if (amount != SCROLL_NONE) { | 528 if (amount != SCROLL_NONE) { |
| 529 ScrollByAmount(amount); | 529 ScrollByAmount(amount); |
| 530 return true; | 530 return true; |
| 531 } | 531 } |
| 532 return false; | 532 return false; |
| 533 } | 533 } |
| 534 | 534 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 thumb_position = thumb_position - (thumb_->GetSize() / 2); | 713 thumb_position = thumb_position - (thumb_->GetSize() / 2); |
| 714 return (thumb_position * contents_size_) / GetTrackSize(); | 714 return (thumb_position * contents_size_) / GetTrackSize(); |
| 715 } | 715 } |
| 716 | 716 |
| 717 void BitmapScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { | 717 void BitmapScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { |
| 718 thumb_track_state_ = state; | 718 thumb_track_state_ = state; |
| 719 SchedulePaint(); | 719 SchedulePaint(); |
| 720 } | 720 } |
| 721 | 721 |
| 722 } // namespace views | 722 } // namespace views |
| OLD | NEW |