comparison os2/dw.c @ 1739:c68ee60fb8b0

Improved method of figuring out the best icon size on OS/2 when drawing bitmap buttons with an icon handle. This prevents stretching to odd dimensions when one direction is small and the other is large. Fixes display issue in the latest dwtest.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 19 May 2012 01:23:04 +0000
parents 46c2846e5750
children a297b2bde127
comparison
equal deleted inserted replaced
1738:d93e860c38d1 1739:c68ee60fb8b0
3838 sl.cbFix = sizeof(BITMAPINFOHEADER); 3838 sl.cbFix = sizeof(BITMAPINFOHEADER);
3839 3839
3840 /* Check the mini icon first */ 3840 /* Check the mini icon first */
3841 if(GpiQueryBitmapParameters(pi.hbmMiniColor, &sl)) 3841 if(GpiQueryBitmapParameters(pi.hbmMiniColor, &sl))
3842 { 3842 {
3843 if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy) 3843 if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy)
3844 { 3844 {
3845 newcx = sl.cx; 3845 newcx = sl.cx;
3846 newcy = sl.cy; 3846 newcy = sl.cy;
3847 } 3847 }
3848 } 3848 }
3849 /* Check the normal icon second */ 3849 /* Check the normal icon second */
3850 if(GpiQueryBitmapParameters(pi.hbmColor, &sl)) 3850 if(GpiQueryBitmapParameters(pi.hbmColor, &sl))
3851 { 3851 {
3852 if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy) 3852 if(sl.cx && sl.cy)
3853 { 3853 {
3854 newcx = sl.cx; 3854 if(cx > sl.cx && cy > sl.cy)
3855 newcy = sl.cy; 3855 {
3856 } 3856 newcx = sl.cx;
3857 newcy = sl.cy;
3858 }
3859 /* In case there was no mini icon... cut it in half */
3860 else if(cx >= (sl.cx/2) && cy >= (sl.cy/2))
3861 {
3862 newcx = sl.cx/2;
3863 newcy = sl.cy/2;
3864 }
3865 }
3857 } 3866 }
3858 cx = newcx; cy = newcy; 3867 cx = newcx; cy = newcy;
3868 /* Safety check to avoid icon dimension stretching */
3869 if(cx != cy)
3870 {
3871 if(cx > cy)
3872 cx = cy;
3873 else
3874 cy = cx;
3875 }
3876 /* Finally center it in the window */
3859 x = (width - cx)/2; 3877 x = (width - cx)/2;
3860 y = (height - cy)/2; 3878 y = (height - cy)/2;
3861 } 3879 }
3862 WinStretchPointer(hps, x + indent, y - indent, cx, cy, icon, halftone); 3880 WinStretchPointer(hps, x + indent, y - indent, cx, cy, icon, halftone);
3863 WinReleasePS(hps); 3881 WinReleasePS(hps);