Mercurial > dwindows
comparison mac/dw.m @ 2090:cdb94c6fd611
Added initial implmentation of dw_feature_get/set() on all platforms.
Only tested on Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 11 Jun 2020 01:11:23 +0000 |
parents | 94ea915bd917 |
children | 68f1924fdd13 |
comparison
equal
deleted
inserted
replaced
2089:bcc7877dcdac | 2090:cdb94c6fd611 |
---|---|
12600 char *temp = malloc(bufflen); | 12600 char *temp = malloc(bufflen); |
12601 if(temp) | 12601 if(temp) |
12602 wcstombs(temp, wstring, bufflen); | 12602 wcstombs(temp, wstring, bufflen); |
12603 return temp; | 12603 return temp; |
12604 } | 12604 } |
12605 | |
12606 /* | |
12607 * Gets the state of the requested library feature. | |
12608 * Parameters: | |
12609 * feature: The requested feature for example DW_FEATURE_DARK_MODE | |
12610 * Returns: | |
12611 * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. | |
12612 * DW_FEATURE_DISABLED if the feature is supported but disabled. | |
12613 * DW_FEATURE_ENABLED if the feature is supported and enabled. | |
12614 * Other value greater than 1, same as enabled but with extra info. | |
12615 */ | |
12616 int API dw_feature_get(DWFEATURE feature) | |
12617 { | |
12618 switch(feature) | |
12619 { | |
12620 #ifdef BUILDING_FOR_MOUNTAIN_LION | |
12621 case DW_FEATURE_NOTIFICATION: | |
12622 #endif | |
12623 case DW_FEATURE_HTML: | |
12624 case DW_FEATURE_HTML_RESULT: | |
12625 case DW_FEATURE_CONTAINER_STRIPE: | |
12626 case DW_FEATURE_MLE_WORD_WRAP: | |
12627 case DW_FEATURE_MLE_AUTO_COMPLETE: | |
12628 return DW_FEATURE_ENABLED; | |
12629 #ifdef BUILDING_FOR_MOJAVE | |
12630 case DW_FEATURE_DARK_MODE: | |
12631 { | |
12632 NSAppearance *appearance = [DWApp appearance]; | |
12633 | |
12634 if(appearance) | |
12635 { | |
12636 NSAppearanceName basicAppearance = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]]; | |
12637 | |
12638 if([basicAppearance isEqualToString:NSAppearanceNameDarkAqua]) | |
12639 return 2; | |
12640 if([basicAppearance isEqualToString:NSAppearanceNameAqua]) | |
12641 return DW_FEATURE_DISABLED; | |
12642 } | |
12643 return DW_FEATURE_ENABLED; | |
12644 } | |
12645 #endif | |
12646 } | |
12647 return DW_FEATURE_UNSUPPORTED; | |
12648 } | |
12649 | |
12650 /* | |
12651 * Sets the state of the requested library feature. | |
12652 * Parameters: | |
12653 * feature: The requested feature for example DW_FEATURE_DARK_MODE | |
12654 * state: DW_FEATURE_DISABLED, DW_FEATURE_ENABLED or any value greater than 1. | |
12655 * Returns: | |
12656 * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature. | |
12657 * DW_ERROR_NONE if the feature is supported and successfully configured. | |
12658 * DW_ERROR_GENERAL if the feature is supported but could not be configured. | |
12659 * Remarks: | |
12660 * These settings are typically used during dw_init() so issue before | |
12661 * setting up the library with dw_init(). | |
12662 */ | |
12663 int API dw_feature_set(DWFEATURE feature, int state) | |
12664 { | |
12665 switch(feature) | |
12666 { | |
12667 /* These features are supported but not configurable */ | |
12668 #ifdef BUILDING_FOR_MOUNTAIN_LION | |
12669 case DW_FEATURE_NOTIFICATION: | |
12670 #endif | |
12671 case DW_FEATURE_HTML: | |
12672 case DW_FEATURE_HTML_RESULT: | |
12673 case DW_FEATURE_CONTAINER_STRIPE: | |
12674 case DW_FEATURE_MLE_WORD_WRAP: | |
12675 case DW_FEATURE_MLE_AUTO_COMPLETE: | |
12676 return DW_ERROR_GENERAL; | |
12677 /* These features are supported and configurable */ | |
12678 #ifdef BUILDING_FOR_MOJAVE | |
12679 case DW_FEATURE_DARK_MODE: | |
12680 { | |
12681 /* Disabled forces the non-dark aqua theme */ | |
12682 if(state == DW_FEATURE_DISABLED) | |
12683 [DWApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]]; | |
12684 /* Enabled lets the OS decide the mode */ | |
12685 else if(state == DW_FEATURE_ENABLED) | |
12686 [DWApp setAppearance:nil]; | |
12687 /* 2 forces dark mode aqua appearance */ | |
12688 else if(state == 2) | |
12689 [DWApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; | |
12690 else | |
12691 return DW_ERROR_GENERAL; | |
12692 return DW_ERROR_NONE; | |
12693 } | |
12694 #endif | |
12695 } | |
12696 return DW_FEATURE_UNSUPPORTED; | |
12697 } |