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

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

Added new logging feature

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