SayoriOS 0.3.3

eki.c
1 #include "desktop/render.h"
2 #include "desktop/widget_button.h"
3 #include "desktop/widget_image.h"
4 #include "desktop/widget_label.h"
5 #include "drv/disk/dpm.h"
6 #include "io/ports.h"
7 #include "../lib/libstring/include/string.h"
8
9 extern DPM_Disk DPM_Disks[32];
10
11 void eki_on_close(Window_t* window);
12
13 void eki_start() {
14 vector_t* eki_strings = vector_new();
15
16 Window_t* eki_mainwindow = window_new("Eki");
17 eki_mainwindow->x = 100;
18 eki_mainwindow->y = 100;
19 eki_mainwindow->width = 200;
20 eki_mainwindow->height = 200;
21 eki_mainwindow->canvas_bgcolor = 0x333333;
22 eki_mainwindow->on_close = eki_on_close;
23 eki_mainwindow->data = eki_strings;
24
25 int yoffset = 0;
26
27 for (int i = 0; i < 32; i++) {
28 if (DPM_Disks[i].Ready) {
29 yoffset++;
30
31 string_t* tempstr = string_new();
32 string_append_char(tempstr, 'A' + i);
33
34 vector_push_back(eki_strings, (size_t) tempstr);
35
36 Widget_t* hello_button = new_widget_button(tempstr->data, 0x00ff00, 0x000000);
37 hello_button->x = 10;
38 hello_button->y = 10 + (yoffset * 20);
39 hello_button->width += 30;
40 hello_button->height += 15;
41
42 window_add_widget(eki_mainwindow, hello_button);
43 }
44 }
45
46 eki_mainwindow->state = DISPLAYING;
47 }
48
49 void eki_on_close(Window_t* window) {
50 qemu_log("EKI close!");
51
52 vector_t* that_vec = (vector_t*)window->data;
53
54 for(int i = 0; i < that_vec->size; i++) {
55 string_destroy((string_t*)vector_get(that_vec, i).element);
56 }
57
58 vector_destroy(that_vec);
59 }
Widget
Definition: widget.h:12
Window
Definition: window.h:25
string
Definition: string.h:10
vector
Definition: vector.h:7