comparison win/dw.c @ 2081:24875681eec5

Added htmlEngine to DWEnv
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 31 May 2020 05:25:18 +0000
parents b4b49d29b940
children f1acc157b2dd
comparison
equal deleted inserted replaced
2080:8f08d4c9d3fc 2081:24875681eec5
4 * 4 *
5 * (C) 2000-2020 Brian Smith <brian@dbsoft.org> 5 * (C) 2000-2020 Brian Smith <brian@dbsoft.org>
6 * (C) 2003-2011 Mark Hessling <mark@rexx.org> 6 * (C) 2003-2011 Mark Hessling <mark@rexx.org>
7 * 7 *
8 */ 8 */
9 9
10 #ifdef AEROGLASS 10 #ifdef AEROGLASS
11 #define _WIN32_IE 0x0501 11 #define _WIN32_IE 0x0501
12 #define WINVER 0x501 12 #define WINVER 0x501
13 #else 13 #else
14 #define _WIN32_IE 0x0500 14 #define _WIN32_IE 0x0500
62 struct GdiplusStartupInput 62 struct GdiplusStartupInput
63 { 63 {
64 UINT32 GdiplusVersion; 64 UINT32 GdiplusVersion;
65 void *DebugEventCallback; 65 void *DebugEventCallback;
66 BOOL SuppressBackgroundThread; 66 BOOL SuppressBackgroundThread;
67 BOOL SuppressExternalCodecs; 67 BOOL SuppressExternalCodecs;
68 }; 68 };
69 69
70 typedef enum { 70 typedef enum {
71 Ok = 0, 71 Ok = 0,
72 GenericError = 1, 72 GenericError = 1,
87 NotTrueTypeFont = 16, 87 NotTrueTypeFont = 16,
88 UnsupportedGdiplusVersion = 17, 88 UnsupportedGdiplusVersion = 17,
89 GdiplusNotInitialized = 18, 89 GdiplusNotInitialized = 18,
90 PropertyNotFound = 19, 90 PropertyNotFound = 19,
91 PropertyNotSupported = 20, 91 PropertyNotSupported = 20,
92 ProfileNotFound = 21 92 ProfileNotFound = 21
93 } GpStatus; 93 } GpStatus;
94 94
95 typedef enum { 95 typedef enum {
96 UnitWorld, 96 UnitWorld,
97 UnitDisplay, 97 UnitDisplay,
102 UnitMillimeter 102 UnitMillimeter
103 } GpUnit; 103 } GpUnit;
104 104
105 typedef enum { 105 typedef enum {
106 FlushIntentionFlush = 0, 106 FlushIntentionFlush = 0,
107 FlushIntentionSync = 1 107 FlushIntentionSync = 1
108 } GpFlushIntention; 108 } GpFlushIntention;
109 109
110 typedef enum { 110 typedef enum {
111 QualityModeInvalid = -1, 111 QualityModeInvalid = -1,
112 QualityModeDefault = 0, 112 QualityModeDefault = 0,
173 GpStatus WINAPI GdipDrawEllipseI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height); 173 GpStatus WINAPI GdipDrawEllipseI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height);
174 GpStatus WINAPI GdipFillEllipseI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height); 174 GpStatus WINAPI GdipFillEllipseI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height);
175 GpStatus WINAPI GdipFlush(GpGraphics *graphics, GpFlushIntention intention); 175 GpStatus WINAPI GdipFlush(GpGraphics *graphics, GpFlushIntention intention);
176 176
177 /* Pixel format information */ 177 /* Pixel format information */
178 #define PixelFormatIndexed 0x00010000 178 #define PixelFormatIndexed 0x00010000
179 #define PixelFormatGDI 0x00020000 179 #define PixelFormatGDI 0x00020000
180 #define PixelFormatAlpha 0x00040000 180 #define PixelFormatAlpha 0x00040000
181 #define PixelFormatPAlpha 0x00080000 181 #define PixelFormatPAlpha 0x00080000
182 #define PixelFormatExtended 0x00100000 182 #define PixelFormatExtended 0x00100000
183 #define PixelFormatCanonical 0x00200000 183 #define PixelFormatCanonical 0x00200000
184 184
185 #define PixelFormatUndefined 0 185 #define PixelFormatUndefined 0
186 #define PixelFormatDontCare 0 186 #define PixelFormatDontCare 0
187 187
188 #define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI) 188 #define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
200 #define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended) 200 #define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended)
201 #define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended) 201 #define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended)
202 #define PixelFormat32bppCMYK (15 | (32 << 8)) 202 #define PixelFormat32bppCMYK (15 | (32 << 8))
203 203
204 /* Token to the GDI+ Instance */ 204 /* Token to the GDI+ Instance */
205 ULONG_PTR gdiplusToken; 205 ULONG_PTR gdiplusToken;
206 #endif 206 #endif
207 207
208 #ifdef AEROGLASS 208 #ifdef AEROGLASS
209 HRESULT (WINAPI *_DwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS *pMarInset) = 0; 209 HRESULT (WINAPI *_DwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS *pMarInset) = 0;
210 HRESULT (WINAPI *_DwmIsCompositionEnabled)(BOOL *pfEnabled) = 0; 210 HRESULT (WINAPI *_DwmIsCompositionEnabled)(BOOL *pfEnabled) = 0;
220 HANDLE hdwm = 0; 220 HANDLE hdwm = 0;
221 #endif 221 #endif
222 /* Aero related but separate functions and handles */ 222 /* Aero related but separate functions and handles */
223 HRESULT (WINAPI *_SetWindowTheme)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList) = 0; 223 HRESULT (WINAPI *_SetWindowTheme)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList) = 0;
224 HANDLE huxtheme = 0; 224 HANDLE huxtheme = 0;
225 225
226 /* Needed for Rich Edit controls */ 226 /* Needed for Rich Edit controls */
227 HANDLE hrichedit = 0; 227 HANDLE hrichedit = 0;
228 HANDLE hmsftedit = 0; 228 HANDLE hmsftedit = 0;
229 229
230 /* 230 /*
328 /* Internal function to queue a window redraw */ 328 /* Internal function to queue a window redraw */
329 void _dw_redraw(HWND window, int skip) 329 void _dw_redraw(HWND window, int skip)
330 { 330 {
331 static HWND lastwindow = 0; 331 static HWND lastwindow = 0;
332 HWND redraw = lastwindow; 332 HWND redraw = lastwindow;
333 333
334 if(skip && !window) 334 if(skip && !window)
335 return; 335 return;
336 336
337 lastwindow = window; 337 lastwindow = window;
338 if(redraw != lastwindow && redraw) 338 if(redraw != lastwindow && redraw)
497 /* Macro and internal function to convert UTF8 to Unicode wide characters */ 497 /* Macro and internal function to convert UTF8 to Unicode wide characters */
498 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) 498 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL)
499 LPWSTR _myUTF8toWide(const char *utf8string, void *outbuf) 499 LPWSTR _myUTF8toWide(const char *utf8string, void *outbuf)
500 { 500 {
501 LPWSTR retbuf = outbuf; 501 LPWSTR retbuf = outbuf;
502 502
503 if(retbuf) 503 if(retbuf)
504 MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, retbuf, MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR)); 504 MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, retbuf, MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR));
505 return retbuf; 505 return retbuf;
506 } 506 }
507 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL) 507 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL)
508 char *_myWideToUTF8(LPCWSTR widestring, void *outbuf) 508 char *_myWideToUTF8(LPCWSTR widestring, void *outbuf)
509 { 509 {
510 char *retbuf = outbuf; 510 char *retbuf = outbuf;
511 511
512 if(retbuf) 512 if(retbuf)
513 WideCharToMultiByte(CP_UTF8, 0, widestring, -1, retbuf, WideCharToMultiByte(CP_UTF8, 0, widestring, -1, NULL, 0, NULL, NULL), NULL, NULL); 513 WideCharToMultiByte(CP_UTF8, 0, widestring, -1, retbuf, WideCharToMultiByte(CP_UTF8, 0, widestring, -1, NULL, 0, NULL, NULL), NULL, NULL);
514 return retbuf; 514 return retbuf;
515 } 515 }
516 #else 516 #else
741 _WINDOWCOMPOSITIONATTRIB Attrib; 741 _WINDOWCOMPOSITIONATTRIB Attrib;
742 PVOID pvData; 742 PVOID pvData;
743 SIZE_T cbData; 743 SIZE_T cbData;
744 } _WINDOWCOMPOSITIONATTRIBDATA; 744 } _WINDOWCOMPOSITIONATTRIBDATA;
745 745
746 HTHEME (WINAPI * _OpenNcThemeData)(HWND, LPCWSTR) = NULL; 746 HTHEME (WINAPI * _OpenNcThemeData)(HWND, LPCWSTR) = NULL;
747 VOID (WINAPI * _RefreshImmersiveColorPolicyState)(VOID) = NULL; 747 VOID (WINAPI * _RefreshImmersiveColorPolicyState)(VOID) = NULL;
748 BOOL (WINAPI * _GetIsImmersiveColorUsingHighContrast)(IMMERSIVE_HC_CACHE_MODE) = NULL; 748 BOOL (WINAPI * _GetIsImmersiveColorUsingHighContrast)(IMMERSIVE_HC_CACHE_MODE) = NULL;
749 BOOL (WINAPI * _ShouldAppsUseDarkMode)(VOID) = NULL; 749 BOOL (WINAPI * _ShouldAppsUseDarkMode)(VOID) = NULL;
750 BOOL (WINAPI * _AllowDarkModeForWindow)(HWND, BOOL) = NULL; 750 BOOL (WINAPI * _AllowDarkModeForWindow)(HWND, BOOL) = NULL;
751 BOOL (WINAPI * _AllowDarkModeForApp)(BOOL) = NULL; 751 BOOL (WINAPI * _AllowDarkModeForApp)(BOOL) = NULL;
752 _PreferredAppMode (WINAPI * _SetPreferredAppMode)(_PreferredAppMode) = NULL; 752 _PreferredAppMode (WINAPI * _SetPreferredAppMode)(_PreferredAppMode) = NULL;
753 BOOL (WINAPI * _IsDarkModeAllowedForWindow)(HWND) = NULL; 753 BOOL (WINAPI * _IsDarkModeAllowedForWindow)(HWND) = NULL;
754 BOOL (WINAPI * _ShouldSystemUseDarkMode)(VOID) = NULL; 754 BOOL (WINAPI * _ShouldSystemUseDarkMode)(VOID) = NULL;
755 BOOL (WINAPI* _SetWindowCompositionAttribute)(HWND, _WINDOWCOMPOSITIONATTRIBDATA *) = NULL; 755 BOOL (WINAPI* _SetWindowCompositionAttribute)(HWND, _WINDOWCOMPOSITIONATTRIBDATA *) = NULL;
756 756
757 BOOL IsHighContrast(VOID) 757 BOOL IsHighContrast(VOID)
758 { 758 {
759 HIGHCONTRASTW highContrast = { sizeof(highContrast) }; 759 HIGHCONTRASTW highContrast = { sizeof(highContrast) };
782 _ShouldSystemUseDarkMode = (BOOL (WINAPI *)(VOID))GetProcAddress(huxtheme, MAKEINTRESOURCEA(138)); 782 _ShouldSystemUseDarkMode = (BOOL (WINAPI *)(VOID))GetProcAddress(huxtheme, MAKEINTRESOURCEA(138));
783 _SetWindowCompositionAttribute = (BOOL (WINAPI*)(HWND, _WINDOWCOMPOSITIONATTRIBDATA*))GetProcAddress(GetModuleHandle(TEXT("user32.dll")), "SetWindowCompositionAttribute"); 783 _SetWindowCompositionAttribute = (BOOL (WINAPI*)(HWND, _WINDOWCOMPOSITIONATTRIBDATA*))GetProcAddress(GetModuleHandle(TEXT("user32.dll")), "SetWindowCompositionAttribute");
784 } 784 }
785 /* Make sure we were able to load all the Dark Mode functions */ 785 /* Make sure we were able to load all the Dark Mode functions */
786 if(_OpenNcThemeData && _RefreshImmersiveColorPolicyState && _ShouldAppsUseDarkMode && _AllowDarkModeForWindow && 786 if(_OpenNcThemeData && _RefreshImmersiveColorPolicyState && _ShouldAppsUseDarkMode && _AllowDarkModeForWindow &&
787 (_AllowDarkModeForApp || _SetPreferredAppMode) && _IsDarkModeAllowedForWindow && 787 (_AllowDarkModeForApp || _SetPreferredAppMode) && _IsDarkModeAllowedForWindow &&
788 (_DwmSetWindowAttribute || _SetWindowCompositionAttribute)) 788 (_DwmSetWindowAttribute || _SetWindowCompositionAttribute))
789 { 789 {
790 _DW_DARK_MODE_SUPPORTED = TRUE; 790 _DW_DARK_MODE_SUPPORTED = TRUE;
791 if(_AllowDarkModeForApp) 791 if(_AllowDarkModeForApp)
792 _AllowDarkModeForApp(TRUE); 792 _AllowDarkModeForApp(TRUE);
800 800
801 BOOL _CanThemeWindow(HWND window) 801 BOOL _CanThemeWindow(HWND window)
802 { 802 {
803 TCHAR tmpbuf[100] = {0}; 803 TCHAR tmpbuf[100] = {0};
804 LONG_PTR style = GetWindowLongPtr(window, GWL_STYLE); 804 LONG_PTR style = GetWindowLongPtr(window, GWL_STYLE);
805 805
806 GetClassName(window, tmpbuf, 99); 806 GetClassName(window, tmpbuf, 99);
807 807
808 /* Some controls don't display properly with visual styles enabled */ 808 /* Some controls don't display properly with visual styles enabled */
809 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0 && 809 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0 &&
810 (style & (BS_AUTOCHECKBOX | BS_CHECKBOX | BS_RADIOBUTTON))) 810 (style & (BS_AUTOCHECKBOX | BS_CHECKBOX | BS_RADIOBUTTON)))
811 return FALSE; 811 return FALSE;
812 #ifdef TOOLBAR 812 #ifdef TOOLBAR
813 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0) 813 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
814 { 814 {
881 } 881 }
882 return TRUE; 882 return TRUE;
883 } 883 }
884 #endif 884 #endif
885 885
886 /* Special wrappers for GetSysColor*() since they currently don't support 886 /* Special wrappers for GetSysColor*() since they currently don't support
887 * dark mode, we will have to return modified colors when dark mode is enabled. 887 * dark mode, we will have to return modified colors when dark mode is enabled.
888 */ 888 */
889 DWORD _DW_GetSysColor(int nIndex) 889 DWORD _DW_GetSysColor(int nIndex)
890 { 890 {
891 DWORD retval = GetSysColor(nIndex); 891 DWORD retval = GetSysColor(nIndex);
892 #ifdef AEROGLASS 892 #ifdef AEROGLASS
893 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED) 893 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED)
894 { 894 {
895 const COLORREF darkBkColor = 0x383838; 895 const COLORREF darkBkColor = 0x383838;
896 const COLORREF darkTextColor = 0xFFFFFF; 896 const COLORREF darkTextColor = 0xFFFFFF;
897 897
898 switch(nIndex) 898 switch(nIndex)
899 { 899 {
900 case COLOR_3DFACE: 900 case COLOR_3DFACE:
901 case COLOR_WINDOW: 901 case COLOR_WINDOW:
902 retval = darkBkColor; 902 retval = darkBkColor;
913 HBRUSH _DW_GetSysColorBrush(int nIndex) 913 HBRUSH _DW_GetSysColorBrush(int nIndex)
914 { 914 {
915 HBRUSH retval = GetSysColorBrush(nIndex); 915 HBRUSH retval = GetSysColorBrush(nIndex);
916 #ifdef AEROGLASS 916 #ifdef AEROGLASS
917 static HBRUSH darkBkColorBrush = 0; 917 static HBRUSH darkBkColorBrush = 0;
918 918
919 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED) 919 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED)
920 { 920 {
921 if(!darkBkColorBrush) 921 if(!darkBkColorBrush)
922 darkBkColorBrush = CreateSolidBrush(0x383838); 922 darkBkColorBrush = CreateSolidBrush(0x383838);
923 923
998 { 998 {
999 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); 999 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
1000 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); 1000 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
1001 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0); 1001 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0);
1002 TCHAR tmpbuf[100] = {0}; 1002 TCHAR tmpbuf[100] = {0};
1003 1003
1004 TOOLINFO ti = { 0 }; 1004 TOOLINFO ti = { 0 };
1005 1005
1006 ti.cbSize = sizeof(TOOLINFO); 1006 ti.cbSize = sizeof(TOOLINFO);
1007 ti.hwnd = handle; 1007 ti.hwnd = handle;
1008 ti.hinst = DWInstance; 1008 ti.hinst = DWInstance;
1009 1009
1010 SendMessage(hwndTooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); 1010 SendMessage(hwndTooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
1011 1011
1012 GetClassName(handle, tmpbuf, 99); 1012 GetClassName(handle, tmpbuf, 99);
1013 1013
1014 /* Don't try to free memory from an embedded IE or Edge/Chromium window */ 1014 /* Don't try to free memory from an embedded IE or Edge/Chromium window */
1015 if(_tcsncmp(tmpbuf, TEXT("Internet Explorer_Server"), 25) == 0 || 1015 if(_tcsncmp(tmpbuf, TEXT("Internet Explorer_Server"), 25) == 0 ||
1016 _tcsncmp(tmpbuf, TEXT("Chrome_WidgetWin_"), 17) == 0) 1016 _tcsncmp(tmpbuf, TEXT("Chrome_WidgetWin_"), 17) == 0)
1037 if(oldbitmap) 1037 if(oldbitmap)
1038 DeleteObject(oldbitmap); 1038 DeleteObject(oldbitmap);
1039 if(oldicon) 1039 if(oldicon)
1040 DestroyIcon(oldicon); 1040 DestroyIcon(oldicon);
1041 } 1041 }
1042 #ifdef TOOLBAR 1042 #ifdef TOOLBAR
1043 /* Bitmap Buttons */ 1043 /* Bitmap Buttons */
1044 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0) 1044 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
1045 { 1045 {
1046 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0); 1046 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0);
1047 HIMAGELIST dimlist = (HIMAGELIST)SendMessage(handle, TB_GETDISABLEDIMAGELIST, 0, 0); 1047 HIMAGELIST dimlist = (HIMAGELIST)SendMessage(handle, TB_GETDISABLEDIMAGELIST, 0, 0);
1048 1048
1049 SendMessage(handle, TB_SETIMAGELIST, 0, 0); 1049 SendMessage(handle, TB_SETIMAGELIST, 0, 0);
1050 SendMessage(handle, TB_SETDISABLEDIMAGELIST, 0, 0); 1050 SendMessage(handle, TB_SETDISABLEDIMAGELIST, 0, 0);
1051 1051
1052 if(imlist) 1052 if(imlist)
1053 ImageList_Destroy(imlist); 1053 ImageList_Destroy(imlist);
1054 if(dimlist) 1054 if(dimlist)
1055 ImageList_Destroy(dimlist); 1055 ImageList_Destroy(dimlist);
1056 } 1056 }
1057 #endif 1057 #endif
1058 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==0) 1058 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==0)
1059 { 1059 {
1060 Box *box = (Box *)thiscinfo; 1060 Box *box = (Box *)thiscinfo;
1061 1061
1062 if(box && box->count && box->items) 1062 if(box && box->count && box->items)
1137 1137
1138 mii.cbSize = sizeof(MENUITEMINFO); 1138 mii.cbSize = sizeof(MENUITEMINFO);
1139 mii.fMask = MIIM_SUBMENU | MIIM_ID; 1139 mii.fMask = MIIM_SUBMENU | MIIM_ID;
1140 1140
1141 if ( GetMenuItemInfo( menu, i, TRUE, &mii ) ) 1141 if ( GetMenuItemInfo( menu, i, TRUE, &mii ) )
1142 { 1142 {
1143 /* Free the data associated with the ID */ 1143 /* Free the data associated with the ID */
1144 if(mii.wID >= 30000) 1144 if(mii.wID >= 30000)
1145 { 1145 {
1146 char buffer[31] = {0}; 1146 char buffer[31] = {0};
1147 1147
1148 _snprintf(buffer, 30, "_dw_id%u", mii.wID); 1148 _snprintf(buffer, 30, "_dw_id%u", mii.wID);
1149 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL ); 1149 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
1150 _snprintf(buffer, 30, "_dw_checkable%u", mii.wID); 1150 _snprintf(buffer, 30, "_dw_checkable%u", mii.wID);
1151 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL ); 1151 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
1152 _snprintf(buffer, 30, "_dw_ischecked%u", mii.wID); 1152 _snprintf(buffer, 30, "_dw_ischecked%u", mii.wID);
1153 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL ); 1153 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
1154 _snprintf(buffer, 30, "_dw_isdisabled%u", mii.wID); 1154 _snprintf(buffer, 30, "_dw_isdisabled%u", mii.wID);
1155 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL ); 1155 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
1156 } 1156 }
1157 1157
1158 /* Check any submenus */ 1158 /* Check any submenus */
1159 if( mii.hSubMenu ) 1159 if( mii.hSubMenu )
1160 _free_menu_data(mii.hSubMenu); 1160 _free_menu_data(mii.hSubMenu);
1161 } 1161 }
1162 } 1162 }
1191 /* These are the window classes which can 1191 /* These are the window classes which can
1192 * obtain input focus. 1192 * obtain input focus.
1193 */ 1193 */
1194 if(_tcsnicmp(tmpbuf, EDITCLASSNAME, _tcslen(EDITCLASSNAME)+1)==0 || /* Entryfield */ 1194 if(_tcsnicmp(tmpbuf, EDITCLASSNAME, _tcslen(EDITCLASSNAME)+1)==0 || /* Entryfield */
1195 _tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0 || /* Button */ 1195 _tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0 || /* Button */
1196 #ifdef TOOLBAR 1196 #ifdef TOOLBAR
1197 _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0 || /* Toolbar */ 1197 _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0 || /* Toolbar */
1198 #endif 1198 #endif
1199 _tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0 || /* Combobox */ 1199 _tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0 || /* Combobox */
1200 _tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1)==0 || /* List box */ 1200 _tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1)==0 || /* List box */
1201 _tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0 || /* Spinbutton */ 1201 _tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0 || /* Spinbutton */
1202 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1)==0 || /* Slider */ 1202 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1)==0 || /* Slider */
1203 _tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0 || /* Container */ 1203 _tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0 || /* Container */
1305 return 1; 1305 return 1;
1306 } 1306 }
1307 else 1307 else
1308 { 1308 {
1309 int type = _validate_focus(box->items[z].hwnd); 1309 int type = _validate_focus(box->items[z].hwnd);
1310 1310
1311 /* Special case notebook, can focus and contains items */ 1311 /* Special case notebook, can focus and contains items */
1312 if(type == 2 && direction == _DW_DIRECTION_FORWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem)) 1312 if(type == 2 && direction == _DW_DIRECTION_FORWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
1313 return 1; 1313 return 1;
1314 if(box->items[z].hwnd == handle) 1314 if(box->items[z].hwnd == handle)
1315 { 1315 {
1316 if(lasthwnd == handle && firsthwnd) 1316 if(lasthwnd == handle && firsthwnd)
1317 SetFocus(firsthwnd); 1317 SetFocus(firsthwnd);
1339 return 1; 1339 return 1;
1340 } 1340 }
1341 } 1341 }
1342 1342
1343 lasthwnd = _normalize_handle(box->items[z].hwnd); 1343 lasthwnd = _normalize_handle(box->items[z].hwnd);
1344 1344
1345 if(!firsthwnd) 1345 if(!firsthwnd)
1346 firsthwnd = lasthwnd; 1346 firsthwnd = lasthwnd;
1347 } 1347 }
1348 else 1348 else
1349 { 1349 {
1384 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, direction, defaultitem)) 1384 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
1385 return 1; 1385 return 1;
1386 } 1386 }
1387 } 1387 }
1388 /* Special case notebook, can focus and contains items */ 1388 /* Special case notebook, can focus and contains items */
1389 if(type == 2 && direction == _DW_DIRECTION_BACKWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem)) 1389 if(type == 2 && direction == _DW_DIRECTION_BACKWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
1390 return 1; 1390 return 1;
1391 } 1391 }
1392 } 1392 }
1393 return 0; 1393 return 0;
1394 } 1394 }
1423 { 1423 {
1424 HWND box, lastbox = GetParent(handle); 1424 HWND box, lastbox = GetParent(handle);
1425 1425
1426 if(!lastbox) 1426 if(!lastbox)
1427 lastbox = handle; 1427 lastbox = handle;
1428 1428
1429 /* Find the toplevel window */ 1429 /* Find the toplevel window */
1430 while((box = GetParent(lastbox))) 1430 while((box = GetParent(lastbox)))
1431 { 1431 {
1432 /* If it hasn't been packed yet.. */ 1432 /* If it hasn't been packed yet.. */
1433 if(box == DW_HWND_OBJECT) 1433 if(box == DW_HWND_OBJECT)
1435 lastbox = box; 1435 lastbox = box;
1436 } 1436 }
1437 if(lastbox) 1437 if(lastbox)
1438 { 1438 {
1439 TCHAR tmpbuf[100] = {0}; 1439 TCHAR tmpbuf[100] = {0};
1440 1440
1441 GetClassName(lastbox, tmpbuf, 99); 1441 GetClassName(lastbox, tmpbuf, 99);
1442 1442
1443 if(_tcsncmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0) 1443 if(_tcsncmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0)
1444 return lastbox; 1444 return lastbox;
1445 } 1445 }
1446 return 0; 1446 return 0;
1447 } 1447 }
1480 * These will be used to find the widest or 1480 * These will be used to find the widest or
1481 * tallest items in a box. 1481 * tallest items in a box.
1482 */ 1482 */
1483 int uymax = 0, uxmax = 0; 1483 int uymax = 0, uxmax = 0;
1484 int upymax = 0, upxmax = 0; 1484 int upymax = 0, upxmax = 0;
1485 1485
1486 /* Reset the box sizes */ 1486 /* Reset the box sizes */
1487 thisbox->minwidth = thisbox->minheight = thisbox->usedpadx = thisbox->usedpady = thisbox->pad * 2; 1487 thisbox->minwidth = thisbox->minheight = thisbox->usedpadx = thisbox->usedpady = thisbox->pad * 2;
1488 1488
1489 if(thisbox->grouphwnd) 1489 if(thisbox->grouphwnd)
1490 { 1490 {
1506 /* If the string height is less than 9... 1506 /* If the string height is less than 9...
1507 * set it to 9 anyway since that is the minimum. 1507 * set it to 9 anyway since that is the minimum.
1508 */ 1508 */
1509 if(thisbox->grouppady < 9) 1509 if(thisbox->grouppady < 9)
1510 thisbox->grouppady = 9; 1510 thisbox->grouppady = 9;
1511 1511
1512 if(thisbox->grouppady) 1512 if(thisbox->grouppady)
1513 thisbox->grouppady += 3; 1513 thisbox->grouppady += 3;
1514 else 1514 else
1515 thisbox->grouppady = 6; 1515 thisbox->grouppady = 6;
1516 1516
1525 1525
1526 /* Count up all the space for all items in the box */ 1526 /* Count up all the space for all items in the box */
1527 for(z=0;z<thisbox->count;z++) 1527 for(z=0;z<thisbox->count;z++)
1528 { 1528 {
1529 int itempad, itemwidth, itemheight; 1529 int itempad, itemwidth, itemheight;
1530 1530
1531 if(thisbox->items[z].type == TYPEBOX) 1531 if(thisbox->items[z].type == TYPEBOX)
1532 { 1532 {
1533 Box *tmp = (Box *)GetWindowLongPtr(thisbox->items[z].hwnd, GWLP_USERDATA); 1533 Box *tmp = (Box *)GetWindowLongPtr(thisbox->items[z].hwnd, GWLP_USERDATA);
1534 1534
1535 if(tmp) 1535 if(tmp)
1536 { 1536 {
1537 /* On the first pass calculate the box contents */ 1537 /* On the first pass calculate the box contents */
1538 if(pass == 1) 1538 if(pass == 1)
1539 { 1539 {
1540 (*depth)++; 1540 (*depth)++;
1541 1541
1542 /* Save the newly calculated values on the box */ 1542 /* Save the newly calculated values on the box */
1543 _resize_box(tmp, depth, x, y, pass); 1543 _resize_box(tmp, depth, x, y, pass);
1544 1544
1545 /* Duplicate the values in the item list for use below */ 1545 /* Duplicate the values in the item list for use below */
1546 thisbox->items[z].width = tmp->minwidth; 1546 thisbox->items[z].width = tmp->minwidth;
1547 thisbox->items[z].height = tmp->minheight; 1547 thisbox->items[z].height = tmp->minheight;
1548 1548
1549 /* If the box has no contents but is expandable... default the size to 1 */ 1549 /* If the box has no contents but is expandable... default the size to 1 */
1550 if(!thisbox->items[z].width && thisbox->items[z].hsize) 1550 if(!thisbox->items[z].width && thisbox->items[z].hsize)
1551 thisbox->items[z].width = 1; 1551 thisbox->items[z].width = 1;
1552 if(!thisbox->items[z].height && thisbox->items[z].vsize) 1552 if(!thisbox->items[z].height && thisbox->items[z].vsize)
1553 thisbox->items[z].height = 1; 1553 thisbox->items[z].height = 1;
1554 1554
1555 (*depth)--; 1555 (*depth)--;
1556 } 1556 }
1557 } 1557 }
1558 } 1558 }
1559 1559
1560 /* Precalculate these values, since they will 1560 /* Precalculate these values, since they will
1561 * be used used repeatedly in the next section. 1561 * be used used repeatedly in the next section.
1562 */ 1562 */
1563 itempad = thisbox->items[z].pad * 2; 1563 itempad = thisbox->items[z].pad * 2;
1564 itemwidth = thisbox->items[z].width + itempad; 1564 itemwidth = thisbox->items[z].width + itempad;
1565 itemheight = thisbox->items[z].height + itempad; 1565 itemheight = thisbox->items[z].height + itempad;
1566 1566
1567 /* Calculate the totals and maximums */ 1567 /* Calculate the totals and maximums */
1568 if(thisbox->type == DW_VERT) 1568 if(thisbox->type == DW_VERT)
1569 { 1569 {
1570 if(itemwidth > uxmax) 1570 if(itemwidth > uxmax)
1571 uxmax = itemwidth; 1571 uxmax = itemwidth;
1572 1572
1573 if(thisbox->items[z].hsize != SIZEEXPAND) 1573 if(thisbox->items[z].hsize != SIZEEXPAND)
1574 { 1574 {
1575 if(itemwidth > upxmax) 1575 if(itemwidth > upxmax)
1576 upxmax = itemwidth; 1576 upxmax = itemwidth;
1577 } 1577 }
1635 if(thisbox->items[z].hsize == SIZEEXPAND) 1635 if(thisbox->items[z].hsize == SIZEEXPAND)
1636 { 1636 {
1637 if(thisbox->type == DW_HORZ) 1637 if(thisbox->type == DW_HORZ)
1638 { 1638 {
1639 int expandablex = thisbox->minwidth - thisbox->usedpadx; 1639 int expandablex = thisbox->minwidth - thisbox->usedpadx;
1640 1640
1641 if(expandablex) 1641 if(expandablex)
1642 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx)); 1642 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx));
1643 } 1643 }
1644 else 1644 else
1645 width = x - (itempad + thispad + thisbox->grouppadx); 1645 width = x - (itempad + thispad + thisbox->grouppadx);
1647 if(thisbox->items[z].vsize == SIZEEXPAND) 1647 if(thisbox->items[z].vsize == SIZEEXPAND)
1648 { 1648 {
1649 if(thisbox->type == DW_VERT) 1649 if(thisbox->type == DW_VERT)
1650 { 1650 {
1651 int expandabley = thisbox->minheight - thisbox->usedpady; 1651 int expandabley = thisbox->minheight - thisbox->usedpady;
1652 1652
1653 if(expandabley) 1653 if(expandabley)
1654 height = (int)(((float)height / (float)expandabley) * (float)(y - thisbox->usedpady)); 1654 height = (int)(((float)height / (float)expandabley) * (float)(y - thisbox->usedpady));
1655 } 1655 }
1656 else 1656 else
1657 height = y - (itempad + thispad + thisbox->grouppady); 1657 height = y - (itempad + thispad + thisbox->grouppady);
1658 } 1658 }
1659 1659
1660 /* If the calculated size is valid... */ 1660 /* If the calculated size is valid... */
1661 if(width > 0 && height > 0) 1661 if(width > 0 && height > 0)
1662 { 1662 {
1663 int pad = thisbox->items[z].pad; 1663 int pad = thisbox->items[z].pad;
1664 HWND handle = thisbox->items[z].hwnd; 1664 HWND handle = thisbox->items[z].hwnd;
1665 TCHAR tmpbuf[100] = {0}; 1665 TCHAR tmpbuf[100] = {0};
1666 1666
1667 GetClassName(handle, tmpbuf, 99); 1667 GetClassName(handle, tmpbuf, 99);
1668 1668
1669 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) 1669 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
1670 { 1670 {
1671 /* Handle special case Combobox */ 1671 /* Handle special case Combobox */
1843 dw_window_redraw(array[pageid]->hwnd); 1843 dw_window_redraw(array[pageid]->hwnd);
1844 } 1844 }
1845 } 1845 }
1846 /* So does the List View... handle delayed cursoring */ 1846 /* So does the List View... handle delayed cursoring */
1847 if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)==0 && width > 10 && height > 10) 1847 if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)==0 && width > 10 && height > 10)
1848 { 1848 {
1849 int index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_cursor")); 1849 int index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_cursor"));
1850 1850
1851 if(index > 0) 1851 if(index > 0)
1852 ListView_EnsureVisible(handle, index, TRUE); 1852 ListView_EnsureVisible(handle, index, TRUE);
1853 } 1853 }
1854 1854
1855 /* Advance the current position in the box */ 1855 /* Advance the current position in the box */
1867 if(x != 0 && y != 0) 1867 if(x != 0 && y != 0)
1868 { 1868 {
1869 if(thisbox) 1869 if(thisbox)
1870 { 1870 {
1871 int depth = 0; 1871 int depth = 0;
1872 1872
1873 /* Calculate space requirements */ 1873 /* Calculate space requirements */
1874 _resize_box(thisbox, &depth, x, y, 1); 1874 _resize_box(thisbox, &depth, x, y, 1);
1875 1875
1876 /* Finally place all the boxes and controls */ 1876 /* Finally place all the boxes and controls */
1877 _resize_box(thisbox, &depth, x, y, 2); 1877 _resize_box(thisbox, &depth, x, y, 2);
1878 } 1878 }
1879 } 1879 }
1880 } 1880 }
2135 2135
2136 if(hWnd == tmp->window || _toplevel_window(hWnd) == tmp->window) 2136 if(hWnd == tmp->window || _toplevel_window(hWnd) == tmp->window)
2137 { 2137 {
2138 int special = 0; 2138 int special = 0;
2139 char *utf8 = NULL, ch[2] = {0}; 2139 char *utf8 = NULL, ch[2] = {0};
2140 #ifdef UNICODE 2140 #ifdef UNICODE
2141 WCHAR uc[2] = { 0 }; 2141 WCHAR uc[2] = { 0 };
2142 2142
2143 uc[0] = (WCHAR)mp1; 2143 uc[0] = (WCHAR)mp1;
2144 utf8 = WideToUTF8(&uc[0]); 2144 utf8 = WideToUTF8(&uc[0]);
2145 #endif 2145 #endif
2146 2146
2147 if(GetAsyncKeyState(VK_SHIFT) & 0x8000) 2147 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
2148 special |= KC_SHIFT; 2148 special |= KC_SHIFT;
2149 if(GetAsyncKeyState(VK_CONTROL) & 0x8000) 2149 if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
2150 special |= KC_CTRL; 2150 special |= KC_CTRL;
2151 if(mp2 & (1 << 29)) 2151 if(mp2 & (1 << 29))
2352 { 2352 {
2353 result = listboxselectfunc(tmp->window, dw_listbox_selected(tmp->window), tmp->data); 2353 result = listboxselectfunc(tmp->window, dw_listbox_selected(tmp->window), tmp->data);
2354 tmp = NULL; 2354 tmp = NULL;
2355 } 2355 }
2356 } 2356 }
2357 #ifdef TOOLBAR 2357 #ifdef TOOLBAR
2358 else if (message == BN_CLICKED && tmp->message == WM_COMMAND && tmp->window == (HWND)mp2) 2358 else if (message == BN_CLICKED && tmp->message == WM_COMMAND && tmp->window == (HWND)mp2)
2359 { 2359 {
2360 TCHAR tmpbuf[100] = {0}; 2360 TCHAR tmpbuf[100] = {0};
2361 2361
2362 GetClassName((HWND)mp2, tmpbuf, 99); 2362 GetClassName((HWND)mp2, tmpbuf, 99);
2366 { 2366 {
2367 result = clickfunc(tmp->window, tmp->data); 2367 result = clickfunc(tmp->window, tmp->data);
2368 tmp = NULL; 2368 tmp = NULL;
2369 } 2369 }
2370 } 2370 }
2371 #endif 2371 #endif
2372 else if (tmp->id && passthru == tmp->id) 2372 else if (tmp->id && passthru == tmp->id)
2373 { 2373 {
2374 HMENU hwndmenu = GetMenu(hWnd), menuowner = _menu_owner((HMENU)tmp->window); 2374 HMENU hwndmenu = GetMenu(hWnd), menuowner = _menu_owner((HMENU)tmp->window);
2375 2375
2376 if (menuowner == hwndmenu || !menuowner) 2376 if (menuowner == hwndmenu || !menuowner)
2466 } 2466 }
2467 2467
2468 /* Now that any handlers are done... do normal processing */ 2468 /* Now that any handlers are done... do normal processing */
2469 switch( msg ) 2469 switch( msg )
2470 { 2470 {
2471 #ifdef AEROGLASS 2471 #ifdef AEROGLASS
2472 case WM_DWMCOMPOSITIONCHANGED: 2472 case WM_DWMCOMPOSITIONCHANGED:
2473 { 2473 {
2474 LONG_PTR styleex = GetWindowLongPtr(hWnd, GWL_EXSTYLE); 2474 LONG_PTR styleex = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
2475 2475
2476 if(_DwmIsCompositionEnabled) 2476 if(_DwmIsCompositionEnabled)
2477 _DwmIsCompositionEnabled(&_dw_composition); 2477 _DwmIsCompositionEnabled(&_dw_composition);
2478 2478
2479 /* If we are no longer compositing... disable layered windows */ 2479 /* If we are no longer compositing... disable layered windows */
2480 if(!_dw_composition && (styleex & WS_EX_LAYERED)) 2480 if(!_dw_composition && (styleex & WS_EX_LAYERED))
2481 { 2481 {
2482 MARGINS mar = {0}; 2482 MARGINS mar = {0};
2483 2483
2484 SetWindowLongPtr(hWnd, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED); 2484 SetWindowLongPtr(hWnd, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED);
2485 if(_DwmExtendFrameIntoClientArea) 2485 if(_DwmExtendFrameIntoClientArea)
2486 _DwmExtendFrameIntoClientArea(hWnd, &mar); 2486 _DwmExtendFrameIntoClientArea(hWnd, &mar);
2487 } 2487 }
2488 } 2488 }
2499 } 2499 }
2500 } 2500 }
2501 break; 2501 break;
2502 #endif 2502 #endif
2503 #ifdef AEROGLASS1 2503 #ifdef AEROGLASS1
2504 case WM_ERASEBKGND: 2504 case WM_ERASEBKGND:
2505 if(_dw_composition && (GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_LAYERED)) 2505 if(_dw_composition && (GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_LAYERED))
2506 { 2506 {
2507 static HBRUSH hbrush = 0; 2507 static HBRUSH hbrush = 0;
2508 RECT rect; 2508 RECT rect;
2509 2509
2510 if(!hbrush) 2510 if(!hbrush)
2511 hbrush = CreateSolidBrush(_dw_transparencykey); 2511 hbrush = CreateSolidBrush(_dw_transparencykey);
2512 2512
2513 GetClientRect(hWnd, &rect); 2513 GetClientRect(hWnd, &rect);
2514 FillRect((HDC)mp1, &rect, hbrush); 2514 FillRect((HDC)mp1, &rect, hbrush);
2515 return TRUE; 2515 return TRUE;
2516 } 2516 }
2517 break; 2517 break;
2618 dw_scrollbar_set_pos(handle, value); 2618 dw_scrollbar_set_pos(handle, value);
2619 } 2619 }
2620 else 2620 else
2621 { 2621 {
2622 TCHAR tmpbuf[100] = {0}; 2622 TCHAR tmpbuf[100] = {0};
2623 2623
2624 GetClassName( hWnd, tmpbuf, 99 ); 2624 GetClassName( hWnd, tmpbuf, 99 );
2625 if ( _tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1 ) == 0 ) 2625 if ( _tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1 ) == 0 )
2626 { 2626 {
2627 _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); 2627 _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
2628 } 2628 }
2705 { 2705 {
2706 SetClassLongPtr(hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)_DW_GetSysColorBrush(COLOR_3DFACE)); 2706 SetClassLongPtr(hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)_DW_GetSysColorBrush(COLOR_3DFACE));
2707 InvalidateRect(hWnd, NULL, TRUE); 2707 InvalidateRect(hWnd, NULL, TRUE);
2708 } 2708 }
2709 break; 2709 break;
2710 case WM_ERASEBKGND: 2710 case WM_ERASEBKGND:
2711 if(_dw_composition && (GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED)) 2711 if(_dw_composition && (GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED))
2712 { 2712 {
2713 static HBRUSH hbrush = 0; 2713 static HBRUSH hbrush = 0;
2714 RECT rect; 2714 RECT rect;
2715 2715
2716 if(!hbrush) 2716 if(!hbrush)
2717 hbrush = CreateSolidBrush(_dw_transparencykey); 2717 hbrush = CreateSolidBrush(_dw_transparencykey);
2718 2718
2719 GetClientRect(hWnd, &rect); 2719 GetClientRect(hWnd, &rect);
2720 FillRect((HDC)mp1, &rect, hbrush); 2720 FillRect((HDC)mp1, &rect, hbrush);
2721 return TRUE; 2721 return TRUE;
2722 } 2722 }
2723 break; 2723 break;
2724 #endif 2724 #endif
2725 case WM_PAINT: 2725 case WM_PAINT:
2726 { 2726 {
2727 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); 2727 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
2728 2728
2729 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) 2729 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
2946 2946
2947 /* These are the window classes which can 2947 /* These are the window classes which can
2948 * obtain input focus. 2948 * obtain input focus.
2949 */ 2949 */
2950 if (_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0 2950 if (_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0
2951 #ifdef TOOLBAR 2951 #ifdef TOOLBAR
2952 || _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0 2952 || _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0
2953 #endif 2953 #endif
2954 ) 2954 )
2955 { 2955 {
2956 /* Generate click on default item */ 2956 /* Generate click on default item */
3128 case WM_CTLCOLORMSGBOX: 3128 case WM_CTLCOLORMSGBOX:
3129 case WM_CTLCOLORSCROLLBAR: 3129 case WM_CTLCOLORSCROLLBAR:
3130 case WM_CTLCOLORDLG: 3130 case WM_CTLCOLORDLG:
3131 { 3131 {
3132 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr((HWND)mp2, GWLP_USERDATA); 3132 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr((HWND)mp2, GWLP_USERDATA);
3133 3133
3134 if(msg == WM_CTLCOLORBTN) 3134 if(msg == WM_CTLCOLORBTN)
3135 { 3135 {
3136 /* Groupbox color info is on the frame window it is attached to */ 3136 /* Groupbox color info is on the frame window it is attached to */
3137 if(GetWindowLongPtr((HWND)mp2, GWL_STYLE) & BS_GROUPBOX) 3137 if(GetWindowLongPtr((HWND)mp2, GWL_STYLE) & BS_GROUPBOX)
3138 { 3138 {
3139 Box *framebox = (Box *)GetWindowLongPtr(hWnd, GWLP_USERDATA); 3139 Box *framebox = (Box *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
3140 if(framebox) 3140 if(framebox)
3141 thiscinfo = &framebox->cinfo; 3141 thiscinfo = &framebox->cinfo;
3142 } 3142 }
3143 } 3143 }
3144 3144
3145 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) 3145 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
3146 { 3146 {
3147 int thisback = thiscinfo->back; 3147 int thisback = thiscinfo->back;
3148 3148
3149 /* Handle foreground */ 3149 /* Handle foreground */
3150 if(thiscinfo->fore != DW_CLR_DEFAULT) 3150 if(thiscinfo->fore != DW_CLR_DEFAULT)
3151 { 3151 {
3152 int fore = _internal_color(thiscinfo->fore); 3152 int fore = _internal_color(thiscinfo->fore);
3153 3153
3161 #endif 3161 #endif
3162 /* Handle background */ 3162 /* Handle background */
3163 if(thiscinfo->back == DW_RGB_TRANSPARENT) 3163 if(thiscinfo->back == DW_RGB_TRANSPARENT)
3164 { 3164 {
3165 ColorInfo *parentcinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); 3165 ColorInfo *parentcinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
3166 3166
3167 if(parentcinfo && parentcinfo->back != -1) 3167 if(parentcinfo && parentcinfo->back != -1)
3168 thisback = parentcinfo->back; 3168 thisback = parentcinfo->back;
3169 } 3169 }
3170 if(thisback == DW_CLR_DEFAULT) 3170 if(thisback == DW_CLR_DEFAULT)
3171 { 3171 {
3177 return (LRESULT)(intptr_t)hbr; 3177 return (LRESULT)(intptr_t)hbr;
3178 } 3178 }
3179 else if(thisback != -1 && thisback != DW_RGB_TRANSPARENT) 3179 else if(thisback != -1 && thisback != DW_RGB_TRANSPARENT)
3180 { 3180 {
3181 int back = _internal_color(thisback); 3181 int back = _internal_color(thisback);
3182 3182
3183 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(back), 3183 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(back),
3184 DW_GREEN_VALUE(back), 3184 DW_GREEN_VALUE(back),
3185 DW_BLUE_VALUE(back))); 3185 DW_BLUE_VALUE(back)));
3186 if(thiscinfo->hbrush) 3186 if(thiscinfo->hbrush)
3187 DeleteObject(thiscinfo->hbrush); 3187 DeleteObject(thiscinfo->hbrush);
3198 { 3198 {
3199 case WM_CTLCOLORSTATIC: 3199 case WM_CTLCOLORSTATIC:
3200 case WM_CTLCOLORBTN: 3200 case WM_CTLCOLORBTN:
3201 case WM_CTLCOLORDLG: 3201 case WM_CTLCOLORDLG:
3202 { 3202 {
3203 3203
3204 if((_dw_composition && GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED) && 3204 if((_dw_composition && GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED) &&
3205 (!thiscinfo || (thiscinfo && (thiscinfo->back == -1 || thiscinfo->back == DW_RGB_TRANSPARENT)))) 3205 (!thiscinfo || (thiscinfo && (thiscinfo->back == -1 || thiscinfo->back == DW_RGB_TRANSPARENT))))
3206 { 3206 {
3207 if(!(msg == WM_CTLCOLORSTATIC && SendMessage((HWND)mp2, STM_GETIMAGE, IMAGE_BITMAP, 0))) 3207 if(!(msg == WM_CTLCOLORSTATIC && SendMessage((HWND)mp2, STM_GETIMAGE, IMAGE_BITMAP, 0)))
3208 { 3208 {
3209 SetBkColor((HDC)mp1, _dw_transparencykey); 3209 SetBkColor((HDC)mp1, _dw_transparencykey);
3229 { 3229 {
3230 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED) 3230 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED)
3231 { 3231 {
3232 ColorInfo *parentcinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); 3232 ColorInfo *parentcinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
3233 int thisback = thiscinfo ? thiscinfo->back : -1; 3233 int thisback = thiscinfo ? thiscinfo->back : -1;
3234 3234
3235 if(thisback == DW_RGB_TRANSPARENT && parentcinfo) 3235 if(thisback == DW_RGB_TRANSPARENT && parentcinfo)
3236 thisback = parentcinfo->back; 3236 thisback = parentcinfo->back;
3237 3237
3238 if(!thiscinfo || (thiscinfo && (thiscinfo->fore == DW_CLR_DEFAULT || thiscinfo->fore == -1))) 3238 if(!thiscinfo || (thiscinfo && (thiscinfo->fore == DW_CLR_DEFAULT || thiscinfo->fore == -1)))
3239 SetTextColor((HDC)mp1, _DW_GetSysColor(COLOR_WINDOWTEXT)); 3239 SetTextColor((HDC)mp1, _DW_GetSysColor(COLOR_WINDOWTEXT));
3297 { 3297 {
3298 RECT rectUpd, rectDestin, rectThis, *rect = &rectThis; 3298 RECT rectUpd, rectDestin, rectThis, *rect = &rectThis;
3299 int iItems, iTop, i; 3299 int iItems, iTop, i;
3300 COLORREF c, odd, even; 3300 COLORREF c, odd, even;
3301 unsigned long temp = _internal_color(continfo->odd); 3301 unsigned long temp = _internal_color(continfo->odd);
3302 3302
3303 /* Create the colors based on the current theme */ 3303 /* Create the colors based on the current theme */
3304 if(continfo->odd == DW_CLR_DEFAULT) 3304 if(continfo->odd == DW_CLR_DEFAULT)
3305 { 3305 {
3306 #ifdef AEROGLASS 3306 #ifdef AEROGLASS
3307 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED) 3307 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED)
3308 odd = RGB(100,100,100); 3308 odd = RGB(100,100,100);
3309 else 3309 else
3310 #endif 3310 #endif
3311 odd = RGB(230, 230, 230); 3311 odd = RGB(230, 230, 230);
3312 } 3312 }
3313 else 3313 else
3314 odd = RGB(DW_RED_VALUE(temp), DW_GREEN_VALUE(temp), DW_BLUE_VALUE(temp)); 3314 odd = RGB(DW_RED_VALUE(temp), DW_GREEN_VALUE(temp), DW_BLUE_VALUE(temp));
3315 temp = _internal_color(continfo->even); 3315 temp = _internal_color(continfo->even);
3316 if(continfo->even == DW_CLR_DEFAULT) 3316 if(continfo->even == DW_CLR_DEFAULT)
3317 even = DW_RGB_TRANSPARENT; 3317 even = DW_RGB_TRANSPARENT;
3318 else 3318 else
3327 /* number of displayed rows */ 3327 /* number of displayed rows */
3328 iItems = ListView_GetCountPerPage(hWnd); 3328 iItems = ListView_GetCountPerPage(hWnd);
3329 /* first visible row */ 3329 /* first visible row */
3330 iTop = ListView_GetTopIndex(hWnd); 3330 iTop = ListView_GetTopIndex(hWnd);
3331 3331
3332 for(i=iTop; i<=(iTop+iItems+1); i++) 3332 for(i=iTop; i<=(iTop+iItems+1); i++)
3333 { 3333 {
3334 /* if row rectangle intersects update rectangle then it requires re-drawing */ 3334 /* if row rectangle intersects update rectangle then it requires re-drawing */
3335 if(ListView_GetItemRect(hWnd, i, rect, LVIR_BOUNDS) && IntersectRect(&rectDestin, &rectUpd, rect)) 3335 if(ListView_GetItemRect(hWnd, i, rect, LVIR_BOUNDS) && IntersectRect(&rectDestin, &rectUpd, rect))
3336 { 3336 {
3337 /* change text background colour accordingly */ 3337 /* change text background colour accordingly */
3338 c = (i % 2) ? odd : even; 3338 c = (i % 2) ? odd : even;
3339 3339
3340 if(c != DW_RGB_TRANSPARENT) 3340 if(c != DW_RGB_TRANSPARENT)
3344 InvalidateRect(hWnd, &rectDestin, FALSE); 3344 InvalidateRect(hWnd, &rectDestin, FALSE);
3345 /* ...force default processing */ 3345 /* ...force default processing */
3346 CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, 0, 0); 3346 CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, 0, 0);
3347 } 3347 }
3348 } 3348 }
3349 } 3349 }
3350 } 3350 }
3351 break; 3351 break;
3352 case WM_LBUTTONDBLCLK: 3352 case WM_LBUTTONDBLCLK:
3353 case WM_CHAR: 3353 case WM_CHAR:
3354 { 3354 {
3492 if(msg == WM_THEMECHANGED) 3492 if(msg == WM_THEMECHANGED)
3493 { 3493 {
3494 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_SUPPORTED) 3494 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_SUPPORTED)
3495 { 3495 {
3496 ContainerInfo *continfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); 3496 ContainerInfo *continfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
3497 3497
3498 if(!continfo || continfo->cinfo.back == -1 || continfo->cinfo.back == DW_CLR_DEFAULT) 3498 if(!continfo || continfo->cinfo.back == -1 || continfo->cinfo.back == DW_CLR_DEFAULT)
3499 TreeView_SetBkColor(hWnd, _DW_GetSysColor(COLOR_WINDOW)); 3499 TreeView_SetBkColor(hWnd, _DW_GetSysColor(COLOR_WINDOW));
3500 if(!continfo || continfo->cinfo.fore == -1 || continfo->cinfo.fore == DW_CLR_DEFAULT) 3500 if(!continfo || continfo->cinfo.fore == -1 || continfo->cinfo.fore == DW_CLR_DEFAULT)
3501 TreeView_SetTextColor(hWnd, _DW_GetSysColor(COLOR_WINDOWTEXT)); 3501 TreeView_SetTextColor(hWnd, _DW_GetSysColor(COLOR_WINDOWTEXT));
3502 } 3502 }
3794 GetWindowText(hwnd, tempbuf, 1024); 3794 GetWindowText(hwnd, tempbuf, 1024);
3795 3795
3796 hdcPaint = BeginPaint(hwnd, &ps); 3796 hdcPaint = BeginPaint(hwnd, &ps);
3797 if(hfont) 3797 if(hfont)
3798 oldfont = (HFONT)SelectObject(hdcPaint, hfont); 3798 oldfont = (HFONT)SelectObject(hdcPaint, hfont);
3799 3799
3800 SetRect(&rc, 0, 0, cx, cy); 3800 SetRect(&rc, 0, 0, cx, cy);
3801 3801
3802 /* If we are in full dark mode, or we have custom colors selected... 3802 /* If we are in full dark mode, or we have custom colors selected...
3803 * we will draw the status window ourselves... otherwise DrawStatusText() 3803 * we will draw the status window ourselves... otherwise DrawStatusText()
3804 */ 3804 */
3805 if( 3805 if(
3806 #ifdef AEROGLASS 3806 #ifdef AEROGLASS
3851 if (!cinfo) 3851 if (!cinfo)
3852 return DefWindowProc(hwnd, msg, mp1, mp2); 3852 return DefWindowProc(hwnd, msg, mp1, mp2);
3853 3853
3854 /* Need the parent to do the check completely */ 3854 /* Need the parent to do the check completely */
3855 parentcinfo = (ColorInfo *)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA); 3855 parentcinfo = (ColorInfo *)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
3856 3856
3857 /* If we don't require themed drawing */ 3857 /* If we don't require themed drawing */
3858 if(((cinfo->back != -1 && cinfo->back != DW_RGB_TRANSPARENT) || (parentcinfo && parentcinfo->back != -1)) 3858 if(((cinfo->back != -1 && cinfo->back != DW_RGB_TRANSPARENT) || (parentcinfo && parentcinfo->back != -1))
3859 || !_dw_composition || !(GetWindowLongPtr(_toplevel_window(hwnd), GWL_EXSTYLE) & WS_EX_LAYERED)) 3859 || !_dw_composition || !(GetWindowLongPtr(_toplevel_window(hwnd), GWL_EXSTYLE) & WS_EX_LAYERED))
3860 return _colorwndproc(hwnd, msg, mp1, mp2); 3860 return _colorwndproc(hwnd, msg, mp1, mp2);
3861 3861
3862 pOldProc = cinfo->pOldProc; 3862 pOldProc = cinfo->pOldProc;
3863 3863
3864 switch(msg) 3864 switch(msg)
3865 { 3865 {
3866 case WM_PAINT: 3866 case WM_PAINT:
3867 { 3867 {
3868 PAINTSTRUCT ps; 3868 PAINTSTRUCT ps;
3873 /* Figure out how to draw */ 3873 /* Figure out how to draw */
3874 HDC hdcPaint = NULL; 3874 HDC hdcPaint = NULL;
3875 RECT rcClient; 3875 RECT rcClient;
3876 LONG_PTR dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); 3876 LONG_PTR dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
3877 LONG_PTR dwStyleEx = GetWindowLongPtr(hwnd, GWL_EXSTYLE); 3877 LONG_PTR dwStyleEx = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
3878 HTHEME hTheme = _OpenThemeData(NULL, L"ControlPanelStyle"); 3878 HTHEME hTheme = _OpenThemeData(NULL, L"ControlPanelStyle");
3879 3879
3880 GetClientRect(hwnd, &rcClient); 3880 GetClientRect(hwnd, &rcClient);
3881 3881
3882 if(hTheme) 3882 if(hTheme)
3883 { 3883 {
3884 /* Create an in memory image to draw to */ 3884 /* Create an in memory image to draw to */
3885 HPAINTBUFFER hBufferedPaint = _BeginBufferedPaint(hdc, &rcClient, BPBF_TOPDOWNDIB, NULL, &hdcPaint); 3885 HPAINTBUFFER hBufferedPaint = _BeginBufferedPaint(hdc, &rcClient, BPBF_TOPDOWNDIB, NULL, &hdcPaint);
3886 3886
3887 if(hdcPaint) 3887 if(hdcPaint)
3888 { 3888 {
3889 LONG_PTR dwStaticStyle = dwStyle & 0x1F; 3889 LONG_PTR dwStaticStyle = dwStyle & 0x1F;
3890 HFONT hFontOld = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0); 3890 HFONT hFontOld = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
3891 int iLen = GetWindowTextLength(hwnd), fore = _internal_color(cinfo->fore); 3891 int iLen = GetWindowTextLength(hwnd), fore = _internal_color(cinfo->fore);
3892 DTTOPTS DttOpts = { sizeof(DTTOPTS) }; 3892 DTTOPTS DttOpts = { sizeof(DTTOPTS) };
3893 static HBRUSH hbrush = 0; 3893 static HBRUSH hbrush = 0;
3894 3894
3895 /* Make sure we have a transparency brush */ 3895 /* Make sure we have a transparency brush */
3896 if(!hbrush) 3896 if(!hbrush)
3897 hbrush = CreateSolidBrush(_dw_transparencykey); 3897 hbrush = CreateSolidBrush(_dw_transparencykey);
3898 3898
3899 /* Fill the background with the transparency color */ 3899 /* Fill the background with the transparency color */
3900 FillRect(hdcPaint, &rcClient, hbrush); 3900 FillRect(hdcPaint, &rcClient, hbrush);
3901 _BufferedPaintSetAlpha(hBufferedPaint, &ps.rcPaint, 0x00); 3901 _BufferedPaintSetAlpha(hBufferedPaint, &ps.rcPaint, 0x00);
3902 3902
3903 /* Setup how we will draw the text */ 3903 /* Setup how we will draw the text */
3904 DttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR; 3904 DttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR;
3905 DttOpts.crText = cinfo->fore == -1 ? RGB(255, 255, 255) : RGB(DW_RED_VALUE(fore), DW_GREEN_VALUE(fore), DW_BLUE_VALUE(fore)); 3905 DttOpts.crText = cinfo->fore == -1 ? RGB(255, 255, 255) : RGB(DW_RED_VALUE(fore), DW_GREEN_VALUE(fore), DW_BLUE_VALUE(fore));
3906 DttOpts.iGlowSize = 12; 3906 DttOpts.iGlowSize = 12;
3907 3907
3908 SetBkMode(hdcPaint, TRANSPARENT); 3908 SetBkMode(hdcPaint, TRANSPARENT);
3909 3909
3910 if(hFontOld) 3910 if(hFontOld)
3911 hFontOld = (HFONT)SelectObject(hdcPaint, hFontOld); 3911 hFontOld = (HFONT)SelectObject(hdcPaint, hFontOld);
3912 3912
3913 /* Make sure there is text to draw */ 3913 /* Make sure there is text to draw */
3914 if(iLen) 3914 if(iLen)
3915 { 3915 {
3916 LPWSTR szText = (LPWSTR)_alloca(sizeof(WCHAR)*(iLen+5)); 3916 LPWSTR szText = (LPWSTR)_alloca(sizeof(WCHAR)*(iLen+5));
3917 3917
3918 if(szText) 3918 if(szText)
3919 { 3919 {
3920 iLen = GetWindowTextW(hwnd, szText, iLen+5); 3920 iLen = GetWindowTextW(hwnd, szText, iLen+5);
3921 if(iLen) 3921 if(iLen)
3922 { 3922 {
3923 DWORD dwFlags = DT_WORDBREAK; 3923 DWORD dwFlags = DT_WORDBREAK;
3924 3924
3925 switch (dwStaticStyle) 3925 switch (dwStaticStyle)
3926 { 3926 {
3927 case SS_CENTER: 3927 case SS_CENTER:
3928 dwFlags |= DT_CENTER; 3928 dwFlags |= DT_CENTER;
3929 break; 3929 break;
3952 if (dwStyleEx&WS_EX_RIGHT) 3952 if (dwStyleEx&WS_EX_RIGHT)
3953 dwFlags |= DT_RIGHT; 3953 dwFlags |= DT_RIGHT;
3954 3954
3955 if(dwStyle & SS_NOPREFIX) 3955 if(dwStyle & SS_NOPREFIX)
3956 dwFlags |= DT_NOPREFIX; 3956 dwFlags |= DT_NOPREFIX;
3957 3957
3958 /* Draw the text! */ 3958 /* Draw the text! */
3959 _DrawThemeTextEx(hTheme, hdcPaint, 0, 0, 3959 _DrawThemeTextEx(hTheme, hdcPaint, 0, 0,
3960 szText, -1, dwFlags, &rcClient, &DttOpts); 3960 szText, -1, dwFlags, &rcClient, &DttOpts);
3961 } 3961 }
3962 } 3962 }
3963 } 3963 }
3964 3964
3965 /* Cleanup */ 3965 /* Cleanup */
3966 if (hFontOld) 3966 if (hFontOld)
3967 SelectObject(hdcPaint, hFontOld); 3967 SelectObject(hdcPaint, hFontOld);
3968 _EndBufferedPaint(hBufferedPaint, TRUE); 3968 _EndBufferedPaint(hBufferedPaint, TRUE);
3969 } 3969 }
3970 _CloseThemeData(hTheme); 3970 _CloseThemeData(hTheme);
3971 } 3971 }
3972 } 3972 }
3973 3973
3974 EndPaint(hwnd, &ps); 3974 EndPaint(hwnd, &ps);
3975 return TRUE; 3975 return TRUE;
3976 } 3976 }
3977 break; 3977 break;
3978 } 3978 }
3979 3979
3980 if ( !pOldProc ) 3980 if ( !pOldProc )
3981 return DefWindowProc(hwnd, msg, mp1, mp2); 3981 return DefWindowProc(hwnd, msg, mp1, mp2);
3982 return CallWindowProc(pOldProc, hwnd, msg, mp1, mp2); 3982 return CallWindowProc(pOldProc, hwnd, msg, mp1, mp2);
3983 } 3983 }
3984 #endif 3984 #endif
4029 4029
4030 /* Make sure it's the right window, and the right ID */ 4030 /* Make sure it's the right window, and the right ID */
4031 if(tmp->window == hwnd) 4031 if(tmp->window == hwnd)
4032 { 4032 {
4033 int checkbox = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_checkbox")); 4033 int checkbox = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_checkbox"));
4034 4034
4035 if(checkbox) 4035 if(checkbox)
4036 in_checkbox_handler = 1; 4036 in_checkbox_handler = 1;
4037 4037
4038 retval = clickfunc(tmp->window, tmp->data); 4038 retval = clickfunc(tmp->window, tmp->data);
4039 4039
4128 } 4128 }
4129 4129
4130 void _create_tooltip(HWND handle, const char *text) 4130 void _create_tooltip(HWND handle, const char *text)
4131 { 4131 {
4132 TOOLINFO ti = { 0 }; 4132 TOOLINFO ti = { 0 };
4133 4133
4134 ti.cbSize = sizeof(TOOLINFO); 4134 ti.cbSize = sizeof(TOOLINFO);
4135 ti.hwnd = handle; 4135 ti.hwnd = handle;
4136 ti.hinst = DWInstance; 4136 ti.hinst = DWInstance;
4137 4137
4138 SendMessage(hwndTooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); 4138 SendMessage(hwndTooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
4139 if(text) 4139 if(text)
4140 { 4140 {
4141 /* Set up "tool" information. 4141 /* Set up "tool" information.
4142 * In this case, the "tool" is the entire parent window. 4142 * In this case, the "tool" is the entire parent window.
4230 WNDCLASS wc; 4230 WNDCLASS wc;
4231 int z; 4231 int z;
4232 INITCOMMONCONTROLSEX icc; 4232 INITCOMMONCONTROLSEX icc;
4233 char *alttmpdir; 4233 char *alttmpdir;
4234 #ifdef GDIPLUS 4234 #ifdef GDIPLUS
4235 struct GdiplusStartupInput si; 4235 struct GdiplusStartupInput si;
4236 #endif 4236 #endif
4237 4237
4238 /* Setup the private data directory */ 4238 /* Setup the private data directory */
4239 if(argc > 0 && argv[0]) 4239 if(argc > 0 && argv[0])
4240 { 4240 {
4241 char *pos = strrchr(argv[0], '\\'); 4241 char *pos = strrchr(argv[0], '\\');
4242 4242
4243 /* Just to be safe try the unix style */ 4243 /* Just to be safe try the unix style */
4244 if(!pos) 4244 if(!pos)
4245 pos = strrchr(argv[0], '/'); 4245 pos = strrchr(argv[0], '/');
4246 4246
4247 if(pos) 4247 if(pos)
4248 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); 4248 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0]));
4249 } 4249 }
4250 /* If that failed... just get the current directory */ 4250 /* If that failed... just get the current directory */
4251 if(!_dw_exec_dir[0]) 4251 if(!_dw_exec_dir[0])
4252 GetCurrentDirectoryA(MAX_PATH, _dw_exec_dir); 4252 GetCurrentDirectoryA(MAX_PATH, _dw_exec_dir);
4253 4253
4254 /* Initialize our thread local storage */ 4254 /* Initialize our thread local storage */
4255 _foreground = TlsAlloc(); 4255 _foreground = TlsAlloc();
4256 _background = TlsAlloc(); 4256 _background = TlsAlloc();
4257 _hPen = TlsAlloc(); 4257 _hPen = TlsAlloc();
4258 _hBrush = TlsAlloc(); 4258 _hBrush = TlsAlloc();
4259 #ifdef GDIPLUS 4259 #ifdef GDIPLUS
4260 _gpPen = TlsAlloc(); 4260 _gpPen = TlsAlloc();
4261 _gpBrush = TlsAlloc(); 4261 _gpBrush = TlsAlloc();
4262 #endif 4262 #endif
4263 4263
4264 icc.dwSize = sizeof(INITCOMMONCONTROLSEX); 4264 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
4265 icc.dwICC = ICC_WIN95_CLASSES|ICC_DATE_CLASSES; 4265 icc.dwICC = ICC_WIN95_CLASSES|ICC_DATE_CLASSES;
4266 4266
4267 InitCommonControlsEx(&icc); 4267 InitCommonControlsEx(&icc);
4394 if(!DW_HWND_OBJECT) 4394 if(!DW_HWND_OBJECT)
4395 { 4395 {
4396 dw_messagebox("Dynamic Windows", DW_MB_OK|DW_MB_ERROR, "Could not initialize the object window. error code %d", GetLastError()); 4396 dw_messagebox("Dynamic Windows", DW_MB_OK|DW_MB_ERROR, "Could not initialize the object window. error code %d", GetLastError());
4397 exit(1); 4397 exit(1);
4398 } 4398 }
4399 4399
4400 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) 4400 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
4401 /* Register HTML renderer class */ 4401 /* Register HTML renderer class */
4402 memset(&wc, 0, sizeof(WNDCLASS)); 4402 memset(&wc, 0, sizeof(WNDCLASS));
4403 wc.lpszClassName = BrowserClassName; 4403 wc.lpszClassName = BrowserClassName;
4404 wc.style = CS_HREDRAW | CS_VREDRAW; 4404 wc.style = CS_HREDRAW | CS_VREDRAW;
4429 /* Initialize Security for named events and memory */ 4429 /* Initialize Security for named events and memory */
4430 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION); 4430 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION);
4431 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE); 4431 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE);
4432 4432
4433 OleInitialize(NULL); 4433 OleInitialize(NULL);
4434 4434
4435 /* 4435 /*
4436 * Get an alternate temporary directory in case TMP doesn't exist 4436 * Get an alternate temporary directory in case TMP doesn't exist
4437 */ 4437 */
4438 if ( (alttmpdir = getenv( "TEMP" ) ) == NULL ) 4438 if ( (alttmpdir = getenv( "TEMP" ) ) == NULL )
4439 { 4439 {
4450 si.DebugEventCallback = NULL; 4450 si.DebugEventCallback = NULL;
4451 si.SuppressBackgroundThread = FALSE; 4451 si.SuppressBackgroundThread = FALSE;
4452 si.SuppressExternalCodecs = FALSE; 4452 si.SuppressExternalCodecs = FALSE;
4453 GdiplusStartup(&gdiplusToken, &si, NULL); 4453 GdiplusStartup(&gdiplusToken, &si, NULL);
4454 #endif 4454 #endif
4455 4455
4456 /* GDI+ Needs to be initialized before calling _dw_init_thread(); */ 4456 /* GDI+ Needs to be initialized before calling _dw_init_thread(); */
4457 _dw_init_thread(); 4457 _dw_init_thread();
4458 4458
4459 #ifdef RICHEDIT 4459 #ifdef RICHEDIT
4460 /* Attempt to load rich edit library: 4.1, 3/2.0 and 1.0 */ 4460 /* Attempt to load rich edit library: 4.1, 3/2.0 and 1.0 */
4461 if(!(hmsftedit = LoadLibrary(TEXT("msftedit")))) 4461 if(!(hmsftedit = LoadLibrary(TEXT("msftedit"))))
4462 { 4462 {
4463 if(!(hrichedit = LoadLibrary(TEXT("riched20")))) 4463 if(!(hrichedit = LoadLibrary(TEXT("riched20"))))
4464 hrichedit = LoadLibrary(TEXT("riched32")); 4464 hrichedit = LoadLibrary(TEXT("riched32"));
4465 } 4465 }
4466 #endif 4466 #endif
4467 return 0; 4467 return 0;
4468 } 4468 }
4469 4469
4470 static int _dw_main_running = FALSE; 4470 static int _dw_main_running = FALSE;
4471 4471
4480 /* Make sure any queued redraws are handled */ 4480 /* Make sure any queued redraws are handled */
4481 _dw_redraw(0, FALSE); 4481 _dw_redraw(0, FALSE);
4482 4482
4483 /* Set the running flag to TRUE */ 4483 /* Set the running flag to TRUE */
4484 _dw_main_running = TRUE; 4484 _dw_main_running = TRUE;
4485 4485
4486 /* Run the loop until the flag is unset... or error */ 4486 /* Run the loop until the flag is unset... or error */
4487 while(_dw_main_running && GetMessage(&msg, NULL, 0, 0)) 4487 while(_dw_main_running && GetMessage(&msg, NULL, 0, 0))
4488 { 4488 {
4489 if(msg.hwnd == NULL && msg.message == WM_TIMER) 4489 if(msg.hwnd == NULL && msg.message == WM_TIMER)
4490 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam); 4490 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
4641 char outbuf[1025] = {0}, *thisbuf = outbuf; 4641 char outbuf[1025] = {0}, *thisbuf = outbuf;
4642 4642
4643 va_start(args, format); 4643 va_start(args, format);
4644 vsnprintf(outbuf, 1024, format, args); 4644 vsnprintf(outbuf, 1024, format, args);
4645 va_end(args); 4645 va_end(args);
4646 4646
4647 OutputDebugString(UTF8toWide(thisbuf)); 4647 OutputDebugString(UTF8toWide(thisbuf));
4648 } 4648 }
4649 4649
4650 /* 4650 /*
4651 * Displays a Message Box with given text and title.. 4651 * Displays a Message Box with given text and title..
4713 */ 4713 */
4714 int API dw_window_show(HWND handle) 4714 int API dw_window_show(HWND handle)
4715 { 4715 {
4716 int rc; 4716 int rc;
4717 RECT rect; 4717 RECT rect;
4718 4718
4719 #ifdef AEROGLASS 4719 #ifdef AEROGLASS
4720 if(_DW_DARK_MODE_SUPPORTED) 4720 if(_DW_DARK_MODE_SUPPORTED)
4721 { 4721 {
4722 /* Try to enable dark mode support if our OS supports it */ 4722 /* Try to enable dark mode support if our OS supports it */
4723 _dw_set_child_window_theme(handle, 0); 4723 _dw_set_child_window_theme(handle, 0);
4724 EnumChildWindows(handle, _dw_set_child_window_theme, 0); 4724 EnumChildWindows(handle, _dw_set_child_window_theme, 0);
4725 if(GetParent(handle) == HWND_DESKTOP) 4725 if(GetParent(handle) == HWND_DESKTOP)
4726 RefreshTitleBarThemeColor(handle); 4726 RefreshTitleBarThemeColor(handle);
4727 } 4727 }
4728 #endif 4728 #endif
4729 4729
4730 GetClientRect(handle, &rect); 4730 GetClientRect(handle, &rect);
4731 4731
4732 /* If the client area is 0x0 then call the autosize routine */ 4732 /* If the client area is 0x0 then call the autosize routine */
4733 if((rect.bottom - rect.top) == 0 || (rect.right - rect.left) == 0) 4733 if((rect.bottom - rect.top) == 0 || (rect.right - rect.left) == 0)
4734 dw_window_set_size(handle, 0, 0); 4734 dw_window_set_size(handle, 0, 0);
4735 4735
4736 rc = ShowWindow(handle, SW_SHOW); 4736 rc = ShowWindow(handle, SW_SHOW);
4737 SetFocus(handle); 4737 SetFocus(handle);
4738 _initial_focus(handle); 4738 _initial_focus(handle);
4739 return rc; 4739 return rc;
4740 } 4740 }
4762 /* Handle special case for menu handle */ 4762 /* Handle special case for menu handle */
4763 if(handle < (HWND)65536) 4763 if(handle < (HWND)65536)
4764 { 4764 {
4765 char buffer[31] = {0}; 4765 char buffer[31] = {0};
4766 ULONG id = (ULONG)(uintptr_t)handle; 4766 ULONG id = (ULONG)(uintptr_t)handle;
4767 4767
4768 _snprintf(buffer, 30, "_dw_id%ld", id); 4768 _snprintf(buffer, 30, "_dw_id%ld", id);
4769 menu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer); 4769 menu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer);
4770 4770
4771 if(menu && IsMenu(menu)) 4771 if(menu && IsMenu(menu))
4772 return dw_menu_delete_item((HMENUI)menu, id); 4772 return dw_menu_delete_item((HMENUI)menu, id);
4773 return DW_ERROR_UNKNOWN; 4773 return DW_ERROR_UNKNOWN;
4774 } 4774 }
4775 4775
4776 parent = GetParent(handle); 4776 parent = GetParent(handle);
4777 menu = GetMenu(handle); 4777 menu = GetMenu(handle);
4778 4778
4779 if(menu) 4779 if(menu)
4780 _free_menu_data(menu); 4780 _free_menu_data(menu);
4781 4781
4782 /* If it is a desktop window let WM_DESTROY handle it */ 4782 /* If it is a desktop window let WM_DESTROY handle it */
4783 if(parent != HWND_DESKTOP) 4783 if(parent != HWND_DESKTOP)
4916 * with information about the packing information regarding object. 4916 * with information about the packing information regarding object.
4917 */ 4917 */
4918 Item *_box_item(HWND handle) 4918 Item *_box_item(HWND handle)
4919 { 4919 {
4920 HWND parent = GetParent(handle); 4920 HWND parent = GetParent(handle);
4921 Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA); 4921 Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA);
4922 4922
4923 /* If it is a desktop window let WM_DESTROY handle it */ 4923 /* If it is a desktop window let WM_DESTROY handle it */
4924 if(parent != HWND_DESKTOP) 4924 if(parent != HWND_DESKTOP)
4925 { 4925 {
4926 if(thisbox && thisbox->count) 4926 if(thisbox && thisbox->count)
4927 { 4927 {
4938 return NULL; 4938 return NULL;
4939 } 4939 }
4940 4940
4941 /* Internal function to calculate the widget's required size.. 4941 /* Internal function to calculate the widget's required size..
4942 * These are the general rules for widget sizes: 4942 * These are the general rules for widget sizes:
4943 * 4943 *
4944 * Render/Unspecified: 1x1 4944 * Render/Unspecified: 1x1
4945 * Scrolled(Container,Tree,MLE): Guessed size clamped to min and max in dw.h 4945 * Scrolled(Container,Tree,MLE): Guessed size clamped to min and max in dw.h
4946 * Entryfield/Combobox/Spinbutton: 150x(maxfontheight) 4946 * Entryfield/Combobox/Spinbutton: 150x(maxfontheight)
4947 * Spinbutton: 50x(maxfontheight) 4947 * Spinbutton: 50x(maxfontheight)
4948 * Text/Status: (textwidth)x(textheight) 4948 * Text/Status: (textwidth)x(textheight)
4963 /* Attempt to get icon from classes that can have them */ 4963 /* Attempt to get icon from classes that can have them */
4964 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0) 4964 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0)
4965 hic = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0); 4965 hic = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
4966 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0) 4966 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0)
4967 hic = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0); 4967 hic = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0);
4968 4968
4969 /* If we got an icon, pull out the internal bitmap */ 4969 /* If we got an icon, pull out the internal bitmap */
4970 if(hic) 4970 if(hic)
4971 { 4971 {
4972 if(GetIconInfo(hic, &ii)) 4972 if(GetIconInfo(hic, &ii))
4973 hbm = ii.hbmMask ? ii.hbmMask : ii.hbmColor; 4973 hbm = ii.hbmMask ? ii.hbmMask : ii.hbmColor;
4974 } 4974 }
4975 4975
4976 /* If we weren't able to get the bitmap from the icon... */ 4976 /* If we weren't able to get the bitmap from the icon... */
4977 if(!hbm) 4977 if(!hbm)
4978 { 4978 {
4979 /* Attempt to get bitmap from classes that can have them */ 4979 /* Attempt to get bitmap from classes that can have them */
4980 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0) 4980 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0)
4981 hbm = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); 4981 hbm = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
4982 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0) 4982 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0)
4983 hbm = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); 4983 hbm = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
4984 } 4984 }
4985 4985
4986 /* If we got an image... set the sizes appropriately */ 4986 /* If we got an image... set the sizes appropriately */
4987 if(hbm) 4987 if(hbm)
4988 { 4988 {
4989 BITMAP bmi = { 0 }; 4989 BITMAP bmi = { 0 };
4990 4990
4991 GetObject(hbm, sizeof(BITMAP), &bmi); 4991 GetObject(hbm, sizeof(BITMAP), &bmi);
4992 thiswidth = bmi.bmWidth; 4992 thiswidth = bmi.bmWidth;
4993 thisheight = bmi.bmHeight; 4993 thisheight = bmi.bmHeight;
4994 } 4994 }
4995 else 4995 else
4996 { 4996 {
4997 char *buf = dw_window_get_text(handle); 4997 char *buf = dw_window_get_text(handle);
4998 4998
4999 /* If we have a string... 4999 /* If we have a string...
5000 * calculate the size with the current font. 5000 * calculate the size with the current font.
5001 */ 5001 */
5002 if(buf) 5002 if(buf)
5003 { 5003 {
5004 if(*buf) 5004 if(*buf)
5007 _tcsnicmp(tmpbuf, StatusbarClassName, _tcslen(StatusbarClassName)+1) == 0) 5007 _tcsnicmp(tmpbuf, StatusbarClassName, _tcslen(StatusbarClassName)+1) == 0)
5008 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); 5008 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
5009 dw_free(buf); 5009 dw_free(buf);
5010 } 5010 }
5011 } 5011 }
5012 5012
5013 /* Combobox */ 5013 /* Combobox */
5014 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1) == 0) 5014 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1) == 0)
5015 { 5015 {
5016 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); 5016 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
5017 thiswidth = 150; 5017 thiswidth = 150;
5018 extraheight = 4; 5018 extraheight = 4;
5019 if(thisheight < 18) 5019 if(thisheight < 18)
5020 thisheight = 18; 5020 thisheight = 18;
5021 } 5021 }
5022 /* Ranged: Percent, Slider, Scrollbar */ 5022 /* Ranged: Percent, Slider, Scrollbar */
5023 else if(_tcsnicmp(tmpbuf, PROGRESS_CLASS, _tcslen(PROGRESS_CLASS)+1) == 0 || 5023 else if(_tcsnicmp(tmpbuf, PROGRESS_CLASS, _tcslen(PROGRESS_CLASS)+1) == 0 ||
5024 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1) == 0 || 5024 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1) == 0 ||
5025 _tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1) == 0) 5025 _tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1) == 0)
5026 { 5026 {
5027 if(_tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1) == 0 && 5027 if(_tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1) == 0 &&
5028 GetWindowLong(handle, GWL_STYLE) & SBS_VERT) 5028 GetWindowLong(handle, GWL_STYLE) & SBS_VERT)
5043 { 5043 {
5044 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); 5044 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
5045 thiswidth = 50; 5045 thiswidth = 50;
5046 extraheight = 6; 5046 extraheight = 6;
5047 } 5047 }
5048 #ifdef TOOLBAR 5048 #ifdef TOOLBAR
5049 /* Bitmap Buttons */ 5049 /* Bitmap Buttons */
5050 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0) 5050 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
5051 { 5051 {
5052 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0); 5052 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0);
5053 int minsize = 24; 5053 int minsize = 24;
5054 5054
5055 if(imlist) 5055 if(imlist)
5056 ImageList_GetIconSize(imlist, &thiswidth, &thisheight); 5056 ImageList_GetIconSize(imlist, &thiswidth, &thisheight);
5057 5057
5058 /* If we are flat the size can be smaller */ 5058 /* If we are flat the size can be smaller */
5059 if(GetWindowLong(handle, GWL_STYLE) & TBSTYLE_FLAT) 5059 if(GetWindowLong(handle, GWL_STYLE) & TBSTYLE_FLAT)
5061 else 5061 else
5062 { 5062 {
5063 thiswidth += 4; 5063 thiswidth += 4;
5064 thisheight += 4; 5064 thisheight += 4;
5065 } 5065 }
5066 5066
5067 if(thiswidth < minsize) 5067 if(thiswidth < minsize)
5068 thiswidth = minsize; 5068 thiswidth = minsize;
5069 if(thisheight < minsize) 5069 if(thisheight < minsize)
5070 thisheight = minsize; 5070 thisheight = minsize;
5071 } 5071 }
5072 #endif 5072 #endif
5073 /* Listbox */ 5073 /* Listbox */
5074 else if(_tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1) == 0) 5074 else if(_tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1) == 0)
5075 { 5075 {
5076 char buf[1025] = {0}; 5076 char buf[1025] = {0};
5077 int x, count = dw_listbox_count(handle); 5077 int x, count = dw_listbox_count(handle);
5078 int basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8; 5078 int basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8;
5079 5079
5080 thisheight = 8; 5080 thisheight = 8;
5081 5081
5082 for(x=0;x<count;x++) 5082 for(x=0;x<count;x++)
5083 { 5083 {
5084 int height, width = 0; 5084 int height, width = 0;
5085 5085
5086 dw_listbox_get_text(handle, x, buf, 1024); 5086 dw_listbox_get_text(handle, x, buf, 1024);
5087 5087
5088 if(strlen(buf)) 5088 if(strlen(buf))
5089 dw_font_text_extents_get(handle, NULL, buf, &width, &height); 5089 dw_font_text_extents_get(handle, NULL, buf, &width, &height);
5090 else 5090 else
5091 dw_font_text_extents_get(handle, NULL, testtext, NULL, &height); 5091 dw_font_text_extents_get(handle, NULL, testtext, NULL, &height);
5092 5092
5093 width += basicwidth; 5093 width += basicwidth;
5094 5094
5095 if(width > thiswidth) 5095 if(width > thiswidth)
5096 thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width; 5096 thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width;
5097 thisheight += height; 5097 thisheight += height;
5098 } 5098 }
5099 5099
5100 if(thiswidth < _DW_SCROLLED_MIN_WIDTH) 5100 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
5101 thiswidth = _DW_SCROLLED_MIN_WIDTH; 5101 thiswidth = _DW_SCROLLED_MIN_WIDTH;
5102 if(thisheight < _DW_SCROLLED_MIN_HEIGHT) 5102 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
5103 thisheight = _DW_SCROLLED_MIN_HEIGHT; 5103 thisheight = _DW_SCROLLED_MIN_HEIGHT;
5104 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) 5104 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
5114 { 5114 {
5115 unsigned long bytes; 5115 unsigned long bytes;
5116 int height, width; 5116 int height, width;
5117 char *buf, *ptr; 5117 char *buf, *ptr;
5118 int basicwidth; 5118 int basicwidth;
5119 5119
5120 if(style & ES_AUTOHSCROLL) 5120 if(style & ES_AUTOHSCROLL)
5121 thisheight = GetSystemMetrics(SM_CYHSCROLL) + 8; 5121 thisheight = GetSystemMetrics(SM_CYHSCROLL) + 8;
5122 else 5122 else
5123 thisheight = 8; 5123 thisheight = 8;
5124 basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8; 5124 basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8;
5125 5125
5126 dw_mle_get_size(handle, &bytes, NULL); 5126 dw_mle_get_size(handle, &bytes, NULL);
5127 5127
5128 ptr = buf = _alloca(bytes + 2); 5128 ptr = buf = _alloca(bytes + 2);
5129 dw_mle_export(handle, buf, 0, (int)bytes); 5129 dw_mle_export(handle, buf, 0, (int)bytes);
5130 buf[bytes] = 0; 5130 buf[bytes] = 0;
5131 strcat(buf, "\n"); 5131 strcat(buf, "\n");
5132 5132
5133 /* MLE */ 5133 /* MLE */
5134 while((ptr = strstr(buf, "\n"))) 5134 while((ptr = strstr(buf, "\n")))
5135 { 5135 {
5136 ptr[0] = 0; 5136 ptr[0] = 0;
5137 width = 0; 5137 width = 0;
5138 if(strlen(buf)) 5138 if(strlen(buf))
5139 dw_font_text_extents_get(handle, NULL, buf, &width, &height); 5139 dw_font_text_extents_get(handle, NULL, buf, &width, &height);
5140 else 5140 else
5141 dw_font_text_extents_get(handle, NULL, testtext, NULL, &height); 5141 dw_font_text_extents_get(handle, NULL, testtext, NULL, &height);
5142 5142
5143 width += basicwidth; 5143 width += basicwidth;
5144 5144
5145 if(!(style & ES_AUTOHSCROLL) && width > _DW_SCROLLED_MAX_WIDTH) 5145 if(!(style & ES_AUTOHSCROLL) && width > _DW_SCROLLED_MAX_WIDTH)
5146 { 5146 {
5147 thiswidth = _DW_SCROLLED_MAX_WIDTH; 5147 thiswidth = _DW_SCROLLED_MAX_WIDTH;
5148 thisheight += height * (width / _DW_SCROLLED_MAX_WIDTH); 5148 thisheight += height * (width / _DW_SCROLLED_MAX_WIDTH);
5149 } 5149 }
5153 thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width; 5153 thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width;
5154 } 5154 }
5155 thisheight += height; 5155 thisheight += height;
5156 buf = &ptr[1]; 5156 buf = &ptr[1];
5157 } 5157 }
5158 5158
5159 if(thiswidth < _DW_SCROLLED_MIN_WIDTH) 5159 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
5160 thiswidth = _DW_SCROLLED_MIN_WIDTH; 5160 thiswidth = _DW_SCROLLED_MIN_WIDTH;
5161 if(thisheight < _DW_SCROLLED_MIN_HEIGHT) 5161 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
5162 thisheight = _DW_SCROLLED_MIN_HEIGHT; 5162 thisheight = _DW_SCROLLED_MIN_HEIGHT;
5163 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) 5163 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
5173 } 5173 }
5174 /* Container */ 5174 /* Container */
5175 else if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0) 5175 else if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0)
5176 { 5176 {
5177 DWORD result = ListView_ApproximateViewRect(handle, _DW_SCROLLED_MAX_WIDTH, _DW_SCROLLED_MAX_HEIGHT, -1); 5177 DWORD result = ListView_ApproximateViewRect(handle, _DW_SCROLLED_MAX_WIDTH, _DW_SCROLLED_MAX_HEIGHT, -1);
5178 5178
5179 thiswidth = LOWORD(result); 5179 thiswidth = LOWORD(result);
5180 thisheight = HIWORD(result); 5180 thisheight = HIWORD(result);
5181 5181
5182 if(thiswidth > _DW_SCROLLED_MAX_WIDTH) 5182 if(thiswidth > _DW_SCROLLED_MAX_WIDTH)
5183 thiswidth = _DW_SCROLLED_MAX_WIDTH; 5183 thiswidth = _DW_SCROLLED_MAX_WIDTH;
5184 if(thiswidth < _DW_SCROLLED_MIN_WIDTH) 5184 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
5185 thiswidth = _DW_SCROLLED_MIN_WIDTH; 5185 thiswidth = _DW_SCROLLED_MIN_WIDTH;
5186 if(thisheight < _DW_SCROLLED_MIN_HEIGHT) 5186 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
5196 } 5196 }
5197 /* Buttons */ 5197 /* Buttons */
5198 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0) 5198 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0)
5199 { 5199 {
5200 ULONG style = GetWindowLong(handle, GWL_STYLE); 5200 ULONG style = GetWindowLong(handle, GWL_STYLE);
5201 5201
5202 /* Bitmap buttons */ 5202 /* Bitmap buttons */
5203 if(hbm) 5203 if(hbm)
5204 { 5204 {
5205 extrawidth = 5; 5205 extrawidth = 5;
5206 extraheight = 5; 5206 extraheight = 5;
5222 { 5222 {
5223 extrawidth = 4; 5223 extrawidth = 4;
5224 extraheight = 2; 5224 extraheight = 2;
5225 } 5225 }
5226 5226
5227 /* Set the requested sizes */ 5227 /* Set the requested sizes */
5228 if(width) 5228 if(width)
5229 *width = thiswidth + extrawidth; 5229 *width = thiswidth + extrawidth;
5230 if(height) 5230 if(height)
5231 *height = thisheight + extraheight; 5231 *height = thisheight + extraheight;
5232 5232
5233 /* Free temporary bitmaps */ 5233 /* Free temporary bitmaps */
5234 if(ii.hbmColor) 5234 if(ii.hbmColor)
5235 DeleteObject(ii.hbmColor); 5235 DeleteObject(ii.hbmColor);
5236 if(ii.hbmMask) 5236 if(ii.hbmMask)
5237 DeleteObject(ii.hbmMask); 5237 DeleteObject(ii.hbmMask);
5287 } 5287 }
5288 /* If we changed the font... */ 5288 /* If we changed the font... */
5289 if(hfont) 5289 if(hfont)
5290 { 5290 {
5291 Item *item = _box_item(handle); 5291 Item *item = _box_item(handle);
5292 5292
5293 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); 5293 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
5294 if(oldfont) 5294 if(oldfont)
5295 DeleteObject(oldfont); 5295 DeleteObject(oldfont);
5296 5296
5297 /* Check to see if any of the sizes need to be recalculated */ 5297 /* Check to see if any of the sizes need to be recalculated */
5298 if(item && (item->origwidth == -1 || item->origheight == -1)) 5298 if(item && (item->origwidth == -1 || item->origheight == -1))
5299 { 5299 {
5300 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); 5300 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
5301 /* Queue a redraw on the top-level window */ 5301 /* Queue a redraw on the top-level window */
5302 _dw_redraw(_toplevel_window(handle), TRUE); 5302 _dw_redraw(_toplevel_window(handle), TRUE);
5303 } 5303 }
5304 return DW_ERROR_NONE; 5304 return DW_ERROR_NONE;
5305 } 5305 }
5518 HWND hwndframe; 5518 HWND hwndframe;
5519 Box *newbox = calloc(sizeof(Box), 1); 5519 Box *newbox = calloc(sizeof(Box), 1);
5520 ULONG flStyleEx = 0; 5520 ULONG flStyleEx = 0;
5521 #ifdef AEROGLASS 5521 #ifdef AEROGLASS
5522 MARGINS mar = {-1}; 5522 MARGINS mar = {-1};
5523 5523
5524 if(_dw_composition && (flStyle & DW_FCF_COMPOSITED)) 5524 if(_dw_composition && (flStyle & DW_FCF_COMPOSITED))
5525 flStyleEx = WS_EX_LAYERED; 5525 flStyleEx = WS_EX_LAYERED;
5526 #endif 5526 #endif
5527 5527
5528 newbox->type = DW_VERT; 5528 newbox->type = DW_VERT;
5841 return _dw_edge_url(handle, url); 5841 return _dw_edge_url(handle, url);
5842 #endif 5842 #endif
5843 return _dw_html_url(handle, url); 5843 return _dw_html_url(handle, url);
5844 #else 5844 #else
5845 return DW_ERROR_GENERAL; 5845 return DW_ERROR_GENERAL;
5846 #endif 5846 #endif
5847 } 5847 }
5848 5848
5849 /* 5849 /*
5850 * Executes the javascript contained in "script" in the HTML window. 5850 * Executes the javascript contained in "script" in the HTML window.
5851 * Parameters: 5851 * Parameters:
5978 SignalHandler *tmp = Root; 5978 SignalHandler *tmp = Root;
5979 5979
5980 while(tmp) 5980 while(tmp)
5981 { 5981 {
5982 if(tmp->id == id) 5982 if(tmp->id == id)
5983 return TRUE; 5983 return TRUE;
5984 tmp = tmp->next; 5984 tmp = tmp->next;
5985 } 5985 }
5986 return FALSE; 5986 return FALSE;
5987 } 5987 }
5988 5988
6018 6018
6019 /* Convert from OS/2 style accellerators to Win32 style */ 6019 /* Convert from OS/2 style accellerators to Win32 style */
6020 if (title) 6020 if (title)
6021 { 6021 {
6022 char *tmp = menutitle = _alloca(strlen(title)+1); 6022 char *tmp = menutitle = _alloca(strlen(title)+1);
6023 6023
6024 strcpy(tmp, title); 6024 strcpy(tmp, title);
6025 6025
6026 while(*tmp) 6026 while(*tmp)
6027 { 6027 {
6028 if(*tmp == '~') 6028 if(*tmp == '~')
6032 } 6032 }
6033 6033
6034 if (menutitle && *menutitle) 6034 if (menutitle && *menutitle)
6035 { 6035 {
6036 /* Code to autogenerate a menu ID if not specified or invalid 6036 /* Code to autogenerate a menu ID if not specified or invalid
6037 * First pool is smaller for transient popup menus 6037 * First pool is smaller for transient popup menus
6038 */ 6038 */
6039 if(id == (ULONG)-1) 6039 if(id == (ULONG)-1)
6040 { 6040 {
6041 static ULONG tempid = 61000; 6041 static ULONG tempid = 61000;
6042 6042
6043 tempid++; 6043 tempid++;
6044 id = tempid; 6044 id = tempid;
6045 6045
6046 if(tempid > 65500) 6046 if(tempid > 65500)
6047 tempid = 61000; 6047 tempid = 61000;
6048 } 6048 }
6049 /* Second pool is larger for more static windows */ 6049 /* Second pool is larger for more static windows */
6050 else if(!id || id >= 30000) 6050 else if(!id || id >= 30000)
6247 /* 6247 /*
6248 * Deletes the menu item specified 6248 * Deletes the menu item specified
6249 * Parameters: 6249 * Parameters:
6250 * menu: The handle to the menu in which the item was appended. 6250 * menu: The handle to the menu in which the item was appended.
6251 * id: Menuitem id. 6251 * id: Menuitem id.
6252 * Returns: 6252 * Returns:
6253 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. 6253 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure.
6254 */ 6254 */
6255 int API dw_menu_delete_item(HMENUI menux, unsigned long id) 6255 int API dw_menu_delete_item(HMENUI menux, unsigned long id)
6256 { 6256 {
6257 HMENU mymenu = (HMENU)menux; 6257 HMENU mymenu = (HMENU)menux;
6259 if ( IsWindow(menux) && !IsMenu(mymenu) ) 6259 if ( IsWindow(menux) && !IsMenu(mymenu) )
6260 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu"); 6260 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu");
6261 6261
6262 if ( mymenu == 0 || DeleteMenu(mymenu, id, MF_BYCOMMAND) == 0 ) 6262 if ( mymenu == 0 || DeleteMenu(mymenu, id, MF_BYCOMMAND) == 0 )
6263 return DW_ERROR_UNKNOWN; 6263 return DW_ERROR_UNKNOWN;
6264 6264
6265 /* If the ID was autogenerated it is safe to remove it */ 6265 /* If the ID was autogenerated it is safe to remove it */
6266 if(id >= 30000) 6266 if(id >= 30000)
6267 dw_signal_disconnect_by_window((HWND)(uintptr_t)id); 6267 dw_signal_disconnect_by_window((HWND)(uintptr_t)id);
6268 6268
6269 /* Make sure the menu is redrawn if needed */ 6269 /* Make sure the menu is redrawn if needed */
6270 if( (HMENU)menux != mymenu ) 6270 if( (HMENU)menux != mymenu )
6271 DrawMenuBar(menux); 6271 DrawMenuBar(menux);
6272 return DW_ERROR_NONE; 6272 return DW_ERROR_NONE;
6273 } 6273 }
6427 6427
6428 cinfo->back = cinfo->fore = -1; 6428 cinfo->back = cinfo->fore = -1;
6429 6429
6430 cinfo->pOldProc = SubclassWindow(tmp, _staticwndproc); 6430 cinfo->pOldProc = SubclassWindow(tmp, _staticwndproc);
6431 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); 6431 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
6432 #endif 6432 #endif
6433 dw_window_set_font(tmp, DefaultFont); 6433 dw_window_set_font(tmp, DefaultFont);
6434 dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT); 6434 dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT);
6435 return tmp; 6435 return tmp;
6436 } 6436 }
6437 6437
6596 cinfo2->fore = cinfo->fore = -1; 6596 cinfo2->fore = cinfo->fore = -1;
6597 cinfo2->back = cinfo->back = -1; 6597 cinfo2->back = cinfo->back = -1;
6598 cinfo2->combo = cinfo->combo = tmp; 6598 cinfo2->combo = cinfo->combo = tmp;
6599 EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo2); 6599 EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo2);
6600 cinfo->buddy = cinfo2->buddy; 6600 cinfo->buddy = cinfo2->buddy;
6601 6601
6602 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); 6602 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
6603 dw_window_set_font(tmp, DefaultFont); 6603 dw_window_set_font(tmp, DefaultFont);
6604 SetWindowText(tmp, UTF8toWide(text)); 6604 SetWindowText(tmp, UTF8toWide(text));
6605 return tmp; 6605 return tmp;
6606 } 6606 }
6635 #ifdef TOOLBAR 6635 #ifdef TOOLBAR
6636 /* Internal function to create a grayscale bitmap from a color one */ 6636 /* Internal function to create a grayscale bitmap from a color one */
6637 void _to_grayscale(HBITMAP hbm, int width, int height) 6637 void _to_grayscale(HBITMAP hbm, int width, int height)
6638 { 6638 {
6639 HDC hdc = CreateCompatibleDC(NULL); 6639 HDC hdc = CreateCompatibleDC(NULL);
6640 if (hdc) 6640 if (hdc)
6641 { 6641 {
6642 HBITMAP hbmPrev = SelectBitmap(hdc, hbm); 6642 HBITMAP hbmPrev = SelectBitmap(hdc, hbm);
6643 int x, y; 6643 int x, y;
6644 6644
6645 for(y=0;y<height;y++) 6645 for(y=0;y<height;y++)
6662 HWND _create_toolbar(const char *text, ULONG id, HICON icon, HBITMAP hbitmap) 6662 HWND _create_toolbar(const char *text, ULONG id, HICON icon, HBITMAP hbitmap)
6663 { 6663 {
6664 HWND tmp; 6664 HWND tmp;
6665 HIMAGELIST imlist, dimlist; 6665 HIMAGELIST imlist, dimlist;
6666 BITMAP bmi = { 0 }; 6666 BITMAP bmi = { 0 };
6667 TBBUTTON tbButtons[] = { 6667 TBBUTTON tbButtons[] = {
6668 { MAKELONG(0, 0), id, TBSTATE_ENABLED, TBSTYLE_BUTTON} 6668 { MAKELONG(0, 0), id, TBSTATE_ENABLED, TBSTYLE_BUTTON}
6669 }; 6669 };
6670 6670
6671 /* Get the bitmap from either the icon or bitmap itself */ 6671 /* Get the bitmap from either the icon or bitmap itself */
6672 if(hbitmap) 6672 if(hbitmap)
6673 { 6673 {
6674 GetObject(hbitmap, sizeof(BITMAP), &bmi); 6674 GetObject(hbitmap, sizeof(BITMAP), &bmi);
6675 imlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32, 1, 0); 6675 imlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32, 1, 0);
6680 DeleteObject(hbitmap); 6680 DeleteObject(hbitmap);
6681 } 6681 }
6682 else if(icon) 6682 else if(icon)
6683 { 6683 {
6684 ICONINFO iconinfo; 6684 ICONINFO iconinfo;
6685 6685
6686 GetIconInfo(icon, &iconinfo); 6686 GetIconInfo(icon, &iconinfo);
6687 GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bmi); 6687 GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bmi);
6688 imlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0); 6688 imlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
6689 ImageList_AddIcon(imlist, icon); 6689 ImageList_AddIcon(imlist, icon);
6690 dimlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0); 6690 dimlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
6696 } 6696 }
6697 else 6697 else
6698 return 0; 6698 return 0;
6699 6699
6700 /* Create the toolbar */ 6700 /* Create the toolbar */
6701 tmp = CreateWindowEx(0L, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_AUTOSIZE | CCS_NORESIZE | 6701 tmp = CreateWindowEx(0L, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_AUTOSIZE | CCS_NORESIZE |
6702 CCS_NOPARENTALIGN | CCS_NODIVIDER, 0, 0, 100, 30, DW_HWND_OBJECT, (HMENU)(uintptr_t)id, DWInstance, NULL); 6702 CCS_NOPARENTALIGN | CCS_NODIVIDER, 0, 0, 100, 30, DW_HWND_OBJECT, (HMENU)(uintptr_t)id, DWInstance, NULL);
6703 6703
6704 /* Disable visual styles by default */ 6704 /* Disable visual styles by default */
6705 if(_SetWindowTheme) 6705 if(_SetWindowTheme)
6706 _SetWindowTheme(tmp, L"", L""); 6706 _SetWindowTheme(tmp, L"", L"");
6710 SendMessage(tmp, TB_SETBUTTONSIZE, 0, MAKELPARAM(bmi.bmWidth, bmi.bmHeight)); 6710 SendMessage(tmp, TB_SETBUTTONSIZE, 0, MAKELPARAM(bmi.bmWidth, bmi.bmHeight));
6711 SendMessage(tmp, TB_SETPADDING, 0, 0); 6711 SendMessage(tmp, TB_SETPADDING, 0, 0);
6712 SendMessage(tmp, TB_SETIMAGELIST, 0, (LPARAM)imlist); 6712 SendMessage(tmp, TB_SETIMAGELIST, 0, (LPARAM)imlist);
6713 SendMessage(tmp, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)dimlist); 6713 SendMessage(tmp, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)dimlist);
6714 SendMessage(tmp, TB_ADDBUTTONS, 1, (LPARAM) &tbButtons); 6714 SendMessage(tmp, TB_ADDBUTTONS, 1, (LPARAM) &tbButtons);
6715 6715
6716 _create_tooltip(tmp, text); 6716 _create_tooltip(tmp, text);
6717 return tmp; 6717 return tmp;
6718 } 6718 }
6719 #endif 6719 #endif
6720 6720
6969 cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc); 6969 cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc);
6970 SetWindowLongPtr(buddy, GWLP_USERDATA, (LONG_PTR)cinfo); 6970 SetWindowLongPtr(buddy, GWLP_USERDATA, (LONG_PTR)cinfo);
6971 6971
6972 cinfo = calloc(1, sizeof(ColorInfo)); 6972 cinfo = calloc(1, sizeof(ColorInfo));
6973 cinfo->buddy = buddy; 6973 cinfo->buddy = buddy;
6974 /* The horrible spinbutton workaround isn't necessary 6974 /* The horrible spinbutton workaround isn't necessary
6975 * any more on Vista or 7... but still seems necessary 6975 * any more on Vista or 7... but still seems necessary
6976 * for XP, so only enable it if on XP or lower. 6976 * for XP, so only enable it if on XP or lower.
6977 */ 6977 */
6978 if(!IS_VISTAPLUS) 6978 if(!IS_VISTAPLUS)
6979 { 6979 {
6980 cinfo->pOldProc = SubclassWindow(tmp, _spinnerwndproc); 6980 cinfo->pOldProc = SubclassWindow(tmp, _spinnerwndproc);
6981 } 6981 }
7179 void _dw_window_set_bitmap(HWND handle, HICON icon, HBITMAP hbitmap) 7179 void _dw_window_set_bitmap(HWND handle, HICON icon, HBITMAP hbitmap)
7180 { 7180 {
7181 HBITMAP oldbitmap = 0; 7181 HBITMAP oldbitmap = 0;
7182 HANDLE oldicon = 0; 7182 HANDLE oldicon = 0;
7183 TCHAR tmpbuf[100] = {0}; 7183 TCHAR tmpbuf[100] = {0};
7184 7184
7185 if (!icon && !hbitmap) 7185 if (!icon && !hbitmap)
7186 return; 7186 return;
7187 7187
7188 GetClassName(handle, tmpbuf, 99); 7188 GetClassName(handle, tmpbuf, 99);
7189 7189
7190 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0) 7190 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0)
7191 { 7191 {
7192 oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); 7192 oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
7193 oldicon = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0); 7193 oldicon = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0);
7194 SendMessage(handle, BM_SETIMAGE, 7194 SendMessage(handle, BM_SETIMAGE,
7195 (icon ? (WPARAM)IMAGE_ICON : (WPARAM)IMAGE_BITMAP), 7195 (icon ? (WPARAM)IMAGE_ICON : (WPARAM)IMAGE_BITMAP),
7196 (icon ? (LPARAM)icon : (LPARAM)hbitmap)); 7196 (icon ? (LPARAM)icon : (LPARAM)hbitmap));
7197 } 7197 }
7198 #ifdef TOOLBAR 7198 #ifdef TOOLBAR
7199 /* Bitmap Buttons */ 7199 /* Bitmap Buttons */
7200 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0) 7200 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
7201 { 7201 {
7202 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0); 7202 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0);
7203 HIMAGELIST dimlist = (HIMAGELIST)SendMessage(handle, TB_GETDISABLEDIMAGELIST, 0, 0); 7203 HIMAGELIST dimlist = (HIMAGELIST)SendMessage(handle, TB_GETDISABLEDIMAGELIST, 0, 0);
7204 BITMAP bmi = { 0 }; 7204 BITMAP bmi = { 0 };
7205 7205
7206 if(hbitmap) 7206 if(hbitmap)
7207 { 7207 {
7208 GetObject(hbitmap, sizeof(BITMAP), &bmi); 7208 GetObject(hbitmap, sizeof(BITMAP), &bmi);
7209 ImageList_Replace(imlist, 0, hbitmap, NULL); 7209 ImageList_Replace(imlist, 0, hbitmap, NULL);
7210 _to_grayscale(hbitmap, bmi.bmWidth, bmi.bmHeight); 7210 _to_grayscale(hbitmap, bmi.bmWidth, bmi.bmHeight);
7212 DeleteObject(hbitmap); 7212 DeleteObject(hbitmap);
7213 } 7213 }
7214 else if(icon) 7214 else if(icon)
7215 { 7215 {
7216 ICONINFO iconinfo; 7216 ICONINFO iconinfo;
7217 7217
7218 GetIconInfo(icon, &iconinfo); 7218 GetIconInfo(icon, &iconinfo);
7219 GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bmi); 7219 GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bmi);
7220 ImageList_ReplaceIcon(imlist, 0, icon); 7220 ImageList_ReplaceIcon(imlist, 0, icon);
7221 _to_grayscale(iconinfo.hbmColor, bmi.bmWidth, bmi.bmHeight); 7221 _to_grayscale(iconinfo.hbmColor, bmi.bmWidth, bmi.bmHeight);
7222 ImageList_Replace(dimlist, 0, iconinfo.hbmColor, iconinfo.hbmMask); 7222 ImageList_Replace(dimlist, 0, iconinfo.hbmColor, iconinfo.hbmMask);
7224 DeleteObject(iconinfo.hbmMask); 7224 DeleteObject(iconinfo.hbmMask);
7225 DestroyIcon(icon); 7225 DestroyIcon(icon);
7226 } 7226 }
7227 InvalidateRect(handle, NULL, FALSE); 7227 InvalidateRect(handle, NULL, FALSE);
7228 } 7228 }
7229 #endif 7229 #endif
7230 else 7230 else
7231 { 7231 {
7232 oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); 7232 oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
7233 oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0); 7233 oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
7234 SendMessage(handle, STM_SETIMAGE, 7234 SendMessage(handle, STM_SETIMAGE,
7242 DeleteObject(oldicon); 7242 DeleteObject(oldicon);
7243 7243
7244 /* If we changed the bitmap... */ 7244 /* If we changed the bitmap... */
7245 { 7245 {
7246 Item *item = _box_item(handle); 7246 Item *item = _box_item(handle);
7247 7247
7248 /* Check to see if any of the sizes need to be recalculated */ 7248 /* Check to see if any of the sizes need to be recalculated */
7249 if(item && (item->origwidth == -1 || item->origheight == -1)) 7249 if(item && (item->origwidth == -1 || item->origheight == -1))
7250 { 7250 {
7251 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); 7251 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
7252 /* Queue a redraw on the top-level window */ 7252 /* Queue a redraw on the top-level window */
7253 _dw_redraw(_toplevel_window(handle), TRUE); 7253 _dw_redraw(_toplevel_window(handle), TRUE);
7254 } 7254 }
7255 } 7255 }
7256 } 7256 }
7281 hbitmap = _dw_load_bitmap(filename, NULL); 7281 hbitmap = _dw_load_bitmap(filename, NULL);
7282 #else 7282 #else
7283 _dw_get_image_handle(filename, &icon, &hbitmap); 7283 _dw_get_image_handle(filename, &icon, &hbitmap);
7284 #endif 7284 #endif
7285 } 7285 }
7286 7286
7287 _dw_window_set_bitmap(handle, icon, hbitmap); 7287 _dw_window_set_bitmap(handle, icon, hbitmap);
7288 } 7288 }
7289 7289
7290 /* 7290 /*
7291 * Sets the bitmap used for a given static window from data. 7291 * Sets the bitmap used for a given static window from data.
7378 SetWindowText( thisbox->grouphwnd, wtext ); 7378 SetWindowText( thisbox->grouphwnd, wtext );
7379 } 7379 }
7380 /* If we changed the text... */ 7380 /* If we changed the text... */
7381 { 7381 {
7382 Item *item = _box_item(handle); 7382 Item *item = _box_item(handle);
7383 7383
7384 /* Check to see if any of the sizes need to be recalculated */ 7384 /* Check to see if any of the sizes need to be recalculated */
7385 if(item && (item->origwidth == -1 || item->origheight == -1)) 7385 if(item && (item->origwidth == -1 || item->origheight == -1))
7386 { 7386 {
7387 int newwidth, newheight; 7387 int newwidth, newheight;
7388 7388
7389 _control_size(handle, &newwidth, &newheight); 7389 _control_size(handle, &newwidth, &newheight);
7390 7390
7391 /* Only update the item and redraw the window if it changed */ 7391 /* Only update the item and redraw the window if it changed */
7392 if((item->origwidth == -1 && item->width != newwidth) || 7392 if((item->origwidth == -1 && item->width != newwidth) ||
7393 (item->origheight == -1 && item->height != newheight)) 7393 (item->origheight == -1 && item->height != newheight))
7394 { 7394 {
7395 if(item->origwidth == -1) 7395 if(item->origwidth == -1)
7410 * bubbletext: The text in the floating bubble tooltip. 7410 * bubbletext: The text in the floating bubble tooltip.
7411 */ 7411 */
7412 void API dw_window_set_tooltip(HWND handle, const char *bubbletext) 7412 void API dw_window_set_tooltip(HWND handle, const char *bubbletext)
7413 { 7413 {
7414 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); 7414 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
7415 7415
7416 if(cinfo && cinfo->buddy) 7416 if(cinfo && cinfo->buddy)
7417 _create_tooltip(cinfo->buddy, bubbletext); 7417 _create_tooltip(cinfo->buddy, bubbletext);
7418 _create_tooltip(handle, bubbletext); 7418 _create_tooltip(handle, bubbletext);
7419 } 7419 }
7420 7420
7447 * and fill it with the current text. 7447 * and fill it with the current text.
7448 */ 7448 */
7449 len = GetWindowTextLength(handle) + 1; 7449 len = GetWindowTextLength(handle) + 1;
7450 if((tempbuf = _alloca(len * sizeof(TCHAR)))) 7450 if((tempbuf = _alloca(len * sizeof(TCHAR))))
7451 GetWindowText(handle, tempbuf, len); 7451 GetWindowText(handle, tempbuf, len);
7452 7452
7453 /* Figure out the UTF8 length, allocate a return buffer 7453 /* Figure out the UTF8 length, allocate a return buffer
7454 * and fill it with the UTF8 text and return it. 7454 * and fill it with the UTF8 text and return it.
7455 */ 7455 */
7456 if(tempbuf && (retbuf = WideToUTF8(tempbuf))) 7456 if(tempbuf && (retbuf = WideToUTF8(tempbuf)))
7457 retbuf = _strdup(retbuf); 7457 retbuf = _strdup(retbuf);
7468 if(handle < (HWND)65536) 7468 if(handle < (HWND)65536)
7469 { 7469 {
7470 char buffer[31] = {0}; 7470 char buffer[31] = {0};
7471 HMENU mymenu; 7471 HMENU mymenu;
7472 ULONG id = (ULONG)(uintptr_t)handle; 7472 ULONG id = (ULONG)(uintptr_t)handle;
7473 7473
7474 _snprintf(buffer, 30, "_dw_id%ld", id); 7474 _snprintf(buffer, 30, "_dw_id%ld", id);
7475 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer); 7475 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer);
7476 7476
7477 if(mymenu && IsMenu(mymenu)) 7477 if(mymenu && IsMenu(mymenu))
7478 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_DISABLED); 7478 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_DISABLED);
7479 } 7479 }
7480 else 7480 else
7481 EnableWindow(handle, FALSE); 7481 EnableWindow(handle, FALSE);
7491 if(handle < (HWND)65536) 7491 if(handle < (HWND)65536)
7492 { 7492 {
7493 char buffer[31] = {0}; 7493 char buffer[31] = {0};
7494 HMENU mymenu; 7494 HMENU mymenu;
7495 ULONG id = (ULONG)(uintptr_t)handle; 7495 ULONG id = (ULONG)(uintptr_t)handle;
7496 7496
7497 _snprintf(buffer, 30, "_dw_id%ld", id); 7497 _snprintf(buffer, 30, "_dw_id%ld", id);
7498 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer); 7498 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer);
7499 7499
7500 if(mymenu && IsMenu(mymenu)) 7500 if(mymenu && IsMenu(mymenu))
7501 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_ENABLED); 7501 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_ENABLED);
7502 } 7502 }
7503 else 7503 else
7504 EnableWindow(handle, TRUE); 7504 EnableWindow(handle, TRUE);
7544 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!"); 7544 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
7545 return; 7545 return;
7546 } 7546 }
7547 7547
7548 GetClassName(box, tmpbuf, 99); 7548 GetClassName(box, tmpbuf, 99);
7549 7549
7550 /* If we are in a scrolled box... extract the interal box */ 7550 /* If we are in a scrolled box... extract the interal box */
7551 if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName)+1)==0) 7551 if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName)+1)==0)
7552 { 7552 {
7553 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box, GWLP_USERDATA); 7553 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box, GWLP_USERDATA);
7554 if(cinfo) 7554 if(cinfo)
7616 tmpitem[index].origwidth = tmpitem[index].width = width; 7616 tmpitem[index].origwidth = tmpitem[index].width = width;
7617 tmpitem[index].origheight = tmpitem[index].height = height; 7617 tmpitem[index].origheight = tmpitem[index].height = height;
7618 tmpitem[index].pad = pad; 7618 tmpitem[index].pad = pad;
7619 tmpitem[index].hsize = hsize ? SIZEEXPAND : SIZESTATIC; 7619 tmpitem[index].hsize = hsize ? SIZEEXPAND : SIZESTATIC;
7620 tmpitem[index].vsize = vsize ? SIZEEXPAND : SIZESTATIC; 7620 tmpitem[index].vsize = vsize ? SIZEEXPAND : SIZESTATIC;
7621 7621
7622 /* If either of the parameters are -1 ... calculate the size */ 7622 /* If either of the parameters are -1 ... calculate the size */
7623 if(width == -1 || height == -1) 7623 if(width == -1 || height == -1)
7624 _control_size(item, width == -1 ? &tmpitem[index].width : NULL, height == -1 ? &tmpitem[index].height : NULL); 7624 _control_size(item, width == -1 ? &tmpitem[index].width : NULL, height == -1 ? &tmpitem[index].height : NULL);
7625 7625
7626 thisbox->items = tmpitem; 7626 thisbox->items = tmpitem;
7643 SetParent(cinfo->buddy, box); 7643 SetParent(cinfo->buddy, box);
7644 ShowWindow(cinfo->buddy, SW_SHOW); 7644 ShowWindow(cinfo->buddy, SW_SHOW);
7645 SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0); 7645 SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0);
7646 } 7646 }
7647 } 7647 }
7648 #ifdef TOOLBAR 7648 #ifdef TOOLBAR
7649 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0) 7649 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
7650 { 7650 {
7651 #ifdef AEROGLASS 7651 #ifdef AEROGLASS
7652 if(!(_dw_composition && (GetWindowLongPtr(_toplevel_window(box), GWL_EXSTYLE) & WS_EX_LAYERED))) 7652 if(!(_dw_composition && (GetWindowLongPtr(_toplevel_window(box), GWL_EXSTYLE) & WS_EX_LAYERED)))
7653 #endif 7653 #endif
7654 { 7654 {
7655 /* Enable double buffering if our window isn't composited */ 7655 /* Enable double buffering if our window isn't composited */
7656 SendMessage(item, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_DOUBLEBUFFER); 7656 SendMessage(item, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_DOUBLEBUFFER);
7657 } 7657 }
7658 } 7658 }
7659 #endif 7659 #endif
7660 /* Queue a redraw on the top-level window */ 7660 /* Queue a redraw on the top-level window */
7661 _dw_redraw(_toplevel_window(box), TRUE); 7661 _dw_redraw(_toplevel_window(box), TRUE);
7662 } 7662 }
7663 } 7663 }
7664 7664
7670 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. 7670 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
7671 */ 7671 */
7672 int API dw_box_unpack(HWND handle) 7672 int API dw_box_unpack(HWND handle)
7673 { 7673 {
7674 HWND parent = GetParent(handle); 7674 HWND parent = GetParent(handle);
7675 7675
7676 if(handle && parent != HWND_DESKTOP) 7676 if(handle && parent != HWND_DESKTOP)
7677 { 7677 {
7678 Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA); 7678 Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA);
7679 7679
7680 /* If the parent box has items... 7680 /* If the parent box has items...
7681 * try to remove it from the layout 7681 * try to remove it from the layout
7682 */ 7682 */
7683 if(thisbox && thisbox->count) 7683 if(thisbox && thisbox->count)
7684 { 7684 {
7685 int z, index = -1; 7685 int z, index = -1;
7686 Item *tmpitem = NULL, *thisitem = thisbox->items; 7686 Item *tmpitem = NULL, *thisitem = thisbox->items;
7738 * Handle to the removed item on success, 0 on failure or padding. 7738 * Handle to the removed item on success, 0 on failure or padding.
7739 */ 7739 */
7740 HWND API dw_box_unpack_at_index(HWND box, int index) 7740 HWND API dw_box_unpack_at_index(HWND box, int index)
7741 { 7741 {
7742 Box *thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA); 7742 Box *thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA);
7743 7743
7744 /* Try to remove it from the layout */ 7744 /* Try to remove it from the layout */
7745 if(thisbox && index > -1 && index < thisbox->count) 7745 if(thisbox && index > -1 && index < thisbox->count)
7746 { 7746 {
7747 int z; 7747 int z;
7748 Item *tmpitem = NULL, *thisitem = thisbox->items; 7748 Item *tmpitem = NULL, *thisitem = thisbox->items;
7838 * children before realization. Only applicable when width or height is less than one. 7838 * children before realization. Only applicable when width or height is less than one.
7839 */ 7839 */
7840 void _get_window_for_size(HWND handle, unsigned long *width, unsigned long *height) 7840 void _get_window_for_size(HWND handle, unsigned long *width, unsigned long *height)
7841 { 7841 {
7842 Box *thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); 7842 Box *thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
7843 7843
7844 if(thisbox) 7844 if(thisbox)
7845 { 7845 {
7846 int depth = 0; 7846 int depth = 0;
7847 DWORD dwStyle = GetWindowLong(handle, GWL_STYLE); 7847 DWORD dwStyle = GetWindowLong(handle, GWL_STYLE);
7848 DWORD dwExStyle = GetWindowLong(handle, GWL_EXSTYLE); 7848 DWORD dwExStyle = GetWindowLong(handle, GWL_EXSTYLE);
7849 HMENU menu = GetMenu(handle) ; 7849 HMENU menu = GetMenu(handle) ;
7850 RECT rc = { 0 } ; 7850 RECT rc = { 0 } ;
7851 7851
7852 /* Calculate space requirements */ 7852 /* Calculate space requirements */
7853 _resize_box(thisbox, &depth, *width, *height, 1); 7853 _resize_box(thisbox, &depth, *width, *height, 1);
7854 7854
7855 rc.right = thisbox->minwidth; 7855 rc.right = thisbox->minwidth;
7856 rc.bottom = thisbox->minheight; 7856 rc.bottom = thisbox->minheight;
7857 7857
7858 /* Take into account the window border and menu here */ 7858 /* Take into account the window border and menu here */
7859 AdjustWindowRectEx(&rc, dwStyle, menu ? TRUE : FALSE, dwExStyle); 7859 AdjustWindowRectEx(&rc, dwStyle, menu ? TRUE : FALSE, dwExStyle);
7860 7860
7861 if ( *width < 1 ) *width = rc.right - rc.left; 7861 if ( *width < 1 ) *width = rc.right - rc.left;
7862 if ( *height < 1 ) *height = rc.bottom - rc.top; 7862 if ( *height < 1 ) *height = rc.bottom - rc.top;
7863 } 7863 }
7864 } 7864 }
7865 7865
7873 void API dw_window_set_size(HWND handle, ULONG width, ULONG height) 7873 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
7874 { 7874 {
7875 /* Attempt to auto-size */ 7875 /* Attempt to auto-size */
7876 if ( width < 1 || height < 1 ) 7876 if ( width < 1 || height < 1 )
7877 _get_window_for_size(handle, &width, &height); 7877 _get_window_for_size(handle, &width, &height);
7878 7878
7879 /* Finally set the size */ 7879 /* Finally set the size */
7880 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE); 7880 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
7881 } 7881 }
7882 7882
7883 /* 7883 /*
7890 void API dw_window_get_preferred_size(HWND handle, int *width, int *height) 7890 void API dw_window_get_preferred_size(HWND handle, int *width, int *height)
7891 { 7891 {
7892 TCHAR tmpbuf[100] = {0}; 7892 TCHAR tmpbuf[100] = {0};
7893 7893
7894 GetClassName(handle, tmpbuf, 99); 7894 GetClassName(handle, tmpbuf, 99);
7895 7895
7896 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1) == 0) 7896 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1) == 0)
7897 { 7897 {
7898 unsigned long thiswidth = 0, thisheight = 0; 7898 unsigned long thiswidth = 0, thisheight = 0;
7899 7899
7900 /* Get the size with the border */ 7900 /* Get the size with the border */
7901 _get_window_for_size(handle, &thiswidth, &thisheight); 7901 _get_window_for_size(handle, &thiswidth, &thisheight);
7902 7902
7903 /* Return what was requested */ 7903 /* Return what was requested */
7904 if(width) *width = (int)thiswidth; 7904 if(width) *width = (int)thiswidth;
7905 if(height) *height = (int)thisheight; 7905 if(height) *height = (int)thisheight;
7906 } 7906 }
7907 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0) 7907 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0)
7908 { 7908 {
7909 Box *thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); 7909 Box *thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
7910 7910
7911 if(thisbox) 7911 if(thisbox)
7912 { 7912 {
7913 int depth = 0; 7913 int depth = 0;
7914 7914
7915 /* Calculate space requirements */ 7915 /* Calculate space requirements */
7916 _resize_box(thisbox, &depth, 0, 0, 1); 7916 _resize_box(thisbox, &depth, 0, 0, 1);
7917 7917
7918 /* Return what was requested */ 7918 /* Return what was requested */
7919 if(width) *width = thisbox->minwidth; 7919 if(width) *width = thisbox->minwidth;
7920 if(height) *height = thisbox->minheight; 7920 if(height) *height = thisbox->minheight;
7921 } 7921 }
7922 } 7922 }
7970 /* Convert the coordinates based on gravity */ 7970 /* Convert the coordinates based on gravity */
7971 void _handle_gravity(HWND handle, long *x, long *y, unsigned long width, unsigned long height) 7971 void _handle_gravity(HWND handle, long *x, long *y, unsigned long width, unsigned long height)
7972 { 7972 {
7973 int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz")); 7973 int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz"));
7974 int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert")); 7974 int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert"));
7975 7975
7976 /* Do any gravity calculations */ 7976 /* Do any gravity calculations */
7977 if(horz || vert) 7977 if(horz || vert)
7978 { 7978 {
7979 long newx = *x, newy = *y; 7979 long newx = *x, newy = *y;
7980 7980
7981 /* Handle horizontal center gravity */ 7981 /* Handle horizontal center gravity */
7982 if((horz & 0xf) == DW_GRAV_CENTER) 7982 if((horz & 0xf) == DW_GRAV_CENTER)
7983 newx += ((dw_screen_width() / 2) - (width / 2)); 7983 newx += ((dw_screen_width() / 2) - (width / 2));
7984 /* Handle right gravity */ 7984 /* Handle right gravity */
7985 else if((horz & 0xf) == DW_GRAV_RIGHT) 7985 else if((horz & 0xf) == DW_GRAV_RIGHT)
7987 /* Handle vertical center gravity */ 7987 /* Handle vertical center gravity */
7988 if((vert & 0xf) == DW_GRAV_CENTER) 7988 if((vert & 0xf) == DW_GRAV_CENTER)
7989 newy += ((dw_screen_height() / 2) - (height / 2)); 7989 newy += ((dw_screen_height() / 2) - (height / 2));
7990 else if((vert & 0xf) == DW_GRAV_BOTTOM) 7990 else if((vert & 0xf) == DW_GRAV_BOTTOM)
7991 newy = dw_screen_height() - height - *y; 7991 newy = dw_screen_height() - height - *y;
7992 7992
7993 /* Save the new values */ 7993 /* Save the new values */
7994 *x = newx; 7994 *x = newx;
7995 *y = newy; 7995 *y = newy;
7996 7996
7997 /* Adjust the values to avoid Taskbar if requested */ 7997 /* Adjust the values to avoid Taskbar if requested */
7998 if((horz | vert) & DW_GRAV_OBSTACLES) 7998 if((horz | vert) & DW_GRAV_OBSTACLES)
7999 { 7999 {
8000 POINT pt = { 0, 0 }; 8000 POINT pt = { 0, 0 };
8001 HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY); 8001 HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
8002 MONITORINFO mi; 8002 MONITORINFO mi;
8003 8003
8004 mi.cbSize = sizeof(MONITORINFO); 8004 mi.cbSize = sizeof(MONITORINFO);
8005 8005
8006 GetMonitorInfo(mon, &mi); 8006 GetMonitorInfo(mon, &mi);
8007 8007
8008 if(horz & DW_GRAV_OBSTACLES) 8008 if(horz & DW_GRAV_OBSTACLES)
8009 { 8009 {
8010 if((horz & 0xf) == DW_GRAV_LEFT) 8010 if((horz & 0xf) == DW_GRAV_LEFT)
8011 *x += (mi.rcWork.left - mi.rcMonitor.left); 8011 *x += (mi.rcWork.left - mi.rcMonitor.left);
8012 else if((horz & 0xf) == DW_GRAV_RIGHT) 8012 else if((horz & 0xf) == DW_GRAV_RIGHT)
8018 *y += (mi.rcWork.top - mi.rcMonitor.top); 8018 *y += (mi.rcWork.top - mi.rcMonitor.top);
8019 else if((vert & 0xf) == DW_GRAV_BOTTOM) 8019 else if((vert & 0xf) == DW_GRAV_BOTTOM)
8020 *y -= (mi.rcMonitor.bottom - mi.rcWork.bottom); 8020 *y -= (mi.rcMonitor.bottom - mi.rcWork.bottom);
8021 } 8021 }
8022 } 8022 }
8023 } 8023 }
8024 } 8024 }
8025 8025
8026 /* 8026 /*
8027 * Sets the position of a given window (widget). 8027 * Sets the position of a given window (widget).
8028 * Parameters: 8028 * Parameters:
8058 void API dw_window_set_pos_size(HWND handle, long x, long y, ULONG width, ULONG height) 8058 void API dw_window_set_pos_size(HWND handle, long x, long y, ULONG width, ULONG height)
8059 { 8059 {
8060 /* Attempt to auto-size */ 8060 /* Attempt to auto-size */
8061 if ( width < 1 || height < 1 ) 8061 if ( width < 1 || height < 1 )
8062 _get_window_for_size(handle, &width, &height); 8062 _get_window_for_size(handle, &width, &height);
8063 8063
8064 _handle_gravity(handle, &x, &y, width, height); 8064 _handle_gravity(handle, &x, &y, width, height);
8065 /* Finally set the size */ 8065 /* Finally set the size */
8066 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE); 8066 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
8067 } 8067 }
8068 8068
8125 if(handle < (HWND)65536) 8125 if(handle < (HWND)65536)
8126 { 8126 {
8127 char buffer[31] = {0}; 8127 char buffer[31] = {0};
8128 HMENU mymenu; 8128 HMENU mymenu;
8129 ULONG id = (ULONG)(uintptr_t)handle; 8129 ULONG id = (ULONG)(uintptr_t)handle;
8130 8130
8131 _snprintf(buffer, 30, "_dw_id%ld", id); 8131 _snprintf(buffer, 30, "_dw_id%ld", id);
8132 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer); 8132 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer);
8133 8133
8134 if(mymenu && IsMenu(mymenu)) 8134 if(mymenu && IsMenu(mymenu))
8135 dw_menu_item_set_state((HMENUI)mymenu, id, style & mask); 8135 dw_menu_item_set_state((HMENUI)mymenu, id, style & mask);
8136 return; 8136 return;
8137 } 8137 }
8138 8138
8139 GetClassName(handle, tmpbuf, 99); 8139 GetClassName(handle, tmpbuf, 99);
8140 8140
8141 currentstyle = GetWindowLong(handle, GWL_STYLE); 8141 currentstyle = GetWindowLong(handle, GWL_STYLE);
8142 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); 8142 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
8143 8143
8144 #ifdef TOOLBAR 8144 #ifdef TOOLBAR
8145 /* Bitmap Buttons */ 8145 /* Bitmap Buttons */
8146 if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0) 8146 if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
8147 { 8147 {
8148 ULONG thisstyle = (TBSTYLE_FLAT | TBSTYLE_TRANSPARENT); 8148 ULONG thisstyle = (TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
8149 8149
8150 if(mask & DW_BS_NOBORDER) 8150 if(mask & DW_BS_NOBORDER)
8151 { 8151 {
8152 SetWindowLong(handle, GWL_STYLE, (style & DW_BS_NOBORDER) ? (currentstyle | thisstyle) : (currentstyle & ~thisstyle)); 8152 SetWindowLong(handle, GWL_STYLE, (style & DW_BS_NOBORDER) ? (currentstyle | thisstyle) : (currentstyle & ~thisstyle));
8153 8153
8154 /* Enable or disable visual themese */ 8154 /* Enable or disable visual themese */
8155 if(_SetWindowTheme) 8155 if(_SetWindowTheme)
8156 _SetWindowTheme(handle, (style & DW_BS_NOBORDER) ? NULL : L"", (style & DW_BS_NOBORDER) ? NULL : L""); 8156 _SetWindowTheme(handle, (style & DW_BS_NOBORDER) ? NULL : L"", (style & DW_BS_NOBORDER) ? NULL : L"");
8157 8157
8158 return; 8158 return;
8159 } 8159 }
8160 } 8160 }
8161 #endif 8161 #endif
8162 8162
8163 tmp = currentstyle | mask; 8163 tmp = currentstyle | mask;
8164 tmp ^= mask; 8164 tmp ^= mask;
8165 tmp |= style & mask; 8165 tmp |= style & mask;
8166 8166
8167 /* Drop out for status bar, it currently doesn't accept styles on Windows */ 8167 /* Drop out for status bar, it currently doesn't accept styles on Windows */
8168 if(_tcsnicmp(tmpbuf, StatusbarClassName, _tcslen(StatusbarClassName)+1)==0) 8168 if(_tcsnicmp(tmpbuf, StatusbarClassName, _tcslen(StatusbarClassName)+1)==0)
8169 return; 8169 return;
8170 else if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0) 8170 else if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0)
8171 { 8171 {
8172 tmp = tmp & 0xffff0000; 8172 tmp = tmp & 0xffff0000;
8173 #ifdef AEROGLASS 8173 #ifdef AEROGLASS
8174 if(mask & DW_FCF_COMPOSITED && _DwmExtendFrameIntoClientArea && _dw_composition) 8174 if(mask & DW_FCF_COMPOSITED && _DwmExtendFrameIntoClientArea && _dw_composition)
8175 { 8175 {
8176 LONG_PTR styleex = GetWindowLongPtr(handle, GWL_EXSTYLE); 8176 LONG_PTR styleex = GetWindowLongPtr(handle, GWL_EXSTYLE);
8177 8177
8178 if(style & DW_FCF_COMPOSITED) 8178 if(style & DW_FCF_COMPOSITED)
8179 { 8179 {
8180 MARGINS mar = {-1}; 8180 MARGINS mar = {-1};
8181 8181
8182 /* Attempt to enable Aero glass background on the entire window */ 8182 /* Attempt to enable Aero glass background on the entire window */
8183 SetWindowLongPtr(handle, GWL_EXSTYLE, styleex | WS_EX_LAYERED); 8183 SetWindowLongPtr(handle, GWL_EXSTYLE, styleex | WS_EX_LAYERED);
8184 SetLayeredWindowAttributes(handle, _dw_transparencykey, 0, LWA_COLORKEY); 8184 SetLayeredWindowAttributes(handle, _dw_transparencykey, 0, LWA_COLORKEY);
8185 _DwmExtendFrameIntoClientArea(handle, &mar); 8185 _DwmExtendFrameIntoClientArea(handle, &mar);
8186 } 8186 }
8187 else 8187 else
8188 { 8188 {
8189 MARGINS mar = {0}; 8189 MARGINS mar = {0};
8190 8190
8191 /* Remove Aero Glass */ 8191 /* Remove Aero Glass */
8192 SetWindowLongPtr(handle, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED); 8192 SetWindowLongPtr(handle, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED);
8193 _DwmExtendFrameIntoClientArea(handle, &mar); 8193 _DwmExtendFrameIntoClientArea(handle, &mar);
8194 } 8194 }
8195 } 8195 }
8196 #endif 8196 #endif
8197 } 8197 }
8198 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0) 8198 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0)
8199 { 8199 {
8200 ULONG thismask = mask & ~(DW_DT_VCENTER | DW_DT_WORDBREAK); 8200 ULONG thismask = mask & ~(DW_DT_VCENTER | DW_DT_WORDBREAK);
8201 ULONG thisstyle = style & ~(DW_DT_VCENTER | DW_DT_WORDBREAK); 8201 ULONG thisstyle = style & ~(DW_DT_VCENTER | DW_DT_WORDBREAK);
8202 ULONG type = style & mask & 0xFL; 8202 ULONG type = style & mask & 0xFL;
8203 8203
8204 /* Need to filter out bits that shouldn't be set */ 8204 /* Need to filter out bits that shouldn't be set */
8205 tmp = currentstyle | thismask; 8205 tmp = currentstyle | thismask;
8206 tmp ^= thismask; 8206 tmp ^= thismask;
8207 tmp |= thisstyle & thismask; 8207 tmp |= thisstyle & thismask;
8208 8208
9055 else 9055 else
9056 { 9056 {
9057 if((dwComctlVer >= PACKVERSION(6,0))) 9057 if((dwComctlVer >= PACKVERSION(6,0)))
9058 { 9058 {
9059 unsigned long style = GetWindowLong(handle, GWL_STYLE); 9059 unsigned long style = GetWindowLong(handle, GWL_STYLE);
9060 9060
9061 if(style & PBS_MARQUEE) 9061 if(style & PBS_MARQUEE)
9062 { 9062 {
9063 /* Stop the bar */ 9063 /* Stop the bar */
9064 SendMessage(handle, PBM_SETMARQUEE, 0, 0); 9064 SendMessage(handle, PBM_SETMARQUEE, 0, 0);
9065 /* Disable the style on the control */ 9065 /* Disable the style on the control */
9687 static HWND lasthwnd = NULL; 9687 static HWND lasthwnd = NULL;
9688 9688
9689 /* We can't add an invalid handle */ 9689 /* We can't add an invalid handle */
9690 if(!hicon) 9690 if(!hicon)
9691 return -1; 9691 return -1;
9692 9692
9693 if(!hSmall || !hLarge) 9693 if(!hSmall || !hLarge)
9694 { 9694 {
9695 hSmall = ImageList_Create(16, 16, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0); 9695 hSmall = ImageList_Create(16, 16, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0);
9696 hLarge = ImageList_Create(32, 32, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0); 9696 hLarge = ImageList_Create(32, 32, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0);
9697 } 9697 }
9814 9814
9815 if(flags[column] & DW_CFA_BITMAPORICON) 9815 if(flags[column] & DW_CFA_BITMAPORICON)
9816 { 9816 {
9817 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE; 9817 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE;
9818 lvi.pszText = NULL; 9818 lvi.pszText = NULL;
9819 9819
9820 if(data) 9820 if(data)
9821 { 9821 {
9822 HICON hicon = *((HICON *)data); 9822 HICON hicon = *((HICON *)data);
9823 9823
9824 lvi.iImage = _lookup_icon(handle, hicon, 0); 9824 lvi.iImage = _lookup_icon(handle, hicon, 0);
10008 { 10008 {
10009 item = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_insertitem")); 10009 item = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_insertitem"));
10010 } 10010 }
10011 10011
10012 memset(&lvi, 0, sizeof(LV_ITEM)); 10012 memset(&lvi, 0, sizeof(LV_ITEM));
10013 10013
10014 lvi.iItem = row + item; 10014 lvi.iItem = row + item;
10015 lvi.mask = LVIF_PARAM; 10015 lvi.mask = LVIF_PARAM;
10016 10016
10017 if(ListView_GetItem(handle, &lvi)) 10017 if(ListView_GetItem(handle, &lvi))
10018 { 10018 {
10019 void **params = (void **)lvi.lParam; 10019 void **params = (void **)lvi.lParam;
10020 void *newparam = data; 10020 void *newparam = data;
10021 10021
10022 /* Make sure we have our pointer array... */ 10022 /* Make sure we have our pointer array... */
10023 if(!params) 10023 if(!params)
10024 { 10024 {
10025 /* If not allocate it */ 10025 /* If not allocate it */
10026 params = (void **)calloc(2, sizeof(void *)); 10026 params = (void **)calloc(2, sizeof(void *));
10031 * freeing any existing string. 10031 * freeing any existing string.
10032 */ 10032 */
10033 if(type == _DW_DATA_TYPE_STRING) 10033 if(type == _DW_DATA_TYPE_STRING)
10034 { 10034 {
10035 void *oldparam = params[type]; 10035 void *oldparam = params[type];
10036 10036
10037 params[type] = NULL; 10037 params[type] = NULL;
10038 10038
10039 if(oldparam) 10039 if(oldparam)
10040 free(oldparam); 10040 free(oldparam);
10041 if(newparam) 10041 if(newparam)
10042 newparam = _strdup((char *)newparam); 10042 newparam = _strdup((char *)newparam);
10043 } 10043 }
10174 int type = _DW_DATA_TYPE_STRING; 10174 int type = _DW_DATA_TYPE_STRING;
10175 char *retval = NULL; 10175 char *retval = NULL;
10176 10176
10177 if(_index == -1) 10177 if(_index == -1)
10178 return retval; 10178 return retval;
10179 10179
10180 if(flags & DW_CR_RETDATA) 10180 if(flags & DW_CR_RETDATA)
10181 type = _DW_DATA_TYPE_POINTER; 10181 type = _DW_DATA_TYPE_POINTER;
10182 10182
10183 memset(&lvi, 0, sizeof(LV_ITEM)); 10183 memset(&lvi, 0, sizeof(LV_ITEM));
10184 10184
10185 lvi.iItem = _index; 10185 lvi.iItem = _index;
10186 lvi.mask = LVIF_PARAM; 10186 lvi.mask = LVIF_PARAM;
10187 10187
10188 ListView_GetItem(handle, &lvi); 10188 ListView_GetItem(handle, &lvi);
10189 params = (void **)lvi.lParam; 10189 params = (void **)lvi.lParam;
10190 10190
10191 if(params) 10191 if(params)
10192 { 10192 {
10193 if(type == _DW_DATA_TYPE_STRING && params[type]) 10193 if(type == _DW_DATA_TYPE_STRING && params[type])
10194 retval = _strdup((char *)params[type]); 10194 retval = _strdup((char *)params[type]);
10195 else 10195 else
10221 if(_index == -1) 10221 if(_index == -1)
10222 return retval; 10222 return retval;
10223 10223
10224 if(flags & DW_CR_RETDATA) 10224 if(flags & DW_CR_RETDATA)
10225 type = _DW_DATA_TYPE_POINTER; 10225 type = _DW_DATA_TYPE_POINTER;
10226 10226
10227 memset(&lvi, 0, sizeof(LV_ITEM)); 10227 memset(&lvi, 0, sizeof(LV_ITEM));
10228 10228
10229 lvi.iItem = _index; 10229 lvi.iItem = _index;
10230 lvi.mask = LVIF_PARAM; 10230 lvi.mask = LVIF_PARAM;
10231 10231
10268 params = (void **)lvi.lParam; 10268 params = (void **)lvi.lParam;
10269 10269
10270 if ( params && params[_DW_DATA_TYPE_STRING] && strcmp( (char *)params[_DW_DATA_TYPE_STRING], text ) == 0 ) 10270 if ( params && params[_DW_DATA_TYPE_STRING] && strcmp( (char *)params[_DW_DATA_TYPE_STRING], text ) == 0 )
10271 { 10271 {
10272 unsigned long width, height; 10272 unsigned long width, height;
10273 10273
10274 ListView_SetItemState( handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED ); 10274 ListView_SetItemState( handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED );
10275 dw_window_get_pos_size( handle, NULL, NULL, &width, &height); 10275 dw_window_get_pos_size( handle, NULL, NULL, &width, &height);
10276 if(width < 10 || height < 10) 10276 if(width < 10 || height < 10)
10277 dw_window_set_data( handle, "_dw_cursor", DW_INT_TO_POINTER(index) ); 10277 dw_window_set_data( handle, "_dw_cursor", DW_INT_TO_POINTER(index) );
10278 ListView_EnsureVisible( handle, index, TRUE ); 10278 ListView_EnsureVisible( handle, index, TRUE );
10307 params = (void **)lvi.lParam; 10307 params = (void **)lvi.lParam;
10308 10308
10309 if ( params && params[_DW_DATA_TYPE_POINTER] == data ) 10309 if ( params && params[_DW_DATA_TYPE_POINTER] == data )
10310 { 10310 {
10311 unsigned long width, height; 10311 unsigned long width, height;
10312 10312
10313 ListView_SetItemState( handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED ); 10313 ListView_SetItemState( handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED );
10314 dw_window_get_pos_size( handle, NULL, NULL, &width, &height); 10314 dw_window_get_pos_size( handle, NULL, NULL, &width, &height);
10315 if(width < 10 || height < 10) 10315 if(width < 10 || height < 10)
10316 dw_window_set_data( handle, "_dw_cursor", DW_INT_TO_POINTER(index) ); 10316 dw_window_set_data( handle, "_dw_cursor", DW_INT_TO_POINTER(index) );
10317 ListView_EnsureVisible( handle, index, TRUE ); 10317 ListView_EnsureVisible( handle, index, TRUE );
10444 while(index != -1) 10444 while(index != -1)
10445 { 10445 {
10446 for(z=0;z<cinfo->columns;z++) 10446 for(z=0;z<cinfo->columns;z++)
10447 { 10447 {
10448 unsigned int width; 10448 unsigned int width;
10449 10449
10450 ListView_GetItemText(handle, index, z, text, 1023); 10450 ListView_GetItemText(handle, index, z, text, 1023);
10451 width = ListView_GetStringWidth(handle, text); 10451 width = ListView_GetStringWidth(handle, text);
10452 10452
10453 /* Figure extra space for the icon for the first column */ 10453 /* Figure extra space for the icon for the first column */
10454 if(z == 0) 10454 if(z == 0)
10460 10460
10461 index = ListView_GetNextItem(handle, index, LVNI_ALL); 10461 index = ListView_GetNextItem(handle, index, LVNI_ALL);
10462 } 10462 }
10463 10463
10464 /* Set the new sizes... Microsoft says we need to add 10464 /* Set the new sizes... Microsoft says we need to add
10465 * padding to the calculated sized but does not give 10465 * padding to the calculated sized but does not give
10466 * a value. Trial and error shows that 16 works for us. 10466 * a value. Trial and error shows that 16 works for us.
10467 */ 10467 */
10468 for(z=0;z<cinfo->columns;z++) 10468 for(z=0;z<cinfo->columns;z++)
10469 ListView_SetColumnWidth(handle, z, columns[z] + 16); 10469 ListView_SetColumnWidth(handle, z, columns[z] + 16);
10470 10470
10562 10562
10563 value = _internal_color(value); 10563 value = _internal_color(value);
10564 foreground = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); 10564 foreground = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
10565 #ifdef GDIPLUS 10565 #ifdef GDIPLUS
10566 gpfore = MAKEARGB(255, DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); 10566 gpfore = MAKEARGB(255, DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
10567 10567
10568 GdipDeletePen(pen); 10568 GdipDeletePen(pen);
10569 GdipCreatePen1(gpfore, 1.0, UnitPixel, &pen); 10569 GdipCreatePen1(gpfore, 1.0, UnitPixel, &pen);
10570 TlsSetValue(_gpPen, (LPVOID)pen); 10570 TlsSetValue(_gpPen, (LPVOID)pen);
10571 GdipSetSolidFillColor(brush, gpfore); 10571 GdipSetSolidFillColor(brush, gpfore);
10572 #endif 10572 #endif
10573 10573
10574 DeleteObject(hPen); 10574 DeleteObject(hPen);
10575 DeleteObject(hBrush); 10575 DeleteObject(hBrush);
10576 TlsSetValue(_foreground, (LPVOID)(uintptr_t)foreground); 10576 TlsSetValue(_foreground, (LPVOID)(uintptr_t)foreground);
10577 TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground)); 10577 TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground));
10633 * y: Y coordinate. 10633 * y: Y coordinate.
10634 */ 10634 */
10635 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) 10635 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
10636 { 10636 {
10637 #ifdef GDIPLUS 10637 #ifdef GDIPLUS
10638 /* There doesn't seem to be an equivalent to SetPixel in GDI+ ... 10638 /* There doesn't seem to be an equivalent to SetPixel in GDI+ ...
10639 * so instead we call dw_draw_rect() with 1 for width and height. 10639 * so instead we call dw_draw_rect() with 1 for width and height.
10640 */ 10640 */
10641 dw_draw_rect(handle, pixmap, DW_DRAW_FILL | DW_DRAW_NOAA, x, y, 1, 1); 10641 dw_draw_rect(handle, pixmap, DW_DRAW_FILL | DW_DRAW_NOAA, x, y, 1, 1);
10642 #else 10642 #else
10643 HDC hdcPaint; 10643 HDC hdcPaint;
10644 10644
10645 if(handle) 10645 if(handle)
10646 hdcPaint = GetDC(handle); 10646 hdcPaint = GetDC(handle);
10647 else if(pixmap) 10647 else if(pixmap)
10650 return; 10650 return;
10651 10651
10652 SetPixel(hdcPaint, x, y, (COLORREF)TlsGetValue(_foreground)); 10652 SetPixel(hdcPaint, x, y, (COLORREF)TlsGetValue(_foreground));
10653 if(!pixmap) 10653 if(!pixmap)
10654 ReleaseDC(handle, hdcPaint); 10654 ReleaseDC(handle, hdcPaint);
10655 #endif 10655 #endif
10656 } 10656 }
10657 10657
10658 /* Draw a line on a window (preferably a render window). 10658 /* Draw a line on a window (preferably a render window).
10659 * Parameters: 10659 * Parameters:
10660 * handle: Handle to the window. 10660 * handle: Handle to the window.
10667 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) 10667 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
10668 { 10668 {
10669 #ifdef GDIPLUS 10669 #ifdef GDIPLUS
10670 GpGraphics *graphics = NULL; 10670 GpGraphics *graphics = NULL;
10671 GpPen *pen = TlsGetValue(_gpPen); 10671 GpPen *pen = TlsGetValue(_gpPen);
10672 10672
10673 if(handle) 10673 if(handle)
10674 GdipCreateFromHWND(handle, &graphics); 10674 GdipCreateFromHWND(handle, &graphics);
10675 else if(pixmap) 10675 else if(pixmap)
10676 GdipCreateFromHDC(pixmap->hdc, &graphics); 10676 GdipCreateFromHDC(pixmap->hdc, &graphics);
10677 else 10677 else
10678 return; 10678 return;
10679 10679
10680 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias); 10680 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias);
10681 GdipDrawLineI(graphics, pen, x1, y1, x2, y2); 10681 GdipDrawLineI(graphics, pen, x1, y1, x2, y2);
10682 GdipDeleteGraphics(graphics); 10682 GdipDeleteGraphics(graphics);
10683 #else 10683 #else
10684 HDC hdcPaint; 10684 HDC hdcPaint;
10707 /* Internal function to generate POINT arrays used by Windows APIs */ 10707 /* Internal function to generate POINT arrays used by Windows APIs */
10708 POINT *_makePoints(int *npoints, int *x, int *y) 10708 POINT *_makePoints(int *npoints, int *x, int *y)
10709 { 10709 {
10710 POINT *points; 10710 POINT *points;
10711 int i; 10711 int i;
10712 10712
10713 /* 10713 /*
10714 * Allocate enough space for the number of points supplied plus 1. 10714 * Allocate enough space for the number of points supplied plus 1.
10715 * Under windows, unless the first and last points are the same 10715 * Under windows, unless the first and last points are the same
10716 * the polygon won't be closed 10716 * the polygon won't be closed
10717 */ 10717 */
10718 points = (POINT *)malloc( ((*npoints)+1) * sizeof(POINT) ); 10718 points = (POINT *)malloc( ((*npoints)+1) * sizeof(POINT) );
10719 10719
10720 if(points) 10720 if(points)
10721 { 10721 {
10722 for ( i = 0 ; i < *npoints ; i++ ) 10722 for ( i = 0 ; i < *npoints ; i++ )
10723 { 10723 {
10724 points[i].x = x[i]; 10724 points[i].x = x[i];
10747 * y[]: Y coordinates. 10747 * y[]: Y coordinates.
10748 */ 10748 */
10749 void API dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y) 10749 void API dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
10750 { 10750 {
10751 POINT *points = NULL; 10751 POINT *points = NULL;
10752 10752
10753 /* Sanity check */ 10753 /* Sanity check */
10754 if(npoints < 1) 10754 if(npoints < 1)
10755 return; 10755 return;
10756 10756
10757 #ifdef GDIPLUS 10757 #ifdef GDIPLUS
10758 { 10758 {
10759 GpGraphics *graphics = NULL; 10759 GpGraphics *graphics = NULL;
10760 10760
10761 if(handle) 10761 if(handle)
10762 GdipCreateFromHWND(handle, &graphics); 10762 GdipCreateFromHWND(handle, &graphics);
10763 else if(pixmap) 10763 else if(pixmap)
10764 GdipCreateFromHDC(pixmap->hdc, &graphics); 10764 GdipCreateFromHDC(pixmap->hdc, &graphics);
10765 else 10765 else
10766 return; 10766 return;
10767 10767
10768 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */ 10768 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */
10769 if(!(flags & DW_DRAW_NOAA)) 10769 if(!(flags & DW_DRAW_NOAA))
10770 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias); 10770 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias);
10771 10771
10772 if((points = _makePoints(&npoints, x, y))) 10772 if((points = _makePoints(&npoints, x, y)))
10773 { 10773 {
10774 if(flags & DW_DRAW_FILL) 10774 if(flags & DW_DRAW_FILL)
10775 { 10775 {
10776 GpBrush *brush = TlsGetValue(_gpBrush); 10776 GpBrush *brush = TlsGetValue(_gpBrush);
10777 10777
10778 GdipFillPolygon2I(graphics, brush, points, npoints); 10778 GdipFillPolygon2I(graphics, brush, points, npoints);
10779 } 10779 }
10780 else 10780 else
10781 { 10781 {
10782 GpPen *pen = TlsGetValue(_gpPen); 10782 GpPen *pen = TlsGetValue(_gpPen);
10783 10783
10784 GdipDrawPolygonI(graphics, pen, points, npoints); 10784 GdipDrawPolygonI(graphics, pen, points, npoints);
10785 } 10785 }
10786 } 10786 }
10787 GdipDeleteGraphics(graphics); 10787 GdipDeleteGraphics(graphics);
10788 } 10788 }
10789 #else 10789 #else
10790 { 10790 {
10791 HDC hdcPaint; 10791 HDC hdcPaint;
10792 10792
10793 if ( handle ) 10793 if ( handle )
10794 hdcPaint = GetDC( handle ); 10794 hdcPaint = GetDC( handle );
10795 else if ( pixmap ) 10795 else if ( pixmap )
10796 hdcPaint = pixmap->hdc; 10796 hdcPaint = pixmap->hdc;
10797 else 10797 else
10798 return; 10798 return;
10799 10799
10800 if((points = _makePoints(&npoints, x, y))) 10800 if((points = _makePoints(&npoints, x, y)))
10801 { 10801 {
10802 HBRUSH oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) ); 10802 HBRUSH oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) );
10803 HPEN oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) ); 10803 HPEN oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
10804 10804
10805 if ( flags & DW_DRAW_FILL ) 10805 if ( flags & DW_DRAW_FILL )
10806 Polygon( hdcPaint, points, npoints ); 10806 Polygon( hdcPaint, points, npoints );
10807 else 10807 else
10808 Polyline( hdcPaint, points, npoints ); 10808 Polyline( hdcPaint, points, npoints );
10809 10809
10810 SelectObject( hdcPaint, oldBrush ); 10810 SelectObject( hdcPaint, oldBrush );
10811 SelectObject( hdcPaint, oldPen ); 10811 SelectObject( hdcPaint, oldPen );
10812 } 10812 }
10813 10813
10814 if ( !pixmap ) 10814 if ( !pixmap )
10815 ReleaseDC( handle, hdcPaint ); 10815 ReleaseDC( handle, hdcPaint );
10816 } 10816 }
10817 #endif 10817 #endif
10818 if(points) 10818 if(points)
10819 free(points); 10819 free(points);
10820 } 10820 }
10821 10821
10822 /* Draw a rectangle on a window (preferably a render window). 10822 /* Draw a rectangle on a window (preferably a render window).
10831 */ 10831 */
10832 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height) 10832 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
10833 { 10833 {
10834 #ifdef GDIPLUS 10834 #ifdef GDIPLUS
10835 GpGraphics *graphics = NULL; 10835 GpGraphics *graphics = NULL;
10836 10836
10837 if(handle) 10837 if(handle)
10838 GdipCreateFromHWND(handle, &graphics); 10838 GdipCreateFromHWND(handle, &graphics);
10839 else if(pixmap) 10839 else if(pixmap)
10840 GdipCreateFromHDC(pixmap->hdc, &graphics); 10840 GdipCreateFromHDC(pixmap->hdc, &graphics);
10841 else 10841 else
10842 return; 10842 return;
10843 10843
10844 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */ 10844 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */
10845 if(!(flags & DW_DRAW_NOAA)) 10845 if(!(flags & DW_DRAW_NOAA))
10846 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias); 10846 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias);
10847 10847
10848 if(flags & DW_DRAW_FILL) 10848 if(flags & DW_DRAW_FILL)
10849 { 10849 {
10850 GpBrush *brush = TlsGetValue(_gpBrush); 10850 GpBrush *brush = TlsGetValue(_gpBrush);
10851 10851
10852 GdipFillRectangleI(graphics, brush, x, y, width, height); 10852 GdipFillRectangleI(graphics, brush, x, y, width, height);
10853 } 10853 }
10854 else 10854 else
10855 { 10855 {
10856 GpPen *pen = TlsGetValue(_gpPen); 10856 GpPen *pen = TlsGetValue(_gpPen);
10857 10857
10858 GdipDrawRectangleI(graphics, pen, x, y, width, height); 10858 GdipDrawRectangleI(graphics, pen, x, y, width, height);
10859 } 10859 }
10860 GdipDeleteGraphics(graphics); 10860 GdipDeleteGraphics(graphics);
10861 #else 10861 #else
10862 HDC hdcPaint; 10862 HDC hdcPaint;
10874 FillRect(hdcPaint, &Rect, TlsGetValue(_hBrush)); 10874 FillRect(hdcPaint, &Rect, TlsGetValue(_hBrush));
10875 else 10875 else
10876 FrameRect(hdcPaint, &Rect, TlsGetValue(_hBrush)); 10876 FrameRect(hdcPaint, &Rect, TlsGetValue(_hBrush));
10877 if(!pixmap) 10877 if(!pixmap)
10878 ReleaseDC(handle, hdcPaint); 10878 ReleaseDC(handle, hdcPaint);
10879 #endif 10879 #endif
10880 } 10880 }
10881 10881
10882 /* Draw an arc on a window (preferably a render window). 10882 /* Draw an arc on a window (preferably a render window).
10883 * Parameters: 10883 * Parameters:
10884 * handle: Handle to the window. 10884 * handle: Handle to the window.
10895 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) 10895 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2)
10896 { 10896 {
10897 #ifdef GDIPLUS 10897 #ifdef GDIPLUS
10898 GpGraphics *graphics = NULL; 10898 GpGraphics *graphics = NULL;
10899 GpPen *pen = TlsGetValue(_gpPen); 10899 GpPen *pen = TlsGetValue(_gpPen);
10900 10900
10901 if(handle) 10901 if(handle)
10902 GdipCreateFromHWND(handle, &graphics); 10902 GdipCreateFromHWND(handle, &graphics);
10903 else if(pixmap) 10903 else if(pixmap)
10904 GdipCreateFromHDC(pixmap->hdc, &graphics); 10904 GdipCreateFromHDC(pixmap->hdc, &graphics);
10905 else 10905 else
10906 return; 10906 return;
10907 10907
10908 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */ 10908 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */
10909 if(!(flags & DW_DRAW_NOAA)) 10909 if(!(flags & DW_DRAW_NOAA))
10910 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias); 10910 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias);
10911 10911
10912 if(flags & DW_DRAW_FULL) 10912 if(flags & DW_DRAW_FULL)
10913 { 10913 {
10914 if(flags & DW_DRAW_FILL) 10914 if(flags & DW_DRAW_FILL)
10915 { 10915 {
10916 GpBrush *brush = TlsGetValue(_gpBrush); 10916 GpBrush *brush = TlsGetValue(_gpBrush);
10917 10917
10918 GdipFillEllipseI(graphics, brush, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2)); 10918 GdipFillEllipseI(graphics, brush, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2));
10919 } 10919 }
10920 else 10920 else
10921 GdipDrawEllipseI(graphics, pen, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2)); 10921 GdipDrawEllipseI(graphics, pen, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2));
10922 } 10922 }
10927 double dx = xorigin - x1; 10927 double dx = xorigin - x1;
10928 double dy = yorigin - y1; 10928 double dy = yorigin - y1;
10929 double r = sqrt(dx*dx + dy*dy); 10929 double r = sqrt(dx*dx + dy*dy);
10930 double sweep; 10930 double sweep;
10931 int ri = (int)r; 10931 int ri = (int)r;
10932 10932
10933 /* Convert to degrees */ 10933 /* Convert to degrees */
10934 a1 *= (180.0 / M_PI); 10934 a1 *= (180.0 / M_PI);
10935 a2 *= (180.0 / M_PI); 10935 a2 *= (180.0 / M_PI);
10936 sweep = fabs(a1 - a2); 10936 sweep = fabs(a1 - a2);
10937 10937
10938 GdipDrawArcI(graphics, pen, xorigin-ri, yorigin-ri, ri*2, ri*2, (REAL)a1, (REAL)sweep); 10938 GdipDrawArcI(graphics, pen, xorigin-ri, yorigin-ri, ri*2, ri*2, (REAL)a1, (REAL)sweep);
10939 } 10939 }
10940 GdipDeleteGraphics(graphics); 10940 GdipDeleteGraphics(graphics);
10941 #else 10941 #else
10942 HDC hdcPaint; 10942 HDC hdcPaint;
10943 HBRUSH oldBrush; 10943 HBRUSH oldBrush;
10944 HPEN oldPen; 10944 HPEN oldPen;
10945 double dx = xorigin - x1; 10945 double dx = xorigin - x1;
10946 double dy = yorigin - y1; 10946 double dy = yorigin - y1;
10951 hdcPaint = GetDC(handle); 10951 hdcPaint = GetDC(handle);
10952 else if(pixmap) 10952 else if(pixmap)
10953 hdcPaint = pixmap->hdc; 10953 hdcPaint = pixmap->hdc;
10954 else 10954 else
10955 return; 10955 return;
10956 10956
10957 if(flags & DW_DRAW_FILL) 10957 if(flags & DW_DRAW_FILL)
10958 oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) ); 10958 oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) );
10959 else 10959 else
10960 oldBrush = SelectObject( hdcPaint, GetStockObject(HOLLOW_BRUSH) ); 10960 oldBrush = SelectObject( hdcPaint, GetStockObject(HOLLOW_BRUSH) );
10961 oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) ); 10961 oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
10962 if(flags & DW_DRAW_FULL) 10962 if(flags & DW_DRAW_FULL)
10966 SelectObject( hdcPaint, oldBrush ); 10966 SelectObject( hdcPaint, oldBrush );
10967 SelectObject( hdcPaint, oldPen ); 10967 SelectObject( hdcPaint, oldPen );
10968 10968
10969 if(!pixmap) 10969 if(!pixmap)
10970 ReleaseDC(handle, hdcPaint); 10970 ReleaseDC(handle, hdcPaint);
10971 #endif 10971 #endif
10972 } 10972 }
10973 10973
10974 #ifdef GDIPLUS 10974 #ifdef GDIPLUS
10975 /* Internal function to increase or decrease coordinates/sizes 10975 /* Internal function to increase or decrease coordinates/sizes
10976 * by the difference of the screen DPI (96) and the context DPI. 10976 * by the difference of the screen DPI (96) and the context DPI.
11413 int API dw_pixmap_set_font(HPIXMAP pixmap, const char *fontname) 11413 int API dw_pixmap_set_font(HPIXMAP pixmap, const char *fontname)
11414 { 11414 {
11415 if(pixmap) 11415 if(pixmap)
11416 { 11416 {
11417 HFONT hfont = _acquire_font2(pixmap->hdc, fontname); 11417 HFONT hfont = _acquire_font2(pixmap->hdc, fontname);
11418 11418
11419 if(hfont) 11419 if(hfont)
11420 { 11420 {
11421 HFONT oldfont = pixmap->font; 11421 HFONT oldfont = pixmap->font;
11422 pixmap->font = hfont; 11422 pixmap->font = hfont;
11423 if(oldfont) 11423 if(oldfont)
11519 _convert_dpi(hdcdest, &xdest, &ydest, TRUE); 11519 _convert_dpi(hdcdest, &xdest, &ydest, TRUE);
11520 _convert_dpi(hdcdest, &width, &height, TRUE); 11520 _convert_dpi(hdcdest, &width, &height, TRUE);
11521 _convert_dpi(hdcsrc, &xsrc, &ysrc, TRUE); 11521 _convert_dpi(hdcsrc, &xsrc, &ysrc, TRUE);
11522 _convert_dpi(hdcsrc, &swidth, &sheight, TRUE); 11522 _convert_dpi(hdcsrc, &swidth, &sheight, TRUE);
11523 #endif 11523 #endif
11524 11524
11525 /* If it is a 32bpp bitmap (with alpha) use AlphaBlend unless it fails */ 11525 /* If it is a 32bpp bitmap (with alpha) use AlphaBlend unless it fails */
11526 if ( srcp && srcp->depth == 32 && AlphaBlend( hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, swidth, sheight, bf ) ) 11526 if ( srcp && srcp->depth == 32 && AlphaBlend( hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, swidth, sheight, bf ) )
11527 { 11527 {
11528 /* Don't do anything */ 11528 /* Don't do anything */
11529 } 11529 }
11908 UnmapViewOfFile(ptr); 11908 UnmapViewOfFile(ptr);
11909 CloseHandle(handle); 11909 CloseHandle(handle);
11910 return 0; 11910 return 0;
11911 } 11911 }
11912 11912
11913 /* 11913 /*
11914 * Generally an internal function called from a newly created 11914 * Generally an internal function called from a newly created
11915 * thread to setup the Dynamic Windows environment for the thread. 11915 * thread to setup the Dynamic Windows environment for the thread.
11916 * However it is exported so language bindings can call it when 11916 * However it is exported so language bindings can call it when
11917 * they create threads that require access to Dynamic Windows. 11917 * they create threads that require access to Dynamic Windows.
11918 */ 11918 */
11922 COLORREF background = DW_RGB_TRANSPARENT; 11922 COLORREF background = DW_RGB_TRANSPARENT;
11923 #ifdef GDIPLUS 11923 #ifdef GDIPLUS
11924 ARGB gpfore = MAKEARGB(255, 128, 128, 128); 11924 ARGB gpfore = MAKEARGB(255, 128, 128, 128);
11925 GpBrush *brush; 11925 GpBrush *brush;
11926 GpPen *pen; 11926 GpPen *pen;
11927 11927
11928 GdipCreatePen1(gpfore, 1.0, UnitPixel, &pen); 11928 GdipCreatePen1(gpfore, 1.0, UnitPixel, &pen);
11929 TlsSetValue(_gpPen, (LPVOID)pen); 11929 TlsSetValue(_gpPen, (LPVOID)pen);
11930 GdipCreateSolidFill(gpfore, &brush); 11930 GdipCreateSolidFill(gpfore, &brush);
11931 TlsSetValue(_gpBrush, brush); 11931 TlsSetValue(_gpBrush, brush);
11932 #endif 11932 #endif
11933 TlsSetValue(_foreground, DW_UINT_TO_POINTER(foreground)); 11933 TlsSetValue(_foreground, DW_UINT_TO_POINTER(foreground));
11934 TlsSetValue(_background, DW_UINT_TO_POINTER(background)); 11934 TlsSetValue(_background, DW_UINT_TO_POINTER(background));
11935 TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground)); 11935 TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground));
11936 TlsSetValue(_hBrush, CreateSolidBrush(foreground)); 11936 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
11937 } 11937 }
11938 11938
11939 /* 11939 /*
11940 * Generally an internal function called from a terminating 11940 * Generally an internal function called from a terminating
11941 * thread to cleanup the Dynamic Windows environment for the thread. 11941 * thread to cleanup the Dynamic Windows environment for the thread.
11942 * However it is exported so language bindings can call it when 11942 * However it is exported so language bindings can call it when
11943 * they exit threads that require access to Dynamic Windows. 11943 * they exit threads that require access to Dynamic Windows.
11944 */ 11944 */
11947 HPEN hPen; 11947 HPEN hPen;
11948 HBRUSH hBrush; 11948 HBRUSH hBrush;
11949 #ifdef GDIPLUS 11949 #ifdef GDIPLUS
11950 GpBrush *brush; 11950 GpBrush *brush;
11951 GpPen *pen; 11951 GpPen *pen;
11952 #endif 11952 #endif
11953 11953
11954 if((hPen = TlsGetValue(_hPen))) 11954 if((hPen = TlsGetValue(_hPen)))
11955 DeleteObject(hPen); 11955 DeleteObject(hPen);
11956 if((hBrush = TlsGetValue(_hBrush))) 11956 if((hBrush = TlsGetValue(_hBrush)))
11957 DeleteObject(hBrush); 11957 DeleteObject(hBrush);
11958 #ifdef GDIPLUS 11958 #ifdef GDIPLUS
11959 if((brush = TlsGetValue(_gpBrush))) 11959 if((brush = TlsGetValue(_gpBrush)))
11960 GdipDeleteBrush(brush); 11960 GdipDeleteBrush(brush);
11961 if((pen = TlsGetValue(_gpPen))) 11961 if((pen = TlsGetValue(_gpPen)))
11962 GdipDeletePen(pen); 11962 GdipDeletePen(pen);
11963 #endif 11963 #endif
11964 } 11964 }
11965 11965
11966 /* 11966 /*
11967 * Encapsulate thread creation on Win32. 11967 * Encapsulate thread creation on Win32.
11968 */ 11968 */
12031 { 12031 {
12032 OleUninitialize(); 12032 OleUninitialize();
12033 #ifdef AEROGLASS 12033 #ifdef AEROGLASS
12034 /* Free any in use libraries */ 12034 /* Free any in use libraries */
12035 FreeLibrary(hdwm); 12035 FreeLibrary(hdwm);
12036 #endif 12036 #endif
12037 FreeLibrary(huxtheme); 12037 FreeLibrary(huxtheme);
12038 DestroyWindow(hwndTooltip); 12038 DestroyWindow(hwndTooltip);
12039 } 12039 }
12040 12040
12041 /* 12041 /*
12213 /* Internal function to set the focus from the window thread */ 12213 /* Internal function to set the focus from the window thread */
12214 void _dw_set_focus(HWND handle) 12214 void _dw_set_focus(HWND handle)
12215 { 12215 {
12216 SetFocus(handle); 12216 SetFocus(handle);
12217 } 12217 }
12218 12218
12219 /* 12219 /*
12220 * Sets the current focus item for a window/dialog. 12220 * Sets the current focus item for a window/dialog.
12221 * Parameters: 12221 * Parameters:
12222 * handle: Handle to the dialog item to be focused. 12222 * handle: Handle to the dialog item to be focused.
12223 * Remarks: 12223 * Remarks:
12276 HANDLE handle; 12276 HANDLE handle;
12277 char *ret = NULL; 12277 char *ret = NULL;
12278 TCHAR *tmp; 12278 TCHAR *tmp;
12279 #ifdef UNICODE 12279 #ifdef UNICODE
12280 int type = CF_UNICODETEXT; 12280 int type = CF_UNICODETEXT;
12281 #else 12281 #else
12282 int type = CF_TEXT; 12282 int type = CF_TEXT;
12283 #endif 12283 #endif
12284 12284
12285 if ( !OpenClipboard( NULL ) ) 12285 if ( !OpenClipboard( NULL ) )
12286 return ret; 12286 return ret;
12316 12316
12317 memcpy(src, str, len); 12317 memcpy(src, str, len);
12318 buf = UTF8toWide(src); 12318 buf = UTF8toWide(src);
12319 free(src); 12319 free(src);
12320 len = (int)_tcslen(buf); 12320 len = (int)_tcslen(buf);
12321 #else 12321 #else
12322 int type = CF_TEXT; 12322 int type = CF_TEXT;
12323 12323
12324 buf = str; 12324 buf = str;
12325 #endif 12325 #endif
12326 12326
12327 if ( !OpenClipboard( NULL ) ) 12327 if ( !OpenClipboard( NULL ) )
12328 return; 12328 return;
12353 * or NULL if none is necessary. 12353 * or NULL if none is necessary.
12354 * Returns: 12354 * Returns:
12355 * A handle to the notification which can be used to attach a "clicked" event if desired, 12355 * A handle to the notification which can be used to attach a "clicked" event if desired,
12356 * or NULL if it fails or notifications are not supported by the system. 12356 * or NULL if it fails or notifications are not supported by the system.
12357 * Remarks: 12357 * Remarks:
12358 * This will create a system notification that will show in the notifaction panel 12358 * This will create a system notification that will show in the notifaction panel
12359 * on supported systems, which may be clicked to perform another task. 12359 * on supported systems, which may be clicked to perform another task.
12360 */ 12360 */
12361 HWND dw_notification_new(const char *title, HPIXMAP pixmap, const char *description, ...) 12361 HWND dw_notification_new(const char *title, HPIXMAP pixmap, const char *description, ...)
12362 { 12362 {
12363 return NULL; 12363 return NULL;
12419 env->MajorBuild = 0; 12419 env->MajorBuild = 0;
12420 } 12420 }
12421 12421
12422 strcpy(env->buildDate, __DATE__); 12422 strcpy(env->buildDate, __DATE__);
12423 strcpy(env->buildTime, __TIME__); 12423 strcpy(env->buildTime, __TIME__);
12424 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
12425 # ifdef BUILD_EDGE
12426 strcpy(env->htmlEngine, "EDGE");
12427 # else
12428 strcpy(env->htmlEngine, "IE");
12429 # endif
12430 #else
12431 strcpy(env->htmlEngine, "N/A");
12432 #endif
12433
12424 env->DWMajorVersion = DW_MAJOR_VERSION; 12434 env->DWMajorVersion = DW_MAJOR_VERSION;
12425 env->DWMinorVersion = DW_MINOR_VERSION; 12435 env->DWMinorVersion = DW_MINOR_VERSION;
12426 #ifdef VER_REV 12436 #ifdef VER_REV
12427 env->DWSubVersion = VER_REV; 12437 env->DWSubVersion = VER_REV;
12428 #else 12438 #else
12432 12442
12433 /* Helper to make sure all /s are \s */ 12443 /* Helper to make sure all /s are \s */
12434 void _to_dos(TCHAR *dst, TCHAR *src) 12444 void _to_dos(TCHAR *dst, TCHAR *src)
12435 { 12445 {
12436 int x = 0; 12446 int x = 0;
12437 12447
12438 while(src[x]) 12448 while(src[x])
12439 { 12449 {
12440 if(src[x] == TEXT('/')) 12450 if(src[x] == TEXT('/'))
12441 dst[x] = TEXT('\\'); 12451 dst[x] = TEXT('\\');
12442 else 12452 else
12515 #endif 12525 #endif
12516 } 12526 }
12517 else 12527 else
12518 { 12528 {
12519 DWORD att = defpath ? GetFileAttributes(UTF8toWide(defpath)) : INVALID_FILE_ATTRIBUTES; 12529 DWORD att = defpath ? GetFileAttributes(UTF8toWide(defpath)) : INVALID_FILE_ATTRIBUTES;
12520 12530
12521 if (ext) 12531 if (ext)
12522 { 12532 {
12523 /* 12533 /*
12524 * The following mess is because sprintf() trunates at first \0 12534 * The following mess is because sprintf() trunates at first \0
12525 * and format of filter is eg: "c files (*.c)\0*.c\0All Files\0*.*\0\0" 12535 * and format of filter is eg: "c files (*.c)\0*.c\0All Files\0*.*\0\0"
12594 newparams = (char **)malloc(sizeof(char *) * (count+1)); 12604 newparams = (char **)malloc(sizeof(char *) * (count+1));
12595 12605
12596 for(z=0;z<count;z++) 12606 for(z=0;z<count;z++)
12597 { 12607 {
12598 if(strchr(params[z], ' ')) 12608 if(strchr(params[z], ' '))
12599 { 12609 {
12600 newparams[z] = malloc(strlen(params[z])+3); 12610 newparams[z] = malloc(strlen(params[z])+3);
12601 strcpy(newparams[z], "\""); 12611 strcpy(newparams[z], "\"");
12602 strcat(newparams[z], params[z]); 12612 strcat(newparams[z], params[z]);
12603 strcat(newparams[z], "\""); 12613 strcat(newparams[z], "\"");
12604 } 12614 }
12605 else 12615 else
12606 newparams[z] = strdup(params[z]); 12616 newparams[z] = strdup(params[z]);
12607 } 12617 }
12608 newparams[count] = NULL; 12618 newparams[count] = NULL;
12609 12619
12610 /* Why does this return intptr_t ... can the PID exceed an integer value? */ 12620 /* Why does this return intptr_t ... can the PID exceed an integer value? */
12650 if(retcode<33 && retcode != 2) 12660 if(retcode<33 && retcode != 2)
12651 return DW_ERROR_UNKNOWN; 12661 return DW_ERROR_UNKNOWN;
12652 return DW_ERROR_NONE; 12662 return DW_ERROR_NONE;
12653 } 12663 }
12654 12664
12655 typedef struct _dwprint 12665 typedef struct _dwprint
12656 { 12666 {
12657 PRINTDLG pd; 12667 PRINTDLG pd;
12658 DOCINFO di; 12668 DOCINFO di;
12659 int (DWSIGNAL *drawfunc)(HPRINT, HPIXMAP, int, void *); 12669 int (DWSIGNAL *drawfunc)(HPRINT, HPIXMAP, int, void *);
12660 void *drawdata; 12670 void *drawdata;
12673 * A handle to the print object or NULL on failure. 12683 * A handle to the print object or NULL on failure.
12674 */ 12684 */
12675 HPRINT API dw_print_new(const char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata) 12685 HPRINT API dw_print_new(const char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
12676 { 12686 {
12677 DWPrint *print; 12687 DWPrint *print;
12678 12688
12679 if(!drawfunc || !(print = calloc(1, sizeof(DWPrint)))) 12689 if(!drawfunc || !(print = calloc(1, sizeof(DWPrint))))
12680 return NULL; 12690 return NULL;
12681 12691
12682 print->drawfunc = drawfunc; 12692 print->drawfunc = drawfunc;
12683 print->drawdata = drawdata; 12693 print->drawdata = drawdata;
12684 print->pd.lStructSize = sizeof(PRINTDLG); 12694 print->pd.lStructSize = sizeof(PRINTDLG);
12685 print->pd.hwndOwner = HWND_DESKTOP; 12695 print->pd.hwndOwner = HWND_DESKTOP;
12686 print->pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC; 12696 print->pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
12712 int API dw_print_run(HPRINT print, unsigned long flags) 12722 int API dw_print_run(HPRINT print, unsigned long flags)
12713 { 12723 {
12714 DWPrint *p = print; 12724 DWPrint *p = print;
12715 HPIXMAP pixmap; 12725 HPIXMAP pixmap;
12716 int x, width, height, result = DW_ERROR_UNKNOWN; 12726 int x, width, height, result = DW_ERROR_UNKNOWN;
12717 12727
12718 if(!p) 12728 if(!p)
12719 return result; 12729 return result;
12720 12730
12721 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 12731 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
12722 return result; 12732 return result;
12723 12733
12724 width = GetDeviceCaps(p->pd.hDC, HORZRES); 12734 width = GetDeviceCaps(p->pd.hDC, HORZRES);
12725 height = GetDeviceCaps(p->pd.hDC, VERTRES); 12735 height = GetDeviceCaps(p->pd.hDC, VERTRES);
12726 12736
12727 pixmap->hbm = CreateCompatibleBitmap(p->pd.hDC, width, height); 12737 pixmap->hbm = CreateCompatibleBitmap(p->pd.hDC, width, height);
12728 pixmap->hdc = p->pd.hDC; 12738 pixmap->hdc = p->pd.hDC;
12729 pixmap->transcolor = DW_RGB_TRANSPARENT; 12739 pixmap->transcolor = DW_RGB_TRANSPARENT;
12738 12748
12739 SelectObject(pixmap->hdc, pixmap->hbm); 12749 SelectObject(pixmap->hdc, pixmap->hbm);
12740 12750
12741 /* Start the job */ 12751 /* Start the job */
12742 StartDoc(p->pd.hDC, &(p->di)); 12752 StartDoc(p->pd.hDC, &(p->di));
12743 12753
12744 /* Cycle through each page */ 12754 /* Cycle through each page */
12745 for(x=p->pd.nFromPage-1; x<p->pd.nToPage && p->drawfunc; x++) 12755 for(x=p->pd.nFromPage-1; x<p->pd.nToPage && p->drawfunc; x++)
12746 { 12756 {
12747 StartPage(p->pd.hDC); 12757 StartPage(p->pd.hDC);
12748 p->drawfunc(print, pixmap, x, p->drawdata); 12758 p->drawfunc(print, pixmap, x, p->drawdata);
12767 * print: Handle to the print object returned by dw_print_new(). 12777 * print: Handle to the print object returned by dw_print_new().
12768 */ 12778 */
12769 void API dw_print_cancel(HPRINT print) 12779 void API dw_print_cancel(HPRINT print)
12770 { 12780 {
12771 DWPrint *p = print; 12781 DWPrint *p = print;
12772 12782
12773 if(p) 12783 if(p)
12774 p->drawfunc = NULL; 12784 p->drawfunc = NULL;
12775 } 12785 }
12776 12786
12777 /* 12787 /*
12806 return _user_dir; 12816 return _user_dir;
12807 } 12817 }
12808 12818
12809 /* 12819 /*
12810 * Returns a pointer to a static buffer which containes the 12820 * Returns a pointer to a static buffer which containes the
12811 * private application data directory. 12821 * private application data directory.
12812 */ 12822 */
12813 char * API dw_app_dir(void) 12823 char * API dw_app_dir(void)
12814 { 12824 {
12815 return _dw_exec_dir; 12825 return _dw_exec_dir;
12816 } 12826 }
13133 while(tmp) 13143 while(tmp)
13134 { 13144 {
13135 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->message == message) 13145 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->message == message)
13136 { 13146 {
13137 void (DWSIGNAL *discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction; 13147 void (DWSIGNAL *discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction;
13138 13148
13139 if(discfunc) 13149 if(discfunc)
13140 { 13150 {
13141 discfunc(tmp->window, tmp->data); 13151 discfunc(tmp->window, tmp->data);
13142 } 13152 }
13143 13153
13144 if(prev) 13154 if(prev)
13145 { 13155 {
13146 prev->next = tmp->next; 13156 prev->next = tmp->next;
13147 free(tmp); 13157 free(tmp);
13148 tmp = prev->next; 13158 tmp = prev->next;
13174 while(tmp) 13184 while(tmp)
13175 { 13185 {
13176 if((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) 13186 if((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window)
13177 { 13187 {
13178 void (DWSIGNAL *discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction; 13188 void (DWSIGNAL *discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction;
13179 13189
13180 if(discfunc) 13190 if(discfunc)
13181 { 13191 {
13182 discfunc(tmp->window, tmp->data); 13192 discfunc(tmp->window, tmp->data);
13183 } 13193 }
13184 13194
13185 if(prev) 13195 if(prev)
13186 { 13196 {
13187 prev->next = tmp->next; 13197 prev->next = tmp->next;
13188 free(tmp); 13198 free(tmp);
13189 tmp = prev->next; 13199 tmp = prev->next;
13216 while(tmp) 13226 while(tmp)
13217 { 13227 {
13218 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->data == data) 13228 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->data == data)
13219 { 13229 {
13220 void (DWSIGNAL *discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction; 13230 void (DWSIGNAL *discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction;
13221 13231
13222 if(discfunc) 13232 if(discfunc)
13223 { 13233 {
13224 discfunc(tmp->window, tmp->data); 13234 discfunc(tmp->window, tmp->data);
13225 } 13235 }
13226 13236
13227 if(prev) 13237 if(prev)
13228 { 13238 {
13229 prev->next = tmp->next; 13239 prev->next = tmp->next;
13230 free(tmp); 13240 free(tmp);
13231 tmp = prev->next; 13241 tmp = prev->next;
13257 { 13267 {
13258 #ifdef UNICODE 13268 #ifdef UNICODE
13259 return _myUTF8toWide(utf8string, malloc(MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR))); 13269 return _myUTF8toWide(utf8string, malloc(MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR)));
13260 #else 13270 #else
13261 return NULL; 13271 return NULL;
13262 #endif 13272 #endif
13263 } 13273 }
13264 13274
13265 /* 13275 /*
13266 * Converts a wide string into a UTF-8 encoded string. 13276 * Converts a wide string into a UTF-8 encoded string.
13267 * Parameters: 13277 * Parameters: