diff options
author | Marvin Borner | 2020-10-25 12:09:38 +0100 |
---|---|---|
committer | Marvin Borner | 2020-10-25 12:09:38 +0100 |
commit | f83d5e4b8e315f2b17f0c8bf390bf967f02f5837 (patch) | |
tree | 5b31cb17c5f5c5b0b438ecfe40af2bf9730411d7 /apps/window.c | |
parent | ffb2c74435ad0e313b7c33ae1f00f02824bb6fc0 (diff) |
Added buttons
Diffstat (limited to 'apps/window.c')
-rw-r--r-- | apps/window.c | 50 |
1 files changed, 2 insertions, 48 deletions
diff --git a/apps/window.c b/apps/window.c index 70131a6..601f187 100644 --- a/apps/window.c +++ b/apps/window.c @@ -12,61 +12,15 @@ int main() { print("[test context loaded]\n"); - struct window *win = gui_init("test", 0, 0); - struct context *ctx = win->ctx; - - int font_height = gfx_font_height(); - int font_width = gfx_font_width(); - - char *hello = "Hello, world!"; - gfx_write(ctx, ctx->width / 2 - (strlen(hello) * font_width) / 2, 0, COLOR_GREEN, hello); + struct element *container = gui_init("test", 0, 0); + gui_add_button(container, 10, 10, 100, 20, "hallo", COLOR_RED); struct message *msg; - int char_x = 0; - int char_y = 1; while (1) { if (!(msg = msg_receive())) { yield(); continue; } - - // TODO: Export to text widget or sth - switch (msg->type) { - case WM_KEYBOARD: { - struct msg_keyboard *event = msg->data; - char ch = event->ch; - if (!event->press) - break; - - if (char_x * font_width >= (int)ctx->width) { - char_y++; - char_x = 0; - } - - if (ch == '\n') { - char_x = 0; - char_y++; - } else if (ch == '\t') { - char_x += 8; - } else if (ch == '\b') { - if (char_x > 0) { - char_x--; - gfx_draw_rectangle(ctx, font_width * char_x, - font_height * char_y, - font_width * (char_x + 1), - font_height * (char_y + 1), COLOR_BG); - } - } else if (ch == ' ' && event->scancode == KEY_SPACE) { - char_x++; - } else if (ch != ' ' && ch != '\0') { - gfx_write_char(ctx, font_width * char_x++, font_height * char_y, - COLOR_CYAN, ch); - } - break; - } - default: - break; - } } return 0; } |