introducde underline and strikethrough
Some checks are pending
pyrite-dev/milsko/pipeline/head Build started...

This commit is contained in:
Nishi 2026-09-18 13:11:34 +09:00
commit 2b15e7e0a3
5 changed files with 53 additions and 18 deletions

View file

@ -58,6 +58,8 @@
#define MwNminute "Iminute"
#define MwNsecond "Isecond"
#define MwNtype "Itype"
#define MwNstrikethrough "Istrikethrough"
#define MwNunderline "Iunderline"
#define MwNtitle "Stitle"
#define MwNtext "Stext"

View file

@ -105,13 +105,15 @@
<integer name="waitLayout" />
<integer name="scale" />
<integer name="columns" />
<integer name="columnSpan" column="yes" />
<integer name="rowSpan" column="yes" />
<integer name="acceptsDnD" column="yes" />
<integer name="commonSpan" common="yes" />
<integer name="rowSpan" common="yes" />
<integer name="acceptsDnD" common="yes" />
<integer name="hour" />
<integer name="minute" />
<integer name="second" />
<integer name="type" />
<integer name="strikethrough" common="yes" />
<integer name="underline" common="yes" />
<!-- waitMS is a special property, only applies to toplevel widget -->
<integer name="waitMS" common="yes" />

View file

@ -69,7 +69,8 @@ static void lldrawhandler(MwLL handle, void* data) {
static void lluphandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
MwMouse* p = data;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
if(p->button == MwMOUSE_LEFT) h->pressed = 0;
h->mouse_point.x = p->point.x;
@ -83,7 +84,8 @@ static void lluphandler(MwLL handle, void* data) {
static void lldownhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
MwMouse* p = data;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
if(p->button == MwMOUSE_LEFT) h->pressed = 1;
h->mouse_point.x = p->point.x;
@ -158,7 +160,8 @@ static void llmovehandler(MwLL handle, void* data) {
static void llkeyhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
int key = *(int*)data;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatch3(h, key, key);
MwDispatchUserHandler(h, MwNkeyHandler, data);
@ -166,28 +169,32 @@ static void llkeyhandler(MwLL handle, void* data) {
static void llkeyrelhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatchUserHandler(h, MwNkeyReleaseHandler, data);
}
static void llfocusinhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatchUserHandler(h, MwNfocusInHandler, data);
}
static void llfocusouthandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatchUserHandler(h, MwNfocusOutHandler, data);
}
static void llclipboardhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatch3(h, clipboard, data);
MwDispatchUserHandler(h, MwNclipboardHandler, data);
@ -195,7 +202,8 @@ static void llclipboardhandler(MwLL handle, void* data) {
static void lldraganddrophandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatchUserHandler(h, MwNdragAndDropHandler, data);
}

View file

@ -39,7 +39,9 @@ static int hex(const char* txt, int len) {
}
static void color_set_disabled_if_disabled(MwWidget handle, MwLLColor rgb) {
if(MwGetInteger(handle, MwNdisabled) == 1) {
int n;
if((n = MwGetInteger(handle, MwNdisabled)) != MwDEFAULT && n) {
MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground));
if(c != NULL) {

View file

@ -82,8 +82,9 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
char* last = input;
int cp;
MwLLColor fadedColor = NULL;
int n;
if(MwGetInteger(handle, MwNdisabled) == 1) {
if((n = MwGetInteger(handle, MwNdisabled)) != MwDEFAULT && n) {
MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground));
if(c != NULL) {
@ -107,8 +108,10 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
input += MwUTF8ToUTF32(input, &cp);
if(*input == 0 || cp == '\n') {
char* line = malloc(input - last + 1);
int i;
char* line = malloc(input - last + 1);
int i;
MwPoint l[2];
int tw, th;
if(!line) {
printf("Out Of Memory\n");
@ -134,20 +137,38 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
continue;
}
tw = MwTextWidth(handle, ttf, line);
th = MwTextHeight(handle, ttf, line);
p.x = point->x;
if(align == MwALIGNMENT_CENTER) {
p.x -= MwTextWidth(handle, ttf, line) / 2;
p.x -= tw / 2;
} else if(align == MwALIGNMENT_END) {
p.x -= MwTextWidth(handle, ttf, line);
p.x -= tw;
}
l[0].x = p.x;
l[1].x = l[0].x + tw;
#ifdef TTF
if(MwFLDrawText)
if(is_bitmap(handle, ttf) || ttf == NULL || MwFLDrawText(handle, ttf, &p, line, fadedColor ? fadedColor : color))
#endif
bitmap_MwDrawText(handle, &p, line, is_bold(handle, ttf), fadedColor ? fadedColor : color);
p.y += MwTextHeight(handle, ttf, line);
l[0].y = l[1].y = p.y;
if((n = MwGetInteger(handle, MwNstrikethrough)) != MwDEFAULT && n) {
MwLLLine(handle->lowlevel, l, color);
}
if((n = MwGetInteger(handle, MwNunderline)) != MwDEFAULT && n) {
l[0].y += th / 2;
l[1].y += th / 2;
MwLLLine(handle->lowlevel, l, color);
}
p.y += th;
free(line);