xref: /haiku/src/add-ons/input_server/methods/pen/PenInputLooper.h (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
1 /*
2 	Copyright 2007, Francois Revol.   All Rights Reserved.
3 	This file may be used under the terms of the Be Sample Code License.
4 */
5 #ifndef _PEN_INPUT_LOOPER_H
6 #define _PEN_INPUT_LOOPER_H
7 
8 #include <MessageRunner.h>
9 #include <Messenger.h>
10 #include <Looper.h>
11 
12 /* internal messages */
13 
14 #define MSG_METHOD_ACTIVATED 'IMAc'
15 #define MSGF_ACTIVE "active" /* bool */
16 
17 #define MSG_BEGIN_INK 'InkB'
18 #define MSG_END_INK 'InkE'
19 
20 #define MSG_SHOW_WIN 'ShoW'
21 #define MSG_HIDE_WIN 'HidW'
22 
23 #define MSG_CHECK_PEN_DOWN 'ChkP'
24 
25 /* menu messages */
26 
27 #define MSG_SET_BACKEND 'SetB'
28 #define MSGF_BACKEND "backend" /* string */
29 
30 #define MSG_SHOW_INK 'InkS' /* toggle */
31 
32 
33 class BMenu;
34 class BWindow;
35 class PenInputServerMethod;
36 class PenInputInkWindow;
37 class PenInputBackend;
38 
39 class PenInputLooper : public BLooper
40 {
41 public:
42 	PenInputLooper(PenInputServerMethod *method);
43 	virtual void	Quit();
44 	void			DispatchMessage(BMessage *message, BHandler *handler);
45 	void			MessageReceived(BMessage *message);
46 	void			EnqueueMessage(BMessage *message);
47 	status_t		InitCheck();
48 
49 //	virtual ~PenInputLooper();
50 	void MethodActivated(bool active);
51 
52 private:
53 	friend class PenInputInkWindow;
54 	void			HandleMethodActivated(bool active);
55 	PenInputServerMethod *fOwner;
56 	PenInputInkWindow *fInkWindow;
57 	PenInputBackend *fBackend;
58 	BMenu *fDeskbarMenu;
59 	BMessenger fInkWindowMsgr;
60 	bool fMouseDown;
61 	bool fStroking;
62 	BMessageRunner *fThresholdRunner;
63 	BMessage *fCachedMouseDown;
64 	/* config */
65 	bool fShowInk;
66 	bigtime_t fMouseDownThreshold;
67 };
68 
69 #endif /* _PEN_INPUT_LOOPER_H */
70