Minor syntactical changes for readability.
[xuni.git] / src / graphics.h
blob08432327cecdee67f44ca52ea1d4ea862d4660a9
1 /*! \file graphics.h
3 */
5 #ifndef XUNI_GUARD_GRAPHICS_H
6 #define XUNI_GUARD_GRAPHICS_H
8 #include "SDL.h"
10 #include "loadso.h"
11 #include "resource/resource.h"
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
17 typedef size_t panel_type_t;
19 #if 1
20 enum pos_pack_t {
21 POS_PACK_NONE,
22 POS_PACK_TOP,
23 POS_PACK_BOTTOM
26 struct scale_pos_t {
27 double x, y, w, h;
30 struct clip_pos_t {
31 int xoff, yoff;
32 int xclip, yclip, wclip, hclip;
35 struct pos_t {
36 enum pos_pack_t pack;
37 struct scale_pos_t scale;
38 struct clip_pos_t *clip;
39 SDL_Rect real;
41 #else
42 enum pos_type_t {
43 POS_NUMBER,
44 POS_SCALE,
45 POS_PACK
48 enum pos_pack_t {
49 POS_PACK_TOP,
50 POS_PACK_BOTTOM
53 struct axis_pos_t {
54 enum pos_type_t type;
55 union {
56 double scale;
57 int absolute;
58 enum pos_pack_t pack;
59 } num;
62 struct xy_pos_t {
63 struct axis_pos_t x, y, w, h;
66 struct pos_t {
67 struct xy_pos_t pos;
68 struct xy_pos_t *offset;
69 struct xy_pos_t *clip;
70 SDL_Rect real;
72 #endif
74 /*struct string_t {
75 char *data;
76 size_t len;
77 };*/
79 /*struct strings_t {
80 char **data;
81 size_t *len;
82 size_t num;
83 };*/
85 #if !1
86 struct font_t {
87 /*struct string_t mononame, sansname;*/
88 struct font_data_t *font;
89 size_t fonts;
91 #endif
93 struct widget_p_t {
94 struct widget_t *widget;
97 struct widget_edit_t {
98 struct label_t *data, *prev; /* need to be widget_ts */
99 struct widget_t *datawidget;
100 size_t alloc, len, pos;
103 struct widget_sel_t {
104 /*Uint8 button;
105 int xp, yp;*/
106 int wasin, clickin;
107 struct widget_p_t p;
109 struct {
110 int xp, yp;
111 double original;
112 } scrollbar;
115 struct widget_tab_t {
116 panel_type_t panel;
117 size_t sel;
120 struct gui_t {
121 struct widget_t *widget;
123 struct widget_sel_t sel;
124 struct widget_edit_t edit;
125 struct widget_p_t active;
126 struct widget_tab_t tab; /* !!! set, but not read from yet */
129 enum cursor_t {
130 CURSOR_NORMAL,
131 CURSOR_TEXT
134 struct cursors_t {
135 SDL_Cursor *normal, *text;
136 enum cursor_t which;
139 struct theme_t {
140 struct widget_t *current;
141 struct cursors_t cursors;
144 struct smode_t {
145 SDL_Surface *screen;
146 int width, height;
147 int depth;
148 int fullscreen;
149 int focus;
150 SDL_GrabMode restrictfocus;
153 struct xuni_t {
154 struct smode_t *smode;
155 /*struct font_t *font;*/
156 struct theme_t *theme;
157 struct gui_t *gui;
158 struct wtype_array_t *wtype;
159 struct loadso_array_t *loadso;
162 typedef void (*xuni_callback_func_t)(void *vdata, struct xuni_t *xuni);
164 struct xuni_callback_t {
165 void *vdata;
166 xuni_callback_func_t func;
169 void restrict_int(int *value, int max);
170 void restrict_pos(double *pos);
171 void wrap_int(int *value, int max);
172 void init_smode(struct smode_t *smode, struct resource_t *settings);
173 void init_sdl_libraries(struct smode_t *smode, const char *icon);
174 SDL_GrabMode set_focus(SDL_GrabMode mode);
175 int focus_in(Uint8 focus);
176 int focus_changed(struct smode_t *smode, Uint8 focus);
177 void quit_sdl_libraries(void);
178 void free_smode(struct smode_t *smode);
179 void free_theme(struct theme_t *theme);
180 void save_screenshot(SDL_Surface *screen);
181 void paint_cursor(struct xuni_t *xuni, struct widget_t *cursor);
182 void show_cursor(int enable);
183 SDL_Surface *load_image(const char *filename);
184 int resize_screen(struct smode_t *smode, const SDL_ResizeEvent *resize);
185 int toggle_fullscreen(struct smode_t *smode);
186 void use_screen_mode(struct xuni_t *xuni, int width, int height);
187 void set_caption(const char *format, ...)
188 #ifdef __GNUC__ /* enables printf()-style format string checking */
189 __attribute__ ((__format__ (__printf__, 1, 2)))
190 #endif
192 SDL_Rect **list_graphics_modes(struct smode_t *smode);
193 void lock_screen(SDL_Surface *screen);
194 void unlock_screen(SDL_Surface *screen);
195 void clear_screen(SDL_Surface *screen);
196 SDL_Surface *new_surface(int w, int h, int d, int alpha);
197 void free_surface(SDL_Surface *surface);
198 void blit_surface(SDL_Surface *screen, SDL_Surface *image, int xp, int yp);
199 void blit_surface_area(SDL_Surface *screen, SDL_Surface *image,
200 int tx, int ty, int fx, int fy, int fw, int fh);
201 void blit_surface_repeat(SDL_Surface *screen, SDL_Surface *image,
202 int xp, int yp, int w, int h);
203 void blit_surface_repeat_area(SDL_Surface *screen, SDL_Surface *image,
204 int tx, int ty, int tw, int th, int fx, int fy, int fw, int fh);
205 void update_screen(struct xuni_t *xuni);
206 int in_rect(int xp, int yp, int x, int y, int w, int h);
207 int in_sdl_rect(int xp, int yp, const SDL_Rect *r);
208 int pos_in_rect(int xp, int yp, const struct pos_t *pos);
209 void blit_surface_fill_from(SDL_Surface *screen, SDL_Surface *image,
210 int tx, int ty, int tw, int th, int fx1, int fy1);
211 void fill_area(SDL_Surface *screen, int x, int y, int w, int h,
212 SDL_Surface *image, int ix, int iy);
214 #ifdef __cplusplus
216 #endif
218 #endif