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

Last change on this file since 2775 was 2611, checked in by cbratschi, 26 years ago

merged controls with wine 20000130

File size: 5.8 KB
Line 
1/* $Id: win32wbasepos.cpp,v 1.12 2000-02-03 17:13:03 cbratschi 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 (HAS_DLGFRAME( dwStyle, dwExStyle ))
62 {
63 xinc = GetSystemMetrics(SM_CXDLGFRAME);
64 yinc = GetSystemMetrics(SM_CYDLGFRAME);
65 }
66 else
67 {
68 xinc = yinc = 0;
69 if (HAS_THICKFRAME(dwStyle, dwExStyle))
70 {
71 xinc += GetSystemMetrics(SM_CXFRAME);
72 yinc += GetSystemMetrics(SM_CYFRAME);
73 }
74 if (dwStyle & WS_BORDER)
75 {
76 xinc += GetSystemMetrics(SM_CXBORDER);
77 yinc += GetSystemMetrics(SM_CYBORDER);
78 }
79 }
80 MinMax.ptMaxSize.x += 2 * xinc;
81 MinMax.ptMaxSize.y += 2 * yinc;
82
83#if 0
84 lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
85 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
86 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
87 else
88 {
89#endif
90 MinMax.ptMaxPosition.x = -xinc;
91 MinMax.ptMaxPosition.y = -yinc;
92// }
93
94 SendInternalMessageA(WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
95
96 /* Some sanity checks */
97
98 dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
99 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
100 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
101 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
102 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
103 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
104 MinMax.ptMinTrackSize.x );
105 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
106 MinMax.ptMinTrackSize.y );
107
108 if (maxSize) *maxSize = MinMax.ptMaxSize;
109 if (maxPos) *maxPos = MinMax.ptMaxPosition;
110 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
111 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
112}
113/***********************************************************************
114 * WINPOS_SendNCCalcSize
115 *
116 * Send a WM_NCCALCSIZE message to a window.
117 * All parameters are read-only except newClientRect.
118 * oldWindowRect, oldClientRect and winpos must be non-NULL only
119 * when calcValidRect is TRUE.
120 */
121LONG Win32BaseWindow::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect,
122 RECT *oldWindowRect,
123 RECT *oldClientRect, WINDOWPOS *winpos,
124 RECT *newClientRect )
125{
126 NCCALCSIZE_PARAMS params;
127 WINDOWPOS winposCopy;
128 LONG result;
129
130 params.rgrc[0] = *newWindowRect;
131 if (calcValidRect)
132 {
133 winposCopy = *winpos;
134 params.rgrc[1] = *oldWindowRect;
135 if(getParent()) {//in parent coordinates
136 MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), (POINT *)oldClientRect, 2);
137 }
138 else {//in screen coordinates (just add window rectangle origin (already in screen coordinates))
139 OffsetRect(oldClientRect, rectWindow.left, rectWindow.top);
140 }
141 params.rgrc[2] = *oldClientRect;
142 params.lppos = &winposCopy;
143 }
144 result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, (LPARAM)&params );
145
146 /* If the application send back garbage, ignore it */
147 if (params.rgrc[0].left <= params.rgrc[0].right && params.rgrc[0].top <= params.rgrc[0].bottom)
148 {
149 *newClientRect = params.rgrc[0];
150 //client rectangle now in screen coordinates; convert to 'frame' coordinates
151 OffsetRect(newClientRect, -rectWindow.left, -rectWindow.top);
152 }
153
154 return result;
155}
156/***********************************************************************
157 * WINPOS_HandleWindowPosChanging
158 *
159 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
160 */
161LONG Win32BaseWindow::HandleWindowPosChanging(WINDOWPOS *winpos)
162{
163 POINT maxSize;
164 if (winpos->flags & SWP_NOSIZE) return 0;
165
166 if ((dwStyle & WS_THICKFRAME) ||
167 ((dwStyle & (WS_POPUP | WS_CHILD)) == 0))
168 {
169 GetMinMaxInfo( &maxSize, NULL, NULL, NULL );
170 winpos->cx = MIN( winpos->cx, maxSize.x );
171 winpos->cy = MIN( winpos->cy, maxSize.y );
172 }
173 return 0;
174}
175//******************************************************************************
176//******************************************************************************
177
Note: See TracBrowser for help on using the repository browser.