PatchworkOS
Loading...
Searching...
No Matches
element.h
Go to the documentation of this file.
1#ifndef PATCHWORK_ELEMENT_H
2#define PATCHWORK_ELEMENT_H 1
3
4#include "cmd.h"
5#include "drawable.h"
6#include "element_id.h"
7#include "font.h"
8#include "procedure.h"
9#include "rect.h"
10#include "theme.h"
11
12#include <stdbool.h>
13#include <stdint.h>
14#include <sys/proc.h>
15
16#if defined(__cplusplus)
17extern "C"
18{
19#endif
20
42
43#define ELEMENT_NONE 0
44#define ELEMENT_TOGGLE (1 << 0)
45#define ELEMENT_FLAT (1 << 1)
46#define ELEMENT_NO_BEZEL (1 << 2)
47#define ELEMENT_NO_OUTLINE (1 << 3)
48
53typedef struct element element_t;
54
68
82
100element_t* element_new(element_t* parent, element_id_t id, const rect_t* rect, const char* text, element_flags_t flags,
101 procedure_t procedure, void* private);
102
110void element_free(element_t* elem);
111
122
129void element_set_private(element_t* elem, void* private);
130
137void* element_get_private(element_t* elem);
138
146
155void element_move(element_t* elem, const rect_t* rect);
156
166
176
184
192
201
210
219
228
236
244
251const char* element_get_text(element_t* elem);
252
262uint64_t element_set_text(element_t* elem, const char* text);
263
273
281
291
301
309
319void element_draw_begin(element_t* elem, drawable_t* draw);
320
330void element_draw_end(element_t* elem, drawable_t* draw);
331
341void element_redraw(element_t* elem, bool shouldPropagate);
342
353
365uint64_t element_dispatch(element_t* elem, const event_t* event);
366
378uint64_t element_emit(element_t* elem, event_type_t type, const void* data, uint64_t size);
379
382#if defined(__cplusplus)
383}
384#endif
385
386#endif
static fd_t data
Definition dwm.c:21
align_t
Alignment type.
Definition drawable.h:48
image_t * element_get_image(element_t *elem)
Get the image of an element.
text_props_t * element_get_text_props(element_t *elem)
Get the text properties of an element.
Definition element.c:361
void element_set_image(element_t *elem, image_t *image)
Set the image of an element.
Definition element.c:381
void element_set_flags(element_t *elem, element_flags_t flags)
Set the flags of an element.
Definition element.c:323
void element_set_private(element_t *elem, void *private)
Set private data for an element.
Definition element.c:163
element_t * element_find(element_t *elem, element_id_t id)
Find a child element by its ID.
Definition element.c:134
uint64_t element_emit(element_t *elem, event_type_t type, const void *data, uint64_t size)
Emit an event to an element.
Definition element.c:555
theme_t * element_get_theme(element_t *elem)
Get the theme of an element.
Definition element.c:401
image_props_t * element_get_image_props(element_t *elem)
Get the image properties of an element.
point_t element_point_to_window(element_t *elem, const point_t *src)
Convert a point from element coordinates to window coordinates.
Definition element.c:269
rect_t element_window_to_rect(element_t *elem, const rect_t *src)
Convert a rectangle from window coordinates to element coordinates.
Definition element.c:283
uint64_t element_dispatch(element_t *elem, const event_t *event)
Dispatch an event to an element.
Definition element.c:476
void element_draw_end(element_t *elem, drawable_t *draw)
End drawing to an element.
Definition element.c:427
element_t * element_new(element_t *parent, element_id_t id, const rect_t *rect, const char *text, element_flags_t flags, procedure_t procedure, void *private)
Allocate and initialize a new element.
Definition element.c:48
rect_t element_get_content_rect(element_t *elem)
Get the element's rectangle in local coordinates.
Definition element.c:213
uint64_t element_flags_t
Element flags type.
Definition element.h:41
void element_draw_begin(element_t *elem, drawable_t *draw)
Begin drawing to an element.
Definition element.c:411
rect_t element_rect_to_window(element_t *elem, const rect_t *src)
Convert a rectangle from element coordinates to window coordinates.
Definition element.c:253
const char * element_get_text(element_t *elem)
Get the text of an element.
uint64_t element_id_t
Element identifier type.
Definition element_id.h:23
rect_t element_get_window_rect(element_t *elem)
Get the rectangle of an element in window coordinates.
Definition element.c:223
void element_free(element_t *elem)
Deinitialize and free an element and all its children.
Definition element.c:113
point_t element_get_window_point(element_t *elem)
Get the top-left point of an element in window coordinates.
Definition element.c:234
void element_redraw(element_t *elem, bool shouldPropagate)
Redraw an element.
Definition element.c:450
element_id_t element_get_id(element_t *elem)
Get the ID of an element.
Definition element.c:183
uint64_t element_set_text(element_t *elem, const char *text)
Set the text of an element.
Definition element.c:343
rect_t element_get_rect(element_t *elem)
Get the rectangle of an element in its parent's coordinate space.
Definition element.c:203
element_flags_t element_get_flags(element_t *elem)
Get the flags of an element.
point_t element_window_to_point(element_t *elem, const point_t *src)
Convert a point from window coordinates to element coordinates.
Definition element.c:299
void element_move(element_t *elem, const rect_t *rect)
Move an element to a new rectangle in its parent's coordinate space.
Definition element.c:193
void element_force_action(element_t *elem, action_type_t action)
Force an action on an element.
Definition element.c:463
void * element_get_private(element_t *elem)
Get private data for an element.
Definition element.c:173
action_type_t
Action type.
Definition event.h:48
uint16_t event_type_t
Event type.
Definition event.h:72
uint64_t(* procedure_t)(window_t *, element_t *, const event_t *)
Definition procedure.h:15
static uint64_t procedure(window_t *win, element_t *elem, const event_t *event)
Definition main.c:46
static image_t * image
Definition main.c:5
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Drawable structure.
Definition drawable.h:35
Opaque element structure.
Definition internal.h:23
Event structure.
Definition event.h:271
Element image properties structure.
Definition element.h:77
point_t srcOffset
Definition element.h:80
align_t xAlign
Definition element.h:78
align_t yAlign
Definition element.h:79
Definition rect.h:13
Element text properties structure.
Definition element.h:63
font_t * font
Definition element.h:66
align_t yAlign
Definition element.h:65
align_t xAlign
Definition element.h:64
Theme structure.
Definition theme.h:71