Mercurial > dwindows
comparison mac/dw.m @ 1492:1608c2a9c2b8
Initial attempt at gravity obstacles on Mac.... doesn't work was trying to debug
but XCode 4.0 is crashing, so going to try with 4.2 on Lion.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 25 Dec 2011 02:59:51 +0000 |
parents | 5393b56ec6d0 |
children | cf960e266444 |
comparison
equal
deleted
inserted
replaced
1491:d77b8cf25f04 | 1492:1608c2a9c2b8 |
---|---|
8534 /* Convert the coordinates based on gravity */ | 8534 /* Convert the coordinates based on gravity */ |
8535 void _handle_gravity(HWND handle, long *x, long *y, unsigned long width, unsigned long height) | 8535 void _handle_gravity(HWND handle, long *x, long *y, unsigned long width, unsigned long height) |
8536 { | 8536 { |
8537 int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz")); | 8537 int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz")); |
8538 int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert")); | 8538 int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert")); |
8539 NSRect visiblerect = [[NSScreen mainScreen] visibleFrame]; | |
8540 NSRect totalrect = [[NSScreen mainScreen] frame]; | |
8539 | 8541 |
8540 /* Do any gravity calculations */ | 8542 /* Do any gravity calculations */ |
8541 if(horz || (vert & 0xf) != DW_GRAV_BOTTOM) | 8543 if(horz || (vert & 0xf) != DW_GRAV_BOTTOM) |
8542 { | 8544 { |
8543 long newx = *x, newy = *y; | 8545 long newx = *x, newy = *y; |
8555 newy = dw_screen_height() - height - *y; | 8557 newy = dw_screen_height() - height - *y; |
8556 | 8558 |
8557 /* Save the new values */ | 8559 /* Save the new values */ |
8558 *x = newx; | 8560 *x = newx; |
8559 *y = newy; | 8561 *y = newy; |
8560 } | 8562 } |
8563 /* Adjust the values to avoid Dock/Menubar if requested */ | |
8564 if(horz & DW_GRAV_OBSTACLES) | |
8565 { | |
8566 if((horz & 0xf) == DW_GRAV_LEFT) | |
8567 *x += visiblerect.origin.x; | |
8568 else if((horz & 0xf) == DW_GRAV_RIGHT) | |
8569 *x -= (totalrect.origin.x + totalrect.size.width) - (visiblerect.origin.x + visiblerect.size.width); | |
8570 } | |
8571 if(vert & DW_GRAV_OBSTACLES) | |
8572 { | |
8573 if((vert & 0xf) == DW_GRAV_BOTTOM) | |
8574 *y += visiblerect.origin.y; | |
8575 else if((vert & 0xf) == DW_GRAV_RIGHT) | |
8576 *y -= (totalrect.origin.y + totalrect.size.height) - (visiblerect.origin.y + visiblerect.size.height); | |
8577 } | |
8561 } | 8578 } |
8562 | 8579 |
8563 /* | 8580 /* |
8564 * Sets the position of a given window (widget). | 8581 * Sets the position of a given window (widget). |
8565 * Parameters: | 8582 * Parameters: |