source: trunk/src/user32/new/win32wbasepos.cpp@ 2435

Last change on this file since 2435 was 2435, checked in by sandervl, 26 years ago

Several window position bugfixes

File size: 6.3 KB
Line 
1/* $Id: win32wbasepos.cpp,v 1.7 2000-01-14 13:16:59 sandervl Exp $ */
2/*
3 * Win32 Window Base Class for OS/2 (nonclient/position methods)
4 *
5 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 1999 Daniela Engert (dani@ngrt.de)
7 *
8 * Parts based on Wine Windows code (windows\win.c, windows\nonclient.c)
9 *
10 * Copyright 1993, 1994 Alexandre Julliard
11 *
12 * TODO: Not thread/process safe
13 *
14 * Wine code based on build 990815
15 *
16 * Project Odin Software License can be found in LICENSE.TXT
17 *
18 */
19#include <os2win.h>
20#include <win.h>
21#include <stdlib.h>
22#include <string.h>
23#include <stdarg.h>
24#include <assert.h>
25#include <misc.h>
26#include <win32wbase.h>
27#include <winres.h>
28#include <spy.h>
29#include "wndmsg.h"
30#include "oslibwin.h"
31#include "oslibutil.h"
32#include "oslibgdi.h"
33#include "oslibres.h"
34#include "oslibdos.h"
35#include "syscolor.h"
36#include "win32wndhandle.h"
37#include "dc.h"
38#include "pmframe.h"
39#include "win32wdesktop.h"
40
41/*******************************************************************
42 * GetMinMaxInfo
43 *
44 * Get the minimized and maximized information for a window.
45 */
46void Win32BaseWindow::GetMinMaxInfo(POINT *maxSize, POINT *maxPos,
47 POINT *minTrack, POINT *maxTrack )
48{
49 MINMAXINFO MinMax;
50 INT xinc, yinc;
51
52 /* Compute default values */
53
54 MinMax.ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN);
55 MinMax.ptMaxSize.y = GetSystemMetrics(SM_CYSCREEN);
56 MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK);
57 MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK);
58 MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN);
59 MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYSCREEN);
60
61 if (flags & WIN_MANAGED) xinc = yinc = 0;
62 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
63 {
64 xinc = GetSystemMetrics(SM_CXDLGFRAME);
65 yinc = GetSystemMetrics(SM_CYDLGFRAME);
66 }
67 else
68 {
69 xinc = yinc = 0;
70 if (HAS_THICKFRAME(dwStyle, dwExStyle))
71 {
72 xinc += GetSystemMetrics(SM_CXFRAME);
73 yinc += GetSystemMetrics(SM_CYFRAME);
74 }
75 if (dwStyle & WS_BORDER)
76 {
77 xinc += GetSystemMetrics(SM_CXBORDER);
78 yinc += GetSystemMetrics(SM_CYBORDER);
79 }
80 }
81 MinMax.ptMaxSize.x += 2 * xinc;
82 MinMax.ptMaxSize.y += 2 * yinc;
83
84#if 0
85 lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
86 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
87 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
88 else
89 {
90#endif
91 MinMax.ptMaxPosition.x = -xinc;
92 MinMax.ptMaxPosition.y = -yinc;
93// }
94
95 SendInternalMessageA(WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
96
97 /* Some sanity checks */
98
99 dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
100 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
101 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
102 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
103 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
104 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
105 MinMax.ptMinTrackSize.x );
106 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
107 MinMax.ptMinTrackSize.y );
108
109 if (maxSize) *maxSize = MinMax.ptMaxSize;
110 if (maxPos) *maxPos = MinMax.ptMaxPosition;
111 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
112 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
113}
114/***********************************************************************
115 * WINPOS_SendNCCalcSize
116 *
117 * Send a WM_NCCALCSIZE message to a window.
118 * All parameters are read-only except newClientRect.
119 * oldWindowRect, oldClientRect and winpos must be non-NULL only
120 * when calcValidRect is TRUE.
121 */
122LONG Win32BaseWindow::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect,
123 RECT *oldWindowRect,
124 RECT *oldClientRect, WINDOWPOS *winpos,
125 RECT *newClientRect )
126{
127 NCCALCSIZE_PARAMS params;
128 WINDOWPOS winposCopy;
129 LONG result;
130
131 params.rgrc[0] = *newWindowRect;
132 if (calcValidRect)
133 {
134 winposCopy = *winpos;
135 params.rgrc[1] = *oldWindowRect;
136 if(getParent()) {//in parent coordinates
137 MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), (POINT *)oldClientRect, 2);
138 }
139 else {//in screen coordinates (just add window rectangle origin (already in screen coordinates))
140 OffsetRect(oldClientRect, rectWindow.left, rectWindow.top);
141 }
142 params.rgrc[2] = *oldClientRect;
143 params.lppos = &winposCopy;
144 }
145 result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, (LPARAM)&params );
146
147 /* If the application send back garbage, ignore it */
148 if (params.rgrc[0].left <= params.rgrc[0].right && params.rgrc[0].top <= params.rgrc[0].bottom)
149 {
150 *newClientRect = params.rgrc[0];
151 //client rectangle now in screen coordinates; convert to 'frame' coordinates
152 OffsetRect(newClientRect, -rectWindow.left, -rectWindow.top);
153 }
154
155 return result;
156}
157/***********************************************************************
158 * WINPOS_HandleWindowPosChanging16
159 *
160 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
161 */
162LONG Win32BaseWindow::HandleWindowPosChanging(WINDOWPOS *winpos)
163{
164 POINT maxSize, minTrack;
165 int rc = 1;
166
167 if (winpos->flags & SWP_NOSIZE)
168 return 1;
169
170 if ((getStyle() & WS_THICKFRAME) ||
171 ((getStyle() & (WS_POPUP | WS_CHILD)) == 0))
172 {
173 GetMinMaxInfo(&maxSize, NULL, &minTrack, NULL );
174 if (maxSize.x < winpos->cx) {
175 winpos->cx = maxSize.x;
176 rc = 0;
177 }
178 if (maxSize.y < winpos->cy) {
179 winpos->cy = maxSize.y;
180 rc = 0;
181 }
182 if (!(getStyle() & WS_MINIMIZE))
183 {
184 if (winpos->cx < minTrack.x ) {
185 winpos->cx = minTrack.x;
186 rc = 0;
187 }
188 if (winpos->cy < minTrack.y ) {
189 winpos->cy = minTrack.y;
190 rc = 0;
191 }
192 }
193 }
194 return rc;
195}
196//******************************************************************************
197//******************************************************************************
198
Note: See TracBrowser for help on using the repository browser.