SayoriOS  0.3.3
widget_label.c
1 #include "desktop/widget.h"
2 #include "desktop/widget_label.h"
3 #include "lib/string.h"
4 #include "drv/psf.h"
5 #include "io/ports.h"
6 #include "mem/vmm.h"
7 
8 void widget_label_renderer(struct Widget* this, __attribute__((unused)) struct Window* container) {
9  Widget_Label_t* this_object = (Widget_Label_t*)(this->custom_widget_data);
10 
11  // uint32_t color = getColorFont();
12  // setColorFont(this_object->color);
13 
14  draw_vga_str(this_object->label,
15 // this_object->length,
16  strlen(this_object->label),
17  this->x, this->y, this_object->color);
18  // setColorFont(color);
19 }
20 
21 Widget_t* new_widget_label(const char *label, size_t x, size_t y, uint32_t color) {
22  Widget_t* wgt = new_bare_widget(
23  &widget_label_renderer,
24  &destroy_widget_label,
25  x, y,
26  1, 1
27  );
28 
29  qemu_log("DESTROY WIDGET Label AT: %x", wgt->destroyer);
30 
31  wgt->custom_widget_data = kcalloc(sizeof(Widget_Label_t), 1);
32  qemu_log("Allocated %d bytes for custom data for Widget Label (%x)", sizeof(Widget_Label_t), wgt->custom_widget_data);
33 
34  Widget_Label_t* wgt_data = (Widget_Label_t*)wgt->custom_widget_data;
35  wgt_data->label = label;
36  wgt_data->color = color;
37  wgt_data->length = strlen(label);
38 
39  qemu_log("Okay?");
40 
41  return wgt;
42 }
43 
44 void destroy_widget_label(Widget_t* widget) {
45  qemu_log("Widget Label destroy its data at: %x", widget->custom_widget_data);
46  kfree(widget->custom_widget_data);
47 }
struct registers __attribute__((packed))
Структура данных пакета от мыши
Definition: psf.h:19
size_t strlen(const char *str)
Возращает длину строки
Definition: string.c:88
Definition: widget.h:12
Definition: window.h:25