Mercurial > dwindows
comparison win/dw.c @ 2255:66d0f1df4b34
Win: Cleanup after testing the last commit... Remove _dw_default_charformat.
After testing on many versions of Windows, CHARFORMAT2 szFaceName is empty and
yHeight is 180 (9 point) so don't bother saving it during MLE creation...
Also the MLE Word Wrap feature test was broken, it always reported unsupported.
Now it will report enabled when Rich Edit MLE is enabled, otherwise unsupported.
Word Wrap feature is not configurable, but Rich Edit MLE is, so use that if needed.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 25 Jan 2021 21:14:13 +0000 |
parents | 48daaf050e82 |
children | 281e2df2c022 |
comparison
equal
deleted
inserted
replaced
2254:48daaf050e82 | 2255:66d0f1df4b34 |
---|---|
40 #endif | 40 #endif |
41 #include <richedit.h> | 41 #include <richedit.h> |
42 | 42 |
43 #ifdef RICHEDIT | 43 #ifdef RICHEDIT |
44 int _DW_MLE_RICH_EDIT = DW_FEATURE_UNSUPPORTED; | 44 int _DW_MLE_RICH_EDIT = DW_FEATURE_UNSUPPORTED; |
45 static CHARFORMAT2 _dw_default_charformat = {0}; | |
46 #endif | 45 #endif |
47 | 46 |
48 #define STATICCLASSNAME TEXT("STATIC") | 47 #define STATICCLASSNAME TEXT("STATIC") |
49 #define COMBOBOXCLASSNAME TEXT("COMBOBOX") | 48 #define COMBOBOXCLASSNAME TEXT("COMBOBOX") |
50 #define LISTBOXCLASSNAME TEXT("LISTBOX") | 49 #define LISTBOXCLASSNAME TEXT("LISTBOX") |
5709 cf.cbSize = sizeof(cf); | 5708 cf.cbSize = sizeof(cf); |
5710 SendMessage(handle, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf); | 5709 SendMessage(handle, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf); |
5711 cf.dwMask = CFM_FACE | CFM_SIZE | CFM_ITALIC | CFM_BOLD; | 5710 cf.dwMask = CFM_FACE | CFM_SIZE | CFM_ITALIC | CFM_BOLD; |
5712 cf.dwEffects = (Italic ? CFE_ITALIC : 0) | (Bold ? CFE_BOLD : 0); | 5711 cf.dwEffects = (Italic ? CFE_ITALIC : 0) | (Bold ? CFE_BOLD : 0); |
5713 _tcsncpy(cf.szFaceName, UTF8toWide(myFontName), (sizeof(cf.szFaceName)/sizeof(TCHAR))-1); | 5712 _tcsncpy(cf.szFaceName, UTF8toWide(myFontName), (sizeof(cf.szFaceName)/sizeof(TCHAR))-1); |
5713 /* yHeight is apparently the point size * 20, defaulting to 9 (180) */ | |
5714 cf.yHeight = (size > 0) ? (size * 20) : 180; | 5714 cf.yHeight = (size > 0) ? (size * 20) : 180; |
5715 SendMessage(handle, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf); | 5715 SendMessage(handle, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf); |
5716 } | 5716 } |
5717 else | 5717 else |
5718 SendMessage(handle, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&_dw_default_charformat); | 5718 { |
5719 /* On testing what the default is, the szFaceName is empty, | |
5720 * yHeight is 180 (9 point). So use that to reset to default. | |
5721 */ | |
5722 CHARFORMAT2 cf = {0}; | |
5723 cf.cbSize = sizeof(cf); | |
5724 cf.yHeight = 180; | |
5725 cf.dwMask = CFM_FACE | CFM_SIZE | CFM_ITALIC | CFM_BOLD; | |
5726 SendMessage(handle, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf); | |
5727 } | |
5719 } | 5728 } |
5720 else | 5729 else |
5721 #endif | 5730 #endif |
5722 { | 5731 { |
5723 /* This needs to be after we get the correct handle */ | 5732 /* This needs to be after we get the correct handle */ |
7035 return NULL; | 7044 return NULL; |
7036 } | 7045 } |
7037 | 7046 |
7038 #ifdef RICHEDIT | 7047 #ifdef RICHEDIT |
7039 if(_DW_MLE_RICH_EDIT == DW_FEATURE_ENABLED && (hrichedit || hmsftedit)) | 7048 if(_DW_MLE_RICH_EDIT == DW_FEATURE_ENABLED && (hrichedit || hmsftedit)) |
7040 { | |
7041 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _richeditwndproc); | 7049 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _richeditwndproc); |
7042 /* Save the default RichEdit font for later use */ | |
7043 _dw_default_charformat.cbSize = sizeof(_dw_default_charformat); | |
7044 SendMessage(tmp, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&_dw_default_charformat); | |
7045 /* Make sure we set the mask we will use for reseting the MLE later */ | |
7046 _dw_default_charformat.dwMask = CFM_FACE | CFM_SIZE | CFM_ITALIC | CFM_BOLD; | |
7047 dw_debug("Default CHARFORMAT szFaceName \"%s\" dwMask %x yHeight %d\n", WideToUTF8(_dw_default_charformat.szFaceName), | |
7048 (int)_dw_default_charformat.dwMask, (int)_dw_default_charformat.yHeight); | |
7049 if(_dw_default_charformat.yHeight < 1) | |
7050 _dw_default_charformat.yHeight = 180; | |
7051 } | |
7052 else | 7050 else |
7053 #endif | 7051 #endif |
7054 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc); | 7052 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc); |
7055 cinfo->cinfo.fore = cinfo->cinfo.back = -1; | 7053 cinfo->cinfo.fore = cinfo->cinfo.back = -1; |
7056 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT; | 7054 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT; |
13872 return _DW_DARK_MODE_ALLOWED; | 13870 return _DW_DARK_MODE_ALLOWED; |
13873 return DW_FEATURE_UNSUPPORTED; | 13871 return DW_FEATURE_UNSUPPORTED; |
13874 } | 13872 } |
13875 #endif | 13873 #endif |
13876 #ifdef RICHEDIT | 13874 #ifdef RICHEDIT |
13875 /* Word wrap support on Windows is tied to Rich Edit, | |
13876 * if Rich Edit MLE is unsupported or disabled... | |
13877 * Word Wrap will return Unsupported. | |
13878 */ | |
13879 case DW_FEATURE_MLE_WORD_WRAP: | |
13880 { | |
13881 if(_DW_MLE_RICH_EDIT == DW_FEATURE_ENABLED && (hrichedit || hmsftedit)) | |
13882 return DW_FEATURE_ENABLED; | |
13883 return DW_FEATURE_UNSUPPORTED; | |
13884 } | |
13877 case DW_FEATURE_MLE_RICH_EDIT: | 13885 case DW_FEATURE_MLE_RICH_EDIT: |
13878 { | 13886 { |
13879 if(hmsftedit || hrichedit) | 13887 if(hmsftedit || hrichedit) |
13880 return _DW_MLE_RICH_EDIT; | 13888 return _DW_MLE_RICH_EDIT; |
13881 return DW_FEATURE_UNSUPPORTED; | 13889 return DW_FEATURE_UNSUPPORTED; |
13936 } | 13944 } |
13937 return DW_ERROR_GENERAL; | 13945 return DW_ERROR_GENERAL; |
13938 } | 13946 } |
13939 #endif | 13947 #endif |
13940 #ifdef RICHEDIT | 13948 #ifdef RICHEDIT |
13949 /* Word wrap support on Windows is tied to Rich Edit, | |
13950 * if Rich Edit MLE is unsupported or disabled... | |
13951 * Word Wrap will return Unsupported. If supported, | |
13952 * it is not configurable, configure Rich Edit instead. | |
13953 */ | |
13954 case DW_FEATURE_MLE_WORD_WRAP: | |
13955 { | |
13956 if(_DW_MLE_RICH_EDIT == DW_FEATURE_ENABLED && (hrichedit || hmsftedit)) | |
13957 return DW_ERROR_GENERAL; | |
13958 return DW_FEATURE_UNSUPPORTED; | |
13959 } | |
13941 case DW_FEATURE_MLE_RICH_EDIT: | 13960 case DW_FEATURE_MLE_RICH_EDIT: |
13942 { | 13961 { |
13943 if(state >= DW_FEATURE_DISABLED && state <= DW_FEATURE_ENABLED) | 13962 if(state >= DW_FEATURE_DISABLED && state <= DW_FEATURE_ENABLED) |
13944 { | 13963 { |
13945 _DW_MLE_RICH_EDIT = state; | 13964 _DW_MLE_RICH_EDIT = state; |