1 | /* $Id: win32wbasepos.cpp,v 1.2 2000-01-02 19:30:45 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 "oslibmenu.h"
|
---|
35 | #include "oslibdos.h"
|
---|
36 | #include "syscolor.h"
|
---|
37 | #include "win32wndhandle.h"
|
---|
38 | #include "dc.h"
|
---|
39 | #include "pmframe.h"
|
---|
40 | #include "win32wdesktop.h"
|
---|
41 |
|
---|
42 | /* Some useful macros */
|
---|
43 | #define HAS_DLGFRAME(style,exStyle) \
|
---|
44 | (((exStyle) & WS_EX_DLGMODALFRAME) || \
|
---|
45 | (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
|
---|
46 |
|
---|
47 | #define HAS_THICKFRAME(style,exStyle) \
|
---|
48 | (((style) & WS_THICKFRAME) && \
|
---|
49 | !((exStyle) & WS_EX_DLGMODALFRAME))
|
---|
50 |
|
---|
51 | #define HAS_THINFRAME(style) \
|
---|
52 | (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
|
---|
53 |
|
---|
54 | #define HAS_BIGFRAME(style,exStyle) \
|
---|
55 | (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
|
---|
56 | ((exStyle) & WS_EX_DLGMODALFRAME))
|
---|
57 |
|
---|
58 | #define HAS_ANYFRAME(style,exStyle) \
|
---|
59 | (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
|
---|
60 | ((exStyle) & WS_EX_DLGMODALFRAME) || \
|
---|
61 | !((style) & (WS_CHILD | WS_POPUP)))
|
---|
62 |
|
---|
63 | #define HAS_3DFRAME(exStyle) \
|
---|
64 | ((exStyle & WS_EX_CLIENTEDGE) || (exStyle & WS_EX_STATICEDGE) || (exStyle & WS_EX_WINDOWEDGE))
|
---|
65 |
|
---|
66 | #define HAS_BORDER(style, exStyle) \
|
---|
67 | ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
|
---|
68 |
|
---|
69 | #define IS_OVERLAPPED(style) \
|
---|
70 | !(style & (WS_CHILD | WS_POPUP))
|
---|
71 |
|
---|
72 | #define HAS_MENU() (!(getStyle() & WS_CHILD) && (GetMenu() != 0))
|
---|
73 |
|
---|
74 | /*******************************************************************
|
---|
75 | * GetMinMaxInfo
|
---|
76 | *
|
---|
77 | * Get the minimized and maximized information for a window.
|
---|
78 | */
|
---|
79 | void Win32BaseWindow::GetMinMaxInfo(POINT *maxSize, POINT *maxPos,
|
---|
80 | POINT *minTrack, POINT *maxTrack )
|
---|
81 | {
|
---|
82 | MINMAXINFO MinMax;
|
---|
83 | INT xinc, yinc;
|
---|
84 |
|
---|
85 | /* Compute default values */
|
---|
86 |
|
---|
87 | MinMax.ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN);
|
---|
88 | MinMax.ptMaxSize.y = GetSystemMetrics(SM_CYSCREEN);
|
---|
89 | MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK);
|
---|
90 | MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK);
|
---|
91 | MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN);
|
---|
92 | MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYSCREEN);
|
---|
93 |
|
---|
94 | if (flags & WIN_MANAGED) xinc = yinc = 0;
|
---|
95 | else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
|
---|
96 | {
|
---|
97 | xinc = GetSystemMetrics(SM_CXDLGFRAME);
|
---|
98 | yinc = GetSystemMetrics(SM_CYDLGFRAME);
|
---|
99 | }
|
---|
100 | else
|
---|
101 | {
|
---|
102 | xinc = yinc = 0;
|
---|
103 | if (HAS_THICKFRAME(dwStyle, dwExStyle))
|
---|
104 | {
|
---|
105 | xinc += GetSystemMetrics(SM_CXFRAME);
|
---|
106 | yinc += GetSystemMetrics(SM_CYFRAME);
|
---|
107 | }
|
---|
108 | if (dwStyle & WS_BORDER)
|
---|
109 | {
|
---|
110 | xinc += GetSystemMetrics(SM_CXBORDER);
|
---|
111 | yinc += GetSystemMetrics(SM_CYBORDER);
|
---|
112 | }
|
---|
113 | }
|
---|
114 | MinMax.ptMaxSize.x += 2 * xinc;
|
---|
115 | MinMax.ptMaxSize.y += 2 * yinc;
|
---|
116 |
|
---|
117 | #if 0
|
---|
118 | lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
|
---|
119 | if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
|
---|
120 | CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
|
---|
121 | else
|
---|
122 | {
|
---|
123 | #endif
|
---|
124 | MinMax.ptMaxPosition.x = -xinc;
|
---|
125 | MinMax.ptMaxPosition.y = -yinc;
|
---|
126 | // }
|
---|
127 |
|
---|
128 | SendInternalMessageA(WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
|
---|
129 |
|
---|
130 | /* Some sanity checks */
|
---|
131 |
|
---|
132 | dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
|
---|
133 | MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
|
---|
134 | MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
|
---|
135 | MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
|
---|
136 | MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
|
---|
137 | MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
|
---|
138 | MinMax.ptMinTrackSize.x );
|
---|
139 | MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
|
---|
140 | MinMax.ptMinTrackSize.y );
|
---|
141 |
|
---|
142 | if (maxSize) *maxSize = MinMax.ptMaxSize;
|
---|
143 | if (maxPos) *maxPos = MinMax.ptMaxPosition;
|
---|
144 | if (minTrack) *minTrack = MinMax.ptMinTrackSize;
|
---|
145 | if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
|
---|
146 | }
|
---|
147 | /***********************************************************************
|
---|
148 | * WINPOS_SendNCCalcSize
|
---|
149 | *
|
---|
150 | * Send a WM_NCCALCSIZE message to a window.
|
---|
151 | * All parameters are read-only except newClientRect.
|
---|
152 | * oldWindowRect, oldClientRect and winpos must be non-NULL only
|
---|
153 | * when calcValidRect is TRUE.
|
---|
154 | */
|
---|
155 | LONG Win32BaseWindow::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect,
|
---|
156 | RECT *oldWindowRect,
|
---|
157 | RECT *oldClientRect, WINDOWPOS *winpos,
|
---|
158 | RECT *newClientRect )
|
---|
159 | {
|
---|
160 | NCCALCSIZE_PARAMS params;
|
---|
161 | WINDOWPOS winposCopy;
|
---|
162 | LONG result;
|
---|
163 |
|
---|
164 | params.rgrc[0] = *newWindowRect;
|
---|
165 | if (calcValidRect)
|
---|
166 | {
|
---|
167 | winposCopy = *winpos;
|
---|
168 | params.rgrc[1] = *oldWindowRect;
|
---|
169 | params.rgrc[2] = *oldClientRect;
|
---|
170 | params.lppos = &winposCopy;
|
---|
171 | }
|
---|
172 | result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect,
|
---|
173 | (LPARAM)¶ms );
|
---|
174 | *newClientRect = params.rgrc[0];
|
---|
175 | return result;
|
---|
176 | }
|
---|
177 | /***********************************************************************
|
---|
178 | * WINPOS_HandleWindowPosChanging16
|
---|
179 | *
|
---|
180 | * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
|
---|
181 | */
|
---|
182 | LONG Win32BaseWindow::HandleWindowPosChanging(WINDOWPOS *winpos)
|
---|
183 | {
|
---|
184 | POINT maxSize, minTrack;
|
---|
185 | int rc = 1;
|
---|
186 |
|
---|
187 | if (winpos->flags & SWP_NOSIZE)
|
---|
188 | return 1;
|
---|
189 |
|
---|
190 | if ((getStyle() & WS_THICKFRAME) ||
|
---|
191 | ((getStyle() & (WS_POPUP | WS_CHILD)) == 0))
|
---|
192 | {
|
---|
193 | GetMinMaxInfo(&maxSize, NULL, &minTrack, NULL );
|
---|
194 | if (maxSize.x < winpos->cx) {
|
---|
195 | winpos->cx = maxSize.x;
|
---|
196 | rc = 0;
|
---|
197 | }
|
---|
198 | if (maxSize.y < winpos->cy) {
|
---|
199 | winpos->cy = maxSize.y;
|
---|
200 | rc = 0;
|
---|
201 | }
|
---|
202 | if (!(getStyle() & WS_MINIMIZE))
|
---|
203 | {
|
---|
204 | if (winpos->cx < minTrack.x ) {
|
---|
205 | winpos->cx = minTrack.x;
|
---|
206 | rc = 0;
|
---|
207 | }
|
---|
208 | if (winpos->cy < minTrack.y ) {
|
---|
209 | winpos->cy = minTrack.y;
|
---|
210 | rc = 0;
|
---|
211 | }
|
---|
212 | }
|
---|
213 | }
|
---|
214 | return rc;
|
---|
215 | }
|
---|
216 | //******************************************************************************
|
---|
217 | //******************************************************************************
|
---|
218 |
|
---|