7 /* GUI_PATH must end with a directory separator. */
8 #define GUI_PATH "gui/"
11 #define ICON_FILE GUI_PATH "icon.bmp"
12 #define LOG_FILE "xuni.log"
14 #define MONOSPACE_FONT GUI_PATH "FreeMono.ttf"
15 #define SANS_SERIF_FONT GUI_PATH "FreeSans.ttf"
17 #define VERSION "xuni version 1.0.0"
18 #define TITLE_PREFIX "xuni: "
22 #define MIN(x,y) ((x) < (y) ? (x) : (y))
23 #define MAX(x,y) ((x) > (y) ? (x) : (y))*/
37 struct string_t mononame
, sansname
;
38 TTF_Font
*mono
, *sans
;
42 struct resize_image_t
{
43 SDL_Surface
*original
, *image
;
50 WIDGET_LISTBOX
/* !!! needs working on */
59 int checked
; /* True if the checkbox is checked. */
67 int ra
; /* !!! not used */
71 struct strings_t data
;
75 enum widget_type_t type
;
78 struct button_t
*button
;
79 struct checkbox_t
*checkbox
;
80 struct textbox_t
*textbox
;
81 void *all
; /* Used by free(). */
103 struct resize_image_t corners
;
106 struct resize_image_t check
;
110 struct widget_t
*widget
;
114 struct widget_sel_t
{
127 SDL_GrabMode restrictfocus
;
129 int main_menu_quality
;
131 struct widget_sel_t sel
;
132 struct widget_p_t active
;
135 void clear_smode(struct smode_t
*smode
);
136 void clear_sel(struct widget_sel_t
*sel
);
137 void clear_active(struct widget_p_t
*wp
);
138 void init_sdl(struct smode_t
*smode
);
139 SDL_GrabMode
set_focus(SDL_GrabMode mode
);
141 void free_resize_image(struct resize_image_t
*image
);
142 void free_fonts(struct font_t
*font
);
143 void free_theme(struct theme_t
*theme
);
144 void load_icon(void);
145 void load_fonts(struct font_t
*font
);
146 void load_theme(struct theme_t
*theme
);
147 SDL_Surface
*load_image(const char *filename
);
148 void load_resize_image(struct resize_image_t
*image
, const char *filename
);
149 int resize_screen(struct smode_t
*smode
, SDL_ResizeEvent
*resize
);
150 int toggle_fullscreen(struct smode_t
*smode
);
151 void reload_fonts(struct font_t
*font
, struct smode_t
*smode
);
152 void resize_theme(struct theme_t
*theme
, struct smode_t
*smode
);
153 void set_caption(const char *s
);
154 void lock_screen(SDL_Surface
*screen
);
155 void unlock_screen(SDL_Surface
*screen
);
156 void blit_surface(SDL_Surface
*screen
, SDL_Surface
*image
, int xp
, int yp
);
157 void blit_surface_area(SDL_Surface
*screen
, SDL_Surface
*image
,
158 int tx
, int ty
, int fx
, int fy
, int fw
, int fh
);
159 void blit_surface_repeat(SDL_Surface
*screen
, SDL_Surface
*image
,
160 int xp
, int yp
, int w
, int h
);
161 void blit_surface_repeat_area(SDL_Surface
*screen
, SDL_Surface
*image
,
162 int tx
, int ty
, int tw
, int th
, int fx
, int fy
, int fw
, int fh
);
163 int in_rect(int xp
, int yp
, int x
, int y
, int w
, int h
);
164 int in_sdl_rect(int xp
, int yp
, SDL_Rect
*r
);
165 void blit_surface_fill_from(SDL_Surface
*screen
, SDL_Surface
*image
,
166 int tx
, int ty
, int tw
, int th
, int fx1
, int fy1
);
167 int is_box_in(enum boxtype_t bt
);
168 int is_box_out(enum boxtype_t bt
);
169 int is_box_normal(enum boxtype_t bt
);
170 int is_box_hover(enum boxtype_t bt
);
171 int is_box_active(enum boxtype_t bt
);
172 enum boxtype_t
paint_box(SDL_Surface
*screen
, struct theme_t
*theme
,
173 SDL_Rect
*b
, enum boxtype_t bt
);
174 void paint_centred_text(SDL_Surface
*screen
, struct theme_t
*theme
,
175 SDL_Surface
*text
, SDL_Rect
*b
, enum boxtype_t bt
);
176 void paint_textbox_text(SDL_Surface
*screen
, struct font_t
*font
,
177 struct theme_t
*theme
, SDL_Surface
*text
, SDL_Rect
*b
, enum boxtype_t bt
,
179 void init_button(struct widget_t
*widget
, TTF_Font
*font
, const char *text
,
180 int x
, int y
, int w
, int h
);
181 void init_checkbox(struct widget_t
*widget
, TTF_Font
*font
, const char *text
,
182 struct theme_t
*theme
, int checked
, int x
, int y
, int w
, int h
, int bw
);
183 void init_textbox(struct widget_t
*widget
, TTF_Font
*font
, const char *data
,
184 size_t len
, struct theme_t
*theme
, int x
, int y
, int w
, int h
);
185 size_t in_widget_array(int xp
, int yp
, struct widget_t
*widget
, size_t n
);
186 int set_widget_sel(struct widget_sel_t
*sel
, int xp
, int yp
, int click
,
187 size_t offset
, struct widget_t
*widget
, size_t n
);
188 enum boxtype_t
paint_widget(struct smode_t
*smode
, struct font_t
*font
,
189 struct theme_t
*theme
, struct widget_t
*widget
);
190 void perform_widget_click(struct widget_t
*widget
);
191 int render_restricted_text(SDL_Surface
**text
, const char *data
,
192 TTF_Font
*font
, int w
);
193 int widget_process_character(struct widget_t
*widget
, SDL_keysym
*sym
,
194 struct smode_t
*smode
, struct font_t
*font
, struct theme_t
*theme
);
195 void paint_widget_array(struct smode_t
*smode
, struct font_t
*font
,
196 struct theme_t
*theme
, struct widget_t
*widget
, size_t n
);
197 int widget_can_be_active(enum widget_type_t wt
);
198 void enable_unicode(enum widget_type_t wt
);
199 void free_widget_array(struct widget_t
*widget
, size_t n
);