fix things

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@490 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
Nishi 2025-10-24 17:31:05 +00:00
commit 453fb8702d
23 changed files with 14131 additions and 14136 deletions

View file

@ -189,7 +189,7 @@ void color_wheel_setup(MwWidget parent, color_wheel* wheel) {
MwSetInteger(wheel->color_display, MwnhasBorder, 1); MwSetInteger(wheel->color_display, MwnhasBorder, 1);
MwSetInteger(wheel->color_display, MwNinverted, 1); MwSetInteger(wheel->color_display, MwNinverted, 1);
wheel->color_display_text = MwCreateWidget(MwLabelClass, "colorDisplayFrameText", wheel->color_display, MwDefaultBorderWidth, MwDefaultBorderWidth, PICKER_SIZE - MwDefaultBorderWidth, (PICKER_SIZE / 16) - (MwDefaultBorderWidth * 2)); wheel->color_display_text = MwCreateWidget(MwLabelClass, "colorDisplayFrameText", wheel->color_display, MwGetDefaultBorderWidth(parent), MwGetDefaultBorderWidth(parent), PICKER_SIZE - MwGetDefaultBorderWidth(parent), (PICKER_SIZE / 16) - (MwGetDefaultBorderWidth(parent) * 2));
wheel->value_slider = MwVaCreateWidget(MwScrollBarClass, "value-slider", wheel->parent, wheel->value_slider = MwVaCreateWidget(MwScrollBarClass, "value-slider", wheel->parent,
// x // x

View file

@ -24,9 +24,10 @@ MWDECL const char* MwDefaultBackground;
MWDECL const char* MwDefaultForeground; MWDECL const char* MwDefaultForeground;
/*! /*!
* %brief Default border width * %brief Gets default border width
* %param handle Widget
*/ */
MWDECL const int MwDefaultBorderWidth; MWDECL int MwGetDefaultBorderWidth(MwWidget handle);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -72,7 +72,6 @@ MWDECL unsigned int MwIconUp[];
*/ */
MWDECL unsigned int MwIconWarning[]; MWDECL unsigned int MwIconWarning[];
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -1,6 +1,13 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
const int MwDefaultBorderWidth = 2;
const char* MwDefaultBackground = "#ddd"; const char* MwDefaultBackground = "#ddd";
const char* MwDefaultForeground = "#000"; const char* MwDefaultForeground = "#000";
int MwGetDefaultBorderWidth(MwWidget handle) {
if(MwGetInteger(handle, MwNmodernLook)) {
return 1;
} else {
return 2;
}
}

View file

@ -124,7 +124,7 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
} }
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) { void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
MwDrawFrameEx(handle, rect, color, invert, MwGetInteger(handle, MwNmodernLook) ? 1 : MwDefaultBorderWidth); MwDrawFrameEx(handle, rect, color, invert, MwGetDefaultBorderWidth(handle));
} }
void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) { void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
@ -195,7 +195,7 @@ void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, i
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) { void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
MwPoint p1[4], p2[4], p3[4], p4[3]; MwPoint p1[4], p2[4], p3[4], p4[3];
const int border = MwGetInteger(handle, MwNmodernLook) ? 1 : MwDefaultBorderWidth; const int border = MwGetInteger(handle, MwNmodernLook) ? 1 : MwGetDefaultBorderWidth(handle);
int ColorDiff = get_color_diff(handle); int ColorDiff = get_color_diff(handle);
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff); MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff); MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);

View file

@ -443,5 +443,4 @@ unsigned int MwIconBack[] = {
0xCCFFFF00, 0xCCFFFF00,
0xCCFFFF00, 0xCCFFFF00,
0xCCFFFF00, 0xCCFFFF00,
0 0};
};

View file

@ -259,5 +259,4 @@ unsigned int MwIconComputer[] = {
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0 0};
};

View file

@ -259,5 +259,4 @@ unsigned int MwIconDirectory[] = {
0x2B251DFF, 0x2B251DFF,
0xC0C0C000, 0xC0C0C000,
0xC0C0C000, 0xC0C0C000,
0 0};
};

View file

@ -2307,5 +2307,4 @@ unsigned int MwIconError[] = {
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0 0};
};

View file

@ -259,5 +259,4 @@ unsigned int MwIconFile[] = {
0xC0C0C000, 0xC0C0C000,
0xC0C0C000, 0xC0C0C000,
0xC0C0C000, 0xC0C0C000,
0 0};
};

View file

@ -443,5 +443,4 @@ unsigned int MwIconForward[] = {
0xCCFFFF00, 0xCCFFFF00,
0xCCFFFF00, 0xCCFFFF00,
0xCCFFFF00, 0xCCFFFF00,
0 0};
};

View file

@ -2307,5 +2307,4 @@ unsigned int MwIconInfo[] = {
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0 0};
};

View file

@ -2307,5 +2307,4 @@ unsigned int MwIconNews[] = {
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0 0};
};

View file

@ -2307,5 +2307,4 @@ unsigned int MwIconNote[] = {
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0 0};
};

View file

@ -443,5 +443,4 @@ unsigned int MwIconSearch[] = {
0x000000FF, 0x000000FF,
0xCCFFFF00, 0xCCFFFF00,
0xCCFFFF00, 0xCCFFFF00,
0 0};
};

View file

@ -443,5 +443,4 @@ unsigned int MwIconUp[] = {
0xCCFFFF00, 0xCCFFFF00,
0xCCFFFF00, 0xCCFFFF00,
0xCCFFFF00, 0xCCFFFF00,
0 0};
};

View file

@ -2307,5 +2307,4 @@ unsigned int MwIconWarning[] = {
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0x00000000, 0x00000000,
0 0};
};

View file

@ -38,8 +38,8 @@ static void draw(MwWidget handle) {
r.width = px->width * sh; r.width = px->width * sh;
r.height = px->height * sh; r.height = px->height * sh;
} }
r.width -= MwDefaultBorderWidth * 2; r.width -= MwGetDefaultBorderWidth(handle) * 2;
r.height -= MwDefaultBorderWidth * 2; r.height -= MwGetDefaultBorderWidth(handle) * 2;
r.x += (double)(ow - r.width) / 2; r.x += (double)(ow - r.width) / 2;
r.y += (double)(oh - r.height) / 2; r.y += (double)(oh - r.height) / 2;

View file

@ -23,10 +23,10 @@ static void draw(MwWidget handle) {
fr.height = MwGetInteger(handle, MwNheight); fr.height = MwGetInteger(handle, MwNheight);
MwDrawFrame(handle, &fr, base, inverted); MwDrawFrame(handle, &fr, base, inverted);
rr.x = MwDefaultBorderWidth; rr.x = MwGetDefaultBorderWidth(handle);
rr.y = MwDefaultBorderWidth; rr.y = MwGetDefaultBorderWidth(handle);
rr.width = MwGetInteger(handle, MwNwidth) - (MwDefaultBorderWidth * 2); rr.width = MwGetInteger(handle, MwNwidth) - (MwGetDefaultBorderWidth(handle) * 2);
rr.height = MwGetInteger(handle, MwNheight) - (MwDefaultBorderWidth * 2); rr.height = MwGetInteger(handle, MwNheight) - (MwGetDefaultBorderWidth(handle) * 2);
} else { } else {
rr.x = 0; rr.x = 0;

View file

@ -124,11 +124,11 @@ static void frame_mouse_down(MwWidget handle, void* user, void* call) {
if(m->button == MwLLMouseLeft) { if(m->button == MwLLMouseLeft) {
int st = 0; int st = 0;
int i; int i;
int y = MwDefaultBorderWidth; int y = MwGetDefaultBorderWidth(handle);
int h = MwGetInteger(handle, MwNheight); int h = MwGetInteger(handle, MwNheight);
st = get_first_entry(handle->parent, lb); st = get_first_entry(handle->parent, lb);
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth * 2) / MwTextHeight(handle, "M"); i++) { for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwGetDefaultBorderWidth(handle) * 2) / MwTextHeight(handle, "M"); i++) {
if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, "M"))) { if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, "M"))) {
unsigned long t; unsigned long t;
int old = lb->selected; int old = lb->selected;
@ -169,11 +169,11 @@ static void frame_mouse_move(MwWidget handle, void* user, void* call) {
if(lb->pressed) { if(lb->pressed) {
int st = 0; int st = 0;
int i; int i;
int y = MwDefaultBorderWidth; int y = MwGetDefaultBorderWidth(handle);
int h = MwGetInteger(handle, MwNheight); int h = MwGetInteger(handle, MwNheight);
st = get_first_entry(handle->parent, lb); st = get_first_entry(handle->parent, lb);
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth * 2) / MwTextHeight(handle, "M"); i++) { for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwGetDefaultBorderWidth(handle) * 2) / MwTextHeight(handle, "M"); i++) {
if(y <= p->y && p->y <= (y + MwTextHeight(handle, "M"))) { if(y <= p->y && p->y <= (y + MwTextHeight(handle, "M"))) {
lb->selected = st + i; lb->selected = st + i;
} }
@ -198,12 +198,12 @@ static void frame_draw(MwWidget handle) {
r.width = MwGetInteger(handle, MwNwidth); r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight); r.height = MwGetInteger(handle, MwNheight);
p.x = MwDefaultBorderWidth; p.x = MwGetDefaultBorderWidth(handle);
p.y = MwDefaultBorderWidth; p.y = MwGetDefaultBorderWidth(handle);
st = get_first_entry(handle->parent, lb); st = get_first_entry(handle->parent, lb);
for(i = st; i < arrlen(lb->list) && i < st + (r.height - MwDefaultBorderWidth * 2) / MwTextHeight(handle, "M"); i++) { for(i = st; i < arrlen(lb->list) && i < st + (r.height - MwGetDefaultBorderWidth(handle) * 2) / MwTextHeight(handle, "M"); i++) {
int selected = lb->selected == i ? 1 : 0; int selected = lb->selected == i ? 1 : 0;
int j; int j;
@ -219,7 +219,7 @@ static void frame_draw(MwWidget handle) {
if(lb->list[i].pixmap != NULL) { if(lb->list[i].pixmap != NULL) {
MwRect r2; MwRect r2;
int h = (lb->list[i].pixmap->height > MwTextHeight(handle, "M")) ? MwTextHeight(handle, "M") : lb->list[i].pixmap->height; int h = (lb->list[i].pixmap->height > MwTextHeight(handle, "M")) ? MwTextHeight(handle, "M") : lb->list[i].pixmap->height;
r2.x = MwDefaultBorderWidth; r2.x = MwGetDefaultBorderWidth(handle);
r2.y = p.y + (MwTextHeight(handle, "M") - h) / 2; r2.y = p.y + (MwTextHeight(handle, "M") - h) / 2;
r2.width = h * lb->list[i].pixmap->width / lb->list[i].pixmap->height; r2.width = h * lb->list[i].pixmap->width / lb->list[i].pixmap->height;
r2.height = h; r2.height = h;
@ -232,9 +232,9 @@ static void frame_draw(MwWidget handle) {
if(t == NULL) t = ""; if(t == NULL) t = "";
p.x += MwDefaultBorderWidth; p.x += MwGetDefaultBorderWidth(handle);
MwDrawText(handle, &p, t, 0, MwALIGNMENT_BEGINNING, selected ? base : text); MwDrawText(handle, &p, t, 0, MwALIGNMENT_BEGINNING, selected ? base : text);
p.x += get_col_width(lb, j) - MwDefaultBorderWidth; p.x += get_col_width(lb, j) - MwGetDefaultBorderWidth(handle);
if(j == 0) p.x -= MwGetInteger(handle->parent, MwNleftPadding); if(j == 0) p.x -= MwGetInteger(handle->parent, MwNleftPadding);
} }
@ -254,7 +254,7 @@ static void resize(MwWidget handle) {
int h = MwGetInteger(handle, MwNheight); int h = MwGetInteger(handle, MwNheight);
int ih, y; int ih, y;
y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, "M") + MwDefaultBorderWidth * 2) : 0; y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, "M") + MwGetDefaultBorderWidth(handle) * 2) : 0;
if(lb->vscroll == NULL) { if(lb->vscroll == NULL) {
lb->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h, NULL); lb->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h, NULL);
@ -283,7 +283,7 @@ static void resize(MwWidget handle) {
MwNheight, h, MwNheight, h,
NULL); NULL);
} }
h -= MwDefaultBorderWidth * 2; h -= MwGetDefaultBorderWidth(handle) * 2;
ih = arrlen(lb->list); ih = arrlen(lb->list);
if(ih == 0) ih = 1; if(ih == 0) ih = 1;
@ -345,16 +345,16 @@ static void draw(MwWidget handle) {
r.x = x; r.x = x;
r.y = 0; r.y = 0;
r.width = get_col_width(lb, i); r.width = get_col_width(lb, i);
r.height = MwDefaultBorderWidth * 2 + MwTextHeight(handle, "M"); r.height = MwGetDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M");
MwDrawFrame(handle, &r, base, 0); MwDrawFrame(handle, &r, base, 0);
x += MwDefaultBorderWidth; x += MwGetDefaultBorderWidth(handle);
p.x = x; p.x = x;
p.y = r.y + r.height / 2; p.y = r.y + r.height / 2;
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_BEGINNING, text); MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_BEGINNING, text);
x += r.width + MwDefaultBorderWidth; x += r.width + MwGetDefaultBorderWidth(handle);
} }
} }

View file

@ -194,13 +194,13 @@ static void mouse_down(MwWidget handle, void* ptr) {
scr->point = handle->mouse_point; scr->point = handle->mouse_point;
scr->drag = 0; scr->drag = 0;
if(or == MwVERTICAL) { if(or == MwVERTICAL) {
int tri = (ww - MwDefaultBorderWidth * 2) + MwDefaultBorderWidth; int tri = (ww - MwGetDefaultBorderWidth(handle) * 2) + MwGetDefaultBorderWidth(handle);
if(tri <= scr->point.y && scr->point.y <= (wh - tri)) { if(tri <= scr->point.y && scr->point.y <= (wh - tri)) {
scr->drag = 1; scr->drag = 1;
scr->pos = calc_positition(handle) - scr->point.y; scr->pos = calc_positition(handle) - scr->point.y;
} }
} else if(or == MwHORIZONTAL) { } else if(or == MwHORIZONTAL) {
int tri = (wh - MwDefaultBorderWidth * 2) + MwDefaultBorderWidth; int tri = (wh - MwGetDefaultBorderWidth(handle) * 2) + MwGetDefaultBorderWidth(handle);
if(tri <= scr->point.x && scr->point.x <= (ww - tri)) { if(tri <= scr->point.x && scr->point.x <= (ww - tri)) {
scr->drag = 1; scr->drag = 1;
scr->pos = calc_positition(handle) - scr->point.x; scr->pos = calc_positition(handle) - scr->point.x;
@ -225,13 +225,13 @@ static int mwScrollBarGetVisibleLengthImpl(MwWidget handle) {
int s = 0; int s = 0;
if(or == MwVERTICAL) { if(or == MwVERTICAL) {
tri = (ww - MwDefaultBorderWidth * 2) * 2; tri = (ww - MwGetDefaultBorderWidth(handle) * 2) * 2;
s = wh; s = wh;
} else if(or == MwHORIZONTAL) { } else if(or == MwHORIZONTAL) {
tri = (wh - MwDefaultBorderWidth * 2) * 2; tri = (wh - MwGetDefaultBorderWidth(handle) * 2) * 2;
s = ww; s = ww;
} }
return s - tri - MwDefaultBorderWidth * 2; return s - tri - MwGetDefaultBorderWidth(handle) * 2;
} }
static void func_handler(MwWidget handle, const char* name, void* out, va_list va) { static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {