]> git.saurik.com Git - wxWidgets.git/blame - src/msw/microwin.c
Compilation fix for !wxUSE_OWNER_DRAWN.
[wxWidgets.git] / src / msw / microwin.c
CommitLineData
bf7b3e2b
JS
1/*
2/////////////////////////////////////////////////////////////////////////////
80fdcdb9 3// Name: src/msw/microwin.cpp
bf7b3e2b
JS
4// Purpose: Extra implementation for MicroWindows
5// Author: Julian Smart
6// Created: 2001-05-31
bf7b3e2b 7// Copyright: (c) Julian Smart
526954c5 8// Licence: wxWindows licence
bf7b3e2b
JS
9/////////////////////////////////////////////////////////////////////////////
10
11*/
12
bf7b3e2b
JS
13#include "mwtypes.h"
14#include "windows.h"
15#include "wintern.h"
16#include "device.h"
8cb172b4 17#include "wx/msw/microwin.h"
bf7b3e2b
JS
18
19void GdMoveCursor(MWCOORD x, MWCOORD y);
20void MwSetCursor(HWND wp, PMWCURSOR pcursor);
21
22BOOL SetCursorPos(int x, int y)
23{
24 GdMoveCursor(x, y);
25 return TRUE;
26}
27
28HCURSOR SetCursor(HCURSOR hCursor)
29{
30 /* TODO */
31 return 0;
32}
33
34int 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
43BOOL ScrollWindow(HWND hWnd, int xAmount, int yAmount,
f4322df6 44 CONST RECT* lpRect, CONST RECT* lpClipRect)
bf7b3e2b
JS
45{
46 /* TODO */
47 return FALSE;
48}
49
50HWND WindowFromPoint(POINT pt)
51{
52 /* TODO */
53 return 0;
54}
55
56SHORT GetKeyState(int nVirtKey)
57{
58 /* TODO */
59 return 0;
60}
61
62HWND SetParent(HWND hWndChild, HWND hWndNewParent)
63{
64 /* TODO */
65 return 0;
66}
67
68VOID DragAcceptFiles(HWND hWnd, BOOL b)
69{
70 /* TODO */
71}
72
73BOOL IsDialogMessage(HWND hWnd, MSG* msg)
74{
75 /* TODO */
76 return FALSE;
77}
78
79DWORD GetMessagePos(VOID)
80{
81 /* TODO */
82 return 0;
83}
84
85BOOL IsIconic(HWND hWnd)
86{
87 /* TODO */
88 return FALSE;
89}
90
89efaf2b 91int SetMapMode(HDC hDC, wxMappingMode mode)
bf7b3e2b
JS
92{
93 return MM_TEXT;
94}
95
89efaf2b 96wxMappingMode GetMapMode(HDC hDC)
bf7b3e2b
JS
97{
98 return MM_TEXT;
99}
100
101HCURSOR LoadCursor(HINSTANCE hInst, int cursor)
102{
103 /* TODO */
104 return 0;
105}
106
107DWORD GetModuleFileName(HINSTANCE hInst, LPSTR name, DWORD sz)
108{
109 /* TODO */
110 name[0] = 0;
111 return 0;
112}
113
114VOID DestroyIcon(HICON hIcon)
115{
116 /* TODO */
117}
118
119COLORREF GetTextColor(HDC hdc)
120{
121 if (!hdc)
122 return CLR_INVALID;
123 return hdc->textcolor ;
124}
125
126COLORREF GetBkColor(HDC hdc)
127{
128 if (!hdc)
129 return CLR_INVALID;
130 return hdc->bkcolor ;
131}
132
133HPALETTE SelectPalette(HDC hdc, HPALETTE hPalette, BOOL b)
134{
135 /* TODO */
136 return 0;
137}
138
139BOOL 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
150BOOL 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
89efaf2b 165 return TRUE;
bf7b3e2b
JS
166}
167
168BOOL 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
174BOOL SetViewportExtEx(HDC hdc, int x, int y, LPSIZE lpSize)
175{
176 /* TODO */
177 return FALSE;
178}
179
180BOOL SetViewportOrgEx(HDC hdc, int x, int y, LPPOINT lpPoint)
181{
182 /* TODO */
183 return FALSE;
184}
185
186BOOL SetWindowExtEx(HDC hdc, int x, int y, LPSIZE lpSize)
187{
188 /* TODO */
189 return FALSE;
190}
191
192BOOL SetWindowOrgEx(HDC hdc, int x, int y, LPPOINT lpSize)
193{
194 /* TODO */
195 return FALSE;
196}
197
198BOOL ExtFloodFill(HDC hdc, int x, int y, COLORREF col, UINT flags)
199{
200 /* TODO */
201 return FALSE;
202}
203
204int SetPolyFillMode(HDC hdc, int mode)
205{
206 /* TODO */
207 return 0;
208}
209
210BOOL 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
216BOOL 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 */
89efaf2b 220 return FALSE;
bf7b3e2b
JS
221}
222
223UINT RealizePalette(HDC hDC)
224{
225 /* TODO */
226 return 0;
227}
228
229BOOL SetBrushOrgEx(HDC hdc, int xOrigin, int yOrigin, LPPOINT lpPoint)
230{
231 /* TODO */
232 return FALSE;
233}
234
235int 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
f4322df6
VZ
245 /* FIXME many items are guessed for the time being*/
246 logFont->lfHeight = fi.height;
bf7b3e2b 247
f4322df6
VZ
248 /* reversed for kaffe port
249 logFont->tmAscent = fi.height - fi.baseline;
250 logFont->tmDescent= fi.baseline;
251 */
bf7b3e2b 252
f4322df6
VZ
253 logFont->lfWidth = fi.widths['x'];
254 logFont->lfWeight = FW_NORMAL;
bf7b3e2b
JS
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;
f4322df6
VZ
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.
bf7b3e2b
JS
269 */
270 logFont->lfFaceName[0] = 0;
271#if 0
f4322df6 272 strncpy(logFont->lfFaceName, ??, sizeof(logFont->lfFaceName));
bf7b3e2b
JS
273#endif
274 return sz;
275 }
276 else
277 {
278 return 0;
279 }
280}
62e1ba75
JS
281
282/* Not in wingdi.c in earlier versions of MicroWindows */
283#if 0
284HBITMAP WINAPI
285CreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight)
286{
f4322df6
VZ
287 MWBITMAPOBJ *hbitmap;
288 int size;
289 int linelen;
62e1ba75 290
f4322df6
VZ
291 if(!hdc)
292 return NULL;
62e1ba75 293
f4322df6
VZ
294 nWidth = MWMAX(nWidth, 1);
295 nHeight = MWMAX(nHeight, 1);
62e1ba75 296
f4322df6
VZ
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;
62e1ba75 300
f4322df6
VZ
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;
62e1ba75 309
f4322df6
VZ
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;
62e1ba75 315
f4322df6 316 return (HBRUSH)hbitmap;
62e1ba75
JS
317}
318#endif
319
320/* Attempt by JACS to create arbitrary bitmap
321 * TODO: make use of lpData
322 */
323
324HBITMAP WINAPI
325CreateBitmap( int nWidth, int nHeight, int nPlanes, int bPP, LPCVOID lpData)
326{
f4322df6
VZ
327 MWBITMAPOBJ *hbitmap;
328 int size;
329 int linelen;
62e1ba75 330
f4322df6 331 HDC hScreenDC;
62e1ba75 332
f4322df6 333 hScreenDC = GetDC(NULL);
62e1ba75 334
f4322df6
VZ
335 nWidth = MWMAX(nWidth, 1);
336 nHeight = MWMAX(nHeight, 1);
62e1ba75 337
f4322df6
VZ
338 /* calc memory allocation size and linelen from width and height*/
339 if(!GdCalcMemGCAlloc(hScreenDC->psd, nWidth, nHeight, nPlanes, bPP, &size, &linelen))
340 {
62e1ba75 341 ReleaseDC(NULL, hScreenDC);
f4322df6
VZ
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;
62e1ba75 364}