Added regedit unit test, a couple minor changes to regedit.
[wine] / dlls / ddraw / dclipper / main.c
1 /*              DirectDrawClipper implementation
2  *
3  * Copyright 2000 Marcus Meissner
4  * Copyright 2000 TransGaming Technologies Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <stdlib.h>
24 #include <string.h>
25
26 #include "ddraw.h"
27 #include "winerror.h"
28
29 #include "ddraw_private.h"
30 #include "dclipper/main.h"
31 #include "ddraw/main.h"
32
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
36
37 /******************************************************************************
38  *                      DirectDrawCreateClipper (DDRAW.@)
39  */
40
41 static ICOM_VTABLE(IDirectDrawClipper) DDRAW_Clipper_VTable;
42
43 HRESULT WINAPI DirectDrawCreateClipper(
44     DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter
45 ) {
46     IDirectDrawClipperImpl* This;
47     TRACE("(%08lx,%p,%p)\n", dwFlags, lplpDDClipper, pUnkOuter);
48
49     if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
50
51     This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
52                      sizeof(IDirectDrawClipperImpl));
53     if (This == NULL) return E_OUTOFMEMORY;
54
55     ICOM_INIT_INTERFACE(This, IDirectDrawClipper, DDRAW_Clipper_VTable);
56     This->ref = 1;
57     This->hWnd = 0;
58     This->ddraw_owner = NULL;
59
60     *lplpDDClipper = ICOM_INTERFACE(This, IDirectDrawClipper);
61     return DD_OK;
62 }
63
64 /* This is the classfactory implementation. */
65 HRESULT DDRAW_CreateDirectDrawClipper(IUnknown* pUnkOuter, REFIID riid,
66                                       LPVOID* ppObj)
67 {
68     HRESULT hr;
69     LPDIRECTDRAWCLIPPER pClip;
70
71     hr = DirectDrawCreateClipper(0, &pClip, pUnkOuter);
72     if (FAILED(hr)) return hr;
73
74     hr = IDirectDrawClipper_QueryInterface(pClip, riid, ppObj);
75     IDirectDrawClipper_Release(pClip);
76     return hr;
77 }
78
79 /******************************************************************************
80  *                      IDirectDrawClipper
81  */
82 HRESULT WINAPI Main_DirectDrawClipper_SetHwnd(
83     LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd
84 ) {
85     ICOM_THIS(IDirectDrawClipperImpl,iface);
86
87     TRACE("(%p)->SetHwnd(0x%08lx,0x%08lx)\n",This,dwFlags,(DWORD)hWnd);
88     if( dwFlags ) {
89         FIXME("dwFlags = 0x%08lx, not supported.\n",dwFlags);
90         return DDERR_INVALIDPARAMS;
91     }
92
93     This->hWnd = hWnd;
94     return DD_OK;
95 }
96
97 static void Main_DirectDrawClipper_Destroy(IDirectDrawClipperImpl* This)
98 {
99     if (This->ddraw_owner != NULL)
100         Main_DirectDraw_RemoveClipper(This->ddraw_owner, This);
101
102     HeapFree(GetProcessHeap(), 0 ,This);
103 }
104
105 void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl* This)
106 {
107     WARN("deleting clipper %p with refcnt %lu\n", This, This->ref);
108     Main_DirectDrawClipper_Destroy(This);
109 }
110
111 ULONG WINAPI Main_DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface) {
112     ICOM_THIS(IDirectDrawClipperImpl,iface);
113     TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
114
115     if (--This->ref == 0)
116     {
117         Main_DirectDrawClipper_Destroy(This);
118         return 0;
119     }
120     else return This->ref;
121 }
122
123 HRESULT WINAPI Main_DirectDrawClipper_GetClipList(
124     LPDIRECTDRAWCLIPPER iface,LPRECT prcClip,LPRGNDATA lprgn,LPDWORD pdwSize
125 ) {
126     ICOM_THIS(IDirectDrawClipperImpl,iface);
127     static int warned = 0;
128     if (warned++ < 10)
129         FIXME("(%p,%p,%p,%p),stub!\n",This,prcClip,lprgn,pdwSize);
130     if (pdwSize) *pdwSize=0;
131     return DDERR_NOCLIPLIST;
132 }
133
134 HRESULT WINAPI Main_DirectDrawClipper_SetClipList(
135     LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD pdwSize
136 ) {
137     ICOM_THIS(IDirectDrawClipperImpl,iface);
138     FIXME("(%p,%p,%ld),stub!\n",This,lprgn,pdwSize);
139     return DD_OK;
140 }
141
142 HRESULT WINAPI Main_DirectDrawClipper_QueryInterface(
143     LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
144 ) {
145     ICOM_THIS(IDirectDrawClipperImpl,iface);
146
147     if (IsEqualGUID(&IID_IUnknown, riid)
148         || IsEqualGUID(&IID_IDirectDrawClipper, riid))
149     {
150         *ppvObj = ICOM_INTERFACE(This, IDirectDrawClipper);
151         ++This->ref;
152         return S_OK;
153     }
154     else
155     {
156         return E_NOINTERFACE;
157     }
158 }
159
160 ULONG WINAPI Main_DirectDrawClipper_AddRef( LPDIRECTDRAWCLIPPER iface )
161 {
162     ICOM_THIS(IDirectDrawClipperImpl,iface);
163     TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
164     return ++This->ref;
165 }
166
167 HRESULT WINAPI Main_DirectDrawClipper_GetHWnd(
168     LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
169 ) {
170     ICOM_THIS(IDirectDrawClipperImpl,iface);
171     FIXME("(%p)->(%p),stub!\n",This,hWndPtr);
172
173     *hWndPtr = This->hWnd;
174
175     return DD_OK;
176 }
177
178 HRESULT WINAPI Main_DirectDrawClipper_Initialize(
179      LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
180 ) {
181     IDirectDrawImpl* pOwner;
182     ICOM_THIS(IDirectDrawClipperImpl,iface);
183     FIXME("(%p)->(%p,0x%08lx),stub!\n",This,lpDD,dwFlags);
184
185     if (This->ddraw_owner != NULL) return DDERR_ALREADYINITIALIZED;
186
187     pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD);
188     This->ddraw_owner = pOwner;
189     Main_DirectDraw_AddClipper(pOwner, This);
190
191     return DD_OK;
192 }
193
194 HRESULT WINAPI Main_DirectDrawClipper_IsClipListChanged(
195     LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
196 ) {
197     ICOM_THIS(IDirectDrawClipperImpl,iface);
198     FIXME("(%p)->(%p),stub!\n",This,lpbChanged);
199
200     /* XXX What is safest? */
201     *lpbChanged = FALSE;
202
203     return DD_OK;
204 }
205
206 static ICOM_VTABLE(IDirectDrawClipper) DDRAW_Clipper_VTable =
207 {
208     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
209     Main_DirectDrawClipper_QueryInterface,
210     Main_DirectDrawClipper_AddRef,
211     Main_DirectDrawClipper_Release,
212     Main_DirectDrawClipper_GetClipList,
213     Main_DirectDrawClipper_GetHWnd,
214     Main_DirectDrawClipper_Initialize,
215     Main_DirectDrawClipper_IsClipListChanged,
216     Main_DirectDrawClipper_SetClipList,
217     Main_DirectDrawClipper_SetHwnd
218 };