This commit is contained in:
2023-03-09 19:53:50 +06:00
parent 44fb1750ec
commit edd5730ebd
17 changed files with 525 additions and 84 deletions

23
src/TUI/TextBlock.c Normal file
View File

@@ -0,0 +1,23 @@
#include "tui_internal.h"
void TextBlock_freeMembers(void* _self){
TextBlock* self=(TextBlock*)_self;
free(self->text.ptr);
}
UI_Maybe TextBlock_draw(Renderer* renderer, UIElement* _self, DrawingArea area){
TextBlock* self=(TextBlock*)_self;
UI_try(UIElement_validate((UIElement*)self, area),_0,;);
UI_try(Renderer_fill(renderer, UTFCHAR(' '), area),_2,;);
UI_try(Renderer_drawBorder(renderer, self->base.borders, area),_1,;);
return MaybeNull;
}
kt_define(TextBlock, TextBlock_freeMembers, NULL);
TextBlock* TextBlock_create(string text){
TextBlock* textBlock=malloc(sizeof(TextBlock));
textBlock->base=__UIElement_createDefault(ktid_name(TextBlock), TextBlock_draw);
textBlock->text=string_copy(text);
return textBlock;
}