diff --git a/include/Mw/StringDefs.h b/include/Mw/StringDefs.h index cf0a723..8d00b40 100644 --- a/include/Mw/StringDefs.h +++ b/include/Mw/StringDefs.h @@ -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" diff --git a/milsko.xml b/milsko.xml index 5b90410..7a7410a 100644 --- a/milsko.xml +++ b/milsko.xml @@ -105,13 +105,15 @@ - - - + + + + + diff --git a/src/core.c b/src/core.c index 481fa34..1403310 100644 --- a/src/core.c +++ b/src/core.c @@ -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); } diff --git a/src/draw.c b/src/draw.c index eb15c76..ab4c9cb 100644 --- a/src/draw.c +++ b/src/draw.c @@ -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) { diff --git a/src/text/text.c b/src/text/text.c index 45e5886..1c9f6e6 100644 --- a/src/text/text.c +++ b/src/text/text.c @@ -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);