vfs: check userland buffers before reading them.
[haiku.git] / src / preferences / touchpad / TouchpadPrefView.h
blobbd4dd5db0d9d45951b3f93cef1c53bbb6802f84a
1 /*
2 * Copyright 2008-2013 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * John Scipione, jscipione@gmail.com
7 * Clemens Zeidler, haiku@Clemens-Zeidler.de
8 */
9 #ifndef TOUCHPAD_PREF_VIEW_H
10 #define TOUCHPAD_PREF_VIEW_H
13 #include <Bitmap.h>
14 #include <Button.h>
15 #include <CheckBox.h>
16 #include <Invoker.h>
17 #include <Slider.h>
18 #include <View.h>
19 #include <GroupView.h>
21 #include "TouchpadPref.h"
22 #include "touchpad_settings.h"
24 #include <Debug.h>
26 #if DEBUG
27 # define LOG(text...) PRINT((text))
28 #else
29 # define LOG(text...)
30 #endif
32 const uint SCROLL_AREA_CHANGED = '&sac';
33 const uint SCROLL_CONTROL_CHANGED = '&scc';
34 const uint TAP_CONTROL_CHANGED = '&tcc';
35 const uint DEFAULT_SETTINGS = '&dse';
36 const uint REVERT_SETTINGS = '&rse';
39 //! Shows a touchpad
40 class TouchpadView : public BView, public BInvoker {
41 public:
42 TouchpadView(BRect frame);
43 virtual ~TouchpadView();
44 virtual void Draw(BRect updateRect);
45 virtual void MouseDown(BPoint point);
46 virtual void MouseUp(BPoint point);
47 virtual void MouseMoved(BPoint point, uint32 transit,
48 const BMessage* dragMessage);
50 virtual void AttachedToWindow();
51 virtual void GetPreferredSize(float* width, float* height);
53 void SetValues(float rightRange, float bottomRange);
54 float GetRightScrollRatio()
55 { return 1 - fXScrollRange / fPadRect.Width(); }
56 float GetBottomScrollRatio()
57 { return 1
58 - fYScrollRange / fPadRect.Height(); }
59 private:
60 virtual void DrawSliders();
62 BRect fPrefRect;
63 BRect fPadRect;
64 BRect fXScrollDragZone;
65 BRect fXScrollDragZone1;
66 BRect fXScrollDragZone2;
67 float fXScrollRange;
68 float fOldXScrollRange;
69 BRect fYScrollDragZone;
70 BRect fYScrollDragZone1;
71 BRect fYScrollDragZone2;
72 float fYScrollRange;
73 float fOldYScrollRange;
75 bool fXTracking;
76 bool fYTracking;
77 BView* fOffScreenView;
78 BBitmap* fOffScreenBitmap;
82 class TouchpadPrefView : public BGroupView {
83 public:
84 TouchpadPrefView();
85 virtual ~TouchpadPrefView();
86 virtual void MessageReceived(BMessage* message);
87 virtual void AttachedToWindow();
88 virtual void DetachedFromWindow();
89 void SetupView();
91 void SetValues(touchpad_settings *settings);
93 private:
94 TouchpadView* fTouchpadView;
95 BCheckBox* fTwoFingerBox;
96 BCheckBox* fTwoFingerHorizontalBox;
97 BSlider* fScrollStepXSlider;
98 BSlider* fScrollStepYSlider;
99 BSlider* fScrollAccelSlider;
100 BSlider* fTapSlider;
101 BButton* fDefaultButton;
102 BButton* fRevertButton;
104 TouchpadPref fTouchpadPref;
108 #endif // TOUCHPAD_PREF_VIEW_H