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 #include "views/controls/scrollbar/base_scroll_bar_button.h" | |
6 | |
7 namespace views { | |
8 | |
9 BaseScrollBarButton::BaseScrollBarButton(ButtonListener* listener) | |
10 : CustomButton(listener), | |
11 ALLOW_THIS_IN_INITIALIZER_LIST(repeater_( | |
12 NewCallback<BaseScrollBarButton>(this, | |
13 &BaseScrollBarButton::RepeaterNotifyClick))) { | |
14 } | |
15 | |
16 BaseScrollBarButton::~BaseScrollBarButton() { | |
17 } | |
18 | |
19 bool BaseScrollBarButton::OnMousePressed(const MouseEvent& event) { | |
20 Button::NotifyClick(event); | |
21 repeater_.Start(); | |
22 return true; | |
23 } | |
24 | |
25 void BaseScrollBarButton::OnMouseReleased(const MouseEvent& event) { | |
26 OnMouseCaptureLost(); | |
27 } | |
28 | |
29 void BaseScrollBarButton::OnMouseCaptureLost() { | |
30 repeater_.Stop(); | |
31 } | |
32 | |
33 void BaseScrollBarButton::RepeaterNotifyClick() { | |
34 #if defined(OS_WIN) | |
35 DWORD pos = GetMessagePos(); | |
36 POINTS points = MAKEPOINTS(pos); | |
37 gfx::Point cursor_point(points.x, points.y); | |
38 #elif defined(OS_LINUX) | |
39 gfx::Point cursor_point = gfx::Screen::GetCursorScreenPoint(); | |
40 #endif | |
41 views::MouseEvent event(ui::ET_MOUSE_RELEASED, | |
42 cursor_point.x(), cursor_point.y(), | |
43 ui::EF_LEFT_BUTTON_DOWN); | |
44 Button::NotifyClick(event); | |
45 } | |
46 | |
47 } // namespace views | |
OLD | NEW |