summaryrefslogtreecommitdiffstats
path: root/chrome/views/native_scroll_bar.h
blob: 711225ad09a59ad9163c48103f1cc512d4009502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_VIEWS_NATIVE_SCROLLBAR_H__
#define CHROME_VIEWS_NATIVE_SCROLLBAR_H__

#include "build/build_config.h"

#include "chrome/views/scroll_bar.h"

namespace views {

class HWNDView;
class ScrollBarContainer;

/////////////////////////////////////////////////////////////////////////////
//
// NativeScrollBar
//
// A View subclass that wraps a Native Windows scrollbar control.
//
// A scrollbar is either horizontal or vertical.
//
/////////////////////////////////////////////////////////////////////////////
class NativeScrollBar : public ScrollBar {
 public:

  // Create new scrollbar, either horizontal or vertical
  explicit NativeScrollBar(bool is_horiz);
  virtual ~NativeScrollBar();

  // Overridden for layout purpose
  virtual void Layout();
  virtual gfx::Size GetPreferredSize();

  // Overridden for keyboard UI purpose
  virtual bool OnKeyPressed(const KeyEvent& event);
  virtual bool OnMouseWheel(const MouseWheelEvent& e);

  virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child);

  // Overridden from ScrollBar
  virtual void Update(int viewport_size, int content_size, int current_pos);
  virtual int GetLayoutSize() const;
  virtual int GetPosition() const;

  // Return the system sizes
  static int GetHorizontalScrollBarHeight();
  static int GetVerticalScrollBarWidth();

 private:
#if defined(OS_WIN)
  // The sb_view_ takes care of keeping sb_container in sync with the
  // view hierarchy
  HWNDView* sb_view_;
#endif  // defined(OS_WIN)

  // sb_container_ is a custom hwnd that we use to wrap the real
  // windows scrollbar. We need to do this to get the scroll events
  // without having to do anything special in the high level hwnd.
  ScrollBarContainer* sb_container_;
};

}  // namespace views

#endif