source: trunk/src/user32/win32wbasepos.cpp@ 3625

Last change on this file since 3625 was 3625, checked in by sandervl, 25 years ago

resource handling changes

File size: 5.9 KB
Line 
1/* $Id: win32wbasepos.cpp,v 1.14 2000-05-28 16:43:47 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 <spy.h>
28#include "wndmsg.h"
29#include "oslibwin.h"
30#include "oslibutil.h"
31#include "oslibgdi.h"
32#include "oslibres.h"
33#include "oslibdos.h"
34#include "syscolor.h"
35#include "win32wndhandle.h"
36#include "dc.h"
37#include "pmframe.h"
38#include "win32wdesktop.h"
39
40#define DBG_LOCALLOG DBG_win32wbasepos
41#include "dbglocal.h"
42
43/*******************************************************************
44 * GetMinMaxInfo
45 *
46 * Get the minimized and maximized information for a window.
47 */
48void Win32BaseWindow::GetMinMaxInfo(POINT *maxSize, POINT *maxPos,
49 POINT *minTrack, POINT *maxTrack )
50{
51 MINMAXINFO MinMax;
52 INT xinc, yinc;
53
54 /* Compute default values */
55
56 MinMax.ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN);
57 MinMax.ptMaxSize.y = GetSystemMetrics(SM_CYSCREEN);
58 MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK);
59 MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK);
60 MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN);
61 MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYSCREEN);
62
63 if (HAS_DLGFRAME( dwStyle, dwExStyle ))
64 {
65 xinc = GetSystemMetrics(SM_CXDLGFRAME);
66 yinc = GetSystemMetrics(SM_CYDLGFRAME);
67 }
68 else
69 {
70 xinc = yinc = 0;
71 if (HAS_THICKFRAME(dwStyle, dwExStyle))
72 {
73 xinc += GetSystemMetrics(SM_CXFRAME);
74 yinc += GetSystemMetrics(SM_CYFRAME);
75 }
76 if (dwStyle & WS_BORDER)
77 {
78 xinc += GetSystemMetrics(SM_CXBORDER);
79 yinc += GetSystemMetrics(SM_CYBORDER);
80 }
81 }
82 MinMax.ptMaxSize.x += 2 * xinc;
83 MinMax.ptMaxSize.y += 2 * yinc;
84
85#if 0
86 lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
87 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
88 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
89 else
90 {
91#endif
92 MinMax.ptMaxPosition.x = -xinc;
93 MinMax.ptMaxPosition.y = -yinc;
94// }
95
96 SendInternalMessageA(WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
97
98 /* Some sanity checks */
99
100 dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
101 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
102 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
103 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
104 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
105 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
106 MinMax.ptMinTrackSize.x );
107 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
108 MinMax.ptMinTrackSize.y );
109
110 if (maxSize) *maxSize = MinMax.ptMaxSize;
111 if (maxPos) *maxPos = MinMax.ptMaxPosition;
112 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
113 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
114}
115/***********************************************************************
116 * WINPOS_SendNCCalcSize
117 *
118 * Send a WM_NCCALCSIZE message to a window.
119 * All parameters are read-only except newClientRect.
120 * oldWindowRect, oldClientRect and winpos must be non-NULL only
121 * when calcValidRect is TRUE.
122 */
123LONG Win32BaseWindow::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect,
124 RECT *oldWindowRect,
125 RECT *oldClientRect, WINDOWPOS *winpos,
126 RECT *newClientRect )
127{
128 NCCALCSIZE_PARAMS params;
129 WINDOWPOS winposCopy;
130 LONG result;
131
132 params.rgrc[0] = *newWindowRect;
133 if (calcValidRect)
134 {
135 winposCopy = *winpos;
136 params.rgrc[1] = *oldWindowRect;
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 params.rgrc[2] = *oldClientRect;
144 params.lppos = &winposCopy;
145 }
146 result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, (LPARAM)&params );
147
148 /* If the application send back garbage, ignore it */
149 if (params.rgrc[0].left <= params.rgrc[0].right && params.rgrc[0].top <= params.rgrc[0].bottom)
150 {
151 *newClientRect = params.rgrc[0];
152 //client rectangle now in screen coordinates; convert to 'frame' coordinates
153 OffsetRect(newClientRect, -rectWindow.left, -rectWindow.top);
154 }
155
156 return result;
157}
158/***********************************************************************
159 * WINPOS_HandleWindowPosChanging
160 *
161 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
162 */
163LONG Win32BaseWindow::HandleWindowPosChanging(WINDOWPOS *winpos)
164{
165 POINT maxSize;
166 if (winpos->flags & SWP_NOSIZE) return 0;
167
168 if ((dwStyle & WS_THICKFRAME) ||
169 ((dwStyle & (WS_POPUP | WS_CHILD)) == 0))
170 {
171 GetMinMaxInfo( &maxSize, NULL, NULL, NULL );
172 winpos->cx = MIN( winpos->cx, maxSize.x );
173 winpos->cy = MIN( winpos->cy, maxSize.y );
174 }
175 return 0;
176}
177//******************************************************************************
178//******************************************************************************
179
Note: See TracBrowser for help on using the repository browser.