GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
include
widgets
gp_widget_json.h
Go to the documentation of this file.
1
//SPDX-License-Identifier: LGPL-2.0-or-later
2
3
/*
4
5
Copyright (c) 2014-2024 Cyril Hrubis <metan@ucw.cz>
6
7
*/
8
18
#ifndef GP_WIDGET_JSON_H
19
#define GP_WIDGET_JSON_H
20
21
#include <
utils/gp_json.h
>
22
#include <
utils/gp_htable.h
>
23
#include <
widgets/gp_widget.h
>
24
25
extern
const
gp_json_obj
*gp_widget_json_attrs;
26
43
typedef
struct
gp_widget_json_addr
{
44
union
{
46
void
*
addr
;
48
int (*
on_event
)(
gp_widget_event
*);
50
const
struct
gp_widget_table_col_ops
*
table_col_ops
;
51
};
53
const
char
*
id
;
54
}
gp_widget_json_addr
;
55
59
struct
gp_widget_json_callbacks
{
61
void
*
default_priv
;
67
const
gp_widget_json_addr
*
addrs
;
68
};
69
73
struct
gp_widget_json_ctx
{
79
gp_htable
**
uids
;
85
gp_widget
*
focused
;
91
const
gp_widget_json_callbacks
*
callbacks
;
92
};
93
103
gp_widget
*
gp_widget_from_json
(
gp_json_reader
*json,
gp_json_val
*val,
gp_widget_json_ctx
*ctx);
104
114
gp_widget
*
gp_widget_from_json_str
(
const
char
*str,
115
const
gp_widget_json_callbacks
*
const
callbacks,
116
gp_htable
**uids);
117
127
gp_widget
*
gp_widget_layout_json
(
const
char
*fname,
128
const
gp_widget_json_callbacks
*
const
callbacks,
129
gp_htable
**uids);
130
141
void
*
gp_widget_callback_addr
(
const
char
*fn_name,
142
const
gp_widget_json_ctx
*ctx);
143
154
void
*
gp_widget_struct_addr
(
const
char
*struct_name,
155
const
gp_widget_json_ctx
*ctx);
156
157
#endif
/* GP_WIDGET_JSON_H */
gp_htable.h
Simple hash table implementation.
gp_json.h
Includes all JSON headers.
gp_widget.h
A widget implementation base.
gp_widget_from_json
gp_widget * gp_widget_from_json(gp_json_reader *json, gp_json_val *val, gp_widget_json_ctx *ctx)
Loads a widget layout given a JSON object.
gp_widget_layout_json
gp_widget * gp_widget_layout_json(const char *fname, const gp_widget_json_callbacks *const callbacks, gp_htable **uids)
Loads a widget layout given a path to a JSON layout description.
gp_widget_callback_addr
void * gp_widget_callback_addr(const char *fn_name, const gp_widget_json_ctx *ctx)
Attempts to get a pointer to a function given it's name.
gp_widget_from_json_str
gp_widget * gp_widget_from_json_str(const char *str, const gp_widget_json_callbacks *const callbacks, gp_htable **uids)
Loads a widget layout given a string with JSON layout.
gp_widget_struct_addr
void * gp_widget_struct_addr(const char *struct_name, const gp_widget_json_ctx *ctx)
Attempts to get a pointer to a structure given it's name.
gp_htable
A hash table.
Definition
gp_htable.h:40
gp_json_obj
A JSON object description.
Definition
gp_json_reader.h:269
gp_json_reader
A JSON parser internal state.
Definition
gp_json_reader.h:43
gp_json_val
A parsed JSON key value pair.
Definition
gp_json_reader.h:68
gp_widget_event
Event structure passed to widget event handler.
Definition
gp_widget_event.h:137
gp_widget_json_addr
A structure to pass widget callbacks.
Definition
gp_widget_json.h:43
gp_widget_json_addr::addr
void * addr
A structure address.
Definition
gp_widget_json.h:46
gp_widget_json_addr::id
const char * id
A callback name used to resolve the target widget on runtime.
Definition
gp_widget_json.h:53
gp_widget_json_addr::table_col_ops
const struct gp_widget_table_col_ops * table_col_ops
A table widget column ops.
Definition
gp_widget_json.h:50
gp_widget_json_addr::on_event
int(* on_event)(gp_widget_event *)
A widget event handler.
Definition
gp_widget_json.h:48
gp_widget_json_callbacks
Structure to pass callbacks to the JSON loader.
Definition
gp_widget_json.h:59
gp_widget_json_callbacks::addrs
const gp_widget_json_addr * addrs
A NULL terminated array of callbacks.
Definition
gp_widget_json.h:67
gp_widget_json_callbacks::default_priv
void * default_priv
A default priv pointer passed to widgets when allocated.
Definition
gp_widget_json.h:61
gp_widget_json_ctx
A context to propagate values top down and bottom up.
Definition
gp_widget_json.h:73
gp_widget_json_ctx::callbacks
const gp_widget_json_callbacks * callbacks
An optional table of widget callbacks.
Definition
gp_widget_json.h:91
gp_widget_json_ctx::focused
gp_widget * focused
A widget that should be focused when layout is loaded.
Definition
gp_widget_json.h:85
gp_widget_json_ctx::uids
gp_htable ** uids
A hash table to store the id -> widget mapping to.
Definition
gp_widget_json.h:79
gp_widget_table_col_ops
Table operations, defined by the application.
Definition
gp_widget_table.h:101
gp_widget
A widget base.
Definition
gp_widget.h:28
Generated by
1.9.8