Mercurial > dwindows
comparison os2/dw.c @ 1472:1794caee0758
Initial versions of dw_window_set_gravity for Windows and OS/2.
Fixed an error in the gravity calculation for bottom on GTK.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 20 Dec 2011 16:10:13 +0000 |
parents | 65986481a3d8 |
children | 4468ac1db710 |
comparison
equal
deleted
inserted
replaced
1471:26dbd11399d6 | 1472:1794caee0758 |
---|---|
6905 /* Attempt to auto-size */ | 6905 /* Attempt to auto-size */ |
6906 if ( width < 1 || height < 1 ) | 6906 if ( width < 1 || height < 1 ) |
6907 _get_window_for_size(handle, &width, &height); | 6907 _get_window_for_size(handle, &width, &height); |
6908 | 6908 |
6909 /* Finally set the size */ | 6909 /* Finally set the size */ |
6910 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SHOW | SWP_SIZE); | 6910 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SIZE); |
6911 } | 6911 } |
6912 | 6912 |
6913 /* | 6913 /* |
6914 * Gets the size the system thinks the widget should be. | 6914 * Gets the size the system thinks the widget should be. |
6915 * Parameters: | 6915 * Parameters: |
6947 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &colors); | 6947 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &colors); |
6948 DevCloseDC(hdc); | 6948 DevCloseDC(hdc); |
6949 return colors; | 6949 return colors; |
6950 } | 6950 } |
6951 | 6951 |
6952 /* Convert the coordinates based on gravity */ | |
6953 void _handle_gravity(HWND handle, long *x, long *y, unsigned long width, unsigned long height) | |
6954 { | |
6955 int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz")); | |
6956 int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert")); | |
6957 | |
6958 /* Do any gravity calculations */ | |
6959 if(horz || (vert & 0xf) != DW_GRAV_BOTTOM) | |
6960 { | |
6961 long newx = *x, newy = *y; | |
6962 | |
6963 /* Handle horizontal center gravity */ | |
6964 if((horz & 0xf) == DW_GRAV_CENTER) | |
6965 newx += ((dw_screen_width() / 2) - (width / 2)); | |
6966 /* Handle right gravity */ | |
6967 else if((horz & 0xf) == DW_GRAV_RIGHT) | |
6968 newx = dw_screen_width() - width - *x; | |
6969 /* Handle vertical center gravity */ | |
6970 if((vert & 0xf) == DW_GRAV_CENTER) | |
6971 newy += ((dw_screen_height() / 2) - (height / 2)); | |
6972 else if((vert & 0xf) == DW_GRAV_TOP) | |
6973 newy = dw_screen_height() - height - *y; | |
6974 | |
6975 /* Save the new values */ | |
6976 *x = newx; | |
6977 *y = newy; | |
6978 } | |
6979 } | |
6952 | 6980 |
6953 /* | 6981 /* |
6954 * Sets the position of a given window (widget). | 6982 * Sets the position of a given window (widget). |
6955 * Parameters: | 6983 * Parameters: |
6956 * handle: Window (widget) handle. | 6984 * handle: Window (widget) handle. |
6957 * x: X location from the bottom left. | 6985 * x: X location from the bottom left. |
6958 * y: Y location from the bottom left. | 6986 * y: Y location from the bottom left. |
6959 */ | 6987 */ |
6960 void API dw_window_set_pos(HWND handle, LONG x, LONG y) | 6988 void API dw_window_set_pos(HWND handle, LONG x, LONG y) |
6961 { | 6989 { |
6962 int myy = _get_frame_height(handle) - (y + _get_height(handle)); | 6990 unsigned long width, height; |
6963 | 6991 |
6964 WinSetWindowPos(handle, NULLHANDLE, x, myy, 0, 0, SWP_MOVE); | 6992 dw_window_get_pos_size(handle, NULL, NULL, &width, &height); |
6993 _handle_gravity(handle, &x, &y, width, height); | |
6994 WinSetWindowPos(handle, NULLHANDLE, x, y, 0, 0, SWP_MOVE); | |
6965 } | 6995 } |
6966 | 6996 |
6967 /* | 6997 /* |
6968 * Sets the position and size of a given window (widget). | 6998 * Sets the position and size of a given window (widget). |
6969 * Parameters: | 6999 * Parameters: |
6973 * width: Width of the widget. | 7003 * width: Width of the widget. |
6974 * height: Height of the widget. | 7004 * height: Height of the widget. |
6975 */ | 7005 */ |
6976 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height) | 7006 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height) |
6977 { | 7007 { |
6978 int myy = _get_frame_height(handle) - (y + height); | |
6979 | |
6980 /* Attempt to auto-size */ | 7008 /* Attempt to auto-size */ |
6981 if ( width < 1 || height < 1 ) | 7009 if ( width < 1 || height < 1 ) |
6982 _get_window_for_size(handle, &width, &height); | 7010 _get_window_for_size(handle, &width, &height); |
6983 | 7011 |
7012 _handle_gravity(handle, &x, &y, width, height); | |
6984 /* Finally set the size */ | 7013 /* Finally set the size */ |
6985 WinSetWindowPos(handle, NULLHANDLE, x, myy, width, height, SWP_MOVE | SWP_SIZE | SWP_SHOW); | 7014 WinSetWindowPos(handle, NULLHANDLE, x, y, width, height, SWP_MOVE | SWP_SIZE); |
6986 } | 7015 } |
6987 | 7016 |
6988 /* | 7017 /* |
6989 * Gets the position and size of a given window (widget). | 7018 * Gets the position and size of a given window (widget). |
6990 * Parameters: | 7019 * Parameters: |