diff --git a/include/Mw/StringDefs.h b/include/Mw/StringDefs.h index a51f981..69a747a 100644 --- a/include/Mw/StringDefs.h +++ b/include/Mw/StringDefs.h @@ -31,6 +31,7 @@ #define MwNshowArrows "IshowArrows" #define MwNpadding "Ipadding" #define MwNborderWidth "IborderWidth" +#define MwNfillArea "IfillArea" #define MwNtitle "Stitle" #define MwNtext "Stext" diff --git a/milsko.xml b/milsko.xml index 45f7c28..98e0d91 100644 --- a/milsko.xml +++ b/milsko.xml @@ -488,6 +488,7 @@ + diff --git a/src/widget/button.c b/src/widget/button.c index d6e5394..d2b790a 100644 --- a/src/widget/button.c +++ b/src/widget/button.c @@ -5,6 +5,7 @@ static int create(MwWidget handle) { MwSetInteger(handle, MwNflat, 0); MwSetInteger(handle, MwNpadding, 0); + MwSetInteger(handle, MwNfillArea, 1); return 0; } @@ -44,18 +45,23 @@ static void draw(MwWidget handle) { int ow = r.width; int oh = r.height; - double sw = (double)ow / px->common.width; - double sh = (double)oh / px->common.height; + if(MwGetInteger(handle, MwNfillArea)) { + double sw = (double)ow / px->common.width; + double sh = (double)oh / px->common.height; - if(sw < sh) { - r.width = px->common.width * sw; - r.height = px->common.height * sw; + if(sw < sh) { + r.width = px->common.width * sw; + r.height = px->common.height * sw; + } else { + r.width = px->common.width * sh; + r.height = px->common.height * sh; + } + r.width -= MwGetInteger(handle, MwNpadding) * 2; + r.height -= MwGetInteger(handle, MwNpadding) * 2; } else { - r.width = px->common.width * sh; - r.height = px->common.height * sh; + r.width = px->common.width; + r.height = px->common.height; } - r.width -= MwGetInteger(handle, MwNpadding) * 2; - r.height -= MwGetInteger(handle, MwNpadding) * 2; r.x += (double)(ow - r.width) / 2; r.y += (double)(oh - r.height) / 2; @@ -77,7 +83,7 @@ static void click(MwWidget handle) { } static void prop_change(MwWidget handle, const char* key) { - if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNpixmap) == 0 || strcmp(key, MwNflat) == 0 || strcmp(key, MwNpadding) == 0) MwForceRender(handle); + if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNpixmap) == 0 || strcmp(key, MwNflat) == 0 || strcmp(key, MwNpadding) == 0 || strcmp(key, MwNfillArea) == 0) MwForceRender(handle); } MwClassRec MwButtonClassRec = {