00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <odin.h>
00015
00016 #define INCL_WIN
00017 #define INCL_GPI
00018 #define INCL_GREALL
00019 #define INCL_DEV
00020 #include <os2wrap.h>
00021
00022 #include <stdlib.h>
00023
00024 #include <string.h>
00025 #include <win32type.h>
00026 #include <win32api.h>
00027 #include <winconst.h>
00028 #include <misc.h>
00029 #include <win32wbase.h>
00030 #include <math.h>
00031 #include <limits.h>
00032 #include "oslibwin.h"
00033 #include "oslibmsg.h"
00034 #include <dcdata.h>
00035 #include <objhandle.h>
00036 #include <wingdi32.h>
00037
00038 #define INCLUDED_BY_DC
00039 #include "dc.h"
00040
00041 #define DBG_LOCALLOG DBG_dcrgn
00042 #include "dbglocal.h"
00043
00044
00045
00046 BOOL WIN32API GetUpdateRect(HWND hwnd, LPRECT pRect, BOOL erase)
00047 {
00048 if (!hwnd)
00049 {
00050 dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
00051 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
00052 return FALSE;
00053 }
00054
00055 RECTL rectl, rectlClient;
00056 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
00057
00058 if (!wnd)
00059 {
00060 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
00061 dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
00062 return FALSE;
00063 }
00064
00065 dprintf(("GetUpdateRect %x %x %d", hwnd, pRect, erase));
00066
00067 BOOL updateRegionExists = WinQueryUpdateRect(wnd->getOS2WindowHandle(), pRect ? &rectl : NULL);
00068 if (!pRect) {
00069 dprintf(("GetUpdateRect returned %d", updateRegionExists));
00070 RELEASE_WNDOBJ(wnd);
00071 return (updateRegionExists);
00072 }
00073
00074 if(updateRegionExists)
00075 {
00076
00077 if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) {
00078 if(pRect) {
00079 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
00080 }
00081 RELEASE_WNDOBJ(wnd);
00082 return FALSE;
00083 }
00084 mapOS2ToWin32Rect(wnd->getClientHeight(), (PRECTLOS2)&rectl, pRect);
00085
00086 if(wnd->isOwnDC() && GetMapMode(wnd->getOwnDC()) != MM_TEXT_W)
00087 {
00088 DPtoLP(wnd->getOwnDC(), (LPPOINT)pRect, 2);
00089 }
00090 if (erase)
00091 sendEraseBkgnd (wnd);
00092 }
00093 else
00094 {
00095 if(pRect) {
00096 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
00097 }
00098 }
00099
00100 dprintf(("GetUpdateRect returned (%d,%d)(%d,%d)", pRect->left, pRect->top, pRect->right, pRect->bottom));
00101 RELEASE_WNDOBJ(wnd);
00102 return updateRegionExists;
00103 }
00104
00105
00106
00107 int WIN32API GetUpdateRgn(HWND hwnd, HRGN hrgn, BOOL erase)
00108 {
00109 LONG lComplexity;
00110 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
00111
00112 hrgn = ObjWinToOS2Region(hrgn);
00113 if(!wnd || !hrgn)
00114 {
00115 dprintf(("WARNING: GetUpdateRgn %x %x %d; invalid handle", hwnd, hrgn, erase));
00116 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
00117 if(wnd) RELEASE_WNDOBJ(wnd);
00118 return ERROR_W;
00119 }
00120 lComplexity = WinQueryUpdateRegion(wnd->getOS2WindowHandle(), hrgn);
00121 if(lComplexity == RGN_ERROR) {
00122 dprintf(("WARNING: GetUpdateRgn %x %x %d; RGN_ERROR", hwnd, hrgn, erase));
00123 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
00124 RELEASE_WNDOBJ(wnd);
00125 return ERROR_W;
00126 }
00127
00128 if(lComplexity != RGN_NULL)
00129 {
00130 if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgn, NULL, wnd->getOS2WindowHandle()))
00131 {
00132 dprintf(("WARNING: GetUpdateRgn %x %x %d; setWinDeviceRegionFromPMDeviceRegion failed!", hwnd, hrgn, erase));
00133 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
00134 RELEASE_WNDOBJ(wnd);
00135 return ERROR_W;
00136 }
00137 if(erase) sendEraseBkgnd(wnd);
00138 }
00139 RELEASE_WNDOBJ(wnd);
00140 return lComplexity;
00141 }
00142
00143
00144
00145 INT WIN32API ExcludeUpdateRgn(HDC hdc, HWND hwnd)
00146 {
00147 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
00148 pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc);
00149 LONG lComplexity;
00150
00151 if(!wnd || !pHps)
00152 {
00153 dprintf(("WARNING: ExcludeUpdateRgn %x %x; invalid handle", hdc, hwnd));
00154 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
00155 if(wnd) RELEASE_WNDOBJ(wnd);
00156 return ERROR_W;
00157 }
00158 dprintf(("USER32: ExcludeUpdateRgn %x %x", hdc, hwnd));
00159
00160 lComplexity = WinExcludeUpdateRegion(pHps->hps, wnd->getOS2WindowHandle());
00161 if(lComplexity == RGN_ERROR) {
00162 SetLastError(ERROR_INVALID_HANDLE_W);
00163 }
00164 else SetLastError(ERROR_SUCCESS_W);
00165
00166 RELEASE_WNDOBJ(wnd);
00167 return lComplexity;
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 int WIN32API GetWindowRgn(HWND hwnd, HRGN hRgn)
00183 {
00184 Win32BaseWindow *window;
00185 HRGN hWindowRegion;
00186
00187 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
00188 if(!window) {
00189 dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
00190 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
00191 return 0;
00192 }
00193 dprintf(("USER32:GetWindowRgn (%x,%x)", hwnd, hRgn));
00194 hWindowRegion = window->GetWindowRegion();
00195 RELEASE_WNDOBJ(window);
00196 return CombineRgn(hRgn, hWindowRegion, 0, RGN_COPY_W);
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 int WIN32API SetWindowRgn(HWND hwnd,
00220 HRGN hRgn,
00221 BOOL bRedraw)
00222 {
00223 Win32BaseWindow *window;
00224 HRGN hWindowRegion;
00225
00226 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
00227 if(!window) {
00228 dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
00229 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
00230 return 0;
00231 }
00232 dprintf(("USER32:SetWindowRgn (%x,%x,%d)", hwnd, hRgn, bRedraw));
00233 if(window->GetWindowRegion()) {
00234 DeleteObject(window->GetWindowRegion());
00235 }
00236 window->SetWindowRegion(hRgn);
00237 if(bRedraw) {
00238 RedrawWindow(hwnd, 0, 0, RDW_UPDATENOW_W);
00239 }
00240 RELEASE_WNDOBJ(window);
00241
00242
00243
00244 return 1;
00245 }
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 BOOL WIN32API WinSetVisibleRgnNotifyProc(HWND hwnd, VISRGN_NOTIFY_PROC lpNotifyProc,
00261 DWORD dwUserData)
00262 {
00263 Win32BaseWindow *window;
00264
00265 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
00266 if(!window) {
00267 dprintf(("WinSetVisibleRgnNotifyProc, window %x not found", hwnd));
00268 return FALSE;
00269 }
00270 BOOL ret = window->setVisibleRgnNotifyProc(lpNotifyProc, dwUserData);
00271 RELEASE_WNDOBJ(window);
00272 return ret;
00273 }
00274
00275