# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1591837883 0 # Node ID cdb94c6fd61150febead91603bfc16afbffeec39 # Parent bcc7877dcdaca447596a555e6bdee6a6bf8b735d Added initial implmentation of dw_feature_get/set() on all platforms. Only tested on Windows. diff -r bcc7877dcdac -r cdb94c6fd611 dw.h --- a/dw.h Fri Jun 05 16:49:31 2020 +0000 +++ b/dw.h Thu Jun 11 01:11:23 2020 +0000 @@ -1467,6 +1467,27 @@ #define DW_MLE_COMPLETE_DASH (1 << 1) #define DW_MLE_COMPLETE_QUOTE (1 << 2) +/* Library feature constants */ +#define DW_FEATURE_UNSUPPORTED -1 +#define DW_FEATURE_DISABLED 0 +#define DW_FEATURE_ENABLED 1 + +typedef enum +{ + DW_FEATURE_HTML = 0, /* Supports the HTML Widget */ + DW_FEATURE_HTML_RESULT, /* Supports the DW_SIGNAL_HTML_RESULT callback */ + DW_FEATURE_WINDOW_BORDER, /* Supports custom window border sizes */ + DW_FEATURE_WINDOW_TRANSPARENCY, /* Supports window frame transparency */ + DW_FEATURE_DARK_MODE, /* Supports Dark Mode user interface */ + DW_FEATURE_MLE_AUTO_COMPLETE, /* Supports auto completion in Multi-line Edit boxes */ + DW_FEATURE_MLE_WORD_WRAP, /* Supports word wrapping in Multi-line Edit boxes */ + DW_FEATURE_CONTAINER_STRIPE, /* Supports striped line display in container widgets */ + DW_FEATURE_MDI, /* Supports Multiple Document Interface window frame */ + DW_FEATURE_NOTEBOOK_STATUS_TEXT, /* Supports status text area on notebook/tabbed controls */ + DW_FEATURE_NOTIFICATION, /* Supports sending system notifications */ + DW_FEATURE_MAX +} DWFEATURE; + /* Macro for casting resource IDs to HICN */ #define DW_RESOURCE(a) (a < 65536 ? (HICN)a : (HICN)0) @@ -1840,6 +1861,8 @@ int API dw_notification_send(HWND notification); wchar_t * API dw_utf8_to_wchar(const char *utf8string); char * API dw_wchar_to_utf8(const wchar_t *wstring); +int API dw_feature_get(DWFEATURE feature); +int API dw_feature_set(DWFEATURE feature, int state); /* Exported for language bindings */ void API _dw_init_thread(void); void API _dw_deinit_thread(void); diff -r bcc7877dcdac -r cdb94c6fd611 gtk/dw.c --- a/gtk/dw.c Fri Jun 05 16:49:31 2020 +0000 +++ b/gtk/dw.c Thu Jun 11 01:11:23 2020 +0000 @@ -13824,3 +13824,67 @@ return retval; } +/* + * Gets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_FEATURE_DISABLED if the feature is supported but disabled. + * DW_FEATURE_ENABLED if the feature is supported and enabled. + * Other value greater than 1, same as enabled but with extra info. + */ +int API dw_feature_get(DWFEATURE feature) +{ + switch(feature) + { +#ifdef USE_WEBKIT + case DW_FEATURE_HTML: +#endif +#if GLIB_CHECK_VERSION(2,40,0) + case DW_FEATURE_NOTIFICATION: +#endif +#ifdef DW_INCLUDE_DEPRECATED + case DW_FEATURE_MDI: +#endif + case DW_FEATURE_CONTAINER_STRIPE: + case DW_FEATURE_MLE_WORD_WRAP: + return DW_FEATURE_ENABLED; + } + return DW_FEATURE_UNSUPPORTED; +} + +/* + * Sets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * state: DW_FEATURE_DISABLED, DW_FEATURE_ENABLED or any value greater than 1. + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_ERROR_NONE if the feature is supported and successfully configured. + * DW_ERROR_GENERAL if the feature is supported but could not be configured. + * Remarks: + * These settings are typically used during dw_init() so issue before + * setting up the library with dw_init(). + */ +int API dw_feature_set(DWFEATURE feature, int state) +{ + switch(feature) + { + /* These features are supported but not configurable */ +#ifdef USE_WEBKIT + case DW_FEATURE_HTML: +#endif +#if GLIB_CHECK_VERSION(2,40,0) + case DW_FEATURE_NOTIFICATION: +#endif +#ifdef DW_INCLUDE_DEPRECATED + case DW_FEATURE_MDI: +#endif + case DW_FEATURE_CONTAINER_STRIPE: + case DW_FEATURE_MLE_WORD_WRAP: + return DW_ERROR_GENERAL; + /* These features are supported and configurable */ + } + return DW_FEATURE_UNSUPPORTED; +} diff -r bcc7877dcdac -r cdb94c6fd611 gtk3/dw.c --- a/gtk3/dw.c Fri Jun 05 16:49:31 2020 +0000 +++ b/gtk3/dw.c Thu Jun 11 01:11:23 2020 +0000 @@ -12310,3 +12310,77 @@ return retval; } +/* + * Gets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_FEATURE_DISABLED if the feature is supported but disabled. + * DW_FEATURE_ENABLED if the feature is supported and enabled. + * Other value greater than 1, same as enabled but with extra info. + */ +int API dw_feature_get(DWFEATURE feature) +{ + switch(feature) + { +#ifdef USE_WEBKIT + case DW_FEATURE_HTML: +#endif +#ifdef USE_WEBKIT2 + case DW_FEATURE_HTML_RESULT: +#endif +#if GLIB_CHECK_VERSION(2,40,0) + case DW_FEATURE_NOTIFICATION: +#endif +#ifdef DW_INCLUDE_DEPRECATED + case DW_FEATURE_MDI: +#endif +#if !GTK_CHECK_VERSION(3,14,0) + case DW_FEATURE_CONTAINER_STRIPE: +#endif + case DW_FEATURE_MLE_WORD_WRAP: + return DW_FEATURE_ENABLED; + } + return DW_FEATURE_UNSUPPORTED; +} + +/* + * Sets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * state: DW_FEATURE_DISABLED, DW_FEATURE_ENABLED or any value greater than 1. + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_ERROR_NONE if the feature is supported and successfully configured. + * DW_ERROR_GENERAL if the feature is supported but could not be configured. + * Remarks: + * These settings are typically used during dw_init() so issue before + * setting up the library with dw_init(). + */ +int API dw_feature_set(DWFEATURE feature, int state) +{ + switch(feature) + { + /* These features are supported but not configurable */ +#ifdef USE_WEBKIT + case DW_FEATURE_HTML: +#endif +#ifdef USE_WEBKIT2 + case DW_FEATURE_HTML_RESULT: +#endif +#if GLIB_CHECK_VERSION(2,40,0) + case DW_FEATURE_NOTIFICATION: +#endif +#ifdef DW_INCLUDE_DEPRECATED + case DW_FEATURE_MDI: +#endif +#if !GTK_CHECK_VERSION(3,14,0) + case DW_FEATURE_CONTAINER_STRIPE: +#endif + case DW_FEATURE_MLE_WORD_WRAP: + return DW_ERROR_GENERAL; + /* These features are supported and configurable */ + } + return DW_FEATURE_UNSUPPORTED; +} diff -r bcc7877dcdac -r cdb94c6fd611 mac/dw.m --- a/mac/dw.m Fri Jun 05 16:49:31 2020 +0000 +++ b/mac/dw.m Thu Jun 11 01:11:23 2020 +0000 @@ -12602,3 +12602,96 @@ wcstombs(temp, wstring, bufflen); return temp; } + +/* + * Gets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_FEATURE_DISABLED if the feature is supported but disabled. + * DW_FEATURE_ENABLED if the feature is supported and enabled. + * Other value greater than 1, same as enabled but with extra info. + */ +int API dw_feature_get(DWFEATURE feature) +{ + switch(feature) + { +#ifdef BUILDING_FOR_MOUNTAIN_LION + case DW_FEATURE_NOTIFICATION: +#endif + case DW_FEATURE_HTML: + case DW_FEATURE_HTML_RESULT: + case DW_FEATURE_CONTAINER_STRIPE: + case DW_FEATURE_MLE_WORD_WRAP: + case DW_FEATURE_MLE_AUTO_COMPLETE: + return DW_FEATURE_ENABLED; +#ifdef BUILDING_FOR_MOJAVE + case DW_FEATURE_DARK_MODE: + { + NSAppearance *appearance = [DWApp appearance]; + + if(appearance) + { + NSAppearanceName basicAppearance = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]]; + + if([basicAppearance isEqualToString:NSAppearanceNameDarkAqua]) + return 2; + if([basicAppearance isEqualToString:NSAppearanceNameAqua]) + return DW_FEATURE_DISABLED; + } + return DW_FEATURE_ENABLED; + } +#endif + } + return DW_FEATURE_UNSUPPORTED; +} + +/* + * Sets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * state: DW_FEATURE_DISABLED, DW_FEATURE_ENABLED or any value greater than 1. + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_ERROR_NONE if the feature is supported and successfully configured. + * DW_ERROR_GENERAL if the feature is supported but could not be configured. + * Remarks: + * These settings are typically used during dw_init() so issue before + * setting up the library with dw_init(). + */ +int API dw_feature_set(DWFEATURE feature, int state) +{ + switch(feature) + { + /* These features are supported but not configurable */ +#ifdef BUILDING_FOR_MOUNTAIN_LION + case DW_FEATURE_NOTIFICATION: +#endif + case DW_FEATURE_HTML: + case DW_FEATURE_HTML_RESULT: + case DW_FEATURE_CONTAINER_STRIPE: + case DW_FEATURE_MLE_WORD_WRAP: + case DW_FEATURE_MLE_AUTO_COMPLETE: + return DW_ERROR_GENERAL; + /* These features are supported and configurable */ +#ifdef BUILDING_FOR_MOJAVE + case DW_FEATURE_DARK_MODE: + { + /* Disabled forces the non-dark aqua theme */ + if(state == DW_FEATURE_DISABLED) + [DWApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]]; + /* Enabled lets the OS decide the mode */ + else if(state == DW_FEATURE_ENABLED) + [DWApp setAppearance:nil]; + /* 2 forces dark mode aqua appearance */ + else if(state == 2) + [DWApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; + else + return DW_ERROR_GENERAL; + return DW_ERROR_NONE; + } +#endif + } + return DW_FEATURE_UNSUPPORTED; +} diff -r bcc7877dcdac -r cdb94c6fd611 os2/dw.c --- a/os2/dw.c Fri Jun 05 16:49:31 2020 +0000 +++ b/os2/dw.c Thu Jun 11 01:11:23 2020 +0000 @@ -13830,3 +13830,54 @@ return NULL; #endif } + +/* + * Gets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_FEATURE_DISABLED if the feature is supported but disabled. + * DW_FEATURE_ENABLED if the feature is supported and enabled. + * Other value greater than 1, same as enabled but with extra info. + */ +int API dw_feature_get(DWFEATURE feature) +{ + switch(feature) + { + case DW_FEATURE_WINDOW_BORDER: + case DW_FEATURE_MLE_WORD_WRAP: + case DW_FEATURE_NOTEBOOK_STATUS_TEXT: + case DW_FEATURE_MDI: + return DW_FEATURE_ENABLED; + } + return DW_FEATURE_UNSUPPORTED; +} + +/* + * Sets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * state: DW_FEATURE_DISABLED, DW_FEATURE_ENABLED or any value greater than 1. + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_ERROR_NONE if the feature is supported and successfully configured. + * DW_ERROR_GENERAL if the feature is supported but could not be configured. + * Remarks: + * These settings are typically used during dw_init() so issue before + * setting up the library with dw_init(). + */ +int API dw_feature_set(DWFEATURE feature, int state) +{ + switch(feature) + { + /* These features are supported but not configurable */ + case DW_FEATURE_WINDOW_BORDER: + case DW_FEATURE_MLE_WORD_WRAP: + case DW_FEATURE_NOTEBOOK_STATUS_TEXT: + case DW_FEATURE_MDI: + return DW_ERROR_GENERAL; + /* These features are supported and configurable */ + } + return DW_FEATURE_UNSUPPORTED; +} diff -r bcc7877dcdac -r cdb94c6fd611 os2/dw.def --- a/os2/dw.def Fri Jun 05 16:49:31 2020 +0000 +++ b/os2/dw.def Thu Jun 11 01:11:23 2020 +0000 @@ -327,3 +327,6 @@ dw_notification_new @530 dw_notification_send @531 + + dw_feature_get @540 + dw_feature_set @541 diff -r bcc7877dcdac -r cdb94c6fd611 win/dw.c --- a/win/dw.c Fri Jun 05 16:49:31 2020 +0000 +++ b/win/dw.c Thu Jun 11 01:11:23 2020 +0000 @@ -13350,3 +13350,86 @@ return NULL; #endif } + +/* + * Gets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_FEATURE_DISABLED if the feature is supported but disabled. + * DW_FEATURE_ENABLED if the feature is supported and enabled. + * Other value greater than 1, same as enabled but with extra info. + */ +int API dw_feature_get(DWFEATURE feature) +{ + switch(feature) + { +#ifdef BUILD_HTML + case DW_FEATURE_HTML: + case DW_FEATURE_HTML_RESULT: +#endif +#ifdef AEROGLASS + case DW_FEATURE_WINDOW_TRANSPARENCY: +#endif +#ifdef BUILD_TOAST + case DW_FEATURE_NOTIFICATION: +#endif + case DW_FEATURE_CONTAINER_STRIPE: + case DW_FEATURE_MDI: + return DW_FEATURE_ENABLED; +#ifdef AEROGLASS + case DW_FEATURE_DARK_MODE: + { + if(_DW_DARK_MODE_SUPPORTED) + return _DW_DARK_MODE_ALLOWED; + break; + } +#endif + } + return DW_FEATURE_UNSUPPORTED; +} + +/* + * Sets the state of the requested library feature. + * Parameters: + * feature: The requested feature for example DW_FEATURE_DARK_MODE + * state: DW_FEATURE_DISABLED, DW_FEATURE_ENABLED or any value greater than 1. + * Returns: + * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. + * DW_ERROR_NONE if the feature is supported and successfully configured. + * DW_ERROR_GENERAL if the feature is supported but could not be configured. + * Remarks: + * These settings are typically used during dw_init() so issue before + * setting up the library with dw_init(). + */ +int API dw_feature_set(DWFEATURE feature, int state) +{ + switch(feature) + { + /* These features are supported but not configurable */ +#ifdef BUILD_HTML + case DW_FEATURE_HTML: + case DW_FEATURE_HTML_RESULT: +#endif +#ifdef AEROGLASS + case DW_FEATURE_WINDOW_TRANSPARENCY: +#endif +#ifdef BUILD_TOAST + case DW_FEATURE_NOTIFICATION: +#endif + case DW_FEATURE_CONTAINER_STRIPE: + case DW_FEATURE_MDI: + return DW_ERROR_GENERAL; + /* These features are supported and configurable */ +#ifdef AEROGLASS + case DW_FEATURE_DARK_MODE: + { + _DW_DARK_MODE_ALLOWED = state; + return DW_ERROR_NONE; + } +#endif + } + return DW_FEATURE_UNSUPPORTED; +} + diff -r bcc7877dcdac -r cdb94c6fd611 win/dw.def --- a/win/dw.def Fri Jun 05 16:49:31 2020 +0000 +++ b/win/dw.def Thu Jun 11 01:11:23 2020 +0000 @@ -324,3 +324,6 @@ dw_notification_new @530 dw_notification_send @531 + + dw_feature_get @540 + dw_feature_set @541