add hmi definitions.
@@ -0,0 +1,596 @@ | ||
1 | +/* | |
2 | + * bchank_hmi.c | |
3 | + * | |
4 | + * Copyright (c) 2013 project bchan | |
5 | + * | |
6 | + * This software is provided 'as-is', without any express or implied | |
7 | + * warranty. In no event will the authors be held liable for any damages | |
8 | + * arising from the use of this software. | |
9 | + * | |
10 | + * Permission is granted to anyone to use this software for any purpose, | |
11 | + * including commercial applications, and to alter it and redistribute it | |
12 | + * freely, subject to the following restrictions: | |
13 | + * | |
14 | + * 1. The origin of this software must not be misrepresented; you must not | |
15 | + * claim that you wrote the original software. If you use this software | |
16 | + * in a product, an acknowledgment in the product documentation would be | |
17 | + * appreciated but is not required. | |
18 | + * | |
19 | + * 2. Altered source versions must be plainly marked as such, and must not be | |
20 | + * misrepresented as being the original software. | |
21 | + * | |
22 | + * 3. This notice may not be removed or altered from any source | |
23 | + * distribution. | |
24 | + * | |
25 | + */ | |
26 | + | |
27 | +/* This file is automatically generated. */ | |
28 | + | |
29 | +#include "bchank_hmi.h" | |
30 | +#include "hmi/hmi_windowscroll.h" | |
31 | + | |
32 | +#include <bstdio.h> | |
33 | +#include <bstdlib.h> | |
34 | +#include <tcode.h> | |
35 | +#include <tstring.h> | |
36 | +#include <btron/btron.h> | |
37 | +#include <btron/hmi.h> | |
38 | +#include <btron/vobj.h> | |
39 | + | |
40 | +#if 1 | |
41 | +# define DP(arg) printf arg | |
42 | +# define DP_ER(msg, err) printf("%s (%d/%x)\n", msg, err>>16, err) | |
43 | +#else | |
44 | +# define DP(arg) /**/ | |
45 | +# define DP_ER(msg, err) /**/ | |
46 | +#endif | |
47 | + | |
48 | +struct editorwindow_t_ { | |
49 | + UW flag; | |
50 | + WID wid; | |
51 | + GID gid; | |
52 | + WID parent; | |
53 | + RECT r; | |
54 | + PAT bgpat; | |
55 | + hmi_windowscroll_t wscr; | |
56 | + WEVENT savedwev; | |
57 | +}; | |
58 | + | |
59 | +#define BCHANKHMI_FLAG_SWITCHBUTDN 0x00000001 | |
60 | + | |
61 | +struct bchankhmi_t_ { | |
62 | + WEVENT wev; | |
63 | + bchankhmievent_t evt; | |
64 | + UW flag; | |
65 | + editorwindow_t *editorwindow; | |
66 | +}; | |
67 | + | |
68 | +#define EDITORWINDOW_FLAG_DRAWREQUEST 0x00000001 | |
69 | +#define EDITORWINDOW_FLAG_RSCROLLING 0x00000002 | |
70 | +#define EDITORWINDOW_FLAG_BSCROLLING 0x00000004 | |
71 | + | |
72 | +#define editorwindow_setflag(window, flagx) (window)->flag = (window)->flag | (flagx) | |
73 | +#define editorwindow_clearflag(window, flagx) (window)->flag = (window)->flag & ~(flagx) | |
74 | +#define editorwindow_issetflag(window, flagx) (((window)->flag & (flagx)) == 0 ? False : True) | |
75 | + | |
76 | +EXPORT VOID editorwindow_scrollbyvalue(editorwindow_t *window, W dh, W dv) | |
77 | +{ | |
78 | + hmi_windowscroll_scrollworkrect(&window->wscr, dh, dv); | |
79 | +} | |
80 | + | |
81 | +EXPORT W editorwindow_setdrawrect(editorwindow_t *window, W l, W t, W r, W b) | |
82 | +{ | |
83 | + return hmi_windowscroll_setdrawrect(&window->wscr, l, t, r, b); | |
84 | +} | |
85 | + | |
86 | +EXPORT W editorwindow_setworkrect(editorwindow_t *window, W l, W t, W r, W b) | |
87 | +{ | |
88 | + return hmi_windowscroll_setworkrect(&window->wscr, l, t, r, b); | |
89 | +} | |
90 | + | |
91 | +EXPORT W editorwindow_scrollworkarea(editorwindow_t *window, W dh, W dv) | |
92 | +{ | |
93 | + W err; | |
94 | + err = wscr_wnd(window->wid, NULL, dh, dv, W_MOVE|W_RDSET); | |
95 | + if (err < 0) { | |
96 | + return err; | |
97 | + } | |
98 | + if ((err & W_RDSET) != 0) { | |
99 | + editorwindow_setflag(window, EDITORWINDOW_FLAG_DRAWREQUEST); | |
100 | + } | |
101 | + return 0; | |
102 | +} | |
103 | + | |
104 | +EXPORT W editorwindow_getworkrect(editorwindow_t *window, RECT *r) | |
105 | +{ | |
106 | + return wget_wrk(window->wid, r); | |
107 | +} | |
108 | + | |
109 | +EXPORT W editorwindow_startredisp(editorwindow_t *window, RECT *r) | |
110 | +{ | |
111 | + return wsta_dsp(window->wid, r, NULL); | |
112 | +} | |
113 | + | |
114 | +EXPORT W editorwindow_endredisp(editorwindow_t *window) | |
115 | +{ | |
116 | + return wend_dsp(window->wid); | |
117 | +} | |
118 | + | |
119 | +EXPORT W editorwindow_eraseworkarea(editorwindow_t *window, RECT *r) | |
120 | +{ | |
121 | + return wera_wnd(window->wid, r); | |
122 | +} | |
123 | + | |
124 | +EXPORT W editorwindow_requestredisp(editorwindow_t *window) | |
125 | +{ | |
126 | + return wreq_dsp(window->wid); | |
127 | +} | |
128 | + | |
129 | +EXPORT GID editorwindow_getGID(editorwindow_t *window) | |
130 | +{ | |
131 | + return wget_gid(window->wid); | |
132 | +} | |
133 | + | |
134 | +EXPORT WID editorwindow_getWID(editorwindow_t *window) | |
135 | +{ | |
136 | + return window->wid; | |
137 | +} | |
138 | + | |
139 | +EXPORT W editorwindow_settitle(editorwindow_t *window, TC *title) | |
140 | +{ | |
141 | + return wset_tit(window->wid, -1, title, 0); | |
142 | +} | |
143 | + | |
144 | +EXPORT Bool editorwindow_isactive(editorwindow_t *window) | |
145 | +{ | |
146 | + WID wid; | |
147 | + wid = wget_act(NULL); | |
148 | + if (window->wid == wid) { | |
149 | + return True; | |
150 | + } | |
151 | + return False; | |
152 | +} | |
153 | + | |
154 | +LOCAL VOID editorwindow_butdnwork(editorwindow_t *window, WEVENT *wev, bchankhmievent_t *evt) | |
155 | +{ | |
156 | +} | |
157 | + | |
158 | +LOCAL VOID editorwindow_resize(editorwindow_t *window, SIZE *sz) | |
159 | +{ | |
160 | + RECT work; | |
161 | + Bool workchange = False; | |
162 | + | |
163 | + wget_wrk(window->wid, &work); | |
164 | + if (work.c.left != 0) { | |
165 | + work.c.left = 0; | |
166 | + workchange = True; | |
167 | + } | |
168 | + if (work.c.top != 0) { | |
169 | + work.c.top = 0; | |
170 | + workchange = True; | |
171 | + } | |
172 | + wset_wrk(window->wid, &work); | |
173 | + gset_vis(window->gid, work); | |
174 | + | |
175 | + if (workchange == True) { | |
176 | + wera_wnd(window->wid, NULL); | |
177 | + wreq_dsp(window->wid); | |
178 | + } | |
179 | + | |
180 | + sz->v = work.c.bottom - work.c.top; | |
181 | + sz->h = work.c.right - work.c.left; | |
182 | +} | |
183 | + | |
184 | +LOCAL W editorwindow_open(editorwindow_t *window, TC *title) | |
185 | +{ | |
186 | + WID wid; | |
187 | + | |
188 | + if (window->wid > 0) { | |
189 | + return 0; | |
190 | + } | |
191 | + | |
192 | + wid = wopn_wnd(WA_STD|WA_SIZE|WA_HHDL|WA_VHDL|WA_BBAR|WA_RBAR, window->parent, &(window->r), NULL, 2, title, &window->bgpat, NULL); | |
193 | + if (wid < 0) { | |
194 | + DP_ER("wopn_wnd: subjectoption error", wid); | |
195 | + return wid; | |
196 | + } | |
197 | + window->wid = wid; | |
198 | + window->gid = wget_gid(wid); | |
199 | + hmi_windowscroll_settarget(&window->wscr, wid); | |
200 | + | |
201 | + | |
202 | + wreq_dsp(wid); | |
203 | + | |
204 | + return 0; | |
205 | +} | |
206 | + | |
207 | +LOCAL VOID bchankhmi_setswitchbutdnflag(bchankhmi_t *hmi) | |
208 | +{ | |
209 | + hmi->flag = hmi->flag | BCHANKHMI_FLAG_SWITCHBUTDN; | |
210 | +} | |
211 | + | |
212 | +LOCAL VOID bchankhmi_clearswitchbutdnflag(bchankhmi_t *hmi) | |
213 | +{ | |
214 | + hmi->flag = hmi->flag & ~BCHANKHMI_FLAG_SWITCHBUTDN; | |
215 | +} | |
216 | + | |
217 | +LOCAL Bool bchankhmi_issetswitchbutdnflag(bchankhmi_t *hmi) | |
218 | +{ | |
219 | + if ((hmi->flag & BCHANKHMI_FLAG_SWITCHBUTDN) == 0) { | |
220 | + return False; | |
221 | + } | |
222 | + return True; | |
223 | +} | |
224 | + | |
225 | +LOCAL Bool bchankhmi_iseditorwindowWID(bchankhmi_t *hmi, WID wid) | |
226 | +{ | |
227 | + if (hmi->editorwindow->wid == wid) { | |
228 | + return True; | |
229 | + } | |
230 | + return False; | |
231 | +} | |
232 | + | |
233 | +LOCAL VOID bchankhmi_weventnull(bchankhmi_t *hmi, WEVENT *wev, bchankhmievent_t *evt) | |
234 | +{ | |
235 | + cidl_par(wev->s.wid, &wev->s.pos); | |
236 | + if (wev->s.cmd != W_WORK) | |
237 | + return; /*作業領域外*/ | |
238 | + if (wev->s.stat & ES_CMD) | |
239 | + return; /*命令キーが押されている*/ | |
240 | + if (bchankhmi_iseditorwindowWID(hmi, wev->s.wid) == True) { | |
241 | + gset_ptr(PS_SELECT, NULL, -1, -1); | |
242 | + return; | |
243 | + } | |
244 | + /*ウィンドウ外*/ | |
245 | + hmi->evt.type = BCHANKHMIEVENT_TYPE_COMMON_MOUSEMOVE; | |
246 | + hmi->evt.data.common_mousemove.pos = wev->s.pos; | |
247 | +} | |
248 | + | |
249 | +LOCAL VOID bchankhmi_weventrequest(bchankhmi_t *hmi, WEVENT *wev, bchankhmievent_t *evt) | |
250 | +{ | |
251 | + switch (wev->g.cmd) { | |
252 | + case W_REDISP: /*再表示要求*/ | |
253 | + if (bchankhmi_iseditorwindowWID(hmi, wev->g.wid) == True) { | |
254 | + evt->type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_DRAW; | |
255 | + break; | |
256 | + } | |
257 | + break; | |
258 | + case W_PASTE: /*貼込み要求*/ | |
259 | + wrsp_evt(wev, 1); /*NACK*/ | |
260 | + break; | |
261 | + case W_DELETE: /*保存終了*/ | |
262 | + wrsp_evt(wev, 0); /*ACK*/ | |
263 | + if (bchankhmi_iseditorwindowWID(hmi, wev->g.wid) == True) { | |
264 | + evt->type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_CLOSE; | |
265 | + evt->data.editorwindow_close.save = True; | |
266 | + break; | |
267 | + } | |
268 | + break; | |
269 | + case W_FINISH: /*廃棄終了*/ | |
270 | + wrsp_evt(wev, 0); /*ACK*/ | |
271 | + if (bchankhmi_iseditorwindowWID(hmi, wev->g.wid) == True) { | |
272 | + evt->type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_CLOSE; | |
273 | + evt->data.editorwindow_close.save = False; | |
274 | + break; | |
275 | + } | |
276 | + break; | |
277 | + } | |
278 | +} | |
279 | + | |
280 | +LOCAL VOID bchankhmi_weventbutdn(bchankhmi_t *hmi, WEVENT *wev, bchankhmievent_t *evt) | |
281 | +{ | |
282 | + W i, err; | |
283 | + W dh, dv; /* TODO: add check for exist scrollable window */ | |
284 | + | |
285 | + switch (wev->s.cmd) { | |
286 | + case W_PICT: | |
287 | + switch (wchk_dck(wev->s.time)) { | |
288 | + case W_DCLICK: | |
289 | + if (bchankhmi_iseditorwindowWID(hmi, wev->s.wid) == True) { | |
290 | + evt->type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_CLOSE; | |
291 | + evt->data.editorwindow_close.save = True; /* TODO: tmp value */ | |
292 | + return; | |
293 | + } | |
294 | + return; | |
295 | + case W_PRESS: | |
296 | + break; | |
297 | + default: | |
298 | + return; | |
299 | + } | |
300 | + case W_FRAM: | |
301 | + case W_TITL: | |
302 | + if (wmov_drg(wev, NULL) > 0) { | |
303 | + if (bchankhmi_iseditorwindowWID(hmi, wev->s.wid) == True) { | |
304 | + evt->type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_DRAW; | |
305 | + return; | |
306 | + } | |
307 | + } | |
308 | + return; | |
309 | + case W_LTHD: | |
310 | + case W_RTHD: | |
311 | + case W_LBHD: | |
312 | + case W_RBHD: | |
313 | + switch (wchk_dck(wev->s.time)) { | |
314 | + case W_DCLICK: | |
315 | + i = wchg_wnd(wev->s.wid, NULL, W_MOVE); | |
316 | + break; | |
317 | + case W_PRESS: | |
318 | + i = wrsz_drg(wev, NULL, NULL); | |
319 | + break; | |
320 | + default: | |
321 | + return; | |
322 | + } | |
323 | + | |
324 | + if (bchankhmi_iseditorwindowWID(hmi, wev->s.wid) == True) { | |
325 | + evt->type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_RESIZE; | |
326 | + editorwindow_resize(hmi->editorwindow, &evt->data.editorwindow_resize.work_sz); | |
327 | + hmi_windowscroll_updatebar(&hmi->editorwindow->wscr); | |
328 | + if (i > 0) { | |
329 | + editorwindow_setflag(hmi->editorwindow, EDITORWINDOW_FLAG_DRAWREQUEST); | |
330 | + } | |
331 | + return; | |
332 | + } | |
333 | + return; | |
334 | + case W_RBAR: | |
335 | + if (bchankhmi_iseditorwindowWID(hmi, wev->s.wid) == True) { | |
336 | + err = hmi_windowscroll_weventrbar(&hmi->editorwindow->wscr, wev, &dh, &dv); | |
337 | + if (err < 0) { | |
338 | + return; | |
339 | + } | |
340 | + if (err == 0) { | |
341 | + editorwindow_clearflag(hmi->editorwindow, EDITORWINDOW_FLAG_RSCROLLING); | |
342 | + } else { | |
343 | + editorwindow_setflag(hmi->editorwindow, EDITORWINDOW_FLAG_RSCROLLING); | |
344 | + } | |
345 | + evt->type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_SCROLL; | |
346 | + evt->data.editorwindow_scroll.dh = dh; | |
347 | + evt->data.editorwindow_scroll.dv = dv; | |
348 | + return; | |
349 | + } | |
350 | + return; | |
351 | + case W_BBAR: | |
352 | + if (bchankhmi_iseditorwindowWID(hmi, wev->s.wid) == True) { | |
353 | + err = hmi_windowscroll_weventbbar(&hmi->editorwindow->wscr, wev, &dh, &dv); | |
354 | + if (err < 0) { | |
355 | + return; | |
356 | + } | |
357 | + if (err == 0) { | |
358 | + editorwindow_clearflag(hmi->editorwindow, EDITORWINDOW_FLAG_BSCROLLING); | |
359 | + } else { | |
360 | + editorwindow_setflag(hmi->editorwindow, EDITORWINDOW_FLAG_BSCROLLING); | |
361 | + } | |
362 | + evt->type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_SCROLL; | |
363 | + evt->data.editorwindow_scroll.dh = dh; | |
364 | + evt->data.editorwindow_scroll.dv = dv; | |
365 | + return; | |
366 | + } | |
367 | + return; | |
368 | + case W_WORK: | |
369 | + if (bchankhmi_iseditorwindowWID(hmi, wev->s.wid) == True) { | |
370 | + editorwindow_butdnwork(hmi->editorwindow, wev, evt); | |
371 | + return; | |
372 | + } | |
373 | + return; | |
374 | + } | |
375 | + | |
376 | + return; | |
377 | +} | |
378 | + | |
379 | +LOCAL VOID bchankhmi_weventswitch(bchankhmi_t *hmi, WEVENT *wev, bchankhmievent_t *evt) | |
380 | +{ | |
381 | + bchankhmi_setswitchbutdnflag(hmi); | |
382 | +} | |
383 | + | |
384 | +LOCAL VOID bchankhmi_weventreswitch(bchankhmi_t *hmi, WEVENT *wev, bchankhmievent_t *evt) | |
385 | +{ | |
386 | + bchankhmi_setswitchbutdnflag(hmi); | |
387 | + if (bchankhmi_iseditorwindowWID(hmi, wev->s.wid) == True) { | |
388 | + evt->type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_DRAW; | |
389 | + } | |
390 | +} | |
391 | + | |
392 | +LOCAL VOID bchankhmi_receivemessage(bchankhmi_t *hmi, bchankhmievent_t *evt) | |
393 | +{ | |
394 | + MESSAGE msg; | |
395 | + W err; | |
396 | + | |
397 | + err = rcv_msg(MM_ALL, &msg, sizeof(MESSAGE), WAIT|NOCLR); | |
398 | + if (err >= 0) { | |
399 | + if (msg.msg_type == MS_TMOUT) { /* should be use other type? */ | |
400 | + evt->type = BCHANKHMIEVENT_TYPE_COMMON_TIMEOUT; | |
401 | + evt->data.common_timeout.code = msg.msg_body.TMOUT.code; | |
402 | + } | |
403 | + } | |
404 | + clr_msg(MM_ALL, MM_ALL); | |
405 | +} | |
406 | + | |
407 | +LOCAL Bool bchankhmi_checkflag(bchankhmi_t *hmi, bchankhmievent_t **evt) | |
408 | +{ | |
409 | + W err, dh, dv; | |
410 | + | |
411 | + if (editorwindow_issetflag(hmi->editorwindow, EDITORWINDOW_FLAG_RSCROLLING) == True) { | |
412 | + err = hmi_windowscroll_weventrbar(&hmi->editorwindow->wscr, &hmi->wev, &dh, &dv); | |
413 | + if (err < 0) { | |
414 | + editorwindow_clearflag(hmi->editorwindow, EDITORWINDOW_FLAG_RSCROLLING); | |
415 | + return False; | |
416 | + } | |
417 | + if (err == 0) { | |
418 | + editorwindow_clearflag(hmi->editorwindow, EDITORWINDOW_FLAG_RSCROLLING); | |
419 | + } else { | |
420 | + editorwindow_setflag(hmi->editorwindow, EDITORWINDOW_FLAG_RSCROLLING); | |
421 | + } | |
422 | + hmi->evt.type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_SCROLL; | |
423 | + hmi->evt.data.editorwindow_scroll.dh = dh; | |
424 | + hmi->evt.data.editorwindow_scroll.dv = dv; | |
425 | + return True; | |
426 | + } | |
427 | + if (editorwindow_issetflag(hmi->editorwindow, EDITORWINDOW_FLAG_BSCROLLING) == True) { | |
428 | + err = hmi_windowscroll_weventbbar(&hmi->editorwindow->wscr, &hmi->wev, &dh, &dv); | |
429 | + if (err < 0) { | |
430 | + editorwindow_clearflag(hmi->editorwindow, EDITORWINDOW_FLAG_BSCROLLING); | |
431 | + return False; | |
432 | + } | |
433 | + if (err == 0) { | |
434 | + editorwindow_clearflag(hmi->editorwindow, EDITORWINDOW_FLAG_BSCROLLING); | |
435 | + } else { | |
436 | + editorwindow_setflag(hmi->editorwindow, EDITORWINDOW_FLAG_BSCROLLING); | |
437 | + } | |
438 | + hmi->evt.type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_SCROLL; | |
439 | + hmi->evt.data.editorwindow_scroll.dh = dh; | |
440 | + hmi->evt.data.editorwindow_scroll.dv = dv; | |
441 | + return True; | |
442 | + } | |
443 | + | |
444 | + return False; | |
445 | +} | |
446 | + | |
447 | +EXPORT W bchankhmi_getevent(bchankhmi_t *hmi, bchankhmievent_t **evt) | |
448 | +{ | |
449 | + WEVENT *wev0; | |
450 | + Bool ok; | |
451 | + | |
452 | + hmi->evt.type = BCHANKHMIEVENT_TYPE_NONE; | |
453 | + *evt = &hmi->evt; | |
454 | + wev0 = &hmi->wev; | |
455 | + | |
456 | + ok = bchankhmi_issetswitchbutdnflag(hmi); | |
457 | + if (ok == True) { | |
458 | + bchankhmi_weventbutdn(hmi, wev0, &hmi->evt); | |
459 | + bchankhmi_clearswitchbutdnflag(hmi); | |
460 | + return 0; | |
461 | + } | |
462 | + | |
463 | + if (editorwindow_issetflag(hmi->editorwindow, EDITORWINDOW_FLAG_DRAWREQUEST) == True) { | |
464 | + hmi->evt.type = BCHANKHMIEVENT_TYPE_EDITORWINDOW_DRAW; | |
465 | + editorwindow_clearflag(hmi->editorwindow, EDITORWINDOW_FLAG_DRAWREQUEST); | |
466 | + return 0; | |
467 | + } | |
468 | + | |
469 | + ok = bchankhmi_checkflag(hmi, evt); | |
470 | + if (ok == True) { | |
471 | + return 0; | |
472 | + } | |
473 | + | |
474 | + wget_evt(wev0, WAIT); | |
475 | + switch (wev0->s.type) { | |
476 | + case EV_NULL: | |
477 | + bchankhmi_weventnull(hmi, wev0, &hmi->evt); | |
478 | + break; | |
479 | + case EV_REQUEST: | |
480 | + bchankhmi_weventrequest(hmi, wev0, &hmi->evt); | |
481 | + break; | |
482 | + case EV_RSWITCH: | |
483 | + bchankhmi_weventreswitch(hmi, wev0, &hmi->evt); | |
484 | + break; | |
485 | + case EV_SWITCH: | |
486 | + bchankhmi_weventswitch(hmi, wev0, &hmi->evt); | |
487 | + break; | |
488 | + case EV_BUTDWN: | |
489 | + bchankhmi_weventbutdn(hmi, wev0, &hmi->evt); | |
490 | + break; | |
491 | + case EV_KEYDWN: | |
492 | + case EV_AUTKEY: | |
493 | + hmi->evt.type = BCHANKHMIEVENT_TYPE_COMMON_KEYDOWN; | |
494 | + hmi->evt.data.common_keydown.keycode = wev0->e.data.key.code; | |
495 | + hmi->evt.data.common_keydown.keytop = wev0->e.data.key.keytop; | |
496 | + hmi->evt.data.common_keydown.stat = wev0->e.stat; | |
497 | + break; | |
498 | + case EV_INACT: | |
499 | + pdsp_msg(NULL); | |
500 | + break; | |
501 | + case EV_DEVICE: | |
502 | + oprc_dev(&wev0->e, NULL, 0); | |
503 | + break; | |
504 | + case EV_MSG: | |
505 | + bchankhmi_receivemessage(hmi, &hmi->evt); | |
506 | + break; | |
507 | + case EV_MENU: | |
508 | + hmi->evt.type = BCHANKHMIEVENT_TYPE_COMMON_MENU; | |
509 | + hmi->evt.data.common_menu.pos = wev0->s.pos; | |
510 | + break; | |
511 | + } | |
512 | + | |
513 | + return 0; | |
514 | +} | |
515 | + | |
516 | +EXPORT editorwindow_t* editorwindow_new(RECT *r, WID parent, TC *title, PAT *bgpat) | |
517 | +{ | |
518 | + editorwindow_t *window; | |
519 | + W err; | |
520 | + | |
521 | + window = (editorwindow_t*)malloc(sizeof(editorwindow_t)); | |
522 | + if (window == NULL) { | |
523 | + return NULL; | |
524 | + } | |
525 | + window->flag = 0; | |
526 | + window->wid = -1; | |
527 | + window->gid = -1; | |
528 | + window->parent = parent; | |
529 | + window->r = *r; | |
530 | + if (bgpat != NULL) { | |
531 | + window->bgpat = *bgpat; | |
532 | + } else { | |
533 | + window->bgpat = (PAT){{0, 16, 16, 0x10ffffff, 0, FILL100}}; | |
534 | + } | |
535 | + err = hmi_windowscroll_initialize(&window->wscr, window->wid); | |
536 | + if (err < 0) { | |
537 | + free(window); | |
538 | + return NULL; | |
539 | + } | |
540 | + | |
541 | + err = editorwindow_open(window, title); | |
542 | + if (err < 0) { | |
543 | + hmi_windowscroll_finalize(&window->wscr); | |
544 | + free(window); | |
545 | + return NULL; | |
546 | + } | |
547 | + | |
548 | + return window; | |
549 | +} | |
550 | + | |
551 | +LOCAL VOID editorwindow_delete(editorwindow_t *window) | |
552 | +{ | |
553 | + if (window->wid > 0) { | |
554 | + wcls_wnd(window->wid, CLR); | |
555 | + } | |
556 | + hmi_windowscroll_finalize(&window->wscr); | |
557 | + free(window); | |
558 | +} | |
559 | + | |
560 | +EXPORT editorwindow_t* bchankhmi_neweditorwindow(bchankhmi_t *hmi, RECT *r, WID parent, TC *title, PAT *bgpat) | |
561 | +{ | |
562 | + if (hmi->editorwindow != NULL) { | |
563 | + return NULL; | |
564 | + } | |
565 | + hmi->editorwindow = editorwindow_new(r, parent, title, bgpat); | |
566 | + return hmi->editorwindow; | |
567 | +} | |
568 | + | |
569 | +EXPORT VOID bchankhmi_deleteeditorwindow(bchankhmi_t *hmi, editorwindow_t *window) | |
570 | +{ | |
571 | + editorwindow_delete(hmi->editorwindow); | |
572 | + hmi->editorwindow = NULL; | |
573 | +} | |
574 | + | |
575 | + | |
576 | +EXPORT bchankhmi_t* bchankhmi_new() | |
577 | +{ | |
578 | + bchankhmi_t *hmi; | |
579 | + | |
580 | + hmi = (bchankhmi_t *)malloc(sizeof(bchankhmi_t)); | |
581 | + if (hmi == NULL) { | |
582 | + return NULL; | |
583 | + } | |
584 | + hmi->flag = 0; | |
585 | + hmi->editorwindow = NULL; | |
586 | + | |
587 | + return hmi; | |
588 | +} | |
589 | + | |
590 | +EXPORT VOID bchankhmi_delete(bchankhmi_t *hmi) | |
591 | +{ | |
592 | + if (hmi->editorwindow != NULL) { | |
593 | + editorwindow_delete(hmi->editorwindow); | |
594 | + } | |
595 | + free(hmi); | |
596 | +} |
@@ -0,0 +1,94 @@ | ||
1 | +# | |
2 | +# bchank_hmi.yaml | |
3 | +# | |
4 | +# Copyright (c) 2013 project bchan | |
5 | +# | |
6 | +# This software is provided 'as-is', without any express or implied | |
7 | +# warranty. In no event will the authors be held liable for any damages | |
8 | +# arising from the use of this software. | |
9 | +# | |
10 | +# Permission is granted to anyone to use this software for any purpose, | |
11 | +# including commercial applications, and to alter it and redistribute it | |
12 | +# freely, subject to the following restrictions: | |
13 | +# | |
14 | +# 1. The origin of this software must not be misrepresented; you must not | |
15 | +# claim that you wrote the original software. If you use this software | |
16 | +# in a product, an acknowledgment in the product documentation would be | |
17 | +# appreciated but is not required. | |
18 | +# | |
19 | +# 2. Altered source versions must be plainly marked as such, and must not be | |
20 | +# misrepresented as being the original software. | |
21 | +# | |
22 | +# 3. This notice may not be removed or altered from any source | |
23 | +# distribution. | |
24 | +# | |
25 | + | |
26 | +generator: | |
27 | + output_source: bchank_hmi.c | |
28 | + output_header: bchank_hmi.h | |
29 | + lisence_source: | | |
30 | + /* | |
31 | + * bchank_hmi.c | |
32 | + * | |
33 | + * Copyright (c) 2013 project bchan | |
34 | + * | |
35 | + * This software is provided 'as-is', without any express or implied | |
36 | + * warranty. In no event will the authors be held liable for any damages | |
37 | + * arising from the use of this software. | |
38 | + * | |
39 | + * Permission is granted to anyone to use this software for any purpose, | |
40 | + * including commercial applications, and to alter it and redistribute it | |
41 | + * freely, subject to the following restrictions: | |
42 | + * | |
43 | + * 1. The origin of this software must not be misrepresented; you must not | |
44 | + * claim that you wrote the original software. If you use this software | |
45 | + * in a product, an acknowledgment in the product documentation would be | |
46 | + * appreciated but is not required. | |
47 | + * | |
48 | + * 2. Altered source versions must be plainly marked as such, and must not be | |
49 | + * misrepresented as being the original software. | |
50 | + * | |
51 | + * 3. This notice may not be removed or altered from any source | |
52 | + * distribution. | |
53 | + * | |
54 | + */ | |
55 | + lisence_header: | | |
56 | + /* | |
57 | + * bchank_hmi.h | |
58 | + * | |
59 | + * Copyright (c) 2013 project bchan | |
60 | + * | |
61 | + * This software is provided 'as-is', without any express or implied | |
62 | + * warranty. In no event will the authors be held liable for any damages | |
63 | + * arising from the use of this software. | |
64 | + * | |
65 | + * Permission is granted to anyone to use this software for any purpose, | |
66 | + * including commercial applications, and to alter it and redistribute it | |
67 | + * freely, subject to the following restrictions: | |
68 | + * | |
69 | + * 1. The origin of this software must not be misrepresented; you must not | |
70 | + * claim that you wrote the original software. If you use this software | |
71 | + * in a product, an acknowledgment in the product documentation would be | |
72 | + * appreciated but is not required. | |
73 | + * | |
74 | + * 2. Altered source versions must be plainly marked as such, and must not be | |
75 | + * misrepresented as being the original software. | |
76 | + * | |
77 | + * 3. This notice may not be removed or altered from any source | |
78 | + * distribution. | |
79 | + * | |
80 | + */ | |
81 | + name: bchankhmi | |
82 | + | |
83 | +windows: | |
84 | + - window_name: editorwindow | |
85 | + attributes: | |
86 | + - scrollable | |
87 | + - resizable | |
88 | + - alwaysopen | |
89 | + title: "アスキーアート編集" | |
90 | + title_max_length: 256 | |
91 | + export_events: | |
92 | + - draw | |
93 | + - close | |
94 | + - scroll |
@@ -0,0 +1,130 @@ | ||
1 | +/* | |
2 | + * bchank_hmi.h | |
3 | + * | |
4 | + * Copyright (c) 2013 project bchan | |
5 | + * | |
6 | + * This software is provided 'as-is', without any express or implied | |
7 | + * warranty. In no event will the authors be held liable for any damages | |
8 | + * arising from the use of this software. | |
9 | + * | |
10 | + * Permission is granted to anyone to use this software for any purpose, | |
11 | + * including commercial applications, and to alter it and redistribute it | |
12 | + * freely, subject to the following restrictions: | |
13 | + * | |
14 | + * 1. The origin of this software must not be misrepresented; you must not | |
15 | + * claim that you wrote the original software. If you use this software | |
16 | + * in a product, an acknowledgment in the product documentation would be | |
17 | + * appreciated but is not required. | |
18 | + * | |
19 | + * 2. Altered source versions must be plainly marked as such, and must not be | |
20 | + * misrepresented as being the original software. | |
21 | + * | |
22 | + * 3. This notice may not be removed or altered from any source | |
23 | + * distribution. | |
24 | + * | |
25 | + */ | |
26 | + | |
27 | +/* This file is automatically generated. */ | |
28 | + | |
29 | +#include <basic.h> | |
30 | +#include <btron/dp.h> | |
31 | +#include <btron/hmi.h> | |
32 | + | |
33 | +#ifndef __BCHANK_HMI_H__ | |
34 | +#define __BCHANK_HMI_H__ | |
35 | + | |
36 | +typedef struct editorwindow_t_ editorwindow_t; | |
37 | +typedef VOID (*editorwindow_scrollcalback)(VP arg, W dh, W dv); | |
38 | + | |
39 | +IMPORT VOID editorwindow_scrollbyvalue(editorwindow_t *window, W dh, W dv); | |
40 | +IMPORT W editorwindow_setdrawrect(editorwindow_t *window, W l, W t, W r, W b); | |
41 | +IMPORT W editorwindow_setworkrect(editorwindow_t *window, W l, W t, W r, W b); | |
42 | +IMPORT W editorwindow_scrollworkarea(editorwindow_t *window, W dh, W dv); | |
43 | +IMPORT W editorwindow_getworkrect(editorwindow_t *window, RECT *r); | |
44 | +IMPORT W editorwindow_startredisp(editorwindow_t *window, RECT *r); | |
45 | +IMPORT W editorwindow_endredisp(editorwindow_t *window); | |
46 | +IMPORT W editorwindow_eraseworkarea(editorwindow_t *window, RECT *r); | |
47 | +IMPORT W editorwindow_requestredisp(editorwindow_t *window); | |
48 | +IMPORT GID editorwindow_getGID(editorwindow_t *window); | |
49 | +IMPORT WID editorwindow_getWID(editorwindow_t *window); | |
50 | +IMPORT W editorwindow_settitle(editorwindow_t *window, TC *title); | |
51 | +IMPORT Bool editorwindow_isactive(editorwindow_t *window); | |
52 | + | |
53 | +enum { | |
54 | + BCHANKHMIEVENT_TYPE_NONE, | |
55 | + BCHANKHMIEVENT_TYPE_COMMON_MOUSEMOVE, | |
56 | + BCHANKHMIEVENT_TYPE_COMMON_KEYDOWN, | |
57 | + BCHANKHMIEVENT_TYPE_COMMON_MENU, | |
58 | + BCHANKHMIEVENT_TYPE_COMMON_TIMEOUT, | |
59 | + BCHANKHMIEVENT_TYPE_EDITORWINDOW_DRAW, | |
60 | + BCHANKHMIEVENT_TYPE_EDITORWINDOW_RESIZE, | |
61 | + BCHANKHMIEVENT_TYPE_EDITORWINDOW_CLOSE, | |
62 | + BCHANKHMIEVENT_TYPE_EDITORWINDOW_SCROLL, | |
63 | +}; | |
64 | + | |
65 | +struct bchankhmi_eventdata_mousemove_t_ { | |
66 | + PNT pos; | |
67 | +}; | |
68 | +typedef struct bchankhmi_eventdata_mousemove_t_ bchankhmi_eventdata_mousemove_t; | |
69 | + | |
70 | +struct bchankhmi_eventdata_keydown_t_ { | |
71 | + TC keycode; | |
72 | + UH keytop; | |
73 | + UW stat; | |
74 | +}; | |
75 | +typedef struct bchankhmi_eventdata_keydown_t_ bchankhmi_eventdata_keydown_t; | |
76 | + | |
77 | +struct bchankhmi_eventdata_menu_t_ { | |
78 | + PNT pos; | |
79 | +}; | |
80 | +typedef struct bchankhmi_eventdata_menu_t_ bchankhmi_eventdata_menu_t; | |
81 | + | |
82 | +struct bchankhmi_eventdata_timeout_t_ { | |
83 | + W code; | |
84 | +}; | |
85 | +typedef struct bchankhmi_eventdata_timeout_t_ bchankhmi_eventdata_timeout_t; | |
86 | + | |
87 | +struct editorwindow_eventdata_draw_t_ { | |
88 | +}; | |
89 | +typedef struct editorwindow_eventdata_draw_t_ editorwindow_eventdata_draw_t; | |
90 | + | |
91 | +struct editorwindow_eventdata_resize_t_ { | |
92 | + SIZE work_sz; | |
93 | +}; | |
94 | +typedef struct editorwindow_eventdata_resize_t_ editorwindow_eventdata_resize_t; | |
95 | + | |
96 | +struct editorwindow_eventdata_close_t_ { | |
97 | + Bool save; | |
98 | +}; | |
99 | +typedef struct editorwindow_eventdata_close_t_ editorwindow_eventdata_close_t; | |
100 | + | |
101 | +struct editorwindow_eventdata_scroll_t_ { | |
102 | + W dh; | |
103 | + W dv; | |
104 | +}; | |
105 | +typedef struct editorwindow_eventdata_scroll_t_ editorwindow_eventdata_scroll_t; | |
106 | + | |
107 | +struct bchankhmievent_t_ { | |
108 | + W type; | |
109 | + union { | |
110 | + bchankhmi_eventdata_mousemove_t common_mousemove; | |
111 | + bchankhmi_eventdata_keydown_t common_keydown; | |
112 | + bchankhmi_eventdata_menu_t common_menu; | |
113 | + bchankhmi_eventdata_timeout_t common_timeout; | |
114 | + editorwindow_eventdata_draw_t editorwindow_draw; | |
115 | + editorwindow_eventdata_resize_t editorwindow_resize; | |
116 | + editorwindow_eventdata_close_t editorwindow_close; | |
117 | + editorwindow_eventdata_scroll_t editorwindow_scroll; | |
118 | + } data; | |
119 | +}; | |
120 | +typedef struct bchankhmievent_t_ bchankhmievent_t; | |
121 | + | |
122 | +typedef struct bchankhmi_t_ bchankhmi_t; | |
123 | + | |
124 | +IMPORT bchankhmi_t* bchankhmi_new(); | |
125 | +IMPORT VOID bchankhmi_delete(bchankhmi_t *hmi); | |
126 | +IMPORT W bchankhmi_getevent(bchankhmi_t *hmi, bchankhmievent_t **evt); | |
127 | +IMPORT editorwindow_t* bchankhmi_neweditorwindow(bchankhmi_t *hmi, RECT *r, WID parent, TC *title, PAT *bgpat); | |
128 | +IMPORT VOID bchankhmi_deleteeditorwindow(bchankhmi_t *hmi, editorwindow_t *window); | |
129 | + | |
130 | +#endif |