1 | /**********************************************************************
|
---|
2 | *<
|
---|
3 | FILE: mouseman.h
|
---|
4 |
|
---|
5 | DESCRIPTION: Manages mouse input
|
---|
6 |
|
---|
7 | CREATED BY: Rolf Berteig
|
---|
8 |
|
---|
9 | HISTORY: created 18 October 1994
|
---|
10 |
|
---|
11 | *> Copyright (c) 1994, All Rights Reserved.
|
---|
12 | **********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef __MOUSEMAN__
|
---|
15 | #define __MOUSEMAN__
|
---|
16 |
|
---|
17 | #include "coreexp.h"
|
---|
18 |
|
---|
19 | /* To create a mouse call back, derive a sub class of this
|
---|
20 | * class and redefine 'proc'
|
---|
21 | */
|
---|
22 |
|
---|
23 | class MouseManager;
|
---|
24 |
|
---|
25 | class MouseCallBack {
|
---|
26 | MouseManager * mouseMan;
|
---|
27 | public:
|
---|
28 | virtual ~MouseCallBack() {}
|
---|
29 |
|
---|
30 | CoreExport virtual int proc(
|
---|
31 | HWND hwnd,
|
---|
32 | int msg,
|
---|
33 | int point,
|
---|
34 | int flags,
|
---|
35 | IPoint2 m );
|
---|
36 | virtual void pan(IPoint2 offset) {}
|
---|
37 | virtual int override(int mode) { return mode; } // Return given mouse mode by default
|
---|
38 | void setMouseManager(MouseManager *mm) { mouseMan = mm; }
|
---|
39 | MouseManager *getMouseManager() { return mouseMan; }
|
---|
40 | };
|
---|
41 |
|
---|
42 |
|
---|
43 | // Messages to a mouse procedure and mouseModes.
|
---|
44 | //
|
---|
45 | #define MOUSE_ABORT 0
|
---|
46 | #define MOUSE_IDLE 0
|
---|
47 | #define MOUSE_POINT 1
|
---|
48 | #define MOUSE_MOVE 2
|
---|
49 | #define MOUSE_DBLCLICK 3
|
---|
50 | #define MOUSE_INIT 4
|
---|
51 | #define MOUSE_UNINIT 5
|
---|
52 | #define MOUSE_FREEMOVE 6
|
---|
53 | #define MOUSE_KEYBOARD 7
|
---|
54 | #define MOUSE_PROPCLICK 8
|
---|
55 |
|
---|
56 | // Drag modes.
|
---|
57 | #define CLICK_MODE_DEFAULT 0 // Returned by CreateMouseCallBack to indicate use of system mouse mode
|
---|
58 | #define CLICK_DRAG_CLICK 1
|
---|
59 | #define CLICK_MOVE_CLICK 2
|
---|
60 | #define CLICK_DOWN_POINT 3 // Point messages on mouse-down only
|
---|
61 |
|
---|
62 | // Buttons
|
---|
63 | #define LEFT_BUTTON 0
|
---|
64 | #define MIDDLE_BUTTON 1
|
---|
65 | #define RIGHT_BUTTON 2
|
---|
66 |
|
---|
67 | // Flags to mouse callback.
|
---|
68 | #define MOUSE_SHIFT (1<<0)
|
---|
69 | #define MOUSE_CTRL (1<<1)
|
---|
70 | #define MOUSE_ALT (1<<2)
|
---|
71 | #define MOUSE_LBUTTON (1<<3) // Left button is down
|
---|
72 | #define MOUSE_MBUTTON (1<<4) // Middle button is down
|
---|
73 | #define MOUSE_RBUTTON (1<<5) // Right button is down
|
---|
74 |
|
---|
75 | class MouseManager {
|
---|
76 | private:
|
---|
77 | // This is shared by all instances.
|
---|
78 | static int clickDragMode;
|
---|
79 |
|
---|
80 | // These are local to each instance.
|
---|
81 | int mouseMode;
|
---|
82 | int curPoint;
|
---|
83 | int curButton;
|
---|
84 | MouseCallBack *TheMouseProc[3];
|
---|
85 | int numPoints[3];
|
---|
86 | int buttonState[3];
|
---|
87 | int mouseProcReplaced;
|
---|
88 | int inMouseProc;
|
---|
89 |
|
---|
90 | public:
|
---|
91 | // Constructor/Destructor
|
---|
92 | CoreExport MouseManager();
|
---|
93 | CoreExport ~MouseManager();
|
---|
94 |
|
---|
95 | CoreExport int SetMouseProc( MouseCallBack *mproc, int button, int numPoints=2 );
|
---|
96 | CoreExport int SetDragMode( int mode );
|
---|
97 | CoreExport int GetDragMode( );
|
---|
98 | CoreExport int SetNumPoints( int numPoints, int button );
|
---|
99 | CoreExport int ButtonFlags();
|
---|
100 | CoreExport void Pan(IPoint2 p);
|
---|
101 | CoreExport LRESULT CALLBACK MouseWinProc(
|
---|
102 | HWND hwnd,
|
---|
103 | UINT message,
|
---|
104 | WPARAM wParam,
|
---|
105 | LPARAM lParam );
|
---|
106 |
|
---|
107 | // RB 4-3-96: Resets back to the MOUSE_IDLE state
|
---|
108 | CoreExport void Reset();
|
---|
109 | int GetMouseMode() {return mouseMode;}
|
---|
110 | };
|
---|
111 |
|
---|
112 |
|
---|
113 | #define WM_MOUSEABORT (WM_USER + 7834)
|
---|
114 |
|
---|
115 | #endif // __MOUSEMAN__
|
---|