|
|
|
|
@@ -6,6 +6,7 @@ static int create(MwWidget handle) {
|
|
|
|
|
MwLLBeginStateChange(handle->lowlevel);
|
|
|
|
|
|
|
|
|
|
MwSetDefault(handle);
|
|
|
|
|
MwSetInteger(handle, MwNleftPadding, 0);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
@@ -53,12 +54,14 @@ static void draw(MwWidget handle) {
|
|
|
|
|
|
|
|
|
|
rc.x = MwDefaultBorderWidth(handle) * 2;
|
|
|
|
|
rc.y = p.y;
|
|
|
|
|
rc.width = r.width - (rc.x * 2);
|
|
|
|
|
rc.height = MwDefaultBorderWidth(handle) * 2;
|
|
|
|
|
rc.width = r.width - (rc.x * 2) - MwGetInteger(handle, MwNleftPadding);
|
|
|
|
|
rc.height = 2;
|
|
|
|
|
|
|
|
|
|
MwDrawFrame(handle, &rc, base, 1);
|
|
|
|
|
rc.x += MwGetInteger(handle, MwNleftPadding);
|
|
|
|
|
|
|
|
|
|
p.y += MwDefaultBorderWidth(handle) * 2 + 1;
|
|
|
|
|
MwDrawFrameEx(handle, &rc, base, 1, 1, 0, 0);
|
|
|
|
|
|
|
|
|
|
p.y += 2 + 1;
|
|
|
|
|
} else {
|
|
|
|
|
int tw = MwTextWidth(handle, menu->sub[i]->name);
|
|
|
|
|
int th = MwTextHeight(handle, menu->sub[i]->name);
|
|
|
|
|
@@ -71,7 +74,7 @@ static void draw(MwWidget handle) {
|
|
|
|
|
MwDrawWidgetBack(handle, &r, base, 0, MwTRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.x = 5 + tw / 2;
|
|
|
|
|
p.x = 5 + tw / 2 + MwGetInteger(handle, MwNleftPadding);
|
|
|
|
|
|
|
|
|
|
p.y += th / 2;
|
|
|
|
|
MwDrawText(handle, &p, menu->sub[i]->name, menu->sub[i]->wsub != NULL ? 1 : 0, MwALIGNMENT_CENTER, text);
|
|
|
|
|
@@ -116,7 +119,11 @@ static void click(MwWidget handle) {
|
|
|
|
|
int th = MwTextHeight(handle, menu->sub[i]->name);
|
|
|
|
|
rc.height = th;
|
|
|
|
|
|
|
|
|
|
if(rc.y <= handle->mouse_point.y && handle->mouse_point.y <= (int)(rc.y + rc.height)) {
|
|
|
|
|
if(strcmp(menu->sub[i]->name, "----") == 0) {
|
|
|
|
|
rc.height = 2 - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(MwGetInteger(handle, MwNleftPadding) <= handle->mouse_point.x && rc.y <= handle->mouse_point.y && handle->mouse_point.y <= (int)(rc.y + rc.height)) {
|
|
|
|
|
if(menu->sub[i]->wsub == NULL && arrlen(menu->sub[i]->sub) > 0) {
|
|
|
|
|
MwPoint p;
|
|
|
|
|
int j;
|
|
|
|
|
@@ -160,51 +167,61 @@ static void click(MwWidget handle) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point, int diff_calc) {
|
|
|
|
|
int i, w = 0, h = 0;
|
|
|
|
|
MwRect rc;
|
|
|
|
|
MwRect rc, sz;
|
|
|
|
|
MwPoint p = *point;
|
|
|
|
|
|
|
|
|
|
MwSubMenuGetSize(handle, menu, &sz);
|
|
|
|
|
|
|
|
|
|
MwGetScreenSize(handle, &rc);
|
|
|
|
|
|
|
|
|
|
handle->internal = menu;
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < arrlen(menu->sub); i++) {
|
|
|
|
|
if(strcmp(menu->sub[i]->name, "----") == 0) {
|
|
|
|
|
h += MwDefaultBorderWidth(handle) * 2 + 2;
|
|
|
|
|
} else {
|
|
|
|
|
int tw = MwTextWidth(handle, menu->sub[i]->name);
|
|
|
|
|
h += MwTextHeight(handle, menu->sub[i]->name) + 3;
|
|
|
|
|
if(tw > w) {
|
|
|
|
|
w = tw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
w += 10 + 15;
|
|
|
|
|
h += 3;
|
|
|
|
|
|
|
|
|
|
w += 32;
|
|
|
|
|
|
|
|
|
|
if(diff_calc) {
|
|
|
|
|
p.y = p.y - h;
|
|
|
|
|
p.y = p.y - sz.height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MwLLMakeToolWindow(handle->lowlevel);
|
|
|
|
|
MwLLDetach(handle->lowlevel, &p);
|
|
|
|
|
|
|
|
|
|
if(MwGetInteger(handle, MwNy) + h > rc.height) {
|
|
|
|
|
if(MwGetInteger(handle, MwNy) + sz.height > rc.height) {
|
|
|
|
|
MwVaApply(handle,
|
|
|
|
|
MwNy, rc.height - h,
|
|
|
|
|
MwNy, rc.height - sz.height,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
MwLLEndStateChange(handle->lowlevel);
|
|
|
|
|
|
|
|
|
|
MwVaApply(handle,
|
|
|
|
|
MwNwidth, w,
|
|
|
|
|
MwNheight, h,
|
|
|
|
|
MwNwidth, sz.width,
|
|
|
|
|
MwNheight, sz.height,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void mwSubMenuGetSizeImpl(MwWidget handle, MwMenu menu, MwRect* rect) {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
rect->width = 0;
|
|
|
|
|
rect->height = 0;
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < arrlen(menu->sub); i++) {
|
|
|
|
|
if(strcmp(menu->sub[i]->name, "----") == 0) {
|
|
|
|
|
rect->height += 2 + 2;
|
|
|
|
|
} else {
|
|
|
|
|
int tw = MwTextWidth(handle, menu->sub[i]->name);
|
|
|
|
|
rect->height += MwTextHeight(handle, menu->sub[i]->name) + 3;
|
|
|
|
|
if(tw > rect->width) {
|
|
|
|
|
rect->width = tw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rect->width += MwGetInteger(handle, MwNleftPadding);
|
|
|
|
|
|
|
|
|
|
rect->width += 10 + 15;
|
|
|
|
|
rect->height += 3;
|
|
|
|
|
|
|
|
|
|
rect->width += 16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {
|
|
|
|
|
(void)out;
|
|
|
|
|
|
|
|
|
|
@@ -213,6 +230,10 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
|
|
|
|
|
MwPoint* point = va_arg(va, MwPoint*);
|
|
|
|
|
int diff_calc = va_arg(va, int);
|
|
|
|
|
mwSubMenuAppearImpl(handle, menu, point, diff_calc);
|
|
|
|
|
} else if(strcmp(name, "mwSubMenuGetSize") == 0) {
|
|
|
|
|
MwMenu menu = va_arg(va, MwMenu);
|
|
|
|
|
MwRect* rect = va_arg(va, MwRect*);
|
|
|
|
|
mwSubMenuGetSizeImpl(handle, menu, rect);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|