1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #ifndef _ANDROID_GUI_H_
20 #define _ANDROID_GUI_H_
21
22 struct android_char_struct
23 {
24 int rbearing;
25 int lbearing;
26 int width;
27 int ascent;
28 int descent;
29 };
30
31 typedef struct android_char_struct XCharStruct;
32
33 typedef unsigned short android_handle;
34
35 typedef android_handle android_pixmap, Emacs_Pixmap;
36 typedef android_handle android_window, Emacs_Window;
37 typedef android_handle android_gcontext, GContext;
38 typedef android_handle android_drawable, Drawable;
39 typedef android_handle android_cursor, Emacs_Cursor;
40
41 typedef unsigned int android_time;
42
43 struct android_rectangle
44 {
45 int x, y;
46 unsigned width, height;
47 };
48
49 struct android_point
50 {
51 int x, y;
52 };
53
54
55
56 enum android_gc_function
57 {
58 ANDROID_GC_COPY = 0,
59 ANDROID_GC_XOR = 1,
60 };
61
62 enum android_gc_value_mask
63 {
64 ANDROID_GC_FOREGROUND = (1 << 0),
65 ANDROID_GC_BACKGROUND = (1 << 1),
66 ANDROID_GC_FUNCTION = (1 << 2),
67 ANDROID_GC_CLIP_X_ORIGIN = (1 << 3),
68 ANDROID_GC_CLIP_Y_ORIGIN = (1 << 4),
69 ANDROID_GC_CLIP_MASK = (1 << 5),
70 ANDROID_GC_STIPPLE = (1 << 6),
71 ANDROID_GC_FILL_STYLE = (1 << 7),
72 ANDROID_GC_TILE_STIP_X_ORIGIN = (1 << 8),
73 ANDROID_GC_TILE_STIP_Y_ORIGIN = (1 << 9),
74 };
75
76 enum android_fill_style
77 {
78 ANDROID_FILL_SOLID = 0,
79 ANDROID_FILL_OPAQUE_STIPPLED = 1,
80 };
81
82 enum android_window_value_mask
83 {
84 ANDROID_CW_BACK_PIXEL = (1 << 1),
85 ANDROID_CW_OVERRIDE_REDIRECT = (1 << 2),
86 };
87
88 struct android_set_window_attributes
89 {
90
91 unsigned long background_pixel;
92
93
94
95 bool override_redirect;
96 };
97
98 struct android_gc_values
99 {
100
101 unsigned long foreground, background;
102
103
104 enum android_gc_function function;
105
106
107 enum android_fill_style fill_style;
108
109
110 int clip_x_origin, clip_y_origin;
111
112
113 android_pixmap clip_mask, stipple;
114
115
116 int ts_x_origin, ts_y_origin;
117 };
118
119
120
121
122
123 struct android_gc
124 {
125
126 struct android_rectangle *clip_rects;
127
128
129
130 int num_clip_rects;
131
132
133 android_gcontext gcontext;
134
135
136 unsigned long foreground;
137
138
139 unsigned long background;
140
141
142 enum android_gc_function function;
143
144
145 enum android_fill_style fill_style;
146
147
148 int clip_x_origin, clip_y_origin;
149
150
151 android_pixmap clip_mask, stipple;
152
153
154 int ts_x_origin, ts_y_origin;
155 };
156
157 enum android_swap_action
158 {
159 ANDROID_COPIED,
160 };
161
162 enum android_shape
163 {
164 ANDROID_CONVEX,
165 };
166
167 enum android_coord_mode
168 {
169 ANDROID_COORD_MODE_ORIGIN,
170 };
171
172 struct android_swap_info
173 {
174
175 android_window swap_window;
176
177
178 enum android_swap_action swap_action;
179 };
180
181 #define NativeRectangle Emacs_Rectangle
182 #define CONVERT_TO_NATIVE_RECT(xr, nr) ((xr) = (nr))
183 #define CONVERT_FROM_EMACS_RECT(xr, nr) ((nr) = (xr))
184
185 #define STORE_NATIVE_RECT(nr, rx, ry, rwidth, rheight) \
186 ((nr).x = (rx), (nr).y = (ry), \
187 (nr).width = (rwidth), (nr).height = (rheight)) \
188
189 #define ForgetGravity 0
190 #define NorthWestGravity 1
191 #define NorthGravity 2
192 #define NorthEastGravity 3
193 #define WestGravity 4
194 #define CenterGravity 5
195 #define EastGravity 6
196 #define SouthWestGravity 7
197 #define SouthGravity 8
198 #define SouthEastGravity 9
199 #define StaticGravity 10
200
201 #define NoValue 0x0000
202 #define XValue 0x0001
203 #define YValue 0x0002
204 #define WidthValue 0x0004
205 #define HeightValue 0x0008
206 #define AllValues 0x000F
207 #define XNegative 0x0010
208 #define YNegative 0x0020
209
210 #define USPosition (1L << 0)
211 #define USSize (1L << 1)
212 #define PPosition (1L << 2)
213 #define PSize (1L << 3)
214 #define PMinSize (1L << 4)
215 #define PMaxSize (1L << 5)
216 #define PResizeInc (1L << 6)
217 #define PAspect (1L << 7)
218 #define PBaseSize (1L << 8)
219 #define PWinGravity (1L << 9)
220
221 #ifndef ANDROID_STUBIFY
222
223
224 static const int ANDROID_NONE, ANDROID_NO_SYMBOL;
225
226
227
228
229 enum android_event_type
230 {
231 ANDROID_KEY_PRESS,
232 ANDROID_KEY_RELEASE,
233 ANDROID_CONFIGURE_NOTIFY,
234 ANDROID_FOCUS_IN,
235 ANDROID_FOCUS_OUT,
236 ANDROID_WINDOW_ACTION,
237 ANDROID_ENTER_NOTIFY,
238 ANDROID_LEAVE_NOTIFY,
239 ANDROID_MOTION_NOTIFY,
240 ANDROID_BUTTON_PRESS,
241 ANDROID_BUTTON_RELEASE,
242 ANDROID_TOUCH_DOWN,
243 ANDROID_TOUCH_UP,
244 ANDROID_TOUCH_MOVE,
245 ANDROID_WHEEL,
246 ANDROID_ICONIFIED,
247 ANDROID_DEICONIFIED,
248 ANDROID_CONTEXT_MENU,
249 ANDROID_EXPOSE,
250 ANDROID_INPUT_METHOD,
251 };
252
253 struct android_any_event
254 {
255 enum android_event_type type;
256 unsigned long serial;
257 android_window window;
258 };
259
260 enum android_modifier_mask
261 {
262 ANDROID_SHIFT_MASK = 193,
263 ANDROID_CONTROL_MASK = 4096,
264 ANDROID_ALT_MASK = 2,
265 ANDROID_SUPER_MASK = 4,
266 ANDROID_META_MASK = 65536,
267 };
268
269 struct android_key_event
270 {
271 enum android_event_type type;
272 unsigned long serial;
273 android_window window;
274 android_time time;
275 unsigned int state;
276 unsigned int keycode;
277
278
279
280 unsigned int unicode_char;
281
282
283
284 unsigned long counter;
285 };
286
287 typedef struct android_key_event android_key_pressed_event;
288
289
290
291
292 #define ANDROID_IS_MODIFIER_KEY(key) \
293 ((key) == 57 || (key) == 58 || (key) == 113 || (key) == 114 \
294 || (key) == 119 || (key) == 117 || (key) == 118 || (key) == 78 \
295 || (key) == 94 || (key) == 59 || (key) == 60 || (key) == 95 \
296 || (key) == 63 || (key) == 115)
297
298 struct android_configure_event
299 {
300 enum android_event_type type;
301 unsigned long serial;
302 android_window window;
303 android_time time;
304 int x, y;
305 int width, height;
306 };
307
308 struct android_focus_event
309 {
310 enum android_event_type type;
311 unsigned long serial;
312 android_window window;
313 android_time time;
314 };
315
316 struct android_window_action_event
317 {
318 enum android_event_type type;
319 unsigned long serial;
320
321
322 android_window window;
323
324
325
326
327
328 unsigned int action;
329 };
330
331 struct android_crossing_event
332 {
333 enum android_event_type type;
334 unsigned long serial;
335 android_window window;
336 int x, y;
337 unsigned long time;
338 };
339
340 struct android_motion_event
341 {
342 enum android_event_type type;
343 unsigned long serial;
344 android_window window;
345 int x, y;
346 unsigned long time;
347 };
348
349 struct android_button_event
350 {
351 enum android_event_type type;
352 unsigned long serial;
353 android_window window;
354 int x, y;
355 unsigned long time;
356 unsigned int state;
357 unsigned int button;
358 };
359
360 struct android_expose_event
361 {
362 enum android_event_type type;
363 unsigned long serial;
364 android_window window;
365 int x, y;
366 int width, height;
367 };
368
369 enum android_touch_event_flags
370 {
371
372
373 ANDROID_TOUCH_SEQUENCE_CANCELED = 1,
374 };
375
376 struct android_touch_event
377 {
378
379 enum android_event_type type;
380
381
382 unsigned long serial;
383
384
385 android_window window;
386
387
388 int x, y;
389
390
391 unsigned long time;
392
393
394 unsigned int pointer_id;
395
396
397 int flags;
398 };
399
400 struct android_wheel_event
401 {
402
403 enum android_event_type type;
404
405
406 unsigned long serial;
407
408
409 android_window window;
410
411
412 int x, y;
413
414
415 unsigned long time;
416
417
418 int state;
419
420
421 double x_delta, y_delta;
422 };
423
424 struct android_iconify_event
425 {
426
427 enum android_event_type type;
428
429
430 unsigned long serial;
431
432
433 android_window window;
434 };
435
436 struct android_menu_event
437 {
438
439 enum android_event_type type;
440
441
442 unsigned long serial;
443
444
445 android_window window;
446
447
448 int menu_event_id;
449
450
451 int menu_event_serial;
452 };
453
454 enum android_ime_operation
455 {
456 ANDROID_IME_COMMIT_TEXT,
457 ANDROID_IME_DELETE_SURROUNDING_TEXT,
458 ANDROID_IME_FINISH_COMPOSING_TEXT,
459 ANDROID_IME_SET_COMPOSING_TEXT,
460 ANDROID_IME_SET_COMPOSING_REGION,
461 ANDROID_IME_SET_POINT,
462 ANDROID_IME_START_BATCH_EDIT,
463 ANDROID_IME_END_BATCH_EDIT,
464 ANDROID_IME_REQUEST_SELECTION_UPDATE,
465 ANDROID_IME_REQUEST_CURSOR_UPDATES,
466 };
467
468 enum
469 {
470 ANDROID_CURSOR_UPDATE_IMMEDIATE = 1,
471 ANDROID_CURSOR_UPDATE_MONITOR = (1 << 1),
472 };
473
474 struct android_ime_event
475 {
476
477 enum android_event_type type;
478
479
480 unsigned long serial;
481
482
483 android_window window;
484
485
486 enum android_ime_operation operation;
487
488
489
490 ptrdiff_t start, end, position;
491
492
493
494
495
496
497 size_t length;
498
499
500
501
502
503
504
505
506 unsigned short *text;
507
508
509 unsigned long counter;
510 };
511
512 union android_event
513 {
514 enum android_event_type type;
515 struct android_any_event xany;
516 struct android_key_event xkey;
517 struct android_configure_event xconfigure;
518 struct android_focus_event xfocus;
519 struct android_window_action_event xaction;
520 struct android_crossing_event xcrossing;
521 struct android_motion_event xmotion;
522 struct android_button_event xbutton;
523 struct android_expose_event xexpose;
524
525
526
527 struct android_touch_event touch;
528
529
530
531
532 struct android_wheel_event wheel;
533
534
535
536 struct android_iconify_event iconified;
537
538
539 struct android_menu_event menu;
540
541
542 struct android_ime_event ime;
543 };
544
545 enum
546 {
547 ANDROID_CURRENT_TIME = 0L,
548 };
549
550 enum android_lookup_status
551 {
552 ANDROID_BUFFER_OVERFLOW,
553 ANDROID_LOOKUP_NONE,
554 ANDROID_LOOKUP_CHARS,
555 ANDROID_LOOKUP_KEYSYM,
556 ANDROID_LOOKUP_BOTH,
557 };
558
559 enum android_ic_mode
560 {
561 ANDROID_IC_MODE_NULL = 0,
562 ANDROID_IC_MODE_ACTION = 1,
563 ANDROID_IC_MODE_TEXT = 2,
564 };
565
566 extern int android_pending (void);
567 extern void android_next_event (union android_event *);
568 extern bool android_check_if_event (union android_event *,
569 bool (*) (union android_event *,
570 void *),
571 void *);
572
573 extern android_window android_create_window (android_window, int,
574 int, int, int,
575 enum android_window_value_mask,
576 struct
577 android_set_window_attributes *);
578 extern void android_change_window_attributes (android_window,
579 enum android_window_value_mask,
580 struct
581 android_set_window_attributes *);
582 extern void android_set_window_background (android_window, unsigned long);
583 extern void android_destroy_window (android_window);
584 extern void android_reparent_window (android_window, android_window,
585 int, int);
586 extern void android_set_clip_rectangles (struct android_gc *,
587 int, int,
588 struct android_rectangle *,
589 int);
590 extern void android_change_gc (struct android_gc *,
591 enum android_gc_value_mask,
592 struct android_gc_values *);
593
594 extern void android_clear_window (android_window);
595 extern void android_map_window (android_window);
596 extern void android_unmap_window (android_window);
597 extern void android_resize_window (android_window, unsigned int,
598 unsigned int);
599 extern void android_move_window (android_window, int, int);
600 extern void android_swap_buffers (struct android_swap_info *, int);
601 extern void android_get_gc_values (struct android_gc *,
602 enum android_gc_value_mask,
603 struct android_gc_values *);
604 extern void android_set_foreground (struct android_gc *,
605 unsigned long);
606 extern void android_fill_rectangle (android_drawable, struct android_gc *,
607 int, int, unsigned int, unsigned int);
608 extern android_pixmap android_create_pixmap_from_bitmap_data (char *,
609 unsigned int,
610 unsigned int,
611 unsigned long,
612 unsigned long,
613 unsigned int);
614 extern void android_set_clip_mask (struct android_gc *, android_pixmap);
615 extern void android_set_fill_style (struct android_gc *,
616 enum android_fill_style);
617 extern void android_copy_area (android_drawable, android_drawable,
618 struct android_gc *, int, int,
619 unsigned int, unsigned int, int, int);
620 extern void android_free_pixmap (android_drawable);
621
622 extern void android_set_background (struct android_gc *, unsigned long);
623 extern void android_fill_polygon (android_drawable, struct android_gc *,
624 struct android_point *, int,
625 enum android_shape,
626 enum android_coord_mode);
627 extern void android_draw_rectangle (android_drawable, struct android_gc *,
628 int, int, unsigned int, unsigned int);
629 extern void android_draw_point (android_window, struct android_gc *,
630 int, int);
631 extern void android_draw_line (android_window, struct android_gc *,
632 int, int, int, int);
633 extern android_pixmap android_create_pixmap (unsigned int, unsigned int,
634 int);
635 extern void android_set_ts_origin (struct android_gc *, int, int);
636 extern void android_clear_area (android_window, int, int, unsigned int,
637 unsigned int);
638 extern android_pixmap android_create_bitmap_from_data (char *, unsigned int,
639 unsigned int);
640
641 extern void android_bell (void);
642 extern void android_set_input_focus (android_window, unsigned long);
643 extern void android_raise_window (android_window);
644 extern void android_lower_window (android_window);
645 extern int android_query_tree (android_window, android_window *,
646 android_window *, android_window **,
647 unsigned int *);
648 extern void android_get_geometry (android_window, android_window *,
649 int *, int *, unsigned int *,
650 unsigned int *, unsigned int *);
651 extern void android_move_resize_window (android_window, int, int,
652 unsigned int, unsigned int);
653 extern void android_map_raised (android_window);
654 extern void android_translate_coordinates (android_window, int,
655 int, int *, int *);
656 extern int android_wc_lookup_string (android_key_pressed_event *,
657 wchar_t *, int, int *,
658 enum android_lookup_status *);
659 extern void android_update_ic (android_window, ptrdiff_t, ptrdiff_t,
660 ptrdiff_t, ptrdiff_t);
661 extern void android_reset_ic (android_window, enum android_ic_mode);
662 extern void android_update_extracted_text (android_window, void *,
663 int);
664 extern void android_update_cursor_anchor_info (android_window, float,
665 float, float, float);
666 extern int android_set_fullscreen (android_window, bool);
667
668 enum android_cursor_shape
669 {
670 ANDROID_XC_XTERM = 1008,
671 ANDROID_XC_LEFT_PTR = 1000,
672 ANDROID_XC_WATCH = 1004,
673 ANDROID_XC_HAND2 = 1002,
674 ANDROID_XC_SB_H_DOUBLE_ARROW = 1014,
675 ANDROID_XC_SB_V_DOUBLE_ARROW = 1015,
676 ANDROID_XC_LEFT_SIDE = 1020,
677 ANDROID_XC_TOP_LEFT_CORNER = 1020,
678 ANDROID_XC_TOP_SIDE = 1020,
679 ANDROID_XC_TOP_RIGHT_CORNER = 1020,
680 ANDROID_XC_RIGHT_SIDE = 1020,
681 ANDROID_XC_BOTTOM_RIGHT_CORNER = 1020,
682 ANDROID_XC_BOTTOM_SIDE = 1020,
683 ANDROID_XC_BOTTOM_LEFT_CORNER = 1020,
684 ANDROID_XC_NULL = 0,
685 };
686
687 extern android_cursor android_create_font_cursor (enum android_cursor_shape);
688 extern void android_define_cursor (android_window, android_cursor);
689 extern void android_free_cursor (android_cursor);
690
691 #endif
692
693
694
695
696
697
698
699 enum android_image_format
700 {
701 ANDROID_Z_PIXMAP,
702 };
703
704 struct android_image
705 {
706 int width, height;
707 enum android_image_format format;
708 char *data;
709 int depth;
710 int bytes_per_line;
711 int bits_per_pixel;
712 };
713
714 extern struct android_image *android_create_image (unsigned int,
715 enum android_image_format,
716 char *, unsigned int,
717 unsigned int);
718 extern void android_destroy_image (struct android_image *);
719
720 extern void android_put_pixel (struct android_image *, int, int,
721 unsigned long);
722 extern unsigned long android_get_pixel (struct android_image *, int, int);
723 extern struct android_image *android_get_image (android_drawable,
724 enum android_image_format);
725 extern void android_put_image (android_pixmap, struct android_image *);
726
727
728
729
730
731
732
733 struct android_transform
734 {
735 float m1, m2, m3;
736 float m4, m5, m6;
737 };
738
739 extern void android_project_image_bilinear (struct android_image *,
740 struct android_image *,
741 struct android_transform *);
742 extern void android_project_image_nearest (struct android_image *,
743 struct android_image *,
744 struct android_transform *);
745
746
747
748
749
750 extern struct android_gc *android_create_gc (enum android_gc_value_mask,
751 struct android_gc_values *);
752 extern void android_free_gc (struct android_gc *);
753
754 #endif