mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-31 06:30:52 +00:00
Compare commits
6 Commits
7b47524286
...
c80987ffe4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c80987ffe4 | ||
|
|
d3a7b0a01d | ||
|
|
e77c4f3c38 | ||
|
|
22b4737c33 | ||
|
|
509351a0a0 | ||
|
|
86effbdfd7 |
@@ -195,7 +195,6 @@ target_compile_definitions(
|
|||||||
_MILSKO
|
_MILSKO
|
||||||
)
|
)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
install(
|
install(
|
||||||
TARGETS Mw
|
TARGETS Mw
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
|||||||
@@ -29,6 +29,16 @@ MwInline void MwSubMenuAppear(MwWidget handle, MwMenu menu, MwPoint* point, int
|
|||||||
MwVaWidgetExecute(handle, "mwSubMenuAppear", NULL, menu, point, diff_calc);
|
MwVaWidgetExecute(handle, "mwSubMenuAppear", NULL, menu, point, diff_calc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Calculates the size of submenu
|
||||||
|
* @param handle Handle
|
||||||
|
* @param menu Menu
|
||||||
|
* @param rect Size
|
||||||
|
*/
|
||||||
|
MwInline void MwSubMenuGetSize(MwWidget handle, MwMenu menu, MwRect* rect) {
|
||||||
|
MwVaWidgetExecute(handle, "mwSubMenuGetSize", NULL, menu, rect);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -640,6 +640,9 @@
|
|||||||
</functions>
|
</functions>
|
||||||
</widget>
|
</widget>
|
||||||
<widget name="SubMenu">
|
<widget name="SubMenu">
|
||||||
|
<properties>
|
||||||
|
<property name="leftPadding" />
|
||||||
|
</properties>
|
||||||
<functions>
|
<functions>
|
||||||
<function name="Appear">
|
<function name="Appear">
|
||||||
<arguments>
|
<arguments>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ static int create(MwWidget handle) {
|
|||||||
MwLLBeginStateChange(handle->lowlevel);
|
MwLLBeginStateChange(handle->lowlevel);
|
||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
MwSetInteger(handle, MwNleftPadding, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -53,12 +54,14 @@ static void draw(MwWidget handle) {
|
|||||||
|
|
||||||
rc.x = MwDefaultBorderWidth(handle) * 2;
|
rc.x = MwDefaultBorderWidth(handle) * 2;
|
||||||
rc.y = p.y;
|
rc.y = p.y;
|
||||||
rc.width = r.width - (rc.x * 2);
|
rc.width = r.width - (rc.x * 2) - MwGetInteger(handle, MwNleftPadding);
|
||||||
rc.height = MwDefaultBorderWidth(handle) * 2;
|
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 {
|
} else {
|
||||||
int tw = MwTextWidth(handle, menu->sub[i]->name);
|
int tw = MwTextWidth(handle, menu->sub[i]->name);
|
||||||
int th = MwTextHeight(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);
|
MwDrawWidgetBack(handle, &r, base, 0, MwTRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.x = 5 + tw / 2;
|
p.x = 5 + tw / 2 + MwGetInteger(handle, MwNleftPadding);
|
||||||
|
|
||||||
p.y += th / 2;
|
p.y += th / 2;
|
||||||
MwDrawText(handle, &p, menu->sub[i]->name, menu->sub[i]->wsub != NULL ? 1 : 0, MwALIGNMENT_CENTER, text);
|
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);
|
int th = MwTextHeight(handle, menu->sub[i]->name);
|
||||||
rc.height = th;
|
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) {
|
if(menu->sub[i]->wsub == NULL && arrlen(menu->sub[i]->sub) > 0) {
|
||||||
MwPoint p;
|
MwPoint p;
|
||||||
int j;
|
int j;
|
||||||
@@ -160,51 +167,61 @@ static void click(MwWidget handle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point, int diff_calc) {
|
static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point, int diff_calc) {
|
||||||
int i, w = 0, h = 0;
|
MwRect rc, sz;
|
||||||
MwRect rc;
|
|
||||||
MwPoint p = *point;
|
MwPoint p = *point;
|
||||||
|
|
||||||
|
MwSubMenuGetSize(handle, menu, &sz);
|
||||||
|
|
||||||
MwGetScreenSize(handle, &rc);
|
MwGetScreenSize(handle, &rc);
|
||||||
|
|
||||||
handle->internal = menu;
|
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) {
|
if(diff_calc) {
|
||||||
p.y = p.y - h;
|
p.y = p.y - sz.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLMakeToolWindow(handle->lowlevel);
|
MwLLMakeToolWindow(handle->lowlevel);
|
||||||
MwLLDetach(handle->lowlevel, &p);
|
MwLLDetach(handle->lowlevel, &p);
|
||||||
|
|
||||||
if(MwGetInteger(handle, MwNy) + h > rc.height) {
|
if(MwGetInteger(handle, MwNy) + sz.height > rc.height) {
|
||||||
MwVaApply(handle,
|
MwVaApply(handle,
|
||||||
MwNy, rc.height - h,
|
MwNy, rc.height - sz.height,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
MwLLEndStateChange(handle->lowlevel);
|
MwLLEndStateChange(handle->lowlevel);
|
||||||
|
|
||||||
MwVaApply(handle,
|
MwVaApply(handle,
|
||||||
MwNwidth, w,
|
MwNwidth, sz.width,
|
||||||
MwNheight, h,
|
MwNheight, sz.height,
|
||||||
NULL);
|
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) {
|
static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {
|
||||||
(void)out;
|
(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*);
|
MwPoint* point = va_arg(va, MwPoint*);
|
||||||
int diff_calc = va_arg(va, int);
|
int diff_calc = va_arg(va, int);
|
||||||
mwSubMenuAppearImpl(handle, menu, point, diff_calc);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user