source: trunk/src/user32/dcrgn.cpp@ 5685

Last change on this file since 5685 was 5685, checked in by sandervl, 24 years ago

client/frame rewrite

File size: 7.9 KB
Line 
1/* $Id: dcrgn.cpp,v 1.4 2001-05-11 08:39:42 sandervl Exp $ */
2
3/*
4 * DC functions for USER32
5 *
6 * Project Odin Software License can be found in LICENSE.TXT
7 *
8 */
9
10/*****************************************************************************
11 * Includes *
12 *****************************************************************************/
13
14#include <odin.h>
15
16#define INCL_WIN
17#define INCL_GPI
18#define INCL_GREALL
19#define INCL_DEV
20#include <os2wrap.h>
21//#include <pmddi.h>
22#include <stdlib.h>
23
24#include <string.h>
25#include <win32type.h>
26#include <win32api.h>
27#include <winconst.h>
28#include <misc.h>
29#include <win32wbase.h>
30#include <math.h>
31#include <limits.h>
32#include "oslibwin.h"
33#include "oslibmsg.h"
34#include <dcdata.h>
35#include <objhandle.h>
36#include <wingdi32.h>
37
38#define INCLUDED_BY_DC
39#include "dc.h"
40
41#define DBG_LOCALLOG DBG_dcrgn
42#include "dbglocal.h"
43
44//******************************************************************************
45//******************************************************************************
46BOOL WIN32API GetUpdateRect(HWND hwnd, LPRECT pRect, BOOL erase)
47{
48 if (!hwnd)
49 {
50 dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
51 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
52 return FALSE;
53 }
54
55 RECTL rectl, rectlClient;
56 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
57
58 if (!wnd)
59 {
60 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
61 dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
62 return FALSE;
63 }
64
65 dprintf(("GetUpdateRect %x %x %d", hwnd, pRect, erase));
66
67 BOOL updateRegionExists = WinQueryUpdateRect(wnd->getOS2WindowHandle(), pRect ? &rectl : NULL);
68 if (!pRect) {
69 return (updateRegionExists);
70 }
71
72 if(updateRegionExists)
73 {
74 //CB: for PM empty rect is valid
75 if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) {
76 if(pRect) {
77 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
78 }
79 return FALSE;
80 }
81 mapOS2ToWin32Rect(wnd->getClientHeight(), (PRECTLOS2)&rectl, pRect);
82
83 if(wnd->isOwnDC() && GetMapMode(wnd->getOwnDC()) != MM_TEXT_W)
84 {
85 DPtoLP(wnd->getOwnDC(), (LPPOINT)pRect, 2);
86 }
87 if (erase)
88 sendEraseBkgnd (wnd);
89 }
90 else
91 {
92 if(pRect) {
93 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
94 }
95 }
96
97 return updateRegionExists;
98}
99//******************************************************************************
100//TODO: Seems to return region in window coordinates instead of client coordinates
101//******************************************************************************
102int WIN32API GetUpdateRgn(HWND hwnd, HRGN hrgn, BOOL erase)
103{
104 LONG lComplexity;
105 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
106
107 hrgn = ObjWinToOS2Region(hrgn);
108 if(!wnd || !hrgn)
109 {
110 dprintf(("WARNING: GetUpdateRgn %x %x %d; invalid handle", hwnd, hrgn, erase));
111 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
112 return ERROR_W;
113 }
114 lComplexity = WinQueryUpdateRegion(wnd->getOS2WindowHandle(), hrgn);
115 if(lComplexity == RGN_ERROR) {
116 dprintf(("WARNING: GetUpdateRgn %x %x %d; RGN_ERROR", hwnd, hrgn, erase));
117 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
118 return ERROR_W;
119 }
120
121 if(lComplexity != RGN_NULL)
122 {
123 if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgn, NULL, wnd->getOS2WindowHandle()))
124 {
125 dprintf(("WARNING: GetUpdateRgn %x %x %d; setWinDeviceRegionFromPMDeviceRegion failed!", hwnd, hrgn, erase));
126 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
127 return ERROR_W;
128 }
129 if(erase) sendEraseBkgnd(wnd);
130 }
131 return lComplexity;
132}
133//******************************************************************************
134//TODO: Check
135//******************************************************************************
136INT WIN32API ExcludeUpdateRgn(HDC hdc, HWND hwnd)
137{
138 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
139 pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc);
140 LONG lComplexity;
141
142 if(!wnd || !pHps)
143 {
144 dprintf(("WARNING: ExcludeUpdateRgn %x %x; invalid handle", hdc, hwnd));
145 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
146 return ERROR_W;
147 }
148 dprintf(("USER32: ExcludeUpdateRgn %x %x", hdc, hwnd));
149
150 lComplexity = WinExcludeUpdateRegion(pHps->hps, wnd->getOS2WindowHandle());
151 if(lComplexity == RGN_ERROR) {
152 SetLastError(ERROR_INVALID_HANDLE_W); //todo: correct error
153 }
154 else SetLastError(ERROR_SUCCESS_W);
155 return lComplexity; // windows and PM values are identical
156}
157/*****************************************************************************
158 * Name : int WIN32API GetWindowRgn
159 * Purpose : The GetWindowRgn function obtains a copy of the window region of a window.
160 * Parameters: HWND hWnd handle to window whose window region is to be obtained
161 * HRGN hRgn handle to region that receives a copy of the window region
162 * Variables :
163 * Result : NULLREGION, SIMPLEREGION, COMPLEXREGION, ERROR
164 * Remark :
165 * Status : UNTESTED STUB
166 *
167 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
168 *****************************************************************************/
169
170int WIN32API GetWindowRgn(HWND hwnd, HRGN hRgn)
171{
172 Win32BaseWindow *window;
173 HRGN hWindowRegion;
174
175 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
176 if(!window) {
177 dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
178 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
179 return 0;
180 }
181 dprintf(("USER32:GetWindowRgn (%x,%x)", hwnd, hRgn));
182 hWindowRegion = window->GetWindowRegion();
183
184 return CombineRgn(hRgn, hWindowRegion, 0, RGN_COPY_W);
185}
186/*****************************************************************************
187 * Name : int WIN32API SetWindowRgn
188 * Purpose : The SetWindowRgn function sets the window region of a window. The
189 * window region determines the area within the window where the
190 * operating system permits drawing. The operating system does not
191 * display any portion of a window that lies outside of the window region
192 * When this function is called, the system sends the WM_WINDOWPOSCHANGING and
193 * WM_WINDOWPOSCHANGED messages to the window.
194 *
195 * Parameters: HWND hWnd handle to window whose window region is to be set
196 * HRGN hRgn handle to region
197 * BOOL bRedraw window redraw flag
198 * Variables :
199 * Result : If the function succeeds, the return value is non-zero.
200 * If the function fails, the return value is zero.
201 * Remark :
202 * Status : UNTESTED STUB
203 *
204 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
205 *****************************************************************************/
206
207int WIN32API SetWindowRgn(HWND hwnd,
208 HRGN hRgn,
209 BOOL bRedraw)
210{
211 Win32BaseWindow *window;
212 HRGN hWindowRegion;
213
214 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
215 if(!window) {
216 dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
217 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
218 return 0;
219 }
220 dprintf(("USER32:SetWindowRgn (%x,%x,%d)", hwnd, hRgn, bRedraw));
221 if(window->GetWindowRegion()) {
222 DeleteObject(window->GetWindowRegion());
223 }
224 window->SetWindowRegion(hRgn);
225 if(bRedraw) {
226 RedrawWindow(hwnd, 0, 0, RDW_UPDATENOW_W);
227 }
228//TODO:
229// When this function is called, the system sends the WM_WINDOWPOSCHANGING and
230// WM_WINDOWPOSCHANGED messages to the window.
231 return 1;
232}
233//******************************************************************************
234//******************************************************************************
Note: See TracBrowser for help on using the repository browser.