X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwlayout.c;h=c308fb333ee9cba7743a5f695c5c98faa8da06cf;hb=HEAD;hp=d5e8153422f2f5b6d5cb8b715389d56525b8b648;hpb=0efdc4c5ef60cf4c15e9dddf3658d2115e4d5d93;p=xboard.git diff --git a/winboard/wlayout.c b/winboard/wlayout.c index d5e8153..c308fb3 100644 --- a/winboard/wlayout.c +++ b/winboard/wlayout.c @@ -3,22 +3,29 @@ * * Author: Alessandro Scotti (Dec 2005) * + * Copyright 2005 Alessandro Scotti + * + * Enhancements Copyright 2009, 2012, 2013, 2014, 2015, 2016 Free + * Software Foundation, Inc. + * * ------------------------------------------------------------------------ - * This program is free software; you can redistribute it and/or modify + * + * GNU XBoard is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU XBoard is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * ------------------------------------------------------------------------ - */ + * along with this program. If not, see http://www.gnu.org/licenses/. * + * + *------------------------------------------------------------------------ + ** See the file ChangeLog for a revision history. */ + #include "config.h" #include /* required for all Windows applications */ @@ -29,6 +36,7 @@ #include #include "common.h" +#include "frontend.h" #include "winboard.h" VOID RestoreWindowPlacement( HWND hWnd, WindowPlacement * wp ) @@ -42,7 +50,7 @@ VOID RestoreWindowPlacement( HWND hWnd, WindowPlacement * wp ) ZeroMemory( &stWP, sizeof(stWP) ); - EnsureOnScreen( &wp->x, &wp->y); + EnsureOnScreen( &wp->x, &wp->y, 0, 0); stWP.length = sizeof(stWP); stWP.flags = 0; @@ -89,7 +97,7 @@ static BOOL IsDefaultPlacement( WindowPlacement * wp ) return result; } -static BOOL GetActualPlacement( HWND hWnd, WindowPlacement * wp ) +BOOL GetActualPlacement( HWND hWnd, WindowPlacement * wp ) { BOOL result = FALSE; @@ -154,3 +162,40 @@ VOID ReattachAfterMove( LPRECT lprcOldPos, int new_x, int new_y, HWND hWndChild, } } } + +extern FILE *debugFP; +VOID ReattachAfterSize( LPRECT lprcOldPos, int new_w, int new_h, HWND hWndChild, WindowPlacement * pwpChild ) +{ + if( ! IsDefaultPlacement( pwpChild ) ) { + GetActualPlacement( hWndChild, pwpChild ); + + if( IsAttachedByWindowPlacement( lprcOldPos, pwpChild ) ) { + /* Get delta of lower right corner */ + int delta_x = new_w - (lprcOldPos->right - lprcOldPos->left); + int delta_y = new_h - (lprcOldPos->bottom - lprcOldPos->top); + + /* Adjust size & placement */ + if(pwpChild->x + pwpChild->width >= lprcOldPos->right && + (pwpChild->x + pwpChild->width < screenGeometry.right - 5 || delta_x > 0) ) // keep right edge glued to display edge if touching + pwpChild->width += delta_x; + if(pwpChild->x + pwpChild->width >= screenGeometry.right ) // don't move right edge off screen + pwpChild->width = screenGeometry.right - pwpChild->x; + if(pwpChild->y + pwpChild->height >= lprcOldPos->bottom && + (pwpChild->y + pwpChild->height < screenGeometry.bottom - 35 || delta_y > 0) ) // keep bottom edge glued to display edge if touching + pwpChild->height += delta_y; + if(pwpChild->y + pwpChild->height >= screenGeometry.bottom - 30 ) // don't move bottom edge off screen + pwpChild->height = screenGeometry.bottom - 30 - pwpChild->y; + if(pwpChild->x >= lprcOldPos->right) pwpChild->width -= delta_x, pwpChild->x += delta_x; + if(pwpChild->y >= lprcOldPos->bottom) pwpChild->height -= delta_y, pwpChild->y += delta_y; + if(pwpChild->width < 30) pwpChild->width = 30; // force minimum width + if(pwpChild->height < 50) pwpChild->height = 50; // force minimum height + /* Move window */ + if( hWndChild != NULL ) { + SetWindowPos( hWndChild, HWND_TOP, + pwpChild->x, pwpChild->y, + pwpChild->width, pwpChild->height, + SWP_NOZORDER ); + } + } + } +}