💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Menkar › files › f3e3f9d91db5edc1200ae1d5a03… captured on 2023-01-29 at 16:31:07. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-07-16)
-=-=-=-=-=-=-
0 #if !defined(WIDGET_H)
1 #define WIDGET_H
2
3 /*
4 * Copyright 2006-2007 Johan Veenhuizen
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 #include <X11/Xlib.h>
26
27 #include "list.h"
28
29 enum widget_type {
30 WIDGET_ANY,
31 WIDGET_WINDOW,
32 WIDGET_TITLE,
33 WIDGET_BUTTON,
34 WIDGET_MENU,
35 WIDGET_RESIZER,
36 WIDGET_SIZEWIN
37 };
38
39 struct dim {
40 int x;
41 int y;
42 int width;
43 int height;
44 };
45
46 struct widget {
47 enum widget_type type;
48 Window xwindow;
49 int mapped;
50 struct dim dim;
51 void (*event)(struct widget *, XEvent *);
52 void (*prepare_repaint)(struct widget *);
53 void (*repaint)(struct widget *);
54 LIST repaintlink;
55 };
56
57 #define WIDGET_XWINDOW(ptr) (((struct widget *)(ptr))->xwindow)
58 #define WIDGET_X(ptr) (((struct widget *)(ptr))->dim.x)
59 #define WIDGET_Y(ptr) (((struct widget *)(ptr))->dim.y)
60 #define WIDGET_WIDTH(ptr) (((struct widget *)(ptr))->dim.width)
61 #define WIDGET_HEIGHT(ptr) (((struct widget *)(ptr))->dim.height)
62 #define WIDGET_MAPPED(ptr) (((struct widget *)(ptr))->mapped)
63
64 #define REPAINT(ptr) schedule_widget_repaint((struct widget *)(ptr));
65
66 void widget_init(void);
67 void widget_fini(void);
68 void create_widget(struct widget *, enum widget_type,
69 Window, unsigned, int, int, int, int);
70 void resize_widget(struct widget *, int, int);
71 void move_widget(struct widget *, int, int);
72 void moveresize_widget(struct widget *, int, int, int, int);
73 void map_widget(struct widget *);
74 void unmap_widget(struct widget *);
75 void destroy_widget(struct widget *);
76 struct widget *find_widget(Window, enum widget_type);
77 void delete_widget_context(Window);
78 void save_widget_context(struct widget *, Window);
79 void schedule_widget_repaint(struct widget *);
80 void repaint_widgets(void);
81
82 #endif /* !defined(WIDGET_H) */
83