diff --git a/examples/basic/periodic.c b/examples/basic/periodic.c index 2280e93..39c6b4a 100644 --- a/examples/basic/periodic.c +++ b/examples/basic/periodic.c @@ -306,13 +306,13 @@ int main() { f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL); add(f); -#if 0 +#if 1 f = frame("SubWindow", -PaddingContent, -PaddingContent, MwViewportClass, MwNratio, 3, NULL); w = child(f); MwViewportSetSize(w, 512, 512); - MwVaCreateWidget(MwSubWindowClass, "swnd", MwViewportGetViewport(w), 0, 0, 512, 512, + MwVaCreateWidget(MwSubWindowClass, "swnd", MwViewportGetViewport(w), 32, 32, 128, 128, MwNtitle, "Sub window", NULL); add(f); diff --git a/include/Mw/Milsko.h b/include/Mw/Milsko.h index 153f124..9600b0c 100644 --- a/include/Mw/Milsko.h +++ b/include/Mw/Milsko.h @@ -51,5 +51,6 @@ #include #include #include +#include #endif diff --git a/include/Mw/Widget/ComboBox.h b/include/Mw/Widget/ComboBox.h index f6170cc..7b2dc2f 100644 --- a/include/Mw/Widget/ComboBox.h +++ b/include/Mw/Widget/ComboBox.h @@ -7,6 +7,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/include/Mw/Widget/Label.h b/include/Mw/Widget/Label.h index 4c75133..f9338e3 100644 --- a/include/Mw/Widget/Label.h +++ b/include/Mw/Widget/Label.h @@ -7,6 +7,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/include/Mw/Widget/SubWindow.h b/include/Mw/Widget/SubWindow.h new file mode 100644 index 0000000..38a1cdd --- /dev/null +++ b/include/Mw/Widget/SubWindow.h @@ -0,0 +1,25 @@ +/*! + * @file Mw/Widget/SubWindow.h + * @brief SubWindow widget + */ +#ifndef __MW_WIDGET_SUBWINDOW_H__ +#define __MW_WIDGET_SUBWINDOW_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * @brief SubWindow widget class + */ +MWDECL MwClass MwSubWindowClass; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/pl/rules.pl b/pl/rules.pl index 6d78115..8534000 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -154,6 +154,7 @@ new_object("src/widget/radiobox.c"); new_object("src/widget/scrollbar.c"); new_object("src/widget/separator.c"); new_object("src/widget/submenu.c"); +new_object("src/widget/subwindow.c"); new_object("src/widget/treeview.c"); new_object("src/widget/viewport.c"); new_object("src/widget/window.c"); diff --git a/src/backend/gdi.c b/src/backend/gdi.c index f273b8b..c87e3fa 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -52,8 +52,8 @@ static void detect_darktheme(MwLL handle) { t = dw ? 0 : 1; if(t && DwmSetWindowAttribute != NULL) { - LPARAM style = GetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE); - if(!(style & WS_CHILD)) MwLLSetDarkTheme(handle, 1); + // LPARAM style = GetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE); + // if(!(style & WS_CHILD)) MwLLSetDarkTheme(handle, 1); } MwLLDispatch(handle, dark_theme, &t); diff --git a/src/core.c b/src/core.c index 5cc7bbd..c73a635 100644 --- a/src/core.c +++ b/src/core.c @@ -173,12 +173,14 @@ static void lldarkthemehandler(MwLL handle, void* data) { int s; if(IsFirstVisible(h) && (shgeti(h->integer, MwNdarkTheme) == -1 || ((s = MwGetInteger(h, MwNdarkThemeAutomatic)) != MwDEFAULT && s))) { - MwVaApply(h, - MwNdarkTheme, *ptr, - MwNdarkThemeAutomatic, 1, - NULL); + if(MwGetInteger(h, MwNmodernLook)){ + MwVaApply(h, + MwNdarkTheme, *ptr, + MwNdarkThemeAutomatic, 1, + NULL); - MwDispatchUserHandler(h, MwNdarkThemeHandler, data); + MwDispatchUserHandler(h, MwNdarkThemeHandler, data); + } } } diff --git a/src/widget/subwindow.c b/src/widget/subwindow.c new file mode 100644 index 0000000..b7051f9 --- /dev/null +++ b/src/widget/subwindow.c @@ -0,0 +1,65 @@ +#include + +#define TitleHeight 20 + +static int wcreate(MwWidget handle) { + MwSetDefault(handle); + + return 0; +} + +static void draw(MwWidget handle) { + MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNbackground)); + MwLLColor c2 = MwParseColor(handle, MwGetText(handle, MwNsubBackground)); + MwRect r, r2; + + r.x = 0; + r.y = 0; + r.width = MwGetInteger(handle, MwNwidth); + r.height = MwGetInteger(handle, MwNheight); + + MwDrawFrame(handle, &r, c, 0); + MwDrawRect(handle, &r, c); + + r2 = r; + r2.height = TitleHeight; + MwDrawRect(handle, &r2, c2); + + r.y += TitleHeight; + r.height -= TitleHeight; + MwDrawFrame(handle, &r, c, 1); + + MwLLFreeColor(c2); + MwLLFreeColor(c); +} + +static void prop_change(MwWidget handle, const char* key) { + if(strcmp(key, MwNtitle) == 0) MwForceRender(handle); +} + +static void func_handler(MwWidget handle, const char* name, void* out, va_list va) { + (void)out; +} + +MwClassRec MwSubWindowClassRec = { + wcreate, /* create */ + NULL, /* destroy */ + draw, /* draw */ + NULL, /* click */ + NULL, /* parent_resize */ + prop_change, /* prop_change */ + NULL, /* mouse_move */ + NULL, /* mouse_up */ + NULL, /* mouse_down */ + NULL, /* key */ + func_handler, /* execute */ + NULL, /* tick */ + NULL, /* resize */ + NULL, /* children_update */ + NULL, /* children_prop_change */ + NULL, /* clipboard */ + NULL, /* props_change */ + NULL, + NULL, + NULL}; +MwClass MwSubWindowClass = &MwSubWindowClassRec;