comparison 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
comparison
equal deleted inserted replaced
1421:63d253a2cdd9 1422:131bedf41332
150 void _handle_resize_events(Box *thisbox); 150 void _handle_resize_events(Box *thisbox);
151 int _remove_userdata(UserData **root, char *varname, int all); 151 int _remove_userdata(UserData **root, char *varname, int all);
152 int _dw_main_iteration(NSDate *date); 152 int _dw_main_iteration(NSDate *date);
153 153
154 /* Internal function to queue a window redraw */ 154 /* Internal function to queue a window redraw */
155 void _dw_redraw(id window) 155 void _dw_redraw(id window, int skip)
156 { 156 {
157 static id lastwindow = nil; 157 static id lastwindow = nil;
158 158
159 if(skip && window == nil)
160 return;
161
159 if(lastwindow != window && lastwindow != nil) 162 if(lastwindow != window && lastwindow != nil)
160 { 163 {
161 dw_window_redraw(lastwindow); 164 dw_window_redraw(lastwindow);
162 } 165 }
163 lastwindow = window; 166 lastwindow = window;
453 456
454 /* Sub function to handle redraws */ 457 /* Sub function to handle redraws */
455 int _event_handler(id object, NSEvent *event, int message) 458 int _event_handler(id object, NSEvent *event, int message)
456 { 459 {
457 int ret = _event_handler1(object, event, message); 460 int ret = _event_handler1(object, event, message);
458 _dw_redraw(nil); 461 if(ret != -1)
462 _dw_redraw(nil, FALSE);
459 return ret; 463 return ret;
460 } 464 }
461 465
462 /* Subclass for the Timer type */ 466 /* Subclass for the Timer type */
463 @interface DWTimerHandler : NSObject { } 467 @interface DWTimerHandler : NSObject { }
3538 * 3542 *
3539 * Scrolled(Container,Tree,MLE)/Render/Unspecified: 1x1 3543 * Scrolled(Container,Tree,MLE)/Render/Unspecified: 1x1
3540 * Entryfield/Combobox/Spinbutton: 150x(maxfontheight) 3544 * Entryfield/Combobox/Spinbutton: 150x(maxfontheight)
3541 * Spinbutton: 50x(maxfontheight) 3545 * Spinbutton: 50x(maxfontheight)
3542 * Text/Status: (textwidth)x(textheight) 3546 * Text/Status: (textwidth)x(textheight)
3543 */ 3547 * Ranged: 100x14 or 14x100 for vertical.
3548 * Buttons/Bitmaps: Size of text or image and border.
3549 */
3544 void _control_size(id handle, int *width, int *height) 3550 void _control_size(id handle, int *width, int *height)
3545 { 3551 {
3546 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0; 3552 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0;
3547 NSString *nsstr = nil; 3553 NSString *nsstr = nil;
3548 id object = handle; 3554 id object = handle;
3777 * buttons can use it later. 3783 * buttons can use it later.
3778 */ 3784 */
3779 [button setParent:view]; 3785 [button setParent:view];
3780 } 3786 }
3781 /* Queue a redraw on the top-level window */ 3787 /* Queue a redraw on the top-level window */
3782 _dw_redraw([object window]); 3788 _dw_redraw([object window], TRUE);
3783 3789
3784 /* Free the old data */ 3790 /* Free the old data */
3785 if(thisbox->count) 3791 if(thisbox->count)
3786 free(thisitem); 3792 free(thisitem);
3787 DW_MUTEX_UNLOCK; 3793 DW_MUTEX_UNLOCK;
8171 /* If we changed the text... */ 8177 /* If we changed the text... */
8172 Item *item = _box_item(handle); 8178 Item *item = _box_item(handle);
8173 8179
8174 /* Check to see if any of the sizes need to be recalculated */ 8180 /* Check to see if any of the sizes need to be recalculated */
8175 if(item && (item->origwidth == -1 || item->origheight == -1)) 8181 if(item && (item->origwidth == -1 || item->origheight == -1))
8182 {
8176 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); 8183 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
8177 /* Queue a redraw on the top-level window */ 8184 /* Queue a redraw on the top-level window */
8178 _dw_redraw([object window]); 8185 _dw_redraw([object window], TRUE);
8186 }
8179 return DW_ERROR_NONE; 8187 return DW_ERROR_NONE;
8180 } 8188 }
8181 return DW_ERROR_UNKNOWN; 8189 return DW_ERROR_UNKNOWN;
8182 } 8190 }
8183 8191
8352 /* If we changed the text... */ 8360 /* If we changed the text... */
8353 Item *item = _box_item(handle); 8361 Item *item = _box_item(handle);
8354 8362
8355 /* Check to see if any of the sizes need to be recalculated */ 8363 /* Check to see if any of the sizes need to be recalculated */
8356 if(item && (item->origwidth == -1 || item->origheight == -1)) 8364 if(item && (item->origwidth == -1 || item->origheight == -1))
8365 {
8357 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); 8366 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
8358 /* Queue a redraw on the top-level window */ 8367 /* Queue a redraw on the top-level window */
8359 _dw_redraw([object window]); 8368 _dw_redraw([object window], TRUE);
8369 }
8360 } 8370 }
8361 8371
8362 /* 8372 /*
8363 * Sets the text used for a given window's floating bubble help. 8373 * Sets the text used for a given window's floating bubble help.
8364 * Parameters: 8374 * Parameters:
8448 if(pixmap) 8458 if(pixmap)
8449 { 8459 {
8450 [iv setImage:pixmap]; 8460 [iv setImage:pixmap];
8451 } 8461 }
8452 [pixmap release]; 8462 [pixmap release];
8453 /* Queue a redraw on the top-level window */ 8463 /* If we changed the text... */
8454 _dw_redraw([iv window]); 8464 Item *item = _box_item(handle);
8465
8466 /* Check to see if any of the sizes need to be recalculated */
8467 if(item && (item->origwidth == -1 || item->origheight == -1))
8468 {
8469 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
8470 /* Queue a redraw on the top-level window */
8471 _dw_redraw([iv window], TRUE);
8472 }
8455 } 8473 }
8456 } 8474 }
8457 8475
8458 /* 8476 /*
8459 * Sets the bitmap used for a given static window. 8477 * Sets the bitmap used for a given static window.
8484 8502
8485 if(bitmap) 8503 if(bitmap)
8486 { 8504 {
8487 [iv setImage:bitmap]; 8505 [iv setImage:bitmap];
8488 /* Queue a redraw on the top-level window */ 8506 /* Queue a redraw on the top-level window */
8489 _dw_redraw([iv window]); 8507 _dw_redraw([iv window], TRUE);
8490 } 8508 }
8491 } 8509 }
8492 } 8510 }
8493 8511
8494 /* 8512 /*