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 UI_VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_GTK_H_ | |
6 #define UI_VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_GTK_H_ | |
7 #pragma once | |
8 | |
9 #include "base/compiler_specific.h" | |
10 #include "ui/views/controls/native_control_gtk.h" | |
11 #include "ui/views/controls/scrollbar/native_scroll_bar_wrapper.h" | |
12 | |
13 namespace views { | |
14 | |
15 ///////////////////////////////////////////////////////////////////////////// | |
16 // | |
17 // NativeScrollBarGtk | |
18 // | |
19 // A View subclass that wraps a Native gtk scrollbar control. | |
20 // | |
21 // A scrollbar is either horizontal or vertical. | |
22 // | |
23 ///////////////////////////////////////////////////////////////////////////// | |
24 class NativeScrollBarGtk : public NativeControlGtk, | |
25 public NativeScrollBarWrapper { | |
26 public: | |
27 // Creates new scrollbar, either horizontal or vertical. | |
28 explicit NativeScrollBarGtk(NativeScrollBar* native_scroll_bar); | |
29 virtual ~NativeScrollBarGtk(); | |
30 | |
31 private: | |
32 // Overridden from View for layout purpose. | |
33 virtual void Layout() OVERRIDE; | |
34 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
35 | |
36 // Overridden from View for keyboard UI purpose. | |
37 virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE; | |
38 virtual bool OnMouseWheel(const MouseWheelEvent& e) OVERRIDE; | |
39 | |
40 // Overridden from NativeControlGtk. | |
41 virtual void CreateNativeControl() OVERRIDE; | |
42 | |
43 // Overridden from NativeScrollBarWrapper. | |
44 virtual int GetPosition() const OVERRIDE; | |
45 virtual View* GetView() OVERRIDE; | |
46 virtual void Update(int viewport_size, | |
47 int content_size, | |
48 int current_pos) OVERRIDE; | |
49 | |
50 // Moves the scrollbar by the given value. Negative value is allowed. | |
51 // (moves upward) | |
52 void MoveBy(int o); | |
53 | |
54 // Moves the scrollbar by the page (viewport) size. | |
55 void MovePage(bool positive); | |
56 | |
57 // Moves the scrollbar by predefined step size. | |
58 void MoveStep(bool positive); | |
59 | |
60 // Moves the scrollbar to the given position. MoveTo(0) moves it to the top. | |
61 void MoveTo(int p); | |
62 | |
63 // Moves the scrollbar to the end. | |
64 void MoveToBottom(); | |
65 | |
66 // Invoked when the scrollbar's position is changed. | |
67 void ValueChanged(); | |
68 static void CallValueChanged(GtkWidget* widget, | |
69 NativeScrollBarGtk* scroll_bar); | |
70 | |
71 // The NativeScrollBar we are bound to. | |
72 NativeScrollBar* native_scroll_bar_; | |
73 | |
74 private: | |
75 DISALLOW_COPY_AND_ASSIGN(NativeScrollBarGtk); | |
76 }; | |
77 | |
78 } // namespace views | |
79 | |
80 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_GTK_H_ | |
OLD | NEW |