]> git.saurik.com Git - wxWidgets.git/blob - src/msw/microwin.c
Make mouse capture checking asserts stronger and more detailed.
[wxWidgets.git] / src / msw / microwin.c
1 /*
2 /////////////////////////////////////////////////////////////////////////////
3 // Name: src/msw/microwin.cpp
4 // Purpose: Extra implementation for MicroWindows
5 // Author: Julian Smart
6 // Created: 2001-05-31
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 */
12
13 #include "mwtypes.h"
14 #include "windows.h"
15 #include "wintern.h"
16 #include "device.h"
17 #include "wx/msw/microwin.h"
18
19 void GdMoveCursor(MWCOORD x, MWCOORD y);
20 void MwSetCursor(HWND wp, PMWCURSOR pcursor);
21
22 BOOL SetCursorPos(int x, int y)
23 {
24 GdMoveCursor(x, y);
25 return TRUE;
26 }
27
28 HCURSOR SetCursor(HCURSOR hCursor)
29 {
30 /* TODO */
31 return 0;
32 }
33
34 int GetScrollPosWX (HWND hWnd, int iSBar)
35 {
36 int pos = 0;
37 if (GetScrollPos(hWnd, iSBar, & pos))
38 return pos;
39 else
40 return 0;
41 }
42
43 BOOL ScrollWindow(HWND hWnd, int xAmount, int yAmount,
44 CONST RECT* lpRect, CONST RECT* lpClipRect)
45 {
46 /* TODO */
47 return FALSE;
48 }
49
50 HWND WindowFromPoint(POINT pt)
51 {
52 /* TODO */
53 return 0;
54 }
55
56 SHORT GetKeyState(int nVirtKey)
57 {
58 /* TODO */
59 return 0;
60 }
61
62 HWND SetParent(HWND hWndChild, HWND hWndNewParent)
63 {
64 /* TODO */
65 return 0;
66 }
67
68 VOID DragAcceptFiles(HWND hWnd, BOOL b)
69 {
70 /* TODO */
71 }
72
73 BOOL IsDialogMessage(HWND hWnd, MSG* msg)
74 {
75 /* TODO */
76 return FALSE;
77 }
78
79 DWORD GetMessagePos(VOID)
80 {
81 /* TODO */
82 return 0;
83 }
84
85 BOOL IsIconic(HWND hWnd)
86 {
87 /* TODO */
88 return FALSE;
89 }
90
91 int SetMapMode(HDC hDC, wxMappingMode mode)
92 {
93 return MM_TEXT;
94 }
95
96 wxMappingMode GetMapMode(HDC hDC)
97 {
98 return MM_TEXT;
99 }
100
101 HCURSOR LoadCursor(HINSTANCE hInst, int cursor)
102 {
103 /* TODO */
104 return 0;
105 }
106
107 DWORD GetModuleFileName(HINSTANCE hInst, LPSTR name, DWORD sz)
108 {
109 /* TODO */
110 name[0] = 0;
111 return 0;
112 }
113
114 VOID DestroyIcon(HICON hIcon)
115 {
116 /* TODO */
117 }
118
119 COLORREF GetTextColor(HDC hdc)
120 {
121 if (!hdc)
122 return CLR_INVALID;
123 return hdc->textcolor ;
124 }
125
126 COLORREF GetBkColor(HDC hdc)
127 {
128 if (!hdc)
129 return CLR_INVALID;
130 return hdc->bkcolor ;
131 }
132
133 HPALETTE SelectPalette(HDC hdc, HPALETTE hPalette, BOOL b)
134 {
135 /* TODO */
136 return 0;
137 }
138
139 BOOL IntersectClipRect(HDC hdc, int x, int y,
140 int right, int bottom)
141 {
142 /* TODO */
143 HRGN rgn = CreateRectRgn(x, y, right, bottom);
144
145 BOOL ret = (ExtSelectClipRgn(hdc, rgn, RGN_AND) != ERROR);
146 DeleteObject(rgn);
147 return ret;
148 }
149
150 BOOL GetClipBox(HDC hdc, RECT* rect)
151 {
152 MWCLIPREGION* r;
153 MWRECT mwrect;
154
155 if (!hdc->region)
156 return FALSE;
157
158 r = ((MWRGNOBJ*) hdc->region)->rgn;
159 GdGetRegionBox(r, & mwrect);
160 rect->left = mwrect.left;
161 rect->top = mwrect.top;
162 rect->right = mwrect.right;
163 rect->bottom = mwrect.bottom;
164
165 return TRUE;
166 }
167
168 BOOL DrawIconEx(HDC hdc, int x, int y, HICON hIcon, int w, int h, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags)
169 {
170 /* TODO */
171 return FALSE;
172 }
173
174 BOOL SetViewportExtEx(HDC hdc, int x, int y, LPSIZE lpSize)
175 {
176 /* TODO */
177 return FALSE;
178 }
179
180 BOOL SetViewportOrgEx(HDC hdc, int x, int y, LPPOINT lpPoint)
181 {
182 /* TODO */
183 return FALSE;
184 }
185
186 BOOL SetWindowExtEx(HDC hdc, int x, int y, LPSIZE lpSize)
187 {
188 /* TODO */
189 return FALSE;
190 }
191
192 BOOL SetWindowOrgEx(HDC hdc, int x, int y, LPPOINT lpSize)
193 {
194 /* TODO */
195 return FALSE;
196 }
197
198 BOOL ExtFloodFill(HDC hdc, int x, int y, COLORREF col, UINT flags)
199 {
200 /* TODO */
201 return FALSE;
202 }
203
204 int SetPolyFillMode(HDC hdc, int mode)
205 {
206 /* TODO */
207 return 0;
208 }
209
210 BOOL RoundRect(HDC hdc, int left, int top, int right, int bottom, int r1, int r2)
211 {
212 /* TODO */
213 return Rectangle(hdc, left, top, right, bottom);
214 }
215
216 BOOL MaskBlt(HDC hdc, int x, int y, int w, int h,
217 HDC hDCSource, int xSrc, int ySrc, HBITMAP hBitmapMask, int xMask, int yMask, DWORD rop)
218 {
219 /* TODO */
220 return FALSE;
221 }
222
223 UINT RealizePalette(HDC hDC)
224 {
225 /* TODO */
226 return 0;
227 }
228
229 BOOL SetBrushOrgEx(HDC hdc, int xOrigin, int yOrigin, LPPOINT lpPoint)
230 {
231 /* TODO */
232 return FALSE;
233 }
234
235 int GetObject(HGDIOBJ hObj, int sz, LPVOID logObj)
236 {
237 if (sz == sizeof(LOGFONT))
238 {
239 LOGFONT* logFont = (LOGFONT*) logObj;
240 MWFONTINFO fi;
241 HFONT hFont = (HFONT) hObj;
242
243 GdGetFontInfo(((MWFONTOBJ*) hFont)->pfont, &fi);
244
245 /* FIXME many items are guessed for the time being*/
246 logFont->lfHeight = fi.height;
247
248 /* reversed for kaffe port
249 logFont->tmAscent = fi.height - fi.baseline;
250 logFont->tmDescent= fi.baseline;
251 */
252
253 logFont->lfWidth = fi.widths['x'];
254 logFont->lfWeight = FW_NORMAL;
255 logFont->lfEscapement = 0;
256 logFont->lfOrientation = 0;
257 logFont->lfOutPrecision = OUT_OUTLINE_PRECIS;
258 logFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
259 logFont->lfQuality = DEFAULT_QUALITY;
260 logFont->lfItalic = 0;
261 logFont->lfUnderline = 0;
262 logFont->lfStrikeOut = 0;
263 /* note that win32 has the TMPF_FIXED_PITCH flags REVERSED...*/
264 logFont->lfPitchAndFamily = fi.fixed?
265 FF_DONTCARE: (FF_DONTCARE | TMPF_FIXED_PITCH);
266 logFont->lfCharSet = OEM_CHARSET;
267 /* TODO I don't know how to get the font name. May
268 * test for different font classes.
269 */
270 logFont->lfFaceName[0] = 0;
271 #if 0
272 strncpy(logFont->lfFaceName, ??, sizeof(logFont->lfFaceName));
273 #endif
274 return sz;
275 }
276 else
277 {
278 return 0;
279 }
280 }
281
282 /* Not in wingdi.c in earlier versions of MicroWindows */
283 #if 0
284 HBITMAP WINAPI
285 CreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight)
286 {
287 MWBITMAPOBJ *hbitmap;
288 int size;
289 int linelen;
290
291 if(!hdc)
292 return NULL;
293
294 nWidth = MWMAX(nWidth, 1);
295 nHeight = MWMAX(nHeight, 1);
296
297 /* calc memory allocation size and linelen from width and height*/
298 if(!GdCalcMemGCAlloc(hdc->psd, nWidth, nHeight, 0, 0, &size, &linelen))
299 return NULL;
300
301 /* allocate gdi object*/
302 hbitmap = (MWBITMAPOBJ *)GdItemAlloc(sizeof(MWBITMAPOBJ)-1+size);
303 if(!hbitmap)
304 return NULL;
305 hbitmap->hdr.type = OBJ_BITMAP;
306 hbitmap->hdr.stockobj = FALSE;
307 hbitmap->width = nWidth;
308 hbitmap->height = nHeight;
309
310 /* create compatible with hdc*/
311 hbitmap->planes = hdc->psd->planes;
312 hbitmap->bpp = hdc->psd->bpp;
313 hbitmap->linelen = linelen;
314 hbitmap->size = size;
315
316 return (HBRUSH)hbitmap;
317 }
318 #endif
319
320 /* Attempt by JACS to create arbitrary bitmap
321 * TODO: make use of lpData
322 */
323
324 HBITMAP WINAPI
325 CreateBitmap( int nWidth, int nHeight, int nPlanes, int bPP, LPCVOID lpData)
326 {
327 MWBITMAPOBJ *hbitmap;
328 int size;
329 int linelen;
330
331 HDC hScreenDC;
332
333 hScreenDC = GetDC(NULL);
334
335 nWidth = MWMAX(nWidth, 1);
336 nHeight = MWMAX(nHeight, 1);
337
338 /* calc memory allocation size and linelen from width and height*/
339 if(!GdCalcMemGCAlloc(hScreenDC->psd, nWidth, nHeight, nPlanes, bPP, &size, &linelen))
340 {
341 ReleaseDC(NULL, hScreenDC);
342 return NULL;
343 }
344 ReleaseDC(NULL, hScreenDC);
345
346 /* allocate gdi object*/
347 hbitmap = (MWBITMAPOBJ *)GdItemAlloc(sizeof(MWBITMAPOBJ)-1+size);
348 if(!hbitmap)
349 return NULL;
350 hbitmap->hdr.type = OBJ_BITMAP;
351 hbitmap->hdr.stockobj = FALSE;
352 hbitmap->width = nWidth;
353 hbitmap->height = nHeight;
354
355 /* create with specified parameters */
356 hbitmap->planes = nPlanes;
357 hbitmap->bpp = bPP;
358 hbitmap->linelen = linelen;
359 hbitmap->size = size;
360
361 /* TODO: copy data */
362
363 return (HBRUSH)hbitmap;
364 }