7 #include "SDL_rotozoom.h"
9 /* GUI_PATH must end with a directory separator. */
10 #define GUI_PATH "gui/"
11 #define GUI_PATH_LEN 4
13 #define ICON_FILE GUI_PATH "icon.bmp"
14 #define LOG_FILE "xuni.log"
16 #define MONOSPACE_FONT GUI_PATH "FreeMono.ttf"
17 #define SANS_SERIF_FONT GUI_PATH "FreeSans.ttf"
19 #define VERSION "xuni version 1.0.0"
20 #define TITLE_PREFIX "xuni: "
24 #define MIN(x,y) ((x) < (y) ? (x) : (y))
25 #define MAX(x,y) ((x) > (y) ? (x) : (y))*/
34 TTF_Font
*mono
, *sans
;
38 struct resize_image_t
{
39 SDL_Surface
*original
, *image
;
67 struct strings_t data
;
71 enum widget_type_t type
;
74 struct button_t
*button
;
75 struct checkbox_t
*checkbox
;
76 struct textbox_t
*textbox
;
98 struct resize_image_t corners
;
101 struct resize_image_t check
;
105 struct widget_t
*widget
;
109 struct widget_sel_t
{
122 SDL_GrabMode restrictfocus
;
124 struct widget_sel_t sel
;
125 struct widget_p_t active
;
128 void default_smode(struct smode_t
*smode
);
129 void clear_smode(struct smode_t
*smode
);
130 void clear_sel(struct widget_sel_t
*sel
);
131 SDL_Surface
*init_sdl(struct smode_t
*smode
);
132 SDL_GrabMode
set_focus(SDL_GrabMode mode
);
134 void free_resize_image(struct resize_image_t
*image
);
135 void free_fonts(struct font_t
*font
);
136 void free_theme(struct theme_t
*theme
);
137 void load_icon(void);
138 void load_fonts(struct font_t
*font
);
139 void load_theme(struct theme_t
*theme
, const char *path
);
140 SDL_Surface
*load_image(const char *filename
);
141 void load_resize_image(struct resize_image_t
*image
, const char *filename
);
142 SDL_Surface
*resize_screen(struct smode_t
*smode
, SDL_ResizeEvent
*resize
);
143 int toggle_fullscreen(SDL_Surface
**screen
, struct smode_t
*smode
);
144 void reload_fonts(struct font_t
*font
, struct smode_t
*smode
);
145 void resize_theme(struct theme_t
*theme
, struct smode_t
*smode
);
146 void set_caption(const char *s
);
147 void lock_screen(SDL_Surface
*screen
);
148 void unlock_screen(SDL_Surface
*screen
);
149 void blit_surface(SDL_Surface
*screen
, SDL_Surface
*image
, int xp
, int yp
);
150 void blit_surface_area(SDL_Surface
*screen
, SDL_Surface
*image
,
151 int tx
, int ty
, int fx
, int fy
, int fw
, int fh
);
152 void blit_surface_repeat(SDL_Surface
*screen
, SDL_Surface
*image
,
153 int xp
, int yp
, int w
, int h
);
154 void blit_surface_repeat_area(SDL_Surface
*screen
, SDL_Surface
*image
,
155 int tx
, int ty
, int tw
, int th
, int fx
, int fy
, int fw
, int fh
);
156 int in_rect(int xp
, int yp
, int x
, int y
, int w
, int h
);
157 int in_sdl_rect(int xp
, int yp
, SDL_Rect
*r
);
158 void blit_surface_fill_from(SDL_Surface
*screen
, SDL_Surface
*image
,
159 int tx
, int ty
, int tw
, int th
, int fx1
, int fy1
);
160 int is_box_in(enum boxtype_t bt
);
161 int is_box_out(enum boxtype_t bt
);
162 int is_box_normal(enum boxtype_t bt
);
163 int is_box_hover(enum boxtype_t bt
);
164 int is_box_active(enum boxtype_t bt
);
165 enum boxtype_t
paint_box(SDL_Surface
*screen
, struct smode_t
*smode
,
166 struct theme_t
*theme
, SDL_Surface
*text
, SDL_Rect
*b
,
167 enum boxtype_t bt
, int centre
);
168 void init_button(struct widget_t
*widget
, TTF_Font
*font
, const char *text
,
169 int x
, int y
, int w
, int h
);
170 void init_checkbox(struct widget_t
*widget
, TTF_Font
*font
, const char *text
,
171 struct theme_t
*theme
, int checked
, int x
, int y
, int w
, int h
, int bw
);
172 void init_textbox(struct widget_t
*widget
, TTF_Font
*font
, const char *data
,
173 size_t len
, struct theme_t
*theme
, int x
, int y
, int w
, int h
);
174 size_t in_widget_array(int xp
, int yp
, struct widget_t
*widget
, size_t n
);
175 int set_widget_sel(struct widget_sel_t
*sel
, int xp
, int yp
, int click
,
176 size_t offset
, struct widget_t
*widget
, size_t n
);
177 enum boxtype_t
paint_widget(SDL_Surface
*screen
, struct smode_t
*smode
,
178 struct theme_t
*theme
, struct widget_t
*widget
);
179 void perform_widget_click(struct widget_t
*widget
);
180 int render_restricted_text(SDL_Surface
**text
, const char *data
,
181 TTF_Font
*font
, int w
);
182 int widget_process_character(struct widget_t
*widget
, SDL_keysym
*sym
,
183 struct font_t
*font
, struct theme_t
*theme
);
184 void paint_widget_array(SDL_Surface
*screen
, struct smode_t
*smode
,
185 struct theme_t
*theme
, struct widget_t
*widget
, size_t n
);
186 int widget_can_be_active(enum widget_type_t wt
);
187 void enable_unicode(enum widget_type_t wt
);
188 void free_widget_array(struct widget_t
*widget
, size_t n
);