2 /////////////////////////////////////////////////////////////////////////////
4 // Purpose: Extra implementation for MicroWindows
5 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
18 #include "wx/msw/microwin.h"
20 void GdMoveCursor(MWCOORD x
, MWCOORD y
);
21 void MwSetCursor(HWND wp
, PMWCURSOR pcursor
);
23 BOOL
SetCursorPos(int x
, int y
)
29 HCURSOR
SetCursor(HCURSOR hCursor
)
35 int GetScrollPosWX (HWND hWnd
, int iSBar
)
38 if (GetScrollPos(hWnd
, iSBar
, & pos
))
44 BOOL
ScrollWindow(HWND hWnd
, int xAmount
, int yAmount
,
45 CONST RECT
* lpRect
, CONST RECT
* lpClipRect
)
51 HWND
WindowFromPoint(POINT pt
)
57 SHORT
GetKeyState(int nVirtKey
)
63 HWND
SetParent(HWND hWndChild
, HWND hWndNewParent
)
69 VOID
DragAcceptFiles(HWND hWnd
, BOOL b
)
74 BOOL
IsDialogMessage(HWND hWnd
, MSG
* msg
)
80 DWORD
GetMessagePos(VOID
)
86 BOOL
IsIconic(HWND hWnd
)
92 int SetMapMode(HDC hDC
, wxMappingMode mode
)
97 wxMappingMode
GetMapMode(HDC hDC
)
102 HCURSOR
LoadCursor(HINSTANCE hInst
, int cursor
)
108 DWORD
GetModuleFileName(HINSTANCE hInst
, LPSTR name
, DWORD sz
)
115 VOID
DestroyIcon(HICON hIcon
)
120 COLORREF
GetTextColor(HDC hdc
)
124 return hdc
->textcolor
;
127 COLORREF
GetBkColor(HDC hdc
)
131 return hdc
->bkcolor
;
134 HPALETTE
SelectPalette(HDC hdc
, HPALETTE hPalette
, BOOL b
)
140 BOOL
IntersectClipRect(HDC hdc
, int x
, int y
,
141 int right
, int bottom
)
144 HRGN rgn
= CreateRectRgn(x
, y
, right
, bottom
);
146 BOOL ret
= (ExtSelectClipRgn(hdc
, rgn
, RGN_AND
) != ERROR
);
151 BOOL
GetClipBox(HDC hdc
, RECT
* rect
)
159 r
= ((MWRGNOBJ
*) hdc
->region
)->rgn
;
160 GdGetRegionBox(r
, & mwrect
);
161 rect
->left
= mwrect
.left
;
162 rect
->top
= mwrect
.top
;
163 rect
->right
= mwrect
.right
;
164 rect
->bottom
= mwrect
.bottom
;
169 BOOL
DrawIconEx(HDC hdc
, int x
, int y
, HICON hIcon
, int w
, int h
, UINT istepIfAniCur
, HBRUSH hbrFlickerFreeDraw
, UINT diFlags
)
175 BOOL
SetViewportExtEx(HDC hdc
, int x
, int y
, LPSIZE lpSize
)
181 BOOL
SetViewportOrgEx(HDC hdc
, int x
, int y
, LPPOINT lpPoint
)
187 BOOL
SetWindowExtEx(HDC hdc
, int x
, int y
, LPSIZE lpSize
)
193 BOOL
SetWindowOrgEx(HDC hdc
, int x
, int y
, LPPOINT lpSize
)
199 BOOL
ExtFloodFill(HDC hdc
, int x
, int y
, COLORREF col
, UINT flags
)
205 int SetPolyFillMode(HDC hdc
, int mode
)
211 BOOL
RoundRect(HDC hdc
, int left
, int top
, int right
, int bottom
, int r1
, int r2
)
214 return Rectangle(hdc
, left
, top
, right
, bottom
);
217 BOOL
MaskBlt(HDC hdc
, int x
, int y
, int w
, int h
,
218 HDC hDCSource
, int xSrc
, int ySrc
, HBITMAP hBitmapMask
, int xMask
, int yMask
, DWORD rop
)
224 UINT
RealizePalette(HDC hDC
)
230 BOOL
SetBrushOrgEx(HDC hdc
, int xOrigin
, int yOrigin
, LPPOINT lpPoint
)
236 int GetObject(HGDIOBJ hObj
, int sz
, LPVOID logObj
)
238 if (sz
== sizeof(LOGFONT
))
240 LOGFONT
* logFont
= (LOGFONT
*) logObj
;
242 HFONT hFont
= (HFONT
) hObj
;
244 GdGetFontInfo(((MWFONTOBJ
*) hFont
)->pfont
, &fi
);
246 /* FIXME many items are guessed for the time being*/
247 logFont
->lfHeight
= fi
.height
;
249 /* reversed for kaffe port
250 logFont->tmAscent = fi.height - fi.baseline;
251 logFont->tmDescent= fi.baseline;
254 logFont
->lfWidth
= fi
.widths
['x'];
255 logFont
->lfWeight
= FW_NORMAL
;
256 logFont
->lfEscapement
= 0;
257 logFont
->lfOrientation
= 0;
258 logFont
->lfOutPrecision
= OUT_OUTLINE_PRECIS
;
259 logFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
260 logFont
->lfQuality
= DEFAULT_QUALITY
;
261 logFont
->lfItalic
= 0;
262 logFont
->lfUnderline
= 0;
263 logFont
->lfStrikeOut
= 0;
264 /* note that win32 has the TMPF_FIXED_PITCH flags REVERSED...*/
265 logFont
->lfPitchAndFamily
= fi
.fixed
?
266 FF_DONTCARE
: (FF_DONTCARE
| TMPF_FIXED_PITCH
);
267 logFont
->lfCharSet
= OEM_CHARSET
;
268 /* TODO I don't know how to get the font name. May
269 * test for different font classes.
271 logFont
->lfFaceName
[0] = 0;
273 strncpy(logFont
->lfFaceName
, ??, sizeof(logFont
->lfFaceName
));
283 /* Not in wingdi.c in earlier versions of MicroWindows */
286 CreateCompatibleBitmap(HDC hdc
, int nWidth
, int nHeight
)
288 MWBITMAPOBJ
*hbitmap
;
295 nWidth
= MWMAX(nWidth
, 1);
296 nHeight
= MWMAX(nHeight
, 1);
298 /* calc memory allocation size and linelen from width and height*/
299 if(!GdCalcMemGCAlloc(hdc
->psd
, nWidth
, nHeight
, 0, 0, &size
, &linelen
))
302 /* allocate gdi object*/
303 hbitmap
= (MWBITMAPOBJ
*)GdItemAlloc(sizeof(MWBITMAPOBJ
)-1+size
);
306 hbitmap
->hdr
.type
= OBJ_BITMAP
;
307 hbitmap
->hdr
.stockobj
= FALSE
;
308 hbitmap
->width
= nWidth
;
309 hbitmap
->height
= nHeight
;
311 /* create compatible with hdc*/
312 hbitmap
->planes
= hdc
->psd
->planes
;
313 hbitmap
->bpp
= hdc
->psd
->bpp
;
314 hbitmap
->linelen
= linelen
;
315 hbitmap
->size
= size
;
317 return (HBRUSH
)hbitmap
;
321 /* Attempt by JACS to create arbitrary bitmap
322 * TODO: make use of lpData
326 CreateBitmap( int nWidth
, int nHeight
, int nPlanes
, int bPP
, LPCVOID lpData
)
328 MWBITMAPOBJ
*hbitmap
;
334 hScreenDC
= GetDC(NULL
);
336 nWidth
= MWMAX(nWidth
, 1);
337 nHeight
= MWMAX(nHeight
, 1);
339 /* calc memory allocation size and linelen from width and height*/
340 if(!GdCalcMemGCAlloc(hScreenDC
->psd
, nWidth
, nHeight
, nPlanes
, bPP
, &size
, &linelen
))
342 ReleaseDC(NULL
, hScreenDC
);
345 ReleaseDC(NULL
, hScreenDC
);
347 /* allocate gdi object*/
348 hbitmap
= (MWBITMAPOBJ
*)GdItemAlloc(sizeof(MWBITMAPOBJ
)-1+size
);
351 hbitmap
->hdr
.type
= OBJ_BITMAP
;
352 hbitmap
->hdr
.stockobj
= FALSE
;
353 hbitmap
->width
= nWidth
;
354 hbitmap
->height
= nHeight
;
356 /* create with specified parameters */
357 hbitmap
->planes
= nPlanes
;
359 hbitmap
->linelen
= linelen
;
360 hbitmap
->size
= size
;
362 /* TODO: copy data */
364 return (HBRUSH
)hbitmap
;