2 /////////////////////////////////////////////////////////////////////////////
4 // Purpose: Extra implementation for MicroWindows
5 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #pragma implementation "microwin.h"
22 #include "wx/msw/microwin.h"
24 void GdMoveCursor(MWCOORD x
, MWCOORD y
);
25 void MwSetCursor(HWND wp
, PMWCURSOR pcursor
);
27 BOOL
SetCursorPos(int x
, int y
)
33 HCURSOR
SetCursor(HCURSOR hCursor
)
39 int GetScrollPosWX (HWND hWnd
, int iSBar
)
42 if (GetScrollPos(hWnd
, iSBar
, & pos
))
48 BOOL
ScrollWindow(HWND hWnd
, int xAmount
, int yAmount
,
49 CONST RECT
* lpRect
, CONST RECT
* lpClipRect
)
55 HWND
WindowFromPoint(POINT pt
)
61 SHORT
GetKeyState(int nVirtKey
)
67 HWND
SetParent(HWND hWndChild
, HWND hWndNewParent
)
73 VOID
DragAcceptFiles(HWND hWnd
, BOOL b
)
78 BOOL
IsDialogMessage(HWND hWnd
, MSG
* msg
)
84 DWORD
GetMessagePos(VOID
)
90 BOOL
IsIconic(HWND hWnd
)
96 int SetMapMode(HDC hDC
, int mode
)
101 int GetMapMode(HDC hDC
)
106 HCURSOR
LoadCursor(HINSTANCE hInst
, int cursor
)
112 DWORD
GetModuleFileName(HINSTANCE hInst
, LPSTR name
, DWORD sz
)
119 VOID
DestroyIcon(HICON hIcon
)
124 COLORREF
GetTextColor(HDC hdc
)
128 return hdc
->textcolor
;
131 COLORREF
GetBkColor(HDC hdc
)
135 return hdc
->bkcolor
;
138 HPALETTE
SelectPalette(HDC hdc
, HPALETTE hPalette
, BOOL b
)
144 BOOL
IntersectClipRect(HDC hdc
, int x
, int y
,
145 int right
, int bottom
)
148 HRGN rgn
= CreateRectRgn(x
, y
, right
, bottom
);
150 BOOL ret
= (ExtSelectClipRgn(hdc
, rgn
, RGN_AND
) != ERROR
);
155 BOOL
GetClipBox(HDC hdc
, RECT
* rect
)
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
;
173 BOOL
DrawIconEx(HDC hdc
, int x
, int y
, HICON hIcon
, int w
, int h
, UINT istepIfAniCur
, HBRUSH hbrFlickerFreeDraw
, UINT diFlags
)
179 BOOL
SetViewportExtEx(HDC hdc
, int x
, int y
, LPSIZE lpSize
)
185 BOOL
SetViewportOrgEx(HDC hdc
, int x
, int y
, LPPOINT lpPoint
)
191 BOOL
SetWindowExtEx(HDC hdc
, int x
, int y
, LPSIZE lpSize
)
197 BOOL
SetWindowOrgEx(HDC hdc
, int x
, int y
, LPPOINT lpSize
)
203 BOOL
ExtFloodFill(HDC hdc
, int x
, int y
, COLORREF col
, UINT flags
)
209 int SetPolyFillMode(HDC hdc
, int mode
)
215 BOOL
RoundRect(HDC hdc
, int left
, int top
, int right
, int bottom
, int r1
, int r2
)
218 return Rectangle(hdc
, left
, top
, right
, bottom
);
221 BOOL
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
)
228 UINT
RealizePalette(HDC hDC
)
234 BOOL
SetBrushOrgEx(HDC hdc
, int xOrigin
, int yOrigin
, LPPOINT lpPoint
)
240 int GetObject(HGDIOBJ hObj
, int sz
, LPVOID logObj
)
242 if (sz
== sizeof(LOGFONT
))
244 LOGFONT
* logFont
= (LOGFONT
*) logObj
;
246 HFONT hFont
= (HFONT
) hObj
;
248 GdGetFontInfo(((MWFONTOBJ
*) hFont
)->pfont
, &fi
);
250 /* FIXME many items are guessed for the time being*/
251 logFont
->lfHeight
= fi
.height
;
253 /* reversed for kaffe port
254 logFont->tmAscent = fi.height - fi.baseline;
255 logFont->tmDescent= fi.baseline;
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.
275 logFont
->lfFaceName
[0] = 0;
277 strncpy(logFont
->lfFaceName
, ??, sizeof(logFont
->lfFaceName
));
287 /* Not in wingdi.c in earlier versions of MicroWindows */
290 CreateCompatibleBitmap(HDC hdc
, int nWidth
, int nHeight
)
292 MWBITMAPOBJ
* hbitmap
;
299 nWidth
= MWMAX(nWidth
, 1);
300 nHeight
= MWMAX(nHeight
, 1);
302 /* calc memory allocation size and linelen from width and height*/
303 if(!GdCalcMemGCAlloc(hdc
->psd
, nWidth
, nHeight
, 0, 0, &size
, &linelen
))
306 /* allocate gdi object*/
307 hbitmap
= (MWBITMAPOBJ
*)GdItemAlloc(sizeof(MWBITMAPOBJ
)-1+size
);
310 hbitmap
->hdr
.type
= OBJ_BITMAP
;
311 hbitmap
->hdr
.stockobj
= FALSE
;
312 hbitmap
->width
= nWidth
;
313 hbitmap
->height
= nHeight
;
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
;
321 return (HBRUSH
)hbitmap
;
325 /* Attempt by JACS to create arbitrary bitmap
326 * TODO: make use of lpData
330 CreateBitmap( int nWidth
, int nHeight
, int nPlanes
, int bPP
, LPCVOID lpData
)
332 MWBITMAPOBJ
* hbitmap
;
338 hScreenDC
= GetDC(NULL
);
340 nWidth
= MWMAX(nWidth
, 1);
341 nHeight
= MWMAX(nHeight
, 1);
343 /* calc memory allocation size and linelen from width and height*/
344 if(!GdCalcMemGCAlloc(hScreenDC
->psd
, nWidth
, nHeight
, nPlanes
, bPP
, &size
, &linelen
))
346 ReleaseDC(NULL
, hScreenDC
);
349 ReleaseDC(NULL
, hScreenDC
);
351 /* allocate gdi object*/
352 hbitmap
= (MWBITMAPOBJ
*)GdItemAlloc(sizeof(MWBITMAPOBJ
)-1+size
);
355 hbitmap
->hdr
.type
= OBJ_BITMAP
;
356 hbitmap
->hdr
.stockobj
= FALSE
;
357 hbitmap
->width
= nWidth
;
358 hbitmap
->height
= nHeight
;
360 /* create with specified parameters */
361 hbitmap
->planes
= nPlanes
;
363 hbitmap
->linelen
= linelen
;
364 hbitmap
->size
= size
;
366 /* TODO: copy data */
368 return (HBRUSH
)hbitmap
;