source: trunk/src/ddraw/OS2CLIPPER.CPP@ 5472

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

compile fix

File size: 6.3 KB
Line 
1/* $Id: OS2CLIPPER.CPP,v 1.11 2001-04-04 09:02:14 sandervl Exp $ */
2
3/*
4 * DX clipper class routines
5 *
6 * Copyright 1998 Sander van Leeuwen
7 * Copyright 1999 Markus Montkowski
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12
13#include <odin.h>
14#include <memory.h>
15
16#define INITGUID
17#include "os2ddraw.h"
18#include "os2clipper.h"
19#define _OS2WIN_H
20#define FAR
21#include <misc.h>
22#include <winerror.h>
23#include <winuser.h>
24
25//******************************************************************************
26//******************************************************************************
27OS2IDirectDrawClipper::OS2IDirectDrawClipper(OS2IDirectDraw *lpDirectDraw) :
28 Referenced(0), lastError(DD_OK),
29 clipWindow(0)
30{
31 lpVtbl = &Vtbl;
32 Vtbl.AddRef = ClipAddRef;
33 Vtbl.Release = ClipRelease;
34 Vtbl.QueryInterface = ClipQueryInterface;
35 Vtbl.GetClipList = ClipGetClipList;
36 Vtbl.GetHWnd = ClipGetHWnd;
37 Vtbl.Initialize = ClipInitialize;
38 Vtbl.IsClipListChanged = ClipIsClipListChanged;
39 Vtbl.SetClipList = ClipSetClipList;
40 Vtbl.SetHWnd = ClipSetHWnd;
41
42 lpDraw = lpDirectDraw;
43 lpDraw->Vtbl.AddRef(lpDraw);
44 hDive = lpDirectDraw->GetDiveInstance();
45 windowRect.left = windowRect.right = windowRect.top = windowRect.bottom = 0;
46}
47//******************************************************************************
48//******************************************************************************
49OS2IDirectDrawClipper::~OS2IDirectDrawClipper()
50{
51 lpDraw->Vtbl.Release(lpDraw);
52}
53//******************************************************************************
54//******************************************************************************
55HRESULT WIN32API ClipQueryInterface(THIS This, REFIID riid, LPVOID FAR * ppvObj)
56{
57 dprintf(("DDRAW: ClipQueryInterface\n"));
58
59 *ppvObj = NULL;
60
61 if(!IsEqualGUID(riid, IID_IDirectDrawClipper) &&
62 !IsEqualGUID(riid, CLSID_DirectDrawClipper))
63//&& !IsEqualGUID(riid, IID_IUnknown))
64 return E_NOINTERFACE;
65
66 *ppvObj = This;
67
68 ClipAddRef(This);
69 return(DD_OK);
70}
71//******************************************************************************
72//******************************************************************************
73ULONG WIN32API ClipAddRef(THIS This)
74{
75 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
76
77 dprintf(("DDRAW: OS2IDirectDrawClipper::AddRef %d\n", me->Referenced+1));
78
79 return ++me->Referenced;
80}
81//******************************************************************************
82//******************************************************************************
83ULONG WIN32API ClipRelease(THIS This)
84{
85 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
86
87 dprintf(("DDRAW: OS2IDirectDrawClipper::Release %d", me->Referenced-1));
88
89 if(me->Referenced)
90 {
91 me->Referenced--;
92 if(me->Referenced == 0)
93 {
94 delete( me);
95 return(0);
96 }
97 else
98 return me->Referenced;
99 }
100 else
101 return(0);
102}
103//******************************************************************************
104//******************************************************************************
105HRESULT WIN32API ClipGetClipList(THIS This, LPRECT lpRect, LPRGNDATA lpClipList,
106 LPDWORD lpdwSize)
107{
108 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
109 HRESULT rc = DD_OK;
110
111 dprintf(("DDRAW: ClipGetClipList %x %x %x %x", This, lpRect, lpClipList, lpdwSize));
112
113 if(!lpdwSize) {
114 return DDERR_INVALIDPARAMS;
115 }
116 if(me->clipWindow)
117 {
118 HRGN hRgn, hRgn1;
119 HDC hdc;
120 int bufneeded;
121
122 hRgn = CreateRectRgn(0, 0, 1, 1);
123 hdc = GetDC(me->clipWindow);
124 if(GetClipRgn(hdc, hRgn)) {
125 if(lpRect) {
126 hRgn1 = CreateRectRgnIndirect(lpRect);
127 CombineRgn(hRgn, hRgn, hRgn1, RGN_AND);
128 DeleteObject(hRgn1);
129 }
130 bufneeded = GetRegionData(hRgn, *lpdwSize, lpClipList);
131 if(bufneeded > *lpdwSize) {
132 rc = DDERR_REGIONTOOSMALL;
133 }
134 }
135 else rc = DDERR_NOCLIPLIST;
136 DeleteObject(hRgn);
137 ReleaseDC(me->clipWindow, hdc);
138 }
139 else { //todo!!
140 dprintf(("ClipGetClipList not complete if not associated with window!"));
141 rc = DDERR_NOCLIPLIST;
142 }
143 return rc;
144}
145//******************************************************************************
146//******************************************************************************
147HRESULT WIN32API ClipGetHWnd(THIS This, HWND FAR *pHwnd)
148{
149 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
150
151 dprintf(("DDRAW: ClipGetHWnd %x %x", This, me->clipWindow));
152
153 *pHwnd = me->clipWindow;
154 return(DD_OK);
155}
156//******************************************************************************
157//******************************************************************************
158HRESULT WIN32API ClipInitialize(THIS This, LPDIRECTDRAW lpDD, DWORD dwFlags)
159{
160 dprintf(("DDRAW: ClipInitialize %x %x %x", This, lpDD, dwFlags));
161
162 return(DDERR_ALREADYINITIALIZED); // Init is done during creation see M$ Doc
163}
164//******************************************************************************
165//******************************************************************************
166HRESULT WIN32API ClipIsClipListChanged(THIS This, BOOL *lpbChanged)
167{
168 dprintf(("DDRAW: ClipIsClipListChanged %x %x", This, lpbChanged));
169
170 return(DD_OK);
171}
172//******************************************************************************
173//******************************************************************************
174HRESULT WIN32API ClipSetClipList(THIS This, LPRGNDATA lpClipList, DWORD lpdwSize)
175{
176 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
177
178 dprintf(("DDRAW: ClipSetClipList %x %x %x", This, lpClipList, lpdwSize));
179
180 if(me->clipWindow) {
181 return DDERR_CLIPPERISUSINGHWND;
182 }
183 return(DD_OK);
184}
185//******************************************************************************
186//DWORD param not used in DirectX 3
187//******************************************************************************
188HRESULT WIN32API ClipSetHWnd(THIS This, DWORD reserved, HWND hwnd)
189{
190 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
191
192 dprintf(("DDRAW: ClipSetHWnd %x %x %x", This, reserved, hwnd));
193
194 me->clipWindow = hwnd;
195 GetClientRect(hwnd, &me->windowRect);
196
197 return(DD_OK);
198}
199//******************************************************************************
200//******************************************************************************
Note: See TracBrowser for help on using the repository browser.