2 /////////////////////////////////////////////////////////////////////////////
3 // Name: src/msw/microwin.cpp
4 // Purpose: Extra implementation for MicroWindows
5 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/msw/microwin.h"
19 void GdMoveCursor(MWCOORD x
, MWCOORD y
);
20 void MwSetCursor(HWND wp
, PMWCURSOR pcursor
);
22 BOOL
SetCursorPos(int x
, int y
)
28 HCURSOR
SetCursor(HCURSOR hCursor
)
34 int GetScrollPosWX (HWND hWnd
, int iSBar
)
37 if (GetScrollPos(hWnd
, iSBar
, & pos
))
43 BOOL
ScrollWindow(HWND hWnd
, int xAmount
, int yAmount
,
44 CONST RECT
* lpRect
, CONST RECT
* lpClipRect
)
50 HWND
WindowFromPoint(POINT pt
)
56 SHORT
GetKeyState(int nVirtKey
)
62 HWND
SetParent(HWND hWndChild
, HWND hWndNewParent
)
68 VOID
DragAcceptFiles(HWND hWnd
, BOOL b
)
73 BOOL
IsDialogMessage(HWND hWnd
, MSG
* msg
)
79 DWORD
GetMessagePos(VOID
)
85 BOOL
IsIconic(HWND hWnd
)
91 int SetMapMode(HDC hDC
, wxMappingMode mode
)
96 wxMappingMode
GetMapMode(HDC hDC
)
101 HCURSOR
LoadCursor(HINSTANCE hInst
, int cursor
)
107 DWORD
GetModuleFileName(HINSTANCE hInst
, LPSTR name
, DWORD sz
)
114 VOID
DestroyIcon(HICON hIcon
)
119 COLORREF
GetTextColor(HDC hdc
)
123 return hdc
->textcolor
;
126 COLORREF
GetBkColor(HDC hdc
)
130 return hdc
->bkcolor
;
133 HPALETTE
SelectPalette(HDC hdc
, HPALETTE hPalette
, BOOL b
)
139 BOOL
IntersectClipRect(HDC hdc
, int x
, int y
,
140 int right
, int bottom
)
143 HRGN rgn
= CreateRectRgn(x
, y
, right
, bottom
);
145 BOOL ret
= (ExtSelectClipRgn(hdc
, rgn
, RGN_AND
) != ERROR
);
150 BOOL
GetClipBox(HDC hdc
, RECT
* rect
)
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
;
168 BOOL
DrawIconEx(HDC hdc
, int x
, int y
, HICON hIcon
, int w
, int h
, UINT istepIfAniCur
, HBRUSH hbrFlickerFreeDraw
, UINT diFlags
)
174 BOOL
SetViewportExtEx(HDC hdc
, int x
, int y
, LPSIZE lpSize
)
180 BOOL
SetViewportOrgEx(HDC hdc
, int x
, int y
, LPPOINT lpPoint
)
186 BOOL
SetWindowExtEx(HDC hdc
, int x
, int y
, LPSIZE lpSize
)
192 BOOL
SetWindowOrgEx(HDC hdc
, int x
, int y
, LPPOINT lpSize
)
198 BOOL
ExtFloodFill(HDC hdc
, int x
, int y
, COLORREF col
, UINT flags
)
204 int SetPolyFillMode(HDC hdc
, int mode
)
210 BOOL
RoundRect(HDC hdc
, int left
, int top
, int right
, int bottom
, int r1
, int r2
)
213 return Rectangle(hdc
, left
, top
, right
, bottom
);
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
)
223 UINT
RealizePalette(HDC hDC
)
229 BOOL
SetBrushOrgEx(HDC hdc
, int xOrigin
, int yOrigin
, LPPOINT lpPoint
)
235 int GetObject(HGDIOBJ hObj
, int sz
, LPVOID logObj
)
237 if (sz
== sizeof(LOGFONT
))
239 LOGFONT
* logFont
= (LOGFONT
*) logObj
;
241 HFONT hFont
= (HFONT
) hObj
;
243 GdGetFontInfo(((MWFONTOBJ
*) hFont
)->pfont
, &fi
);
245 /* FIXME many items are guessed for the time being*/
246 logFont
->lfHeight
= fi
.height
;
248 /* reversed for kaffe port
249 logFont->tmAscent = fi.height - fi.baseline;
250 logFont->tmDescent= fi.baseline;
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.
270 logFont
->lfFaceName
[0] = 0;
272 strncpy(logFont
->lfFaceName
, ??, sizeof(logFont
->lfFaceName
));
282 /* Not in wingdi.c in earlier versions of MicroWindows */
285 CreateCompatibleBitmap(HDC hdc
, int nWidth
, int nHeight
)
287 MWBITMAPOBJ
*hbitmap
;
294 nWidth
= MWMAX(nWidth
, 1);
295 nHeight
= MWMAX(nHeight
, 1);
297 /* calc memory allocation size and linelen from width and height*/
298 if(!GdCalcMemGCAlloc(hdc
->psd
, nWidth
, nHeight
, 0, 0, &size
, &linelen
))
301 /* allocate gdi object*/
302 hbitmap
= (MWBITMAPOBJ
*)GdItemAlloc(sizeof(MWBITMAPOBJ
)-1+size
);
305 hbitmap
->hdr
.type
= OBJ_BITMAP
;
306 hbitmap
->hdr
.stockobj
= FALSE
;
307 hbitmap
->width
= nWidth
;
308 hbitmap
->height
= nHeight
;
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
;
316 return (HBRUSH
)hbitmap
;
320 /* Attempt by JACS to create arbitrary bitmap
321 * TODO: make use of lpData
325 CreateBitmap( int nWidth
, int nHeight
, int nPlanes
, int bPP
, LPCVOID lpData
)
327 MWBITMAPOBJ
*hbitmap
;
333 hScreenDC
= GetDC(NULL
);
335 nWidth
= MWMAX(nWidth
, 1);
336 nHeight
= MWMAX(nHeight
, 1);
338 /* calc memory allocation size and linelen from width and height*/
339 if(!GdCalcMemGCAlloc(hScreenDC
->psd
, nWidth
, nHeight
, nPlanes
, bPP
, &size
, &linelen
))
341 ReleaseDC(NULL
, hScreenDC
);
344 ReleaseDC(NULL
, hScreenDC
);
346 /* allocate gdi object*/
347 hbitmap
= (MWBITMAPOBJ
*)GdItemAlloc(sizeof(MWBITMAPOBJ
)-1+size
);
350 hbitmap
->hdr
.type
= OBJ_BITMAP
;
351 hbitmap
->hdr
.stockobj
= FALSE
;
352 hbitmap
->width
= nWidth
;
353 hbitmap
->height
= nHeight
;
355 /* create with specified parameters */
356 hbitmap
->planes
= nPlanes
;
358 hbitmap
->linelen
= linelen
;
359 hbitmap
->size
= size
;
361 /* TODO: copy data */
363 return (HBRUSH
)hbitmap
;