comparison mac/dw.m @ 1530:eecfceaf581f

On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 07 Jan 2012 03:46:10 +0000
parents 92bed442620a
children 783a464afab2
comparison
equal deleted inserted replaced
1529:92bed442620a 1530:eecfceaf581f
8542 * width: Width in pixels of the item or NULL if not needed. 8542 * width: Width in pixels of the item or NULL if not needed.
8543 * height: Height in pixels of the item or NULL if not needed. 8543 * height: Height in pixels of the item or NULL if not needed.
8544 */ 8544 */
8545 void API dw_window_get_preferred_size(HWND handle, int *width, int *height) 8545 void API dw_window_get_preferred_size(HWND handle, int *width, int *height)
8546 { 8546 {
8547 _control_size(handle, width, height); 8547 id object = handle;
8548
8549 if([object isMemberOfClass:[DWWindow class]])
8550 {
8551 Box *thisbox;
8552
8553 if((thisbox = [[object contentView] box]))
8554 {
8555 int depth = 0;
8556 NSRect frame;
8557
8558 /* Calculate space requirements */
8559 _resize_box(thisbox, &depth, 0, 0, 1);
8560
8561 frame = [NSWindow frameRectForContentRect:NSMakeRect(0, 0, thisbox->minwidth, thisbox->minheight) styleMask:[object styleMask]];
8562
8563 /* Might need to take into account the window border here */
8564 if(width) *width = frame.size.width;
8565 if(height) *height = frame.size.height;
8566 }
8567 }
8568 else if([object isMemberOfClass:[DWBox class]])
8569 {
8570 Box *thisbox;
8571
8572 if((thisbox = [object box]))
8573 {
8574 int depth = 0;
8575
8576 /* Calculate space requirements */
8577 _resize_box(thisbox, &depth, 0, 0, 1);
8578
8579 /* Might need to take into account the window border here */
8580 if(width) *width = thisbox->minwidth;
8581 if(height) *height = thisbox->minheight;
8582 }
8583 }
8584 else
8585 _control_size(handle, width, height);
8548 } 8586 }
8549 8587
8550 /* 8588 /*
8551 * Sets the gravity of a given window (widget). 8589 * Sets the gravity of a given window (widget).
8552 * Gravity controls which corner of the screen and window the position is relative to. 8590 * Gravity controls which corner of the screen and window the position is relative to.