Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_gui.h
Go to the documentation of this file.
1
8#ifndef __NILOREA_GUI__
9#define __NILOREA_GUI__
10
11#ifdef __cplusplus
12extern "C"
13{
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
47
50
89
91 typedef struct N_GUI_WIDGET
92 {
96 size_t type ;
97 size_t
99 x ,
107
108
110 typedef struct N_GUI_DIALOG
111 {
117
119 typedef struct N_GUI_TOKEN
120 {
122 size_t type;
125 } N_GUI_TOKEN;
126
128 typedef struct N_GUI_TOKENIZER
129 {
131 const char *input;
133 size_t position;
135
136 // Function prototypes
137 void n_gui_init_tokenizer(N_GUI_TOKENIZER *tokenizer, const char *input);
138 char n_gui_next_char(N_GUI_TOKENIZER *tokenizer);
139 char n_gui_peek_char(N_GUI_TOKENIZER *tokenizer);
140 int n_gui_is_eof(N_GUI_TOKENIZER *tokenizer);
141 N_GUI_TOKEN n_gui_next_token(N_GUI_TOKENIZER *tokenizer, bool *inside_open_tag);
142 void n_gui_print_token(N_GUI_TOKEN token);
143 N_GUI_DIALOG *n_gui_load_dialog( char *html, char *css );
144
145#ifdef __cplusplus
146}
147#endif
152#endif // header guard
#define N_ENUM_DECLARE(MACRO_DEFINITION, enum_name)
Macro to declare a N_ENUM.
Definition n_enum.h:135
TREE * tree
tree of widgets
Definition n_gui.h:113
size_t margin_right
margin right
Definition n_gui.h:78
N_GUI_LAYOUT layout
layout of the widget
Definition n_gui.h:94
size_t margin_top
margin top
Definition n_gui.h:72
size_t margin_bottom
margin bottom
Definition n_gui.h:74
size_t x
computed x position
Definition n_gui.h:99
size_t type
type of widget
Definition n_gui.h:96
size_t vertical_align
vertical align type
Definition n_gui.h:66
size_t font_size
font size
Definition n_gui.h:68
N_STR * font
font file string
Definition n_gui.h:85
size_t max_width
maximum width
Definition n_gui.h:58
size_t max_height
maximum height
Definition n_gui.h:62
size_t font_style
font style
Definition n_gui.h:70
size_t min_width
minimum width
Definition n_gui.h:56
HASH_TABLE * styles
hash table of styles
Definition n_gui.h:115
size_t y
computed y position
Definition n_gui.h:101
ALLEGRO_COLOR background_color
background color
Definition n_gui.h:81
size_t type
type of token
Definition n_gui.h:122
N_STR * background_image
background image file string
Definition n_gui.h:87
char value[N_GUI_MAX_TOKEN_SIZE]
token content
Definition n_gui.h:124
size_t w
computed width
Definition n_gui.h:103
size_t h
computed height
Definition n_gui.h:105
size_t margin_left
margin left
Definition n_gui.h:76
size_t horizontal_align
horziontal align type
Definition n_gui.h:64
size_t min_height
minimum height
Definition n_gui.h:60
size_t position
position in the input text
Definition n_gui.h:133
const char * input
pointer to the input text
Definition n_gui.h:131
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:189
#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:111
structure of a N_GUI_DIALOG or N_GUI_WIDGET layout
Definition n_gui.h:53
structure of a N_GUI_TOKENIZER token
Definition n_gui.h:120
structure of a N_GUI_DIALOG tokenizer
Definition n_gui.h:129
structure of a N_GUI_DIALOG widget
Definition n_gui.h:92
structure of a hash table
Definition n_hash.h:108
A box including a string and his lenght.
Definition n_str.h:173
structure of a TREE
Definition n_trees.h:69
Allegro5 helpers.
Common headers and low-level hugly functions & define.
__N_GUI_TOKEN
type for a token
Definition n_gui.c:16
Hash functions and table.
List structures and definitions.
Generic log system.
N_STR and string function declaration.
trees module headers