Add ICU message format support
[chromium-blink-merge.git] / ui / views / controls / scrollbar / scroll_bar.h
blobcd6fc377a5fd44d68bde8fc2f9262aa81840a4ee
1 // Copyright (c) 2012 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.
5 #ifndef UI_VIEWS_CONTROLS_SCROLLBAR_SCROLL_BAR_H_
6 #define UI_VIEWS_CONTROLS_SCROLLBAR_SCROLL_BAR_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "ui/views/view.h"
11 #include "ui/views/views_export.h"
13 namespace views {
15 class ScrollBar;
17 /////////////////////////////////////////////////////////////////////////////
19 // ScrollBarController
21 // ScrollBarController defines the method that should be implemented to
22 // receive notification from a scrollbar
24 /////////////////////////////////////////////////////////////////////////////
25 class VIEWS_EXPORT ScrollBarController {
26 public:
27 // Invoked by the scrollbar when the scrolling position changes
28 // This method typically implements the actual scrolling.
30 // The provided position is expressed in pixels. It is the new X or Y
31 // position which is in the GetMinPosition() / GetMaxPosition range.
32 virtual void ScrollToPosition(ScrollBar* source, int position) = 0;
34 // Returns the amount to scroll. The amount to scroll may be requested in
35 // two different amounts. If is_page is true the 'page scroll' amount is
36 // requested. The page scroll amount typically corresponds to the
37 // visual size of the view. If is_page is false, the 'line scroll' amount
38 // is being requested. The line scroll amount typically corresponds to the
39 // size of one row/column.
41 // The return value should always be positive. A value <= 0 results in
42 // scrolling by a fixed amount.
43 virtual int GetScrollIncrement(ScrollBar* source,
44 bool is_page,
45 bool is_positive) = 0;
48 /////////////////////////////////////////////////////////////////////////////
50 // ScrollBar
52 // A View subclass to wrap to implement a ScrollBar. Our current windows
53 // version simply wraps a native windows scrollbar.
55 // A scrollbar is either horizontal or vertical
57 /////////////////////////////////////////////////////////////////////////////
58 class VIEWS_EXPORT ScrollBar : public View {
59 public:
60 ~ScrollBar() override;
62 // Overridden from View:
63 void GetAccessibleState(ui::AXViewState* state) override;
65 // Returns whether this scrollbar is horizontal.
66 bool IsHorizontal() const;
68 void set_controller(ScrollBarController* controller) {
69 controller_ = controller;
71 ScrollBarController* controller() const { return controller_; }
73 // Update the scrollbar appearance given a viewport size, content size and
74 // current position
75 virtual void Update(int viewport_size, int content_size, int current_pos);
77 // Returns the max and min positions.
78 int GetMaxPosition() const;
79 int GetMinPosition() const;
81 // Returns the position of the scrollbar.
82 virtual int GetPosition() const = 0;
84 // Get the width or height of this scrollbar, for use in layout calculations.
85 // For a vertical scrollbar, this is the width of the scrollbar, likewise it
86 // is the height for a horizontal scrollbar.
87 virtual int GetLayoutSize() const = 0;
89 // Get the width or height for this scrollbar which overlaps with the content.
90 // Default is 0.
91 virtual int GetContentOverlapSize() const;
93 virtual void OnMouseEnteredScrollView(const ui::MouseEvent& event);
94 virtual void OnMouseExitedScrollView(const ui::MouseEvent& event);
96 protected:
97 // Create new scrollbar, either horizontal or vertical. These are protected
98 // since you need to be creating either a NativeScrollBar or a
99 // ImageScrollBar.
100 explicit ScrollBar(bool is_horiz);
102 private:
103 const bool is_horiz_;
105 ScrollBarController* controller_;
107 int max_pos_;
109 DISALLOW_COPY_AND_ASSIGN(ScrollBar);
112 } // namespace views
114 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_SCROLL_BAR_H_