forked from pyrite-dev/milsko
introducde underline and strikethrough
This commit is contained in:
parent
3e9ffcee0b
commit
2b15e7e0a3
5 changed files with 53 additions and 18 deletions
|
|
@ -58,6 +58,8 @@
|
||||||
#define MwNminute "Iminute"
|
#define MwNminute "Iminute"
|
||||||
#define MwNsecond "Isecond"
|
#define MwNsecond "Isecond"
|
||||||
#define MwNtype "Itype"
|
#define MwNtype "Itype"
|
||||||
|
#define MwNstrikethrough "Istrikethrough"
|
||||||
|
#define MwNunderline "Iunderline"
|
||||||
|
|
||||||
#define MwNtitle "Stitle"
|
#define MwNtitle "Stitle"
|
||||||
#define MwNtext "Stext"
|
#define MwNtext "Stext"
|
||||||
|
|
|
||||||
|
|
@ -105,13 +105,15 @@
|
||||||
<integer name="waitLayout" />
|
<integer name="waitLayout" />
|
||||||
<integer name="scale" />
|
<integer name="scale" />
|
||||||
<integer name="columns" />
|
<integer name="columns" />
|
||||||
<integer name="columnSpan" column="yes" />
|
<integer name="commonSpan" common="yes" />
|
||||||
<integer name="rowSpan" column="yes" />
|
<integer name="rowSpan" common="yes" />
|
||||||
<integer name="acceptsDnD" column="yes" />
|
<integer name="acceptsDnD" common="yes" />
|
||||||
<integer name="hour" />
|
<integer name="hour" />
|
||||||
<integer name="minute" />
|
<integer name="minute" />
|
||||||
<integer name="second" />
|
<integer name="second" />
|
||||||
<integer name="type" />
|
<integer name="type" />
|
||||||
|
<integer name="strikethrough" common="yes" />
|
||||||
|
<integer name="underline" common="yes" />
|
||||||
|
|
||||||
<!-- waitMS is a special property, only applies to toplevel widget -->
|
<!-- waitMS is a special property, only applies to toplevel widget -->
|
||||||
<integer name="waitMS" common="yes" />
|
<integer name="waitMS" common="yes" />
|
||||||
|
|
|
||||||
24
src/core.c
24
src/core.c
|
|
@ -69,7 +69,8 @@ static void lldrawhandler(MwLL handle, void* data) {
|
||||||
static void lluphandler(MwLL handle, void* data) {
|
static void lluphandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
MwMouse* p = data;
|
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;
|
if(p->button == MwMOUSE_LEFT) h->pressed = 0;
|
||||||
h->mouse_point.x = p->point.x;
|
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) {
|
static void lldownhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
MwMouse* p = data;
|
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;
|
if(p->button == MwMOUSE_LEFT) h->pressed = 1;
|
||||||
h->mouse_point.x = p->point.x;
|
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) {
|
static void llkeyhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
int key = *(int*)data;
|
int key = *(int*)data;
|
||||||
if(MwGetInteger(h, MwNdisabled) == 1) return;
|
int n;
|
||||||
|
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
|
||||||
|
|
||||||
MwDispatch3(h, key, key);
|
MwDispatch3(h, key, key);
|
||||||
MwDispatchUserHandler(h, MwNkeyHandler, data);
|
MwDispatchUserHandler(h, MwNkeyHandler, data);
|
||||||
|
|
@ -166,28 +169,32 @@ static void llkeyhandler(MwLL handle, void* data) {
|
||||||
|
|
||||||
static void llkeyrelhandler(MwLL handle, void* data) {
|
static void llkeyrelhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
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);
|
MwDispatchUserHandler(h, MwNkeyReleaseHandler, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void llfocusinhandler(MwLL handle, void* data) {
|
static void llfocusinhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
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);
|
MwDispatchUserHandler(h, MwNfocusInHandler, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void llfocusouthandler(MwLL handle, void* data) {
|
static void llfocusouthandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
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);
|
MwDispatchUserHandler(h, MwNfocusOutHandler, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void llclipboardhandler(MwLL handle, void* data) {
|
static void llclipboardhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
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);
|
MwDispatch3(h, clipboard, data);
|
||||||
MwDispatchUserHandler(h, MwNclipboardHandler, data);
|
MwDispatchUserHandler(h, MwNclipboardHandler, data);
|
||||||
|
|
@ -195,7 +202,8 @@ static void llclipboardhandler(MwLL handle, void* data) {
|
||||||
|
|
||||||
static void lldraganddrophandler(MwLL handle, void* data) {
|
static void lldraganddrophandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
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);
|
MwDispatchUserHandler(h, MwNdragAndDropHandler, data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,9 @@ static int hex(const char* txt, int len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void color_set_disabled_if_disabled(MwWidget handle, MwLLColor rgb) {
|
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));
|
MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground));
|
||||||
|
|
||||||
if(c != NULL) {
|
if(c != NULL) {
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,9 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
|
||||||
char* last = input;
|
char* last = input;
|
||||||
int cp;
|
int cp;
|
||||||
MwLLColor fadedColor = NULL;
|
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));
|
MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground));
|
||||||
|
|
||||||
if(c != NULL) {
|
if(c != NULL) {
|
||||||
|
|
@ -107,8 +108,10 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
|
||||||
input += MwUTF8ToUTF32(input, &cp);
|
input += MwUTF8ToUTF32(input, &cp);
|
||||||
|
|
||||||
if(*input == 0 || cp == '\n') {
|
if(*input == 0 || cp == '\n') {
|
||||||
char* line = malloc(input - last + 1);
|
char* line = malloc(input - last + 1);
|
||||||
int i;
|
int i;
|
||||||
|
MwPoint l[2];
|
||||||
|
int tw, th;
|
||||||
|
|
||||||
if(!line) {
|
if(!line) {
|
||||||
printf("Out Of Memory\n");
|
printf("Out Of Memory\n");
|
||||||
|
|
@ -134,20 +137,38 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tw = MwTextWidth(handle, ttf, line);
|
||||||
|
th = MwTextHeight(handle, ttf, line);
|
||||||
|
|
||||||
p.x = point->x;
|
p.x = point->x;
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
if(align == MwALIGNMENT_CENTER) {
|
||||||
p.x -= MwTextWidth(handle, ttf, line) / 2;
|
p.x -= tw / 2;
|
||||||
} else if(align == MwALIGNMENT_END) {
|
} 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
|
#ifdef TTF
|
||||||
if(MwFLDrawText)
|
if(MwFLDrawText)
|
||||||
if(is_bitmap(handle, ttf) || ttf == NULL || MwFLDrawText(handle, ttf, &p, line, fadedColor ? fadedColor : color))
|
if(is_bitmap(handle, ttf) || ttf == NULL || MwFLDrawText(handle, ttf, &p, line, fadedColor ? fadedColor : color))
|
||||||
#endif
|
#endif
|
||||||
bitmap_MwDrawText(handle, &p, line, is_bold(handle, ttf), fadedColor ? fadedColor : color);
|
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);
|
free(line);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue