diff os2/dw.c @ 1792:b0bdec1b820c

Similar fixes to the Mac one on OS/2 and Windows.... Plus a performance optimization on all three platforms. Don't redraw the window if the calculated control size did not change.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 05 Aug 2012 13:47:57 +0000
parents a640714f9087
children 9304241b7b33
line wrap: on
line diff
--- a/os2/dw.c	Sun Aug 05 13:02:39 2012 +0000
+++ b/os2/dw.c	Sun Aug 05 13:47:57 2012 +0000
@@ -5204,10 +5204,15 @@
                thisheight = bmp.cy;
             }
        }
-       else if(dw_window_get_data(handle, "_dw_status"))
+       else
        {
-           extrawidth = 4;
-           extraheight = 4;
+            if(thiswidth == 1 && thisheight == 1)
+               dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
+            if(dw_window_get_data(handle, "_dw_status"))
+            {
+               extrawidth = 4;
+               extraheight = 4;
+            }
        }
    }
    /* Ranged: Slider/Percent */
@@ -7523,9 +7528,21 @@
       /* Check to see if any of the sizes need to be recalculated */
       if(item && (item->origwidth == -1 || item->origheight == -1))
       {
-         _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); 
-          /* Queue a redraw on the top-level window */
-         _dw_redraw(_toplevel_window(handle), TRUE);
+         int newwidth, newheight;
+         
+         _control_size(handle, &newwidth, &newheight); 
+         
+         /* Only update the item and redraw the window if it changed */
+         if((item->origwidth == -1 && item->width != newwidth) ||
+            (item->origheight == -1 && item->height != newheight))
+         {
+            if(item->origwidth == -1)
+               item->width = newwidth;
+            if(item->origheight == -1)
+               item->height = newheight;
+            /* Queue a redraw on the top-level window */
+            _dw_redraw(_toplevel_window(handle), TRUE);
+         }
       }
    }
 }