dirty redraw and SDL framebuffer example
[windtk] / src / windtk.h
index 6b6724c..996d473 100644 (file)
@@ -49,10 +49,18 @@ struct wt_image {
 };
 
 struct wt_rect {
-       int x, y, width, height;
+       int x, y, w, h;
+};
+
+/* graphics flags */
+enum {
+       WT_GFX_RGB              = 1,    /* RGB mode, calls newcolor to set current, not to allocate */
+       WT_GFX_NODIRTY  = 2             /* don't use dirty rects, always redraw completely */
 };
 
 struct wt_graphics {
+       unsigned int flags;
+
        int (*newcolor)(int r, int g, int b);
        void (*color)(int c);
 
@@ -68,11 +76,29 @@ struct wt_graphics {
        int (*baseline)(int font);
 };
 
+typedef void (*wt_draw_func)(wt_widget*, struct wt_graphics*);
+
+struct wt_theme {
+       char *name;
+       void *so;
+       wt_draw_func draw_window;
+       wt_draw_func draw_label;
+       wt_draw_func draw_button;
+       wt_draw_func draw_checkbox;
+       wt_draw_func draw_textfield;
+
+       struct wt_theme *next;
+};
+
 void wt_allocator(void *(*allocfunc)(size_t), void (*freefunc)(void*));
 
 int wt_init(int w, int h, struct wt_graphics *gfx);
 void wt_destroy(void);
 
+struct wt_theme *wt_load_theme(const char *path);      /* load dynamically, where applicable */
+void wt_unload_theme(struct wt_theme *theme);
+void wt_use_theme(struct wt_theme *theme);
+
 void wt_viewport(int x, int y, int w, int h);
 void wt_graphics(struct wt_graphics *gfx);
 
@@ -82,10 +108,17 @@ void wt_inp_motion(int x, int y);
 
 void wt_draw(void);
 
+/* screen regions updated by the last wt_draw */
+int wt_num_upd(void);
+struct wt_rect *wt_upd_rect(int idx);
+void wt_add_upd_rect(struct wt_rect *r);
+
 wt_widget *wt_alloc_widget(wt_widget *par);
 void wt_free_widget(wt_widget *w);
 void wt_free_tree(wt_widget *tree);
 
+void wt_dirty_widget(wt_widget *w);            /* propagates to children */
+
 wt_widget *wt_window(wt_widget *par, const char *title, int style, int x, int y, int width, int height);
 wt_widget *wt_label(wt_widget *par, const char *text, int x, int y);
 wt_widget *wt_button(wt_widget *par, const char *text, int x, int y, int width, int height);
@@ -135,6 +168,8 @@ int wt_isenabled(wt_widget *w);
 
 void wt_callback(wt_widget *w, int type, wt_callback_func func, void *cls);
 
-void wt_setrect(struct wt_rect *r, int x, int y, int w, int h);
+void wt_rect(struct wt_rect *r, int x, int y, int w, int h);
+void wt_rect_union(struct wt_rect *a, struct wt_rect *b);
+int wt_rect_overlap(struct wt_rect *a, struct wt_rect *b);
 
 #endif /* WINDTK_H_ */