Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_gui.h
Go to the documentation of this file.
1
9#ifndef __NILOREA_GUI__
10#define __NILOREA_GUI__
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <ctype.h>
24#include <stdbool.h>
25
27#define N_GUI_MAX_TOKEN_SIZE 1024
28
29#include <nilorea/n_allegro5.h>
30#include <nilorea/n_common.h>
31#include <nilorea/n_str.h>
32#include <nilorea/n_log.h>
33#include <nilorea/n_list.h>
34#include <nilorea/n_hash.h>
35#include <nilorea/n_trees.h>
36
38#define N_ENUM_N_GUI_TOKEN(_) \
39 _(N_GUI_TOKEN_TAG_OPEN, 2) \
40 _(N_GUI_TOKEN_TAG_CLOSE, 4) \
41 _(N_GUI_TOKEN_TAG_NAME, 8) \
42 _(N_GUI_TOKEN_ATTR_NAME, 16) \
43 _(N_GUI_TOKEN_ATTR_VALUE, 32) \
44 _(N_GUI_TOKEN_TEXT, 64) \
45 _(N_GUI_TOKEN_EOF, 128)
46
49
87
89typedef struct N_GUI_WIDGET {
93 size_t type;
94 size_t
104
112
114typedef struct N_GUI_TOKEN {
116 size_t type;
120
122typedef struct N_GUI_TOKENIZER {
124 const char* input;
126 size_t position;
128
129// Function prototypes
130void n_gui_init_tokenizer(N_GUI_TOKENIZER* tokenizer, const char* input);
131char n_gui_next_char(N_GUI_TOKENIZER* tokenizer);
132char n_gui_peek_char(N_GUI_TOKENIZER* tokenizer);
133int n_gui_is_eof(N_GUI_TOKENIZER* tokenizer);
134N_GUI_TOKEN n_gui_next_token(N_GUI_TOKENIZER* tokenizer, bool* inside_open_tag);
136N_GUI_DIALOG* n_gui_load_dialog(char* html, char* css);
137
138#ifdef __cplusplus
139}
140#endif
145#endif // header guard
#define N_ENUM_DECLARE(MACRO_DEFINITION, enum_name)
Macro to declare a N_ENUM.
Definition n_enum.h:133
TREE * tree
tree of widgets
Definition n_gui.h:108
size_t margin_right
margin right
Definition n_gui.h:76
char value[1024]
token content
Definition n_gui.h:118
N_GUI_LAYOUT layout
layout of the widget
Definition n_gui.h:91
size_t margin_top
margin top
Definition n_gui.h:70
size_t margin_bottom
margin bottom
Definition n_gui.h:72
size_t x
computed x position
Definition n_gui.h:96
size_t type
type of widget
Definition n_gui.h:93
size_t vertical_align
vertical align type
Definition n_gui.h:64
size_t font_size
font size
Definition n_gui.h:66
N_STR * font
font file string
Definition n_gui.h:83
size_t max_width
maximum width
Definition n_gui.h:56
size_t max_height
maximum height
Definition n_gui.h:60
size_t font_style
font style
Definition n_gui.h:68
size_t min_width
minimum width
Definition n_gui.h:54
HASH_TABLE * styles
hash table of styles
Definition n_gui.h:110
size_t y
computed y position
Definition n_gui.h:98
ALLEGRO_COLOR background_color
background color
Definition n_gui.h:79
size_t type
type of token
Definition n_gui.h:116
N_STR * background_image
background image file string
Definition n_gui.h:85
size_t w
computed width
Definition n_gui.h:100
size_t h
computed height
Definition n_gui.h:102
size_t margin_left
margin left
Definition n_gui.h:74
size_t horizontal_align
horizontal align type
Definition n_gui.h:62
size_t min_height
minimum height
Definition n_gui.h:58
size_t position
position in the input text
Definition n_gui.h:126
const char * input
pointer to the input text
Definition n_gui.h:124
__N_GUI_TOKEN
Network codes declaration.
Definition n_gui.h:48
char n_gui_next_char(N_GUI_TOKENIZER *tokenizer)
Get next character from input.
Definition n_gui.c:34
void n_gui_print_token(N_GUI_TOKEN token)
Function to print a token (for debugging purposes)
Definition n_gui.c:171
int n_gui_is_eof(N_GUI_TOKENIZER *tokenizer)
 
Definition n_gui.c:52
char n_gui_peek_char(N_GUI_TOKENIZER *tokenizer)
Peek at next character without advancing the position.
Definition n_gui.c:43
N_GUI_DIALOG * n_gui_load_dialog(char *html, char *css)
Load a html + css file into a N_GUI_DIALOG.
Definition n_gui.c:203
#define N_GUI_MAX_TOKEN_SIZE
maximum size of a single token content
Definition n_gui.h:27
void n_gui_init_tokenizer(N_GUI_TOKENIZER *tokenizer, const char *input)
Initialize tokenizer.
Definition n_gui.c:24
#define N_ENUM_N_GUI_TOKEN(_)
N_GUI_CTX codes definition.
Definition n_gui.h:38
N_GUI_TOKEN n_gui_next_token(N_GUI_TOKENIZER *tokenizer, bool *inside_open_tag)
Read next N_GUI_TOKEN from input.
Definition n_gui.c:62
structure of a N_GUI_DIALOG
Definition n_gui.h:106
structure of a N_GUI_DIALOG or N_GUI_WIDGET layout
Definition n_gui.h:51
structure of a N_GUI_TOKENIZER token
Definition n_gui.h:114
structure of a N_GUI_DIALOG tokenizer
Definition n_gui.h:122
structure of a N_GUI_DIALOG widget
Definition n_gui.h:89
structure of a hash table
Definition n_hash.h:117
A box including a string and his lenght.
Definition n_str.h:39
structure of a TREE
Definition n_trees.h:64
Allegro5 helpers.
Common headers and low-level functions & define.
Hash functions and table.
List structures and definitions.
Generic log system.
N_STR and string function declaration.
trees module headers