diff -r 000000000000 -r 2483f517c562 ui/wpf/graphics.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/wpf/graphics.c Sun Jan 21 16:30:18 2024 +0100 @@ -0,0 +1,74 @@ +#include +#include + +#include "graphics.h" +#include "container.h" +#include "../../ucx/mempool.h" +#include "../common/context.h" +#include "../common/object.h" + +UIWIDGET ui_drawingarea(UiObject *obj, ui_drawfunc f, void *userdata) { + UiDrawEvent *eventdata = NULL; + ui_draw_callback cb = NULL; + if(f) { + eventdata = malloc(sizeof(UiDrawEvent)); + eventdata->obj = obj; + eventdata->draw = f; + eventdata->userdata = userdata; + cb = ui_draw_event; + } + + UiContainer *container = uic_get_current_container(obj); + return UIdrawingarea(container, cb, eventdata); +} + +void ui_draw_event(void *gc, UiDrawEvent *event, int width, int height) { + UiEvent e; + e.obj = event->obj; + e.window = e.obj->window; + e.document = e.obj->ctx->document; + e.eventdata = NULL; + e.intval = 0; + + UiWPFGraphics g; + g.g.width = width; + g.g.height = height; + g.gc = gc; + + event->draw(&e, &g.g, event->userdata); +} + + +void ui_drawingarea_mousehandler(UiObject *obj, UIWIDGET widget, ui_callback f, void *u) { + +} + +void ui_drawingarea_getsize(UIWIDGET drawingarea, int *width, int *height) { + +} + +void ui_drawingarea_redraw(UIWIDGET drawingarea) { + UIdrawingarea_redraw(drawingarea); +} + + +/* ------------------------- drawing functions ------------------------- */ + +void ui_graphics_color(UiGraphics *g, int red, int green, int blue) { + UiWPFGraphics *wg = (UiWPFGraphics*)g; + UIgraphics_color(wg->gc, red, green, blue); +} + +void ui_draw_line(UiGraphics *g, int x1, int y1, int x2, int y2) { + UiWPFGraphics *wg = (UiWPFGraphics*)g; + UIdraw_line(wg->gc, x1, y1, x2, y2); +} + +void ui_draw_rect(UiGraphics *g, int x, int y, int w, int h, int fill) { + UiWPFGraphics *wg = (UiWPFGraphics*)g; + UIdraw_rect(wg->gc, x, y, w, h, fill); +} + +void ui_draw_text(UiGraphics *g, int x, int y, UiTextLayout *text) { + +}