Mercurial > dwindows
comparison os2/dw.c @ 1661:fc135161f2b1
Workaround WinLoadPointer() modifying the icon size on OS/2 by
loading the icon width directly from the resource data.
Also fix drawing icon buttons not taking into account the no border flag.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 17 Apr 2012 19:54:30 +0000 |
parents | 6fe1e91da477 |
children | 9dbd2984c1e5 |
comparison
equal
deleted
inserted
replaced
1660:28775ce2d26c | 1661:fc135161f2b1 |
---|---|
3685 HPIXMAP disable = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap_disabled"); | 3685 HPIXMAP disable = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap_disabled"); |
3686 HPOINTER icon = (HPOINTER)dw_window_get_data(hwnd, "_dw_button_icon"); | 3686 HPOINTER icon = (HPOINTER)dw_window_get_data(hwnd, "_dw_button_icon"); |
3687 MRESULT res; | 3687 MRESULT res; |
3688 unsigned long width, height; | 3688 unsigned long width, height; |
3689 int x = 5, y = 5; | 3689 int x = 5, y = 5; |
3690 ULONG style = WinQueryWindowULong(hwnd, QWL_STYLE); | |
3690 | 3691 |
3691 dw_window_get_pos_size(hwnd, NULL, NULL, &width, &height); | 3692 dw_window_get_pos_size(hwnd, NULL, NULL, &width, &height); |
3692 | 3693 |
3693 if(!oldproc) | 3694 if(!oldproc) |
3694 res = WinDefWindowProc(hwnd, msg, mp1, mp2); | 3695 res = WinDefWindowProc(hwnd, msg, mp1, mp2); |
3702 int cx, cy; | 3703 int cx, cy; |
3703 | 3704 |
3704 if(dw_window_get_data(hwnd, "_dw_disabled")) | 3705 if(dw_window_get_data(hwnd, "_dw_disabled")) |
3705 halftone = DP_HALFTONED; | 3706 halftone = DP_HALFTONED; |
3706 | 3707 |
3707 cx = width - 10; | 3708 /* If there is a border take that into account */ |
3708 cy = height - 10; | 3709 if(style & BS_NOBORDER) |
3710 { | |
3711 cx = width; | |
3712 cy = height; | |
3713 } | |
3714 else | |
3715 { | |
3716 cx = width - 8; | |
3717 cy = height - 8; | |
3718 } | |
3709 | 3719 |
3710 if(WinQueryPointerInfo(icon, &pi)) | 3720 if(WinQueryPointerInfo(icon, &pi)) |
3711 { | 3721 { |
3712 BITMAPINFOHEADER sl; | 3722 BITMAPINFOHEADER sl; |
3713 int newcx = cx, newcy = cy; | 3723 int newcx = cx, newcy = cy; |
5002 /* Handle bitmap buttons */ | 5012 /* Handle bitmap buttons */ |
5003 if(dw_window_get_data(handle, "_dw_bitmapbutton")) | 5013 if(dw_window_get_data(handle, "_dw_bitmapbutton")) |
5004 { | 5014 { |
5005 HPOINTER hpr = (HPOINTER)dw_window_get_data(handle, "_dw_button_icon"); | 5015 HPOINTER hpr = (HPOINTER)dw_window_get_data(handle, "_dw_button_icon"); |
5006 HBITMAP hbm = 0; | 5016 HBITMAP hbm = 0; |
5017 int iconwidth = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_button_icon_width")); | |
5007 | 5018 |
5008 /* Handle case of icon resource */ | 5019 /* Handle case of icon resource */ |
5009 if(hpr) | 5020 if(hpr) |
5010 { | 5021 { |
5011 POINTERINFO pi; | 5022 if(iconwidth) |
5012 | 5023 thisheight = thiswidth = iconwidth; |
5013 /* Get the internal HBITMAP handles */ | 5024 else |
5014 if(WinQueryPointerInfo(hpr, &pi)) | 5025 { |
5015 hbm = pi.hbmColor ? pi.hbmColor : pi.hbmPointer; | 5026 POINTERINFO pi; |
5027 | |
5028 /* Get the internal HBITMAP handles */ | |
5029 if(WinQueryPointerInfo(hpr, &pi)) | |
5030 hbm = pi.hbmColor ? pi.hbmColor : pi.hbmPointer; | |
5031 } | |
5016 } | 5032 } |
5017 | 5033 |
5018 /* If we didn't load it from the icon... */ | 5034 /* If we didn't load it from the icon... */ |
5019 if(!hbm) | 5035 if(!hbm && !iconwidth) |
5020 { | 5036 { |
5021 WNDPARAMS wp; | 5037 WNDPARAMS wp; |
5022 BTNCDATA bcd; | 5038 BTNCDATA bcd; |
5023 | 5039 |
5024 wp.fsStatus = WPM_CTLDATA; | 5040 wp.fsStatus = WPM_CTLDATA; |
6219 blah->oldproc = WinSubclassWindow(tmp, _BtProc); | 6235 blah->oldproc = WinSubclassWindow(tmp, _BtProc); |
6220 | 6236 |
6221 WinSetWindowPtr(tmp, QWP_USER, blah); | 6237 WinSetWindowPtr(tmp, QWP_USER, blah); |
6222 | 6238 |
6223 if(icon) | 6239 if(icon) |
6224 dw_window_set_data(tmp, "_dw_button_icon", (void *)icon); | 6240 { |
6225 dw_window_set_data(tmp, "_dw_bitmapbutton", (void *)1); | 6241 PVOID ResPtr; |
6242 ULONG ResSize; | |
6243 | |
6244 /* Since WinLoadPointer() can change the size of the icon... | |
6245 * We will query the resource directly and check the size ourselves. | |
6246 */ | |
6247 if(DosQueryResourceSize(NULLHANDLE, RT_POINTER, id, &ResSize) == NO_ERROR && ResSize && | |
6248 DosGetResource(NULLHANDLE, RT_POINTER, id, &ResPtr) == NO_ERROR) | |
6249 { | |
6250 PBITMAPFILEHEADER2 header = ResPtr; | |
6251 | |
6252 /* We can only check for icons and pointers */ | |
6253 if(header->usType == 0x4943 /* Icon 'CI' */ || | |
6254 header->usType == 0x5043 /* Pointer 'CP' */) | |
6255 { | |
6256 /* Check the new style header */ | |
6257 if(header->bmp2.cbFix == sizeof(BITMAPINFOHEADER2)) | |
6258 dw_window_set_data(tmp, "_dw_button_icon_width", DW_INT_TO_POINTER(header->bmp2.cx)); | |
6259 else if(header->bmp2.cbFix == sizeof(BITMAPINFOHEADER)) | |
6260 { | |
6261 /* Check the old style header */ | |
6262 PBITMAPINFOHEADER bi = (PBITMAPINFOHEADER)&(header->bmp2); | |
6263 | |
6264 dw_window_set_data(tmp, "_dw_button_icon_width", DW_INT_TO_POINTER(bi->cx)); | |
6265 } | |
6266 } | |
6267 DosFreeResource(ResPtr); | |
6268 } | |
6269 dw_window_set_data(tmp, "_dw_button_icon", DW_POINTER(icon)); | |
6270 } | |
6271 dw_window_set_data(tmp, "_dw_bitmapbutton", DW_INT_TO_POINTER(1)); | |
6226 return tmp; | 6272 return tmp; |
6227 } | 6273 } |
6228 | 6274 |
6229 /* | 6275 /* |
6230 * Create a new bitmap button window (widget) to be packed from a file. | 6276 * Create a new bitmap button window (widget) to be packed from a file. |