diff 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
line wrap: on
line diff
--- 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;
       }