# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1337390584 0 # Node ID c68ee60fb8b083217083209fba2ed51642e9934d # Parent d93e860c38d1d8f0982cbd6436928d4f8aa518fb 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. diff -r d93e860c38d1 -r c68ee60fb8b0 os2/dw.c --- a/os2/dw.c Fri May 18 06:58:21 2012 +0000 +++ b/os2/dw.c Sat May 19 01:23:04 2012 +0000 @@ -3840,22 +3840,40 @@ /* Check the mini icon first */ if(GpiQueryBitmapParameters(pi.hbmMiniColor, &sl)) { - if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy) - { - newcx = sl.cx; - newcy = sl.cy; - } + if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy) + { + newcx = sl.cx; + newcy = sl.cy; + } } /* Check the normal icon second */ if(GpiQueryBitmapParameters(pi.hbmColor, &sl)) { - if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy) - { - newcx = sl.cx; - newcy = sl.cy; - } + if(sl.cx && sl.cy) + { + if(cx > sl.cx && cy > sl.cy) + { + newcx = sl.cx; + newcy = sl.cy; + } + /* In case there was no mini icon... cut it in half */ + else if(cx >= (sl.cx/2) && cy >= (sl.cy/2)) + { + newcx = sl.cx/2; + newcy = sl.cy/2; + } + } } cx = newcx; cy = newcy; + /* Safety check to avoid icon dimension stretching */ + if(cx != cy) + { + if(cx > cy) + cx = cy; + else + cy = cx; + } + /* Finally center it in the window */ x = (width - cx)/2; y = (height - cy)/2; }