1 /*$
2  Copyright (C) 2016-2020 Azel.
3 
4  This file is part of AzPainterB.
5 
6  AzPainterB is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  AzPainterB is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 $*/
19 
20 #ifndef MLIB_EVENT_H
21 #define MLIB_EVENT_H
22 
23 typedef struct
24 {
25 	uint32_t code,
26 		sys_vcode,
27 		state;
28 	int rawcode;
29 	mBool bGrab;
30 }mEventKey;
31 
32 typedef struct
33 {
34 	char ch;
35 }mEventChar;
36 
37 typedef struct
38 {
39 	int flags,x,y,w,h;
40 }mEventConfigure;
41 
42 typedef struct
43 {
44 	int type,x,y,rootx,rooty,btt;
45 	uint32_t state;
46 }mEventPointer;
47 
48 typedef struct
49 {
50 	int dir;
51 	uint32_t state;
52 }mEventScroll;
53 
54 typedef struct
55 {
56 	int bOut,by;
57 }mEventFocus;
58 
59 typedef struct
60 {
61 	mWidget *widgetFrom;
62 	int type,id;
63 	intptr_t param1,param2;
64 }mEventNotify;
65 
66 typedef struct
67 {
68 	uint32_t id;
69 	intptr_t param;
70 }mEventTimer;
71 
72 typedef struct
73 {
74 	mMenu *menu;
75 	int itemID;
76 	mBool bMenuBar;
77 }mEventMenuPopup;
78 
79 typedef struct
80 {
81 	int id,by;
82 	intptr_t param;
83 }mEventCommand;
84 
85 typedef struct
86 {
87 	int len;
88 }mEventString;
89 
90 typedef struct
91 {
92 	int type,btt,device_id;
93 	uint32_t state,flags;
94 	double x,y,rootx,rooty,pressure;
95 	mBool bPenTablet;
96 }mEventPenTablet;
97 
98 /*------------*/
99 
100 typedef struct _mEvent
101 {
102 	int type;
103 	mWidget *widget;
104 	void *data;
105 
106 	union {
107 		mEventKey key;
108 		mEventChar ch;
109 		mEventString str;
110 		mEventPointer pt;
111 		mEventScroll scr;
112 		mEventConfigure config;
113 		mEventFocus focus;
114 		mEventTimer timer;
115 		mEventNotify notify;
116 		mEventCommand cmd;
117 		mEventMenuPopup popup;
118 		mEventPenTablet pen;
119 	};
120 }mEvent;
121 
122 /*------------*/
123 
124 enum MEVENT_TYPE
125 {
126 	MEVENT_QUIT = 1,
127 	MEVENT_CLOSE,
128 	MEVENT_MAP,
129 	MEVENT_UNMAP,
130 	MEVENT_CONFIGURE,
131 	MEVENT_FOCUS,
132 	MEVENT_ENTER,
133 	MEVENT_LEAVE,
134 	MEVENT_KEYDOWN,
135 	MEVENT_KEYUP,
136 	MEVENT_CHAR,
137 	MEVENT_STRING,
138 	MEVENT_POINTER,
139 	MEVENT_POINTER_MODAL,
140 	MEVENT_SCROLL,
141 	MEVENT_TIMER,
142 	MEVENT_NOTIFY,
143 	MEVENT_COMMAND,
144 	MEVENT_MENU_POPUP,
145 	MEVENT_CONSTRUCT,
146 	MEVENT_PENTABLET,
147 	MEVENT_PENTABLET_MODAL,
148 
149 	MEVENT_USER = 10000
150 };
151 
152 enum MEVENT_POINTER_TYPE
153 {
154 	MEVENT_POINTER_TYPE_MOTION = 0,
155 	MEVENT_POINTER_TYPE_PRESS,
156 	MEVENT_POINTER_TYPE_RELEASE,
157 	MEVENT_POINTER_TYPE_DBLCLK
158 };
159 
160 enum MEVENT_CONFIGURE_FLAGS
161 {
162 	MEVENT_CONFIGURE_FLAGS_MOVE = 1,
163 	MEVENT_CONFIGURE_FLAGS_SIZE = 2
164 };
165 
166 enum MEVENT_SCROLL_DIR
167 {
168 	MEVENT_SCROLL_DIR_UP,
169 	MEVENT_SCROLL_DIR_DOWN,
170 	MEVENT_SCROLL_DIR_LEFT,
171 	MEVENT_SCROLL_DIR_RIGHT
172 };
173 
174 enum MEVENT_FOCUS_BY
175 {
176 	MEVENT_FOCUS_BY_UNKNOWN,
177 	MEVENT_FOCUS_BY_WINDOW,
178 	MEVENT_FOCUS_BY_TABMOVE,
179 	MEVENT_FOCUS_BY_UNGRAB
180 };
181 
182 enum MEVENT_COMMAND_BY
183 {
184 	MEVENT_COMMAND_BY_UNKNOWN,
185 	MEVENT_COMMAND_BY_MENU,
186 	MEVENT_COMMAND_BY_ACCEL,
187 	MEVENT_COMMAND_BY_ICONBUTTONS_BUTTON,
188 	MEVENT_COMMAND_BY_ICONBUTTONS_DROP
189 };
190 
191 enum MEVENT_PENTABLET_FLAGS
192 {
193 	MEVENT_PENTAB_FLAGS_STYLUS = 1<<0,
194 	MEVENT_PENTAB_FLAGS_ERASER = 1<<1
195 };
196 
197 #endif
198