1 /****************************************************************************
5 Copyright (C) 1999-2002 Lubos Lunak <l.lunak@kde.org>
7 Distributed under the terms of the GNU General Public License version 2.
9 ****************************************************************************/
17 #include <QtCore/QPointer>
29 KDE_EXPORT
extern QPointer
<Gesture
> gesture_handler
;
31 class KDE_EXPORT Stroke
34 // maximum number of numbers in stroke
35 enum { MAX_SEQUENCE
= 25 };
36 // largest number of points allowed to be sampled
37 enum { MAX_POINTS
= 5000 };
38 // default percentage of sample points in a bin from all points to be valid
39 enum { MIN_BIN_POINTS_PERCENTAGE
= 5 };
40 // default threshold of size of smaller axis needed for it to define its own bin size
41 enum { SCALE_RATIO
= 4 };
42 // default number of sample points required to have a valid stroke
43 enum { MIN_POINTS
= 10 };
46 bool record( int x
, int y
);
47 char* translate( int min_bin_points_percentage_P
= MIN_BIN_POINTS_PERCENTAGE
,
48 int scale_ratio_P
= SCALE_RATIO
, int min_points_P
= MIN_POINTS
); // CHECKME returns ret_val ( see below )
51 int bin( int x
, int y
);
52 // metrics for input stroke
57 int bound_x_1
, bound_x_2
;
58 int bound_y_1
, bound_y_2
;
65 char ret_val
[ MAX_SEQUENCE
];
68 class KDE_EXPORT Gesture
69 : public QWidget
// not QObject because of x11EventFilter()
73 Gesture( bool enabled_P
, QObject
* parent_P
);
75 void enable( bool enable_P
);
76 void set_mouse_button( unsigned int button_P
);
77 void set_timeout( int time_P
);
78 void set_exclude( Windowdef_list
* windows_P
);
79 void register_handler( QObject
* receiver_P
, const char* slot_P
);
80 void unregister_handler( QObject
* receiver_P
, const char* slot_P
);
82 virtual bool x11Event( XEvent
* ev_P
);
84 void stroke_timeout();
85 void active_window_changed( WId window_P
);
87 void handle_gesture( const QString
&gesture
, WId window
);
90 void grab_mouse( bool grab_P
);
91 void mouse_replay( bool release_P
);
95 QTimer nostroke_timer
;
100 Windowdef_list
* exclude
;
101 QMap
< QObject
*, bool > handlers
; // bool is just a dummy
104 // Gesture class must be QWidget derived because of x11Event()
105 // but it should be QObject owned -> use a QObject proxy that will delete it
111 DeleteObject( QWidget
* widget_P
, QObject
* parent_P
)
112 : QObject( parent_P
), widget( widget_P
) {}
113 virtual ~DeleteObject() { delete widget
; }
119 //***************************************************************************
121 //***************************************************************************
123 } // namespace KHotKeys