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

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

Client rectangle changes, GetDCEx bugfix (CS_OWNDC), scroll rectangle calculation fixes

File size: 6.6 KB
Line 
1/* $Id: win32wbasepos.cpp,v 1.6 2000-01-13 20:11:39 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 0
137 if(getParent()) {//in parent coordinates
138 MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), (POINT *)oldClientRect, 2);
139 }
140 else {//in screen coordinates (just add window rectangle origin (already in screen coordinates))
141 OffsetRect(oldClientRect, rectWindow.left, rectWindow.top);
142 }
143#endif
144 params.rgrc[2] = *oldClientRect;
145 params.lppos = &winposCopy;
146 }
147 result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, (LPARAM)&params );
148 if (calcValidRect)
149 {
150 /* If the application send back garbage, ignore it */
151 if (params.rgrc[2].left <= params.rgrc[2].right && params.rgrc[2].top <= params.rgrc[2].bottom)
152 {
153 *newClientRect = params.rgrc[2];
154#if 0
155 if(getParent()) {//in parent coordinates
156 MapWindowPoints(getParent()->getWindowHandle(), getWindowHandle(), (POINT *)newClientRect, 2);
157 }
158 else {//in screen coordinates (just add window rectangle origin (already in screen coordinates))
159 OffsetRect(newClientRect, -rectWindow.left, -rectWindow.top);
160 }
161#endif
162 }
163 else
164 SetRectEmpty(newClientRect);
165 }
166
167 return result;
168}
169/***********************************************************************
170 * WINPOS_HandleWindowPosChanging16
171 *
172 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
173 */
174LONG Win32BaseWindow::HandleWindowPosChanging(WINDOWPOS *winpos)
175{
176 POINT maxSize, minTrack;
177 int rc = 1;
178
179 if (winpos->flags & SWP_NOSIZE)
180 return 1;
181
182 if ((getStyle() & WS_THICKFRAME) ||
183 ((getStyle() & (WS_POPUP | WS_CHILD)) == 0))
184 {
185 GetMinMaxInfo(&maxSize, NULL, &minTrack, NULL );
186 if (maxSize.x < winpos->cx) {
187 winpos->cx = maxSize.x;
188 rc = 0;
189 }
190 if (maxSize.y < winpos->cy) {
191 winpos->cy = maxSize.y;
192 rc = 0;
193 }
194 if (!(getStyle() & WS_MINIMIZE))
195 {
196 if (winpos->cx < minTrack.x ) {
197 winpos->cx = minTrack.x;
198 rc = 0;
199 }
200 if (winpos->cy < minTrack.y ) {
201 winpos->cy = minTrack.y;
202 rc = 0;
203 }
204 }
205 }
206 return rc;
207}
208//******************************************************************************
209//******************************************************************************
210
Note: See TracBrowser for help on using the repository browser.