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