ui/wpf/graphics.c

Thu, 15 Feb 2024 21:33:08 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 15 Feb 2024 21:33:08 +0100
branch
newapi
changeset 262
81778b9589d0
parent 137
c9b8b9e0cfe8
permissions
-rw-r--r--

port progressbar to new API (GTK)

#include <stdio.h>
#include <stdlib.h>

#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) {
    
}

mercurial