diff mac/dw.m @ 1422:131bedf41332

Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support. Also some code optimization and cleanup on the Mac gleaned from the Windows changes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 03 Dec 2011 02:08:40 +0000
parents 63d253a2cdd9
children 1628bf383893
line wrap: on
line diff
--- a/mac/dw.m	Sat Dec 03 00:09:34 2011 +0000
+++ b/mac/dw.m	Sat Dec 03 02:08:40 2011 +0000
@@ -152,10 +152,13 @@
 int _dw_main_iteration(NSDate *date);
 
 /* Internal function to queue a window redraw */
-void _dw_redraw(id window)
+void _dw_redraw(id window, int skip)
 {
     static id lastwindow = nil;
     
+    if(skip && window == nil)
+      return;
+
     if(lastwindow != window && lastwindow != nil)
     {
         dw_window_redraw(lastwindow);
@@ -455,7 +458,8 @@
 int _event_handler(id object, NSEvent *event, int message)
 {
     int ret = _event_handler1(object, event, message);
-    _dw_redraw(nil);
+    if(ret != -1)
+        _dw_redraw(nil, FALSE);
     return ret;
 }
 
@@ -3540,7 +3544,9 @@
  * Entryfield/Combobox/Spinbutton: 150x(maxfontheight)
  * Spinbutton: 50x(maxfontheight)
  * Text/Status: (textwidth)x(textheight)
- */
+ * Ranged: 100x14 or 14x100 for vertical.
+ * Buttons/Bitmaps: Size of text or image and border.
+*/
 void _control_size(id handle, int *width, int *height)
 {
     int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0;
@@ -3779,7 +3785,7 @@
         [button setParent:view];
     }
     /* Queue a redraw on the top-level window */
-    _dw_redraw([object window]);
+    _dw_redraw([object window], TRUE);
 
     /* Free the old data */
     if(thisbox->count)
@@ -8173,9 +8179,11 @@
         
         /* 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([object window]);
+            /* Queue a redraw on the top-level window */
+            _dw_redraw([object window], TRUE);
+        }
         return DW_ERROR_NONE;
     }
     return DW_ERROR_UNKNOWN;
@@ -8354,9 +8362,11 @@
     
     /* 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([object window]);
+        /* Queue a redraw on the top-level window */
+        _dw_redraw([object window], TRUE);
+    }
 }
 
 /*
@@ -8450,8 +8460,16 @@
             [iv setImage:pixmap];
         }
         [pixmap release];
-        /* Queue a redraw on the top-level window */
-        _dw_redraw([iv window]);
+        /* If we changed the text... */
+        Item *item = _box_item(handle);
+       
+        /* 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([iv window], TRUE);
+        }
     }
 }
 
@@ -8486,7 +8504,7 @@
         {
             [iv setImage:bitmap];
             /* Queue a redraw on the top-level window */
-            _dw_redraw([iv window]);
+            _dw_redraw([iv window], TRUE);
         }
     }
 }