OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_VIEWS_H_ | |
6 #define VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_VIEWS_H_ | |
7 #pragma once | |
8 | |
9 #include "ui/gfx/native_theme.h" | |
10 #include "ui/gfx/point.h" | |
11 #include "views/controls/button/button.h" | |
12 #include "views/controls/scrollbar/native_scroll_bar_wrapper.h" | |
13 #include "views/view.h" | |
14 | |
15 namespace gfx { | |
16 class Canvas; | |
17 } | |
18 | |
19 namespace views { | |
20 | |
21 class ScrollBarContainer; | |
22 class ScrollBarThumb; | |
23 | |
24 // Views implementation for the scrollbar. | |
25 class NativeScrollBarViews : public View, | |
26 public ButtonListener, | |
27 public NativeScrollBarWrapper { | |
28 public: | |
29 // Creates new scrollbar, either horizontal or vertical. | |
30 explicit NativeScrollBarViews(NativeScrollBar* native_scroll_bar); | |
31 virtual ~NativeScrollBarViews(); | |
32 | |
33 private: | |
34 // Overridden from View for layout purpose. | |
35 virtual void Layout(); | |
36 virtual gfx::Size GetPreferredSize(); | |
37 | |
38 // Overridden from View for keyboard UI purpose. | |
39 virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE; | |
40 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; | |
41 virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; | |
42 virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; | |
43 virtual bool OnMouseWheel(const MouseWheelEvent& e) OVERRIDE; | |
44 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
45 | |
46 // BaseButton::ButtonListener overrides: | |
47 virtual void ButtonPressed(Button* sender, | |
48 const views::Event& event) OVERRIDE; | |
49 | |
50 // Overridden from NativeScrollBarWrapper. | |
51 virtual int GetPosition() const; | |
52 virtual View* GetView(); | |
53 virtual void Update(int viewport_size, int content_size, int current_pos); | |
54 | |
55 // Moves the scrollbar by the given value. Negative value is allowed. | |
56 // (moves upward) | |
57 void MoveBy(int o); | |
Ben Goodger (Google)
2011/08/19 17:44:33
What is the unit. Pixels or something else?
| |
58 | |
59 // Moves the scrollbar by the page (viewport) size. | |
60 void MovePage(bool positive); | |
Ben Goodger (Google)
2011/08/19 17:44:33
I would prefer if this expressed direction up or d
| |
61 | |
62 // Moves the scrollbar by predefined step size. | |
63 void MoveStep(bool positive); | |
Ben Goodger (Google)
2011/08/19 17:44:33
MoveByStep.
| |
64 | |
65 // Moves the scrollbar to the given position. MoveTo(0) moves it to the top. | |
66 void MoveTo(int p); | |
67 | |
68 // Moves the scrollbar to the end. | |
69 void MoveToBottom(); | |
Ben Goodger (Google)
2011/08/19 17:44:33
Prefer start/end terminology to top/bottom left/ri
| |
70 | |
71 // Invoked when the scrollbar's position is changed. | |
72 void ValueChanged(); | |
73 | |
74 // Returns the area for the track. This is the area of the scrollbar minus | |
75 // the size of the arrow buttons. | |
76 gfx::Rect GetTrackBounds() const; | |
77 | |
78 // The NativeScrollBar we are bound to. | |
79 NativeScrollBar* native_scroll_bar_; | |
80 | |
81 // The scroll bar buttons (Up/Down, Left/Right). | |
82 Button* prev_button_; | |
83 Button* next_button_; | |
84 | |
85 ScrollBarThumb* thumb_; | |
86 | |
87 gfx::NativeTheme::ExtraParams params_; | |
88 gfx::NativeTheme::Part part_; | |
89 gfx::NativeTheme::State state_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(NativeScrollBarViews); | |
92 }; | |
93 | |
94 } // namespace views | |
95 | |
96 #endif // #ifndef VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_VIEWS_H_ | |
97 | |
OLD | NEW |