UNIXworkcode

1 #include <stdio.h> 2 #include <stdlib.h> 3 4 #include "graphics.h" 5 #include "container.h" 6 #include "../../ucx/mempool.h" 7 #include "../common/context.h" 8 #include "../common/object.h" 9 10 UIWIDGET ui_drawingarea(UiObject *obj, ui_drawfunc f, void *userdata) { 11 UiDrawEvent *eventdata = NULL; 12 ui_draw_callback cb = NULL; 13 if(f) { 14 eventdata = malloc(sizeof(UiDrawEvent)); 15 eventdata->obj = obj; 16 eventdata->draw = f; 17 eventdata->userdata = userdata; 18 cb = ui_draw_event; 19 } 20 21 UiContainer *container = uic_get_current_container(obj); 22 return UIdrawingarea(container, cb, eventdata); 23 } 24 25 void ui_draw_event(void *gc, UiDrawEvent *event, int width, int height) { 26 UiEvent e; 27 e.obj = event->obj; 28 e.window = e.obj->window; 29 e.document = e.obj->ctx->document; 30 e.eventdata = NULL; 31 e.intval = 0; 32 33 UiWPFGraphics g; 34 g.g.width = width; 35 g.g.height = height; 36 g.gc = gc; 37 38 event->draw(&e, &g.g, event->userdata); 39 } 40 41 42 void ui_drawingarea_mousehandler(UiObject *obj, UIWIDGET widget, ui_callback f, void *u) { 43 44 } 45 46 void ui_drawingarea_getsize(UIWIDGET drawingarea, int *width, int *height) { 47 48 } 49 50 void ui_drawingarea_redraw(UIWIDGET drawingarea) { 51 UIdrawingarea_redraw(drawingarea); 52 } 53 54 55 /* ------------------------- drawing functions ------------------------- */ 56 57 void ui_graphics_color(UiGraphics *g, int red, int green, int blue) { 58 UiWPFGraphics *wg = (UiWPFGraphics*)g; 59 UIgraphics_color(wg->gc, red, green, blue); 60 } 61 62 void ui_draw_line(UiGraphics *g, int x1, int y1, int x2, int y2) { 63 UiWPFGraphics *wg = (UiWPFGraphics*)g; 64 UIdraw_line(wg->gc, x1, y1, x2, y2); 65 } 66 67 void ui_draw_rect(UiGraphics *g, int x, int y, int w, int h, int fill) { 68 UiWPFGraphics *wg = (UiWPFGraphics*)g; 69 UIdraw_rect(wg->gc, x, y, w, h, fill); 70 } 71 72 void ui_draw_text(UiGraphics *g, int x, int y, UiTextLayout *text) { 73 74 } 75