git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@234 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-09 00:41:36 +00:00
parent 662f5796c5
commit 99de2b52fa
3 changed files with 22 additions and 7 deletions

View File

@@ -4,6 +4,7 @@
static int create(MwWidget handle) {
MwSetDefault(handle);
MwSetText(handle, MwNtext, "dkdqdnqwjkneqwewkeqkenkqwenneqweknqwenqwjkenqwkenqwkenkqwenkqwnejkqwenkwqnekqwneknqwkw");
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
return 0;
@@ -23,8 +24,12 @@ static void draw(MwWidget handle) {
MwDrawFrame(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0);
MwDrawRect(handle, &r, base);
if(str != NULL) {
int w = MwTextWidth(handle, "M");
int h = MwTextHeight(handle, "M");
MwPoint p;
char* show;
int len;
int i;
p.x = (r.height - h) / 2;
p.y = r.height / 2;
@@ -32,7 +37,17 @@ static void draw(MwWidget handle) {
/* limit so there isn't a crazy padding */
if(p.x > 4) p.x = 4;
MwDrawText(handle, &p, str, 0, MwALIGNMENT_BEGINNING, text);
len = (r.width - p.x * 2) / w;
show = malloc(len + 1);
memset(show, 0, len + 1);
for(i = 0; i < len; i++) {
show[i] = str[i];
}
MwDrawText(handle, &p, show, 0, MwALIGNMENT_BEGINNING, text);
free(show);
}
MwLLFreeColor(text);