OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/rtos/ecos-2.0/packages/services/gfx/mw/v2_0/include
    from Rev 27 to Rev 174
    Reverse comparison

Rev 27 → Rev 174

/microwin/windows.h
0,0 → 1,149
#ifndef _WINDOWS_H
#define _WINDOWS_H
/* windows.h*/
/*
* Copyright (c) 1999, 2000 Greg Haerr <greg@censoft.com>
*
* Microwindows Win32 API master public header file
*/
#ifdef __cplusplus
extern "C" {
#endif
 
#include "mwtypes.h"
#include "windef.h"
#include "wingdi.h"
#include "winfont.h"
#include "winkbd.h"
#include "winuser.h" /* now includes winctl.h for resource compiler*/
 
/* external routines*/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nShowCmd);
 
int MwUserInit(int ac, char **av);
 
/* Internal Microwindows non-win32 definitions*/
 
/* GDI Objects*/
 
typedef struct { /* GDI object hdr*/
int type; /* OBJ_xxx type*/
BOOL stockobj; /* TRUE if stock (unallocated) object*/
} MWGDIOBJHDR;
 
/* gdiobj*/
struct hgdiobj {
MWGDIOBJHDR hdr; /* all gdi object start with this hdr*/
/* additional data...*/ /* allocated per object type*/
};
 
typedef struct {
MWGDIOBJHDR hdr;
int style; /* pen style*/
COLORREF color; /* pen color*/
} MWPENOBJ;
 
typedef struct {
MWGDIOBJHDR hdr;
int style; /* brush style*/
COLORREF color; /* brush color*/
} MWBRUSHOBJ;
 
typedef struct {
MWGDIOBJHDR hdr;
PMWFONT pfont; /* allocated font*/
char name[32]; /* font name (stock objects only)*/
} MWFONTOBJ;
 
typedef struct {
MWGDIOBJHDR hdr;
int width; /* width*/
int height; /* height*/
int planes; /* # planes*/
int bpp; /* bits per pixel*/
int linelen; /* bytes per line*/
int size; /* allocated size in bytes*/
char bits[1]; /* beginning of bitmap*/
} MWBITMAPOBJ;
 
typedef struct {
MWGDIOBJHDR hdr;
MWCLIPREGION * rgn; /* clip region*/
} MWRGNOBJ;
 
/* device context*/
struct hdc {
struct _mwscreendevice *psd; /* screen or memory device*/
HWND hwnd; /* associated window*/
DWORD flags; /* clipping flags*/
int bkmode; /* background mode*/
UINT textalign; /* text alignment flags*/
MWCOLORVAL bkcolor; /* text background color*/
MWCOLORVAL textcolor; /* text color*/
MWBRUSHOBJ * brush; /* current brush*/
MWPENOBJ * pen; /* current pen*/
MWFONTOBJ * font; /* current font*/
MWBITMAPOBJ * bitmap; /* current bitmap (mem dc's only)*/
MWRGNOBJ * region; /* user specified clip region*/
int drawmode; /* rop2 drawing mode */
POINT pt; /* current pen pos in client coords*/
};
 
/* cursor*/
struct hcursor {
int usecount; /* use counter */
MWCURSOR cursor; /* software cursor definition*/
};
 
/* built-in scrollbars*/
typedef struct {
int minPos; /* min value of scroll range.*/
int maxPos; /* max value of scroll range.*/
int curPos; /* current scroll pos.*/
int pageStep; /* steps per page.*/
int barStart; /* start pixel of bar.*/
int barLen; /* length of bar.*/
int status; /* status of scroll bar.*/
RECT rc; /* screen coordinates position*/
} MWSCROLLBARINFO, *PMWSCROLLBARINFO;
 
/* window*/
struct hwnd {
RECT winrect; /* window rect in screen coords*/
RECT clirect; /* client rect in screen coords*/
RECT restorerc; /* restore rect from maximized*/
DWORD style; /* window style*/
DWORD exstyle; /* window extended style*/
PWNDCLASS pClass; /* window class*/
struct hwnd *parent; /* z-order parent window */
struct hwnd *owner; /* owner window*/
struct hwnd *children; /* first child window */
struct hwnd *siblings; /* next sibling window */
struct hwnd *next; /* next window in complete list */
struct hcursor *cursor; /* cursor for this window */
struct hdc * owndc; /* owndc if CS_OWNDC*/
int unmapcount; /* count of reasons not really mapped */
int id; /* window id */
CHAR szTitle[64]; /* window title*/
int gotPaintMsg; /* window had WM_PAINT PostMessage*/
int paintSerial; /* experimental serial # for alphblend*/
int paintNC; /* experimental NC paint handling*/
MWCLIPREGION * update; /* update region in screen coords*/
DWORD userdata; /* setwindowlong user data*/
DWORD userdata2; /* additional user data (will remove)*/
MWSCROLLBARINFO hscroll; /* NC scrollbars*/
MWSCROLLBARINFO vscroll;
int nextrabytes; /* # window extra bytes*/
char extrabytes[1]; /* window extra bytes - must be last*/
};
 
/* misc apis - will move to another header file*/
DWORD WINAPI GetTickCount(VOID);
VOID WINAPI Sleep(DWORD dwMilliseconds);
 
#ifdef __cplusplus
}
#endif
 
#endif /* _WINDOWS_H*/
/microwin/winuser.h
0,0 → 1,504
/* winuser.h*/
/*
* Copyright (c) 1999, 2000 Greg Haerr <greg@censoft.com>
*
* Win32 USER structures and API
*/
#include "winctl.h" /* required compatibility for resource compiler*/
 
/* moved from windef.h for resource compiler*/
typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
typedef LRESULT (CALLBACK* DLGPROC)(HWND, UINT, WPARAM, LPARAM);
 
/* win api*/
LRESULT WINAPI DefWindowProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
 
/* Class styles*/
#define CS_VREDRAW 0x0001
#define CS_HREDRAW 0x0002
#define CS_DBLCLKS 0x0008
#define CS_OWNDC 0x0020
#define CS_CLASSDC 0x0040
#define CS_PARENTDC 0x0080
#define CS_NOCLOSE 0x0200
#define CS_SAVEBITS 0x0800
#define CS_BYTEALIGNCLIENT 0x1000
#define CS_BYTEALIGNWINDOW 0x2000
#define CS_GLOBALCLASS 0x4000
 
typedef struct tagWNDCLASSA {
MWLIST link; /* microwin*/
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra; /* nyi*/
int cbWndExtra;
HINSTANCE hInstance; /* nyi*/
HICON hIcon; /* nyi*/
HCURSOR hCursor; /* nyi*/
HBRUSH hbrBackground;
LPCSTR lpszMenuName; /* nyi*/
LPCSTR lpszClassName;
CHAR szClassName[40]; /* microwin*/
} WNDCLASS, *PWNDCLASS, NEAR *NPWNDCLASS, FAR *LPWNDCLASS;
 
ATOM WINAPI RegisterClass(CONST WNDCLASS *lpWndClass);
 
/*
* Message structure
*/
typedef struct tagMSG {
MWLIST link; /* microwin*/
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG, *PMSG, NEAR *NPMSG, FAR *LPMSG;
 
#define POINTSTOPOINT(pt, pts) \
{ (pt).x = (LONG)(SHORT)LOWORD(*(LONG*)&pts); \
(pt).y = (LONG)(SHORT)HIWORD(*(LONG*)&pts); }
 
#define POINTTOPOINTS(pt) (MAKELONG((short)((pt).x), (short)((pt).y)))
#define MAKEWPARAM(l, h) (WPARAM)MAKELONG(l, h)
#define MAKELPARAM(l, h) (LPARAM)MAKELONG(l, h)
#define MAKELRESULT(l, h) (LRESULT)MAKELONG(l, h)
 
/* window messages*/
#define WM_NULL 0x0000
#define WM_CREATE 0x0001
#define WM_DESTROY 0x0002
#define WM_MOVE 0x0003
#define WM_SIZE 0x0005
#define WM_ACTIVATE 0x0006
#define WM_SETFOCUS 0x0007
#define WM_KILLFOCUS 0x0008
#define WM_ENABLE 0x000A
#define WM_SETTEXT 0x000C
#define WM_GETTEXT 0x000D
#define WM_GETTEXTLENGTH 0x000E
#define WM_PAINT 0x000F
#define WM_CLOSE 0x0010
#define WM_QUIT 0x0012
#define WM_ERASEBKGND 0x0014
#define WM_SHOWWINDOW 0x0018
#define WM_SETFONT 0x0030
#define WM_GETFONT 0x0031
#define WM_WINDOWPOSCHANGED 0x0047
#define WM_NCCALCSIZE 0x0083
#define WM_NCHITTEST 0x0084
#define WM_NCPAINT 0x0085
#define WM_GETDLGCODE 0x0087
#define WM_NCMOUSEMOVE 0x00A0
#define WM_NCLBUTTONDOWN 0x00A1
#define WM_NCLBUTTONUP 0x00A2
#define WM_NCLBUTTONDBLCLK 0x00A3
#define WM_NCRBUTTONDOWN 0x00A4
#define WM_NCRBUTTONUP 0x00A5
#define WM_NCRBUTTONDBLCLK 0x00A6
#define WM_KEYFIRST 0x0100
#define WM_KEYDOWN 0x0100
#define WM_KEYUP 0x0101
#define WM_CHAR 0x0102
#define WM_DEADCHAR 0x0103 /* notimp*/
#define WM_SYSKEYDOWN 0x0104 /* nyi*/
#define WM_SYSKEYUP 0x0105 /* nyi*/
#define WM_SYSCHAR 0x0106 /* nyi*/
#define WM_SYSDEADCHAR 0x0107 /* notimp*/
#define WM_KEYLAST 0x0108
#define WM_COMMAND 0x0111
#define WM_TIMER 0x0113
#define WM_HSCROLL 0x0114
#define WM_VSCROLL 0x0115
 
#define WM_MOUSEFIRST 0x0200
#define WM_MOUSEMOVE 0x0200
#define WM_LBUTTONDOWN 0x0201
#define WM_LBUTTONUP 0x0202
#define WM_LBUTTONDBLCLK 0x0203
#define WM_RBUTTONDOWN 0x0204
#define WM_RBUTTONUP 0x0205
#define WM_RBUTTONDBLCLK 0x0206
#define WM_MBUTTONDOWN 0x0207
#define WM_MBUTTONUP 0x0208
#define WM_MBUTTONDBLCLK 0x0209
#define WM_MOUSEWHEEL 0x020A
#define WM_MOUSELAST 0x020A
 
#define WM_CARET_CREATE 0x03E0 /* Microwindows only*/
#define WM_CARET_DESTROY 0x03E1 /* Microwindows only*/
#define WM_CARET_BLINK 0x03E2 /* Microwindows only*/
#define WM_FDINPUT 0x03F0 /* Microwindows only*/
#define WM_FDOUTPUT 0x03F1 /* Microwindows only*/
#define WM_FDEXCEPT 0x03F2 /* Microwindows only*/
#define WM_USER 0x0400
 
/* WM_ACTIVATE state values*/
#define WA_INACTIVE 0
#define WA_ACTIVE 1
#define WA_CLICKACTIVE 2
 
/* WM_NCHITTEST codes*/
#define HTERROR (-2)
#define HTTRANSPARENT (-1)
#define HTNOWHERE 0
#define HTCLIENT 1
#define HTCAPTION 2
#define HTSYSMENU 3
#define HTGROWBOX 4
#define HTSIZE HTGROWBOX
#define HTMENU 5
#define HTHSCROLL 6
#define HTVSCROLL 7
#define HTMINBUTTON 8
#define HTMAXBUTTON 9
#define HTLEFT 10
#define HTRIGHT 11
#define HTTOP 12
#define HTTOPLEFT 13
#define HTTOPRIGHT 14
#define HTBOTTOM 15
#define HTBOTTOMLEFT 16
#define HTBOTTOMRIGHT 17
#define HTBORDER 18
#define HTREDUCE HTMINBUTTON
#define HTZOOM HTMAXBUTTON
#define HTSIZEFIRST HTLEFT
#define HTSIZELAST HTBOTTOMRIGHT
#define HTOBJECT 19
#define HTCLOSE 20
#define HTHELP 21
 
/* WM_SIZE wparam values*/
#define SIZE_RESTORED 0
#define SIZE_MINIMIZED 1
#define SIZE_MAXIMIZED 2
#define SIZE_MAXSHOW 3
#define SIZE_MAXHIDE 4
 
LRESULT WINAPI CallWindowProc(WNDPROC lpPrevWndFunc, HWND hwnd, UINT Msg,
WPARAM wParam, LPARAM lParam);
LRESULT WINAPI SendMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam);
BOOL WINAPI PostMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam);
BOOL WINAPI PostThreadMessage(DWORD dwThreadId, UINT Msg, WPARAM wParam,
LPARAM lParam);
VOID WINAPI PostQuitMessage(int nExitCode);
 
/* PeekMessage options*/
#define PM_NOREMOVE 0x0000
#define PM_REMOVE 0x0001
#define PM_NOYIELD 0x0002
 
BOOL WINAPI PeekMessage(LPMSG lpMsg, HWND hwnd, UINT uMsgFilterMin,
UINT uMsgFilterMax, UINT wRemoveMsg);
BOOL WINAPI GetMessage(LPMSG lpMsg,HWND hwnd,UINT wMsgFilterMin,
UINT wMsgFilterMax);
BOOL WINAPI TranslateMessage(CONST MSG *lpMsg);
LONG WINAPI DispatchMessage(CONST MSG *lpMsg);
 
/* note: the following struct is in reverse order from the
* microsoft version since WINAPI is cdecl in this implementation
*/
typedef struct tagCREATESTRUCT {
DWORD dwExStyle;
LPCSTR lpszClass;
LPCSTR lpszName;
LONG style;
int x;
int y;
int cx;
int cy;
HWND hwndParent;
HMENU hMenu;
HINSTANCE hInstance;
LPVOID lpCreateParams;
} CREATESTRUCT, *LPCREATESTRUCT;
 
/*
* Window Styles
*/
#define WS_OVERLAPPED 0x00000000L
#define WS_POPUP 0x80000000L
#define WS_CHILD 0x40000000L
#define WS_MINIMIZE 0x20000000L
#define WS_VISIBLE 0x10000000L
#define WS_DISABLED 0x08000000L
#define WS_CLIPSIBLINGS 0x04000000L
#define WS_CLIPCHILDREN 0x02000000L
#define WS_MAXIMIZE 0x01000000L
#define WS_CAPTION 0x00C00000L /* WS_BORDER | WS_DLGFRAME */
#define WS_BORDER 0x00800000L
#define WS_DLGFRAME 0x00400000L
#define WS_VSCROLL 0x00200000L
#define WS_HSCROLL 0x00100000L
#define WS_SYSMENU 0x00080000L
#define WS_THICKFRAME 0x00040000L
#define WS_GROUP 0x00020000L
#define WS_TABSTOP 0x00010000L
 
#define WS_MINIMIZEBOX 0x00020000L
#define WS_MAXIMIZEBOX 0x00010000L
 
 
#define WS_TILED WS_OVERLAPPED
#define WS_ICONIC WS_MINIMIZE
#define WS_SIZEBOX WS_THICKFRAME
#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
 
/*
* Common Window Styles
*/
#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | \
WS_CAPTION | \
WS_SYSMENU | \
WS_THICKFRAME | \
WS_MINIMIZEBOX | \
WS_MAXIMIZEBOX)
 
#define WS_POPUPWINDOW (WS_POPUP | \
WS_BORDER | \
WS_SYSMENU)
 
#define WS_CHILDWINDOW (WS_CHILD)
 
/*
* Extended Window Styles
*/
#define WS_EX_DLGMODALFRAME 0x00000001L
#define WS_EX_NOPARENTNOTIFY 0x00000004L
#define WS_EX_TOPMOST 0x00000008L
#define WS_EX_ACCEPTFILES 0x00000010L
#define WS_EX_TRANSPARENT 0x00000020L
#define WS_EX_MDICHILD 0x00000040L
#define WS_EX_TOOLWINDOW 0x00000080L
#define WS_EX_WINDOWEDGE 0x00000100L
#define WS_EX_CLIENTEDGE 0x00000200L
#define WS_EX_CONTEXTHELP 0x00000400L
 
#define WS_EX_RIGHT 0x00001000L
#define WS_EX_LEFT 0x00000000L
#define WS_EX_RTLREADING 0x00002000L
#define WS_EX_LTRREADING 0x00000000L
#define WS_EX_LEFTSCROLLBAR 0x00004000L
#define WS_EX_RIGHTSCROLLBAR 0x00000000L
 
#define WS_EX_CONTROLPARENT 0x00010000L
#define WS_EX_STATICEDGE 0x00020000L
#define WS_EX_APPWINDOW 0x00040000L
#define WS_EX_LAYERED 0x00080000L
 
#define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
#define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
 
#define CW_USEDEFAULT ((int)0x80000000)
 
#define HWND_DESKTOP ((HWND)0)
 
#define CreateWindow(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, hMenu, hInstance, lpParam)\
CreateWindowEx(0L, lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hwndParent, hMenu, hInstance, lpParam)
 
HWND WINAPI CreateWindowEx(DWORD dwExStyle, LPCSTR lpClassName,
LPCSTR lpWindowName, DWORD dwStyle, int X, int Y,
int nWidth, int nHeight, HWND hwndParent, HMENU hMenu,
HINSTANCE hInstance, LPVOID lpParam);
BOOL WINAPI DestroyWindow(HWND hwnd);
BOOL WINAPI IsWindow(HWND hwnd);
#define IsWindowVisible(hwnd) ((BOOL)((hwnd)->unmapcount == 0))
 
/*
* ShowWindow() Commands
*/
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_FORCEMINIMIZE 11
#define SW_MAX 11
 
BOOL WINAPI ShowWindow(HWND hwnd, int nCmdShow);
BOOL WINAPI InvalidateRect(HWND hwnd, CONST RECT *lpRect, BOOL bErase);
BOOL WINAPI InvalidateRgn(HWND hwnd, HRGN hrgn, BOOL bErase);
BOOL WINAPI ValidateRect(HWND hwnd, CONST RECT *lprc);
BOOL WINAPI ValidateRgn(HWND hwnd, HRGN hrgn);
BOOL WINAPI UpdateWindow(HWND hwnd);
 
BOOL WINAPI SetLayeredWindowAttributes(HWND hwnd, COLORREF crKey,
BYTE bAlpha, DWORD dwFlags);
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002
 
HWND WINAPI GetFocus(VOID);
HWND WINAPI SetFocus(HWND hwnd);
BOOL WINAPI SetForegroundWindow(HWND hwnd);
HWND WINAPI SetActiveWindow(HWND hwnd);
HWND WINAPI GetActiveWindow(VOID);
BOOL WINAPI BringWindowToTop(HWND hwnd);
HWND WINAPI GetDesktopWindow(VOID);
HWND WINAPI GetParent(HWND hwnd);
BOOL WINAPI EnableWindow(HWND hwnd, BOOL bEnable);
#define IsWindowEnabled(hwnd) ((BOOL)(((hwnd)->style&WS_DISABLED) == 0))
 
BOOL WINAPI AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu,
DWORD dwExStyle);
BOOL WINAPI GetClientRect(HWND hwnd, LPRECT lpRect);
BOOL WINAPI GetWindowRect(HWND hwnd, LPRECT lpRect);
 
BOOL WINAPI ClientToScreen(HWND hwnd, LPPOINT lpPoint);
BOOL WINAPI ScreenToClient(HWND hwnd, LPPOINT lpPoint);
int WINAPI MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
UINT cPoints);
 
BOOL WINAPI SetRect(LPRECT lprc,int xLeft,int yTop,int xRight,int yBottom);
BOOL WINAPI SetRectEmpty(LPRECT lprc);
BOOL WINAPI CopyRect(LPRECT lprcDst, CONST RECT *lprcSrc);
BOOL WINAPI IsRectEmpty(CONST RECT *lprc);
BOOL WINAPI InflateRect(LPRECT lprc, int dx, int dy);
BOOL WINAPI OffsetRect(LPRECT lprc, int dx, int dy);
/* The bcc compiler doesn't work passing structs by value, so we have this*/
#if ELKS
#define PtInRect(lprc,pt) MwPTINRECT(lprc, *(long *)&(pt))
#else
#define PtInRect(lprc,pt) MwPTINRECT(lprc, pt)
#endif
BOOL WINAPI MwPTINRECT(CONST RECT *lprc, POINT pt);
 
/*
* Window field offsets for GetWindowLong()
*/
#define GWL_WNDPROC (-4)
#define GWL_HINSTANCE (-6)
#define GWL_HWNDPARENT (-8)
#define GWL_STYLE (-16)
#define GWL_EXSTYLE (-20)
#define GWL_USERDATA (-21)
#define GWL_ID (-12)
 
/*
* Class field offsets for GetClassLong()
*/
#define GCL_MENUNAME (-8)
#define GCL_HBRBACKGROUND (-10)
#define GCL_HCURSOR (-12)
#define GCL_HICON (-14)
#define GCL_HMODULE (-16)
#define GCL_CBWNDEXTRA (-18)
#define GCL_CBCLSEXTRA (-20)
#define GCL_WNDPROC (-24)
#define GCL_STYLE (-26)
#define GCW_ATOM (-32)
#define GCL_HICONSM (-34)
 
LONG WINAPI GetWindowLong(HWND hwnd, int nIndex);
LONG WINAPI SetWindowLong(HWND hwnd, int nIndex, LONG lNewLong);
WORD WINAPI GetWindowWord(HWND hwnd, int nIndex);
WORD WINAPI SetWindowWord(HWND hwnd, int nIndex, WORD wNewWord);
#define GetDlgCtrlID(hwnd) ((int)(hwnd)->id)
DWORD WINAPI GetClassLong(HWND hwnd, int nIndex);
int WINAPI GetWindowTextLength(HWND hwnd);
int WINAPI GetWindowText(HWND hwnd, LPSTR lpString, int nMaxCount);
BOOL WINAPI SetWindowText(HWND hwnd, LPCSTR lpString);
 
BOOL WINAPI MoveWindow(HWND hwnd, int x, int y, int nWidth, int nHeight,
BOOL bRepaint);
 
/* SetWindowPos Flags*/
#define SWP_NOSIZE 0x0001
#define SWP_NOMOVE 0x0002
#define SWP_NOZORDER 0x0004
#define SWP_NOREDRAW 0x0008
#define SWP_NOACTIVATE 0x0010 /* nyi*/
#define SWP_FRAMECHANGED 0x0020 /* nyi*/
#define SWP_SHOWWINDOW 0x0040
#define SWP_HIDEWINDOW 0x0080
#define SWP_NOCOPYBITS 0x0100 /* nyi*/
#define SWP_NOOWNERZORDER 0x0200 /* nyi*/
#define SWP_NOSENDCHANGING 0x0400 /* nyi*/
#define SWP_DRAWFRAME SWP_FRAMECHANGED
#define SWP_NOREPOSITION SWP_NOOWNERZORDER
#define SWP_DEFERERASE 0x2000 /* nyi*/
#define SWP_ASYNCWINDOWPOS 0x4000 /* nyi*/
 
#define HWND_TOP ((HWND)0) /* nyi*/
#define HWND_BOTTOM ((HWND)1) /* nyi*/
#define HWND_TOPMOST ((HWND)-1) /* nyi*/
#define HWND_NOTOPMOST ((HWND)-2) /* nyi*/
 
/* WM_WINDOWPOSCHANGED message*/
typedef struct tagWINDOWPOS {
HWND hwnd;
HWND hwndInsertAfter;
int x;
int y;
int cx;
int cy;
UINT flags;
} WINDOWPOS, *LPWINDOWPOS, *PWINDOWPOS;
 
BOOL WINAPI SetWindowPos(HWND hwnd, HWND hwndInsertAfter, int x, int y,
int cx, int cy, UINT fuFlags);
 
BOOL WINAPI GetCursorPos(LPPOINT lpPoint);
HWND WINAPI GetCapture(VOID);
HWND WINAPI SetCapture(HWND hwnd);
BOOL WINAPI ReleaseCapture(VOID);
 
/*
* WM_NCCALCSIZE parameter structure
*/
typedef struct tagNCCALCSIZE_PARAMS {
RECT rgrc[3];
/*PWINDOWPOS lppos;*/ /* removed for microwin*/
} NCCALCSIZE_PARAMS, *LPNCCALCSIZE_PARAMS;
 
typedef FARPROC TIMERPROC;
 
UINT WINAPI SetTimer(HWND hwnd, UINT idTimer, UINT uTimeout,
TIMERPROC lpTimerFunc);
BOOL WINAPI KillTimer(HWND hwnd, UINT idTimer);
UINT MwGetNextTimeoutValue(void);
void MwHandleTimers(void);
 
/* GetSystemMetrics indices*/
#define SM_CXSCREEN 0
#define SM_CYSCREEN 1
#define SM_CXVSCROLL 2
#define SM_CYHSCROLL 3
#define SM_CYCAPTION 4
#define SM_CXBORDER 5
#define SM_CYBORDER 6
#define SM_CXDLGFRAME 7
#define SM_CYDLGFRAME 8
#define SM_CXFIXEDFRAME SM_CXDLGFRAME
#define SM_CYFIXEDFRAME SM_CYDLGFRAME
#define SM_CYMENU 15
#define SM_CYVSCROLL 20
#define SM_CXHSCROLL 21
#define SM_CXFRAME 32
#define SM_CYFRAME 33
#define SM_CXSIZEFRAME SM_CXFRAME
#define SM_CYSIZEFRAME SM_CYFRAME
 
int WINAPI GetSystemMetrics(int nIndex);
 
HWND WINAPI GetDlgItem(HWND hDlg, int nIDDlgItem);
 
/**************************** Caret support **********************************/
BOOL WINAPI CreateCaret(HWND hwnd, HBITMAP hBitmap, int nWidth, int nHeight);
BOOL WINAPI DestroyCaret(VOID);
BOOL WINAPI HideCaret (HWND hwnd);
BOOL WINAPI ShowCaret(HWND hwnd);
BOOL WINAPI SetCaretPos(int nX, int nY);
BOOL WINAPI GetCaretPos(LPPOINT lpPoint);
UINT WINAPI GetCaretBlinkTime(VOID);
BOOL WINAPI SetCaretBlinkTime(UINT uMSeconds);
/microwin/mwobjects.h
0,0 → 1,494
/*
Copyright (C) Chris Johns (ccj@acm.org)
 
MicroWindows C++ Wrappers.
 
*/
 
#if !defined (_MWOBJECTS_H_)
#define _MWOBJECTS_H_
 
extern "C"
{
#include "windows.h"
#include "wintern.h"
#include "graph3d.h"
};
 
#include <set>
#include <iostream>
 
namespace MicroWindowsObjects
{
class FileDescriptor;
 
//
// Manage Window Classes. Notice you do not need to specify
// a Window Procedure function pointer. This is handled for
// you.
//
 
class WindowClass
{
public:
WindowClass ();
WindowClass (LPCSTR lpszClassName,
UINT style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW,
int cbClsExtra = 0,
int cbWndExtra = 0,
HINSTANCE hInstance = 0,
HICON hIcon = 0,
HCURSOR hCursor = 0,
HBRUSH hbrBackground = 0,
LPCSTR lpszMenuName = 0);
void set_style (UINT style)
{ wclass.style = style; }
 
void set_class_extra (int cbClsExtra)
{ wclass.cbClsExtra = cbClsExtra; }
 
void set_window_extra (int cbWndExtra)
{ wclass.cbWndExtra = cbWndExtra; }
 
void set_instance (HINSTANCE hInstance)
{ wclass.hInstance = hInstance; }
 
void set_icon (HICON hIcon)
{ wclass.hIcon = hIcon; }
 
void set_cursor (HCURSOR hCursor)
{ wclass.hCursor = hCursor; }
 
void set_background (HBRUSH hbrBackground)
{ wclass.hbrBackground = hbrBackground; }
 
void set_menu_name (LPCSTR lpszMenuName)
{ wclass.lpszMenuName = lpszMenuName; }
ATOM register_class ();
private:
 
//
// This variable is a local copy which is
// registered. After that is class does little.
//
 
WNDCLASS wclass;
};
class Window
{
friend WindowClass;
public:
 
Window ();
Window (DWORD dwExStyle,
LPCSTR lpClassName,
LPCSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hwndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam);
 
virtual ~Window ();
HWND create (DWORD dwExStyle,
LPCSTR lpClassName,
LPCSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hwndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam);
 
BOOL destory ();
 
HWND get_handle () const
{ return hwnd; }
operator HWND () const
{ return get_handle (); }
BOOL is_visible ()
{ return IsWindowVisible (hwnd); }
BOOL show (int nCmdShow)
{ return ::ShowWindow (hwnd, nCmdShow); }
BOOL update ()
{ return ::UpdateWindow (hwnd); }
BOOL invalidate_rect (CONST RECT *lpRect, BOOL bErase)
{ return ::InvalidateRect (hwnd, lpRect, bErase); }
 
HWND get_focus ()
{ return ::GetFocus (); }
HWND set_focus ()
{ return ::SetFocus (hwnd); }
 
BOOL move (int x, int y, int nWidth, int nHeight, BOOL bRepaint)
{ return MoveWindow (hwnd, x, y, nWidth, nHeight, bRepaint); }
 
// FIXME: Should these be here ?
BOOL client_to_screen (LPPOINT lpPoint)
{ return ::ClientToScreen (hwnd, lpPoint); }
BOOL screen_to_client (LPPOINT lpPoint)
{ return ::ClientToScreen (hwnd, lpPoint); }
 
LONG get_long (int nIndex)
{ return ::GetWindowLong (hwnd, nIndex); }
LONG set_long (int nIndex, LONG wNewLong)
{ return ::SetWindowWord (hwnd, nIndex, wNewLong); }
WORD get_word (int nIndex)
{ return ::GetWindowWord (hwnd, nIndex); }
WORD set_word (int nIndex, WORD wNewWord)
{ return ::SetWindowWord (hwnd, nIndex, wNewWord); }
 
DWORD get_class_long (int nIndex)
{ return ::GetClassLong (hwnd, nIndex); }
 
int get_text (LPSTR lpString, int nMaxCount)
{ return GetWindowText (hwnd, lpString, nMaxCount); }
BOOL set_text (LPCSTR lpString)
{ return SetWindowText (hwnd, lpString); }
 
//
// File Descriptor handlers.
//
 
virtual bool attach (const int fd, FileDescriptor& file_descriptor);
virtual bool detach (FileDescriptor& file_descriptor);
 
protected:
 
//
// The message handler. Insure you call this class's default
// handler for default message handling so any special
// filtering can occur.
//
 
virtual LRESULT message_handler (UINT msg,
WPARAM wParam,
LPARAM lParam);
 
private:
 
//
// We only need one WndProc.
//
 
static LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
 
HWND hwnd;
LPVOID lpCreateParams;
//
// Set of FileDescriptor objects
//
 
struct ltint
{
bool operator() (const FileDescriptor* f1, const FileDescriptor* f2) const;
};
 
set<FileDescriptor*, ltint> file_descriptors;
};
class Rect
{
public:
 
Rect ()
{ empty (); }
Rect (int xLeft, int yTop, int xRight, int yBottom)
{ set (xLeft, yTop, xRight, yBottom); }
Rect (HWND hwnd)
{ get_window (hwnd); }
BOOL get_window (HWND hwnd)
{ return GetWindowRect (hwnd, &rect); }
BOOL get_client (HWND hwnd)
{ return GetClientRect (hwnd, &rect); }
 
BOOL set (int xLeft, int yTop, int xRight, int yBottom)
{ return ::SetRect (&rect, xLeft, yTop, xRight, yBottom); }
 
BOOL empty ()
{ return ::SetRectEmpty (&rect); }
 
Rect& operator= (const Rect& other)
{ CopyRect (&rect, &other.rect); return *this; }
 
operator bool () const
{ return ::IsRectEmpty (&rect); }
 
operator RECT* ()
{ return &rect; }
BOOL copy (LPRECT lpRectDst)
{ return ::CopyRect (lpRectDst, &rect); }
 
BOOL inflate (int dx, int dy)
{ return ::InflateRect (&rect, dx, dy); }
 
BOOL offset (int dx, int dy)
{ return ::OffsetRect (&rect, dx, dy); }
 
BOOL point_inside (POINT Point)
{ return PtInRect (&rect, Point); }
 
MWCOORD left () const
{ return rect.left; }
MWCOORD top () const
{ return rect.top; }
MWCOORD right () const
{ return rect.right; }
MWCOORD bottom () const
{ return rect.bottom; }
private:
 
RECT rect;
};
 
inline ostream& operator<< (ostream& s, const Rect& r) {
s << "rect"
<< "(l=" << r.left () << ",t=" << r.top ()
<< ",r=" << r.right () << ",b=" << r.bottom ()
<< ")";
return s;
}
 
//
// Generic Paint class. Try to help the paint message.
//
 
class Paint
{
public:
 
enum { TEXT_BUF_SIZE = 512 };
Paint (HWND hwnd);
Paint (HWND hwnd, LPARAM lpParam);
virtual ~Paint ();
//
// These begin and end a paint session.
//
 
void begin (bool init_3d = false, bool draw_3d_in_memory = false);
void end ();
//
// Aspects of the client paint area under our control.
//
 
operator HWND ()
{ return hwnd; }
operator RECT* ()
{ return r; }
operator HDC ()
{ return hdc; }
operator PAINTSTRUCT* ()
{ return &ps; }
operator POINT* ()
{ return &pt; }
 
GDICOORD get_point_x () const
{ return pt.x; }
GDICOORD get_point_y () const
{ return pt.y; }
MWCOORD left () const
{ return r.left (); }
MWCOORD top () const
{ return r.top (); }
MWCOORD right () const
{ return r.right (); }
MWCOORD bottom () const
{ return r.bottom (); }
//
// Colour Control.
//
 
DWORD get_system_colour (int nIndex)
{ return ::GetSysColor (nIndex); }
//
// Pixel, line and rectange draw support.
//
 
COLORREF set_pixel (int x, int y, COLORREF crColour)
{ return ::SetPixel (hdc, x, y, crColour); }
 
BOOL move_to (int x, int y)
{ return ::MoveToEx (hdc, x, y, 0); }
 
BOOL line_to (int x, int y)
{ return ::LineTo (hdc, x, y); }
 
BOOL line_to (int x1, int y1, int x2, int y2)
{ if (!move_to (x1, y1)) return FALSE;
return line_to (x2, y2); }
 
BOOL rectangle (int x1, int y1, int x2, int y2)
{ return ::Rectangle (hdc, x1, y1, x2, y2); }
 
BOOL fill_rectangle (int x1, int y1, int x2, int y2, HBRUSH hbr)
{ Rect r (x1, y1, x2, y2);
return ::FillRect (hdc, r, hbr); }
//
// Paint any 3d objects.
//
 
void initialise_3d (bool draw_3d_in_mem)
{ if (!draw_3d) {
draw_3d = true; ::init3 (hdc, draw_3d_in_mem ? hwnd : 0); } }
void paint_3d ()
{ if (draw_3d) { ::paint3 (hdc); draw_3d = false; } }
//
// Text Output.
//
 
void set_text_fromat (UINT uFormat)
{ text_format = uFormat; }
int text_out (int x, int y, const char *format, ...);
 
private:
 
HWND hwnd;
bool draw_3d;
bool drawing;
Rect r;
HDC hdc;
PAINTSTRUCT ps;
POINT pt;
UINT text_format;
char format_buf[TEXT_BUF_SIZE];
};
 
//
// FileDescriptor handles fd event from the User Registered File
// Descriptor support.
//
 
class FileDescriptor
{
friend class Window;
public:
 
FileDescriptor ();
virtual ~FileDescriptor ();
 
//
// Enable/disable controls.
//
 
bool enable_read ();
bool disable_read ();
bool read_enabled () const
{ return read_is_enabled; }
bool enable_write ();
bool disable_write ();
bool write_enabled () const
{ return write_is_enabled; }
bool enable_except ();
bool disable_except ();
bool except_enabled () const
{ return except_is_enabled; }
int fd () const
{ return file_desc; }
operator int () const
{ return fd (); }
const Window *get_window () const
{ return window; }
protected:
 
//
// These are called in responce to user fd messages to the window.
//
 
virtual LRESULT read ();
virtual LRESULT write ();
virtual LRESULT except ();
private:
 
int file_desc;
bool read_is_enabled;
bool write_is_enabled;
bool except_is_enabled;
Window *window;
};
class Application
{
public:
Application ();
Application (MWIMAGEHDR& background);
virtual ~Application ();
HINSTANCE instance () const
{ return app_instance; }
HINSTANCE prev_instance () const
{ return app_prev_instance; }
 
LPSTR cmd_line () const
{ return app_cmd_line; }
 
int show_cmd ()
{ return app_show_cmd; }
//
// This is called the public C linkage WinMain. Do not call.
//
 
static int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd);
protected:
virtual int initialise ();
virtual int shutdown ();
 
private:
MWIMAGEHDR *background;
HINSTANCE app_instance;
HINSTANCE app_prev_instance;
LPSTR app_cmd_line;
int app_show_cmd;
 
};
}
 
#endif
 
/microwin/device.h
0,0 → 1,654
#ifndef _DEVICE_H
#define _DEVICE_H
/*
* Copyright (c) 1999, 2000 Greg Haerr <greg@censoft.com>
*
* Engine-level Screen, Mouse and Keyboard device driver API's and types
*
* Contents of this file are not for general export
*/
#include "mwtypes.h" /* public export typedefs*/
 
/* Changeable limits and options*/
#define ALPHABLEND 1 /* =1 to include blending code*/
#define DYNAMICREGIONS 1 /* =1 to use MWCLIPREGIONS*/
#define HAVEFLOAT 1 /* =1 incl float, GdArcAngle*/
#define POLYREGIONS 1 /* =1 includes polygon regions*/
#define ANIMATEPALETTE 0 /* =1 animated palette test*/
#define FONTMAPPER 0 /* =1 for Morten's font mapper*/
#define USE_ALLOCA 1 /* alloca() is available */
#define EPRINTF GdError /* error output*/
#define DPRINTF GdErrorNull /* debug output*/
 
/* max char height/width must be >= 16 and a multiple of sizeof(MWIMAGEBITS)*/
#define MAX_CHAR_HEIGHT 128 /* maximum text bitmap height*/
#define MAX_CHAR_WIDTH 128 /* maximum text bitmap width*/
#define MIN_MWCOORD ((MWCOORD) -32768) /* minimum coordinate value */
#define MAX_MWCOORD ((MWCOORD) 32767) /* maximum coordinate value */
#define MAX_CLIPRECTS 200 /* max clip rects (obsolete)*/
 
typedef struct _mwscreendevice *PSD;
 
/* builtin C-based proportional/fixed font structure*/
typedef struct {
char * name; /* font name*/
int maxwidth; /* max width in pixels*/
int height; /* height in pixels*/
int ascent; /* ascent (baseline) height*/
int firstchar; /* first character in bitmap*/
int size; /* font size in characters*/
MWIMAGEBITS * bits; /* 16-bit right-padded bitmap data*/
unsigned short *offset; /* 256 offsets into bitmap data*/
unsigned char * width; /* 256 character widths or 0 if fixed*/
} MWCFONT, *PMWCFONT;
 
/* draw procs associated with fonts. Strings are [re]packed using defencoding*/
typedef struct {
int encoding; /* routines expect this encoding*/
MWBOOL (*GetFontInfo)(PMWFONT pfont, PMWFONTINFO pfontinfo);
void (*GetTextSize)(PMWFONT pfont, const void *text, int cc,
MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase);
void (*GetTextBits)(PMWFONT pfont, int ch, MWIMAGEBITS *retmap,
MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase);
void (*DestroyFont)(PMWFONT pfont);
void (*DrawText)(PMWFONT pfont, PSD psd, MWCOORD x, MWCOORD y,
const void *str, int count, int flags);
void (*SetFontSize)(PMWFONT pfont, MWCOORD fontsize);
void (*SetFontRotation)(PMWFONT pfont, int tenthdegrees);
void (*SetFontAttr)(PMWFONT pfont, int setflags, int clrflags);
} MWFONTPROCS, *PMWFONTPROCS;
 
/* new multi-renderer font struct*/
typedef struct _mwfont { /* common hdr for all font structures*/
PMWFONTPROCS fontprocs; /* font-specific rendering routines*/
MWCOORD fontsize; /* font height in pixels*/
int fontrotation; /* font rotation*/
int fontattr; /* font attributes: kerning/antialias*/
/* font-specific rendering data here*/
} MWFONT;
 
/* fontattr flags*/
#define FS_FREETYPE 0x0800
 
/* builtin core font struct*/
typedef struct {
PMWFONTPROCS fontprocs; /* common hdr*/
MWCOORD fontsize;
int fontrotation;
int fontattr;
 
char * name; /* Microwindows font name*/
PMWCFONT cfont; /* builtin font data*/
} MWCOREFONT, *PMWCOREFONT;
 
/* This structure is used to pass parameters into the low
* level device driver functions.
*/
typedef struct {
MWCOORD dstx, dsty, dstw, dsth, dst_linelen;
MWCOORD srcx, srcy, src_linelen;
void *pixels, *misc;
MWPIXELVAL bg_color, fg_color;
int gr_usebg;
} driver_gc_t;
 
/* Operations for the Blitter/Area functions */
#define PSDOP_COPY 0
#define PSDOP_COPYALL 1
#define PSDOP_COPYTRANS 2
#define PSDOP_ALPHAMAP 3
#define PSDOP_ALPHACOL 4
#define PSDOP_PIXMAP_COPYALL 5
 
/* common blitter parameter structure*/
typedef struct {
PSD dstpsd; /* dst drawable*/
MWCOORD dstx, dsty; /* dst x,y,w,h*/
MWCOORD dstw, dsth;
MWCOORD srcx, srcy; /* src x,y*/
MWCOORD srcw, srch; /* src w,h if stretchblit*/
PSD srcpsd; /* src drawable*/
unsigned long rop; /* raster opcode*/
PSD alphachan; /* alpha chan for MWROP_BLENDCHANNEL*/
MWPIXELVAL fgcolor; /* fg/bg color for MWROP_BLENDFGBG*/
MWPIXELVAL bgcolor;
MWPIXELVAL transcolor; /* trans color for MWROP_SRCTRANSCOPY*/
} MWBLITARGS, *PMWBLITARGS;
 
/* screen subdriver entry points: one required for each draw function*/
/* NOTE: currently used for fb driver only*/
typedef struct {
int (*Init)(PSD psd);
void (*DrawPixel)(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c);
MWPIXELVAL (*ReadPixel)(PSD psd, MWCOORD x, MWCOORD y);
void (*DrawHorzLine)(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y,
MWPIXELVAL c);
void (*DrawVertLine)(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2,
MWPIXELVAL c);
void (*FillRect)(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,
MWCOORD y2,MWPIXELVAL c);
void (*Blit)(PSD destpsd, MWCOORD destx, MWCOORD desty, MWCOORD w,
MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op);
void (*DrawArea)(PSD psd, driver_gc_t *gc, int op);
void (*StretchBlit)(PSD destpsd, MWCOORD destx, MWCOORD desty,
MWCOORD dstw, MWCOORD dsth, PSD srcpsd, MWCOORD srcx,
MWCOORD srcy, MWCOORD srcw, MWCOORD srch, long op);
} SUBDRIVER, *PSUBDRIVER;
 
/*
* Interface to Screen Device Driver
* This structure is also allocated for memory (offscreen) drawing and blitting.
*/
typedef struct _mwscreendevice {
MWCOORD xres; /* X screen res (real) */
MWCOORD yres; /* Y screen res (real) */
MWCOORD xvirtres; /* X drawing res (will be flipped in portrait mode) */
MWCOORD yvirtres; /* Y drawing res (will be flipped in portrait mode) */
int planes; /* # planes*/
int bpp; /* # bpp*/
int linelen; /* line length in bytes for bpp 1,2,4,8*/
/* line length in pixels for bpp 16, 24, 32*/
int size; /* size of memory allocated*/
long ncolors; /* # screen colors*/
int pixtype; /* format of pixel value*/
int flags; /* device flags*/
void * addr; /* address of memory allocated (memdc or fb)*/
 
PSD (*Open)(PSD psd);
void (*Close)(PSD psd);
void (*GetScreenInfo)(PSD psd,PMWSCREENINFO psi);
void (*SetPalette)(PSD psd,int first,int count,MWPALENTRY *pal);
void (*DrawPixel)(PSD psd,MWCOORD x,MWCOORD y,MWPIXELVAL c);
MWPIXELVAL (*ReadPixel)(PSD psd,MWCOORD x,MWCOORD y);
void (*DrawHorzLine)(PSD psd,MWCOORD x1,MWCOORD x2,MWCOORD y,
MWPIXELVAL c);
void (*DrawVertLine)(PSD psd,MWCOORD x,MWCOORD y1,MWCOORD y2,
MWPIXELVAL c);
void (*FillRect)(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,
MWPIXELVAL c);
PMWCOREFONT builtin_fonts;
 
/***void (*DrawText)(PSD psd,MWCOORD x,MWCOORD y,const MWUCHAR *str,
int count, MWPIXELVAL fg, PMWFONT pfont);***/
 
void (*Blit)(PSD destpsd,MWCOORD destx,MWCOORD desty,MWCOORD w,
MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op);
void (*PreSelect)(PSD psd);
void (*DrawArea)(PSD psd, driver_gc_t *gc, int op);
int (*SetIOPermissions)(PSD psd);
PSD (*AllocateMemGC)(PSD psd);
MWBOOL (*MapMemGC)(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,
int linelen,int size,void *addr);
void (*FreeMemGC)(PSD mempsd);
void (*StretchBlit)(PSD destpsd,MWCOORD destx,MWCOORD desty,
MWCOORD destw,MWCOORD desth,PSD srcpsd,MWCOORD srcx,
MWCOORD srcy,MWCOORD srcw,MWCOORD srch,long op);
void (*SetPortrait)(PSD psd,int portraitmode);
int portrait; /* screen portrait mode*/
PSUBDRIVER orgsubdriver; /* original subdriver for portrait modes*/
} SCREENDEVICE;
 
/* PSD flags*/
#define PSF_SCREEN 0x0001 /* screen device*/
#define PSF_MEMORY 0x0002 /* memory device*/
#define PSF_HAVEBLIT 0x0004 /* have bitblit*/
#define PSF_HAVEOP_COPY 0x0008 /* psd->DrawArea can do area copy*/
#define PSF_ADDRMALLOC 0x0010 /* psd->addr was malloc'd*/
#define PSF_ADDRSHAREDMEM 0x0020 /* psd->addr is shared memory*/
 
/* Interface to Mouse Device Driver*/
typedef struct _mousedevice {
int (*Open)(struct _mousedevice *);
void (*Close)(void);
int (*GetButtonInfo)(void);
void (*GetDefaultAccel)(int *pscale,int *pthresh);
int (*Read)(MWCOORD *dx,MWCOORD *dy,MWCOORD *dz,int *bp);
int (*Poll)(void); /* not required if have select()*/
} MOUSEDEVICE;
 
/* Interface to Keyboard Device Driver*/
typedef struct _kbddevice {
int (*Open)(struct _kbddevice *pkd);
void (*Close)(void);
void (*GetModifierInfo)(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers);
int (*Read)(MWKEY *buf,MWKEYMOD *modifiers,MWSCANCODE *scancode);
int (*Poll)(void); /* not required if have select()*/
} KBDDEVICE;
 
/* Clip areas*/
#define CLIP_VISIBLE 0
#define CLIP_INVISIBLE 1
#define CLIP_PARTIAL 2
 
/* static clip rectangle: drawing allowed if point within rectangle*/
typedef struct {
MWCOORD x; /* x coordinate of top left corner */
MWCOORD y; /* y coordinate of top left corner */
MWCOORD width; /* width of rectangle */
MWCOORD height; /* height of rectangle */
} MWCLIPRECT;
 
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
 
#define MWMIN(a,b) ((a) < (b) ? (a) : (b))
#define MWMAX(a,b) ((a) > (b) ? (a) : (b))
 
/* MWIMAGEBITS macros*/
#define MWIMAGE_SIZE(width, height) ((height) * (((width) + MWIMAGE_BITSPERIMAGE - 1) / MWIMAGE_BITSPERIMAGE))
#define MWIMAGE_WORDS(x) (((x)+15)/16)
#define MWIMAGE_BYTES(x) (((x)+7)/8)
#define MWIMAGE_BITSPERIMAGE (sizeof(MWIMAGEBITS) * 8)
#define MWIMAGE_FIRSTBIT ((MWIMAGEBITS) 0x8000)
#define MWIMAGE_NEXTBIT(m) ((MWIMAGEBITS) ((m) >> 1))
#define MWIMAGE_TESTBIT(m) ((m) & MWIMAGE_FIRSTBIT) /* use with shiftbit*/
#define MWIMAGE_SHIFTBIT(m) ((MWIMAGEBITS) ((m) << 1)) /* for testbit*/
 
/* color and palette defines*/
#define RGBDEF(r,g,b) {r, g, b}
 
#define GETPALENTRY(pal,index) ((unsigned long)(pal[index].r |\
(pal[index].g << 8) | (pal[index].b << 16)))
/*#define GETPALENTRY(pal,index) ((*(unsigned long *)&pal[index])&0x00ffffff)*/
 
#define REDVALUE(rgb) ((rgb) & 0xff)
#define GREENVALUE(rgb) (((rgb) >> 8) & 0xff)
#define BLUEVALUE(rgb) (((rgb) >> 16) & 0xff)
 
/* Truecolor color conversion and extraction macros*/
/*
* Conversion from RGB to MWPIXELVAL
*/
/* create 24 bit 8/8/8 format pixel (0x00RRGGBB) from RGB triplet*/
#define RGB2PIXEL888(r,g,b) \
(((r) << 16) | ((g) << 8) | (b))
 
/* create 16 bit 5/6/5 format pixel from RGB triplet */
#define RGB2PIXEL565(r,g,b) \
((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
 
/* create 16 bit 5/5/5 format pixel from RGB triplet */
#define RGB2PIXEL555(r,g,b) \
((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3))
 
/* create 8 bit 3/3/2 format pixel from RGB triplet*/
#define RGB2PIXEL332(r,g,b) \
(((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
 
/*
* Conversion from MWCOLORVAL to MWPIXELVAL
*/
/* create 24 bit 8/8/8 format pixel from RGB colorval (0x00BBGGRR)*/
#define COLOR2PIXEL888(c) \
((((c) & 0xff) << 16) | ((c) & 0xff00) | (((c) & 0xff0000) >> 16))
 
/* create 16 bit 5/6/5 format pixel from RGB colorval (0x00BBGGRR)*/
#define COLOR2PIXEL565(c) \
((((c) & 0xf8) << 8) | (((c) & 0xfc00) >> 5) | (((c) & 0xf80000) >> 19))
 
/* create 16 bit 5/5/5 format pixel from RGB colorval (0x00BBGGRR)*/
#if 0
#define COLOR2PIXEL555(c) \
((((c) & 0xf8) << 7) | (((c) & 0xf800) >> 6) | (((c) & 0xf80000) >> 19))
#else
#define COLOR2PIXEL555(c) \
((((c) & 0xf8) >> (3-0)) | (((c) & 0xf800) >> (11-5)) | (((c) & 0xf80000) >> (19-10)))
#endif
 
/* create 8 bit 3/3/2 format pixel from RGB colorval (0x00BBGGRR)*/
#define COLOR2PIXEL332(c) \
(((c) & 0xe0) | (((c) & 0xe000) >> 11) | (((c) & 0xc00000) >> 22))
 
/*
* Conversion from MWPIXELVAL to red, green or blue components
*/
/* return 8/8/8 bit r, g or b component of 24 bit pixelval*/
#define PIXEL888RED(pixelval) (((pixelval) >> 16) & 0xff)
#define PIXEL888GREEN(pixelval) (((pixelval) >> 8) & 0xff)
#define PIXEL888BLUE(pixelval) ((pixelval) & 0xff)
 
/* return 5/6/5 bit r, g or b component of 16 bit pixelval*/
#define PIXEL565RED(pixelval) (((pixelval) >> 11) & 0x1f)
#define PIXEL565GREEN(pixelval) (((pixelval) >> 5) & 0x3f)
#define PIXEL565BLUE(pixelval) ((pixelval) & 0x1f)
 
/* return 5/5/5 bit r, g or b component of 16 bit pixelval*/
#define PIXEL555RED(pixelval) (((pixelval) >> 10) & 0x1f)
#define PIXEL555GREEN(pixelval) (((pixelval) >> 5) & 0x1f)
#define PIXEL555BLUE(pixelval) ((pixelval) & 0x1f)
 
/* return 3/3/2 bit r, g or b component of 8 bit pixelval*/
#define PIXEL332RED(pixelval) (((pixelval) >> 5) & 0x07)
#define PIXEL332GREEN(pixelval) (((pixelval) >> 2) & 0x07)
#define PIXEL332BLUE(pixelval) ((pixelval) & 0x03)
 
/*
* Conversion from MWPIXELVAL to MWCOLORVAL
*/
/* create RGB colorval (0x00BBGGRR) from 8/8/8 format pixel*/
#define PIXEL888TOCOLORVAL(p) \
((((p) & 0xff0000) >> 16) | ((p) & 0xff00) | (((p) & 0xff) << 16))
 
/* create RGB colorval (0x00BBGGRR) from 5/6/5 format pixel*/
#define PIXEL565TOCOLORVAL(p) \
((((p) & 0xf800) >> 8) | (((p) & 0x07e0) << 5) | (((p) & 0x1f) << 19))
 
#define PIXEL555TOCOLORVAL(p) \
((((p) & 0x7c00) >> 7) | (((p) & 0x03e0) << 6) | (((p) & 0x1f) << 19))
 
/* create RGB colorval (0x00BBGGRR) from 3/3/2 format pixel*/
#define PIXEL332TOCOLORVAL(p) \
((((p) & 0xe0)) | (((p) & 0x1c) << 11) | (((p) & 0x03) << 19))
 
#if (MWPIXEL_FORMAT == MWPF_TRUECOLOR888) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR0888)
#define RGB2PIXEL(r,g,b) RGB2PIXEL888(r,g,b)
#define COLORVALTOPIXELVAL(c) COLOR2PIXEL888(c)
#define PIXELVALTOCOLORVAL(p) PIXEL888TOCOLORVAL(p)
#define PIXEL2RED(p) PIXEL888RED(p)
#define PIXEL2GREEN(p) PIXEL888GREEN(p)
#define PIXEL2BLUE(p) PIXEL888BLUE(p)
#endif
 
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR565
#define RGB2PIXEL(r,g,b) RGB2PIXEL565(r,g,b)
#define COLORVALTOPIXELVAL(c) COLOR2PIXEL565(c)
#define PIXELVALTOCOLORVAL(p) PIXEL565TOCOLORVAL(p)
#define PIXEL2RED(p) PIXEL565RED(p)
#define PIXEL2GREEN(p) PIXEL565GREEN(p)
#define PIXEL2BLUE(p) PIXEL565BLUE(p)
#endif
 
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR555
#define RGB2PIXEL(r,g,b) RGB2PIXEL555(r,g,b)
#define COLORVALTOPIXELVAL(c) COLOR2PIXEL555(c)
#define PIXELVALTOCOLORVAL(p) PIXEL555TOCOLORVAL(p)
#define PIXEL2RED(p) PIXEL555RED(p)
#define PIXEL2GREEN(p) PIXEL555GREEN(p)
#define PIXEL2BLUE(p) PIXEL555BLUE(p)
#endif
 
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR332
#define RGB2PIXEL(r,g,b) RGB2PIXEL332(r,g,b)
#define COLORVALTOPIXELVAL(c) COLOR2PIXEL332(c)
#define PIXELVALTOCOLORVAL(p) PIXEL332TOCOLORVAL(p)
#define PIXEL2RED(p) PIXEL332RED(p)
#define PIXEL2GREEN(p) PIXEL332GREEN(p)
#define PIXEL2BLUE(p) PIXEL332BLUE(p)
#endif
 
/* Alpha blend two pixels using 8-bit alpha */
/* FIXME this will be quite a bit faster as an inlined function */
#define ALPHAPIXELRED(pixelvalsrc, pixelvaldest, alpha) \
(unsigned char)((((PIXEL2RED(pixelvalsrc) - PIXEL2RED(pixelvaldest))\
* alpha) >> 8) + PIXEL2RED(pixelvaldest))
 
#define ALPHAPIXELGREEN(pixelvalsrc, pixelvaldest, alpha) \
(unsigned char)((((PIXEL2GREEN(pixelvalsrc)-PIXEL2GREEN(pixelvaldest))\
* alpha) >> 8) + PIXEL2GREEN(pixelvaldest))
 
#define ALPHAPIXELBLUE(pixelvalsrc, pixelvaldest, alpha) \
(unsigned char)((((PIXEL2BLUE(pixelvalsrc) - PIXEL2BLUE(pixelvaldest))\
* alpha) >> 8) + PIXEL2BLUE(pixelvaldest))
 
#if 0000
/* colors assumed in first 16 palette entries*/
/* note: don't use palette indices if the palette may
* be reloaded. Use the RGB values instead.
*/
#define BLACK PALINDEX(0) /* 0, 0, 0*/
#define BLUE PALINDEX(1)
#define GREEN PALINDEX(2)
#define CYAN PALINDEX(3)
#define RED PALINDEX(4)
#define MAGENTA PALINDEX(5)
#define BROWN PALINDEX(6)
#define LTGRAY PALINDEX(7) /* 192, 192, 192*/
#define GRAY PALINDEX(8) /* 128, 128, 128*/
#define LTBLUE PALINDEX(9)
#define LTGREEN PALINDEX(10)
#define LTCYAN PALINDEX(11)
#define LTRED PALINDEX(12)
#define LTMAGENTA PALINDEX(13)
#define YELLOW PALINDEX(14)
#define WHITE PALINDEX(15) /* 255, 255, 255*/
#endif
 
/* GdMakePaletteConversionTable bLoadType types*/
#define LOADPALETTE 1 /* load image palette into system palette*/
#define MERGEPALETTE 2 /* merge image palette into system palette*/
 
/* entry points*/
 
/* devdraw.c*/
PSD GdOpenScreen(void);
void GdCloseScreen(PSD psd);
int GdSetPortraitMode(PSD psd, int portraitmode);
int GdSetMode(int mode);
MWBOOL GdSetUseBackground(MWBOOL flag);
MWPIXELVAL GdSetForeground(MWPIXELVAL fg);
MWPIXELVAL GdSetBackground(MWPIXELVAL bg);
void GdResetPalette(void);
void GdSetPalette(PSD psd,int first, int count, MWPALENTRY *palette);
int GdGetPalette(PSD psd,int first, int count, MWPALENTRY *palette);
MWPIXELVAL GdFindColor(MWCOLORVAL c);
MWPIXELVAL GdFindNearestColor(MWPALENTRY *pal, int size, MWCOLORVAL cr);
int GdCaptureScreen(char *path);
void GdGetScreenInfo(PSD psd,PMWSCREENINFO psi);
void GdPoint(PSD psd,MWCOORD x, MWCOORD y);
void GdLine(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,
MWBOOL bDrawLastPoint);
void GdRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
void GdFillRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
void GdBitmap(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
MWIMAGEBITS *imagebits);
MWBOOL GdColorInPalette(MWCOLORVAL cr,MWPALENTRY *palette,int palsize);
void GdMakePaletteConversionTable(PSD psd,MWPALENTRY *palette,int palsize,
MWPIXELVAL *convtable,int fLoadType);
void GdDrawImage(PSD psd,MWCOORD x, MWCOORD y, PMWIMAGEHDR pimage);
void GdPoly(PSD psd,int count, MWPOINT *points);
void GdFillPoly(PSD psd,int count, MWPOINT *points);
void GdReadArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
MWPIXELVAL *pixels);
void GdArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
void *pixels, int pixtype);
void GdTranslateArea(MWCOORD width, MWCOORD height, void *in, int inpixtype,
MWCOORD inpitch, void *out, int outpixtype, int outpitch);
void GdCopyArea(PSD psd,MWCOORD srcx,MWCOORD srcy,MWCOORD width,
MWCOORD height, MWCOORD destx, MWCOORD desty);
void GdBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD width,
MWCOORD height,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long rop);
void GdStretchBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw,
MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy,
MWCOORD srcw, MWCOORD srch, long rop);
int GdCalcMemGCAlloc(PSD psd, unsigned int width, unsigned int height,
int planes, int bpp, int *size, int *linelen);
extern SCREENDEVICE scrdev;
 
/* devarc.c*/
/* requires float*/
void GdArcAngle(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry,
MWCOORD angle1, MWCOORD angle2, int type);
/* integer only*/
void GdArc(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry,
MWCOORD ax, MWCOORD ay, MWCOORD bx, MWCOORD by, int type);
void GdEllipse(PSD psd,MWCOORD x, MWCOORD y, MWCOORD rx, MWCOORD ry,
MWBOOL fill);
 
/* devfont.c*/
void GdClearFontList(void);
int GdAddFont(char *fndry, char *family, char *fontname, PMWLOGFONT lf,
unsigned int flags);
PMWFONT GdSetFont(PMWFONT pfont);
PMWFONT GdCreateFont(PSD psd, const char *name, MWCOORD height,
const PMWLOGFONT plogfont);
MWCOORD GdSetFontSize(PMWFONT pfont, MWCOORD fontsize);
void GdGetFontList(MWFONTLIST ***list, int *num);
void GdFreeFontList(MWFONTLIST ***list, int num);
int GdSetFontRotation(PMWFONT pfont, int tenthdegrees);
int GdSetFontAttr(PMWFONT pfont, int setflags, int clrflags);
void GdDestroyFont(PMWFONT pfont);
MWBOOL GdGetFontInfo(PMWFONT pfont, PMWFONTINFO pfontinfo);
int GdConvertEncoding(const void *istr, int iflags, int cc, void *ostr,
int oflags);
void GdGetTextSize(PMWFONT pfont, const void *str, int cc, MWCOORD *pwidth,
MWCOORD *pheight, MWCOORD *pbase, int flags);
int GdGetTextSizeEx(PMWFONT pfont, const void *str, int cc,
int nMaxExtent, int *lpnFit, int *alpDx, MWCOORD *pwidth,
MWCOORD *pheight, MWCOORD *pbase, int flags);
void GdText(PSD psd,MWCOORD x,MWCOORD y,const void *str,int count,int flags);
 
/* devclip1.c*/
void GdSetClipRects(PSD psd,int count,MWCLIPRECT *table);
MWBOOL GdClipPoint(PSD psd,MWCOORD x,MWCOORD y);
int GdClipArea(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2);
extern MWCOORD clipminx, clipminy, clipmaxx, clipmaxy;
 
/* devclip2.c*/
void GdSetClipRegion(PSD psd, MWCLIPREGION *reg);
 
/* devrgn.c - multi-rectangle region entry points*/
MWBOOL GdPtInRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);
int GdRectInRegion(MWCLIPREGION *rgn, const MWRECT *rect);
MWBOOL GdEqualRegion(MWCLIPREGION *r1, MWCLIPREGION *r2);
MWBOOL GdEmptyRegion(MWCLIPREGION *rgn);
MWCLIPREGION *GdAllocRegion(void);
MWCLIPREGION *GdAllocRectRegion(MWCOORD left,MWCOORD top,MWCOORD right,MWCOORD bottom);
MWCLIPREGION *GdAllocRectRegionIndirect(MWRECT *prc);
void GdSetRectRegion(MWCLIPREGION *rgn, MWCOORD left, MWCOORD top,
MWCOORD right, MWCOORD bottom);
void GdSetRectRegionIndirect(MWCLIPREGION *rgn, MWRECT *prc);
void GdDestroyRegion(MWCLIPREGION *rgn);
void GdOffsetRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);
int GdGetRegionBox(MWCLIPREGION *rgn, MWRECT *prc);
void GdUnionRectWithRegion(const MWRECT *rect, MWCLIPREGION *rgn);
void GdSubtractRectFromRegion(const MWRECT *rect, MWCLIPREGION *rgn);
void GdCopyRegion(MWCLIPREGION *d, MWCLIPREGION *s);
void GdIntersectRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
void GdUnionRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
void GdSubtractRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
void GdXorRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
 
/* devrgn2.c*/
MWCLIPREGION *GdAllocPolygonRegion(MWPOINT *points, int count, int mode);
MWCLIPREGION *GdAllocPolyPolygonRegion(MWPOINT *points, int *count,
int nbpolygons, int mode);
 
/* devmouse.c*/
int GdOpenMouse(void);
void GdCloseMouse(void);
void GdGetButtonInfo(int *buttons);
void GdRestrictMouse(MWCOORD newminx,MWCOORD newminy,MWCOORD newmaxx,
MWCOORD newmaxy);
void GdSetAccelMouse(int newthresh, int newscale);
void GdMoveMouse(MWCOORD newx, MWCOORD newy);
int GdReadMouse(MWCOORD *px, MWCOORD *py, int *pb);
void GdMoveCursor(MWCOORD x, MWCOORD y);
MWBOOL GdGetCursorPos(MWCOORD *px, MWCOORD *py);
void GdSetCursor(PMWCURSOR pcursor);
int GdShowCursor(PSD psd);
int GdHideCursor(PSD psd);
void GdCheckCursor(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2);
void GdFixCursor(PSD psd);
extern MOUSEDEVICE mousedev;
 
/* devkbd.c*/
int GdOpenKeyboard(void);
void GdCloseKeyboard(void);
void GdGetModifierInfo(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers);
int GdReadKeyboard(MWKEY *buf, MWKEYMOD *modifiers, MWSCANCODE *scancode);
extern KBDDEVICE kbddev;
 
/* devimage.c */
 
int GdLoadImageFromBuffer(PSD psd, void *buffer, int size, int flags);
void GdDrawImageFromBuffer(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
MWCOORD height, void *buffer, int size, int flags);
void GdDrawImageFromFile(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
MWCOORD height, char *path, int flags);
int GdLoadImageFromFile(PSD psd, char *path, int flags);
void GdDrawImageToFit(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
MWCOORD height, int id);
void GdFreeImage(int id);
MWBOOL GdGetImageInfo(int id, PMWIMAGEINFO pii);
void GdStretchImage(PMWIMAGEHDR src, MWCLIPRECT *srcrect, PMWIMAGEHDR dst,
MWCLIPRECT *dstrect);
 
/* devlist.c*/
/* field offset*/
#define MWITEM_OFFSET(type, field) ((long)&(((type *)0)->field))
 
void * GdItemAlloc(unsigned int size);
void GdListAdd(PMWLISTHEAD pHead,PMWLIST pItem);
void GdListInsert(PMWLISTHEAD pHead,PMWLIST pItem);
void GdListRemove(PMWLISTHEAD pHead,PMWLIST pItem);
#define GdItemNew(type) ((type *)GdItemAlloc(sizeof(type)))
#define GdItemFree(ptr) free((void *)ptr)
 
/* return base item address from list ptr*/
#define GdItemAddr(p,type,list) ((type *)((long)p - MWITEM_OFFSET(type,list)))
 
#if UNIX || DOS_DJGPP
 
#include <sys/time.h>
 
typedef void (*MWTIMERCB)(void *);
 
#define MWTIMER_ONESHOT 0
#define MWTIMER_PERIODIC 1
 
typedef struct mw_timer MWTIMER;
struct mw_timer {
struct timeval timeout;
MWTIMERCB callback;
void *arg;
MWTIMER *next;
MWTIMER *prev;
int type; /* MWTIMER_ONESHOT or MWTIMER_PERIODIC */
MWTIMEOUT period;
};
 
MWTIMER *GdAddTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);
MWTIMER *GdAddPeriodicTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);
void GdDestroyTimer(MWTIMER *timer);
MWTIMER *GdFindTimer(void *arg);
MWBOOL GdGetNextTimeout(struct timeval *tv, MWTIMEOUT timeout);
MWBOOL GdTimeout(void);
 
#endif
 
/* error.c*/
int GdError(const char *format, ...);
int GdErrorNull(const char *format, ...); /* doesn't print msgs */
 
#ifdef USE_ALLOCA
/* alloca() is available, so use it for better performance */
#define ALLOCA(size) alloca(size)
#define FREEA(pmem)
#else
/* no alloca(), so use malloc()/free() instead */
#define ALLOCA(size) malloc(size)
#define FREEA(pmem) free(pmem)
#endif
 
/* no assert() in MSDOS or ELKS...*/
#if MSDOS | ELKS
#undef assert
#define assert(x)
#endif
 
/* RTEMS requires rtems_main()*/
#if __rtems__
#define main rtems_main
#endif
 
#if !_MINIX
#ifndef __rtems__
#define HAVESELECT 1 /* has select system call*/
#endif
#endif
 
#endif /*_DEVICE_H*/
/microwin/winctl.h
0,0 → 1,434
/* winctl.h*/
/*
* Header file for builtin controls
* This currently includes button, progressbar, listbox, edit
*/
 
/* entry points*/
int WINAPI MwRegisterButtonControl(HINSTANCE hInstance);
int WINAPI MwRegisterListboxControl(HINSTANCE hInstance);
int WINAPI MwRegisterEditControl(HINSTANCE hInstance);
int WINAPI MwRegisterStaticControl(HINSTANCE hInstance);
int WINAPI MwRegisterProgressBarControl(HINSTANCE hInstance);
int WINAPI MwRegisterComboboxControl(HINSTANCE hInstance);
int WINAPI MwRegisterScrollbarControl(HINSTANCE hInstance);
int WINAPI MwRegisterMEditControl(HINSTANCE hInstance);
 
/* temporarily in button.c*/
void WINAPI CheckRadioButton(HWND hDlg, int nIDFirst,int nIDLast,
int nIDCheckButton);
 
/* Dialog Codes*/
#define DLGC_WANTARROWS 0x0001 /* Control wants arrow keys */
#define DLGC_WANTTAB 0x0002 /* Control wants tab keys */
#define DLGC_WANTALLKEYS 0x0004 /* Control wants all keys */
#define DLGC_WANTMESSAGE 0x0004 /* Pass message to control */
#define DLGC_HASSETSEL 0x0008 /* Understands EM_SETSEL message */
#define DLGC_DEFPUSHBUTTON 0x0010 /* Default pushbutton */
#define DLGC_UNDEFPUSHBUTTON 0x0020 /* Non-default pushbutton */
#define DLGC_RADIOBUTTON 0x0040 /* Radio button */
#define DLGC_WANTCHARS 0x0080 /* Want WM_CHAR messages */
#define DLGC_STATIC 0x0100 /* Static item: don't include */
#define DLGC_BUTTON 0x2000 /* Button item: can be checked */
 
/* Button Control Styles*/
#define BS_PUSHBUTTON 0x00000000L
#define BS_DEFPUSHBUTTON 0x00000001L
#define BS_CHECKBOX 0x00000002L
#define BS_AUTOCHECKBOX 0x00000003L
#define BS_RADIOBUTTON 0x00000004L
#define BS_3STATE 0x00000005L
#define BS_AUTO3STATE 0x00000006L
#define BS_GROUPBOX 0x00000007L
#define BS_USERBUTTON 0x00000008L
#define BS_AUTORADIOBUTTON 0x00000009L
#define BS_OWNERDRAW 0x0000000BL
#define BS_LEFTTEXT 0x00000020L
#define BS_TEXT 0x00000000L
#define BS_ICON 0x00000040L
#define BS_BITMAP 0x00000080L
#define BS_LEFT 0x00000100L
#define BS_RIGHT 0x00000200L
#define BS_CENTER 0x00000300L
#define BS_TOP 0x00000400L
#define BS_BOTTOM 0x00000800L
#define BS_VCENTER 0x00000C00L
#define BS_PUSHLIKE 0x00001000L
#define BS_MULTILINE 0x00002000L
#define BS_NOTIFY 0x00004000L
#define BS_FLAT 0x00008000L
#define BS_RIGHTBUTTON BS_LEFTTEXT
 
/* User Button Notification Codes*/
#define BN_CLICKED 0
#define BN_PAINT 1
#define BN_HILITE 2
#define BN_UNHILITE 3
#define BN_DISABLE 4
#define BN_DOUBLECLICKED 5
#define BN_PUSHED BN_HILITE
#define BN_UNPUSHED BN_UNHILITE
#define BN_DBLCLK BN_DOUBLECLICKED
#define BN_SETFOCUS 6
#define BN_KILLFOCUS 7
 
/* Button Control Messages*/
#define BM_GETCHECK 0x00F0
#define BM_SETCHECK 0x00F1
#define BM_GETSTATE 0x00F2
#define BM_SETSTATE 0x00F3
#define BM_SETSTYLE 0x00F4
#define BM_CLICK 0x00F5
#define BM_GETIMAGE 0x00F6
#define BM_SETIMAGE 0x00F7
 
#define BST_UNCHECKED 0x0000
#define BST_CHECKED 0x0001
#define BST_INDETERMINATE 0x0002
#define BST_PUSHED 0x0004
#define BST_FOCUS 0x0008
 
/* Progress Bar messages*/
#define PBM_SETRANGE 0xF0A0
#define PBM_SETSTEP 0xF0A1
#define PBM_SETPOS 0xF0A2
#define PBM_DELTAPOS 0xF0A3
#define PBM_STEPIT 0xF0A4
 
/* Progress Bar styles */
#define PBS_NOTIFY 0x0001L
#define PBS_VERTICAL 0x0002L
 
/* Progress Bar notification code */
#define PBN_REACHMAX 1
#define PBN_REACHMIN 2
 
/* Listbox messages*/
#define LB_ADDSTRING 0xF180
#define LB_INSERTSTRING 0xF181
#define LB_DELETESTRING 0xF182
#define LB_SELITEMRANGEEX 0xF183
#define LB_RESETCONTENT 0xF184
#define LB_SETSEL 0xF185
#define LB_SETCURSEL 0xF186
#define LB_GETSEL 0xF187
#define LB_GETCURSEL 0xF188
#define LB_GETTEXT 0xF189
#define LB_GETTEXTLEN 0xF18A
#define LB_GETCOUNT 0xF18B
#define LB_SELECTSTRING 0xF18C
#define LB_DIR 0xF18D
#define LB_GETTOPINDEX 0xF18E
#define LB_FINDSTRING 0xF18F
#define LB_GETSELCOUNT 0xF190
#define LB_GETSELITEMS 0xF191
#define LB_SETTABSTOPS 0xF192
#define LB_GETHORIZONTALEXTENT 0xF193
#define LB_SETHORIZONTALEXTENT 0xF194
#define LB_SETCOLUMNWIDTH 0xF195
#define LB_ADDFILE 0xF196
#define LB_SETTOPINDEX 0xF197
#define LB_GETITEMRECT 0xF198
#define LB_GETITEMDATA 0xF199
#define LB_SETITEMDATA 0xF19A
#define LB_SELITEMRANGE 0xF19B
#define LB_SETANCHORINDEX 0xF19C
#define LB_GETANCHORINDEX 0xF19D
#define LB_SETCARETINDEX 0xF19E
#define LB_GETCARETINDEX 0xF19F
#define LB_SETITEMHEIGHT 0xF1A0
#define LB_GETITEMHEIGHT 0xF1A1
#define LB_FINDSTRINGEXACT 0xF1A2
#define LB_SETLOCALE 0xF1A5
#define LB_GETLOCALE 0xF1A6
#define LB_SETCOUNT 0xF1A7
#define LB_INITSTORAGE 0xF1A8
#define LB_ITEMFROMPOINT 0xF1A9
#define LB_SETTEXT 0xF1AA
#define LB_GETCHECKMARK 0xF1AB
#define LB_SETCHECKMARK 0xF1AC
#define LB_GETITEMADDDATA 0xF1AD
#define LB_SETITEMADDDATA 0xF1AE
#define LB_MSGMAX 0xF1B0
 
/* Listbox styles */
#define LBS_NOTIFY 0x0001L
#define LBS_SORT 0x0002L
#define LBS_NOREDRAW 0x0004L /* not supported*/
#define LBS_MULTIPLESEL 0x0008L
#define LBS_OWNERDRAWFIXED 0x0010L /* nyi*/
#define LBS_OWNERDRAWVARIABLE 0x0020L /* nyi*/
#define LBS_HASSTRINGS 0x0040L /* not supported*/
#define LBS_USETABSTOPS 0x0080L /* nyi*/
#define LBS_NOINTEGRALHEIGHT 0x0100L /* not supported*/
#define LBS_MULTICOLUMN 0x0200L /* nyi*/
#define LBS_WANTKEYBOARDINPUT 0x0400L /* not supported*/
#define LBS_EXTENDEDSEL 0x0800L /* not supported*/
#define LBS_STANDARD (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)
#define LBS_CHECKBOX 0x1000L /* non std*/
#define LBS_USEICON 0x2000L /* non std*/
#define LBS_AUTOCHECK 0x4000L /* non std*/
#define LBS_AUTOCHECKBOX 0x5000L /* non std*/
/* private Microwindows styles for combobox*/
#define LBS_PRELOADED 0x4000L /* Microwindows private*/
#define LBS_COMBOLBOX 0x8000L /* Microwindows private*/
 
#if 0
#define LBS_DISABLENOSCROLL 0x1000L
#define LBS_NODATA 0x2000L
#define LBS_NOSEL 0x4000L
#endif
 
/* Listbox Notification Codes */
#define LBN_ERRSPACE (-2)
#define LBN_SELCHANGE 1
#define LBN_DBLCLK 2
#define LBN_SELCANCEL 3
#define LBN_SETFOCUS 4
#define LBN_KILLFOCUS 5
#define LBN_CLICKCHECKMARK 6 /* non std*/
 
/* Listbox return value */
#define LB_OKAY 0
#define LB_ERR (-1)
#define LB_ERRSPACE (-2)
 
/* Edit Control Notification Codes*/
#define EN_SETFOCUS 0x0100
#define EN_KILLFOCUS 0x0200
#define EN_CHANGE 0x0300
#define EN_UPDATE 0x0400
#define EN_ERRSPACE 0x0500
#define EN_MAXTEXT 0x0501
#define EN_HSCROLL 0x0601
#define EN_VSCROLL 0x0602
 
/* Edit Control Styles*/
#define ES_LEFT 0x0000L
#define ES_CENTER 0x0001L
#define ES_RIGHT 0x0002L
#define ES_MULTILINE 0x0004L
#define ES_UPPERCASE 0x0008L
#define ES_LOWERCASE 0x0010L
#define ES_PASSWORD 0x0020L
#define ES_AUTOVSCROLL 0x0040L
#define ES_AUTOHSCROLL 0x0080L
#define ES_NOHIDESEL 0x0100L
#define ES_OEMCONVERT 0x0400L
#define ES_READONLY 0x0800L
#define ES_WANTRETURN 0x1000L
#define ES_NUMBER 0x2000L
 
/* Edit Control Messages*/
#define EM_GETSEL 0xF0B0
#define EM_SETSEL 0xF0B1
#define EM_GETRECT 0xF0B2
#define EM_SETRECT 0xF0B3
#define EM_SETRECTNP 0xF0B4
#define EM_SCROLL 0xF0B5
#define EM_LINESCROLL 0xF0B6
#define EM_SCROLLCARET 0xF0B7
#define EM_GETMODIFY 0xF0B8
#define EM_SETMODIFY 0xF0B9
#define EM_GETLINECOUNT 0xF0BA
#define EM_LINEINDEX 0xF0BB
#define EM_SETHANDLE 0xF0BC
#define EM_GETHANDLE 0xF0BD
#define EM_GETTHUMB 0xF0BE
#define EM_LINELENGTH 0xF0C1
#define EM_REPLACESEL 0xF0C2
#define EM_GETLINE 0xF0C4
#define EM_LIMITTEXT 0xF0C5
#define EM_CANUNDO 0xF0C6
#define EM_UNDO 0xF0C7
#define EM_FMTLINES 0xF0C8
#define EM_LINEFROMCHAR 0xF0C9
#define EM_SETTABSTOPS 0xF0CB
#define EM_SETPASSWORDCHAR 0xF0CC
#define EM_EMPTYUNDOBUFFER 0xF0CD
#define EM_GETFIRSTVISIBLELINE 0xF0CE
#define EM_SETREADONLY 0xF0CF
#define EM_SETWORDBREAKPROC 0xF0D0
#define EM_GETWORDBREAKPROC 0xF0D1
#define EM_GETPASSWORDCHAR 0xF0D2
#define EM_SETMARGINS 0xF0D3
#define EM_GETMARGINS 0xF0D4
#define EM_SETLIMITTEXT EM_LIMITTEXT
#define EM_GETLIMITTEXT 0xF0D5
#define EM_POSFROMCHAR 0xF0D6
#define EM_CHARFROMPOS 0xF0D7
#define EM_SETIMESTATUS 0xF0D8
#define EM_GETIMESTATUS 0xF0D9
 
/* Static Control messages*/
#define STM_SETICON 0xF170
#define STM_GETICON 0xF171
#define STM_SETIMAGE 0xF172
#define STM_GETIMAGE 0xF173
#define STM_MSGMAX 0xF174
 
/* Static Control notification code*/
#define STN_CLICKED 0
#define STN_DBLCLK 1
#define STN_ENABLE 2
#define STN_DISABLE 3
 
/* Static Control Styles */
#define SS_LEFT 0x00000000L
#define SS_CENTER 0x00000001L
#define SS_RIGHT 0x00000002L
#define SS_ICON 0x00000003L
#define SS_BLACKRECT 0x00000004L
#define SS_GRAYRECT 0x00000005L
#define SS_WHITERECT 0x00000006L
#define SS_BLACKFRAME 0x00000007L
#define SS_GRAYFRAME 0x00000008L
#define SS_WHITEFRAME 0x00000009L
#define SS_GROUPBOX 0x0000000AL
#define SS_SIMPLE 0x0000000BL
#define SS_LEFTNOWORDWRAP 0x0000000CL
#define SS_OWNERDRAW 0x0000000DL
#define SS_BITMAP 0x0000000EL
#define SS_ENHMETAFILE 0x0000000FL
#define SS_TYPEMASK 0x0000000FL
#define SS_NOPREFIX 0x00000080L
#define SS_ETCHEDHORZ 0x00000010L
#define SS_ETCHEDVERT 0x00000011L
#define SS_ETCHEDFRAME 0x00000012L
#define SS_ETCTYPEMAKS 0x0000001FL
#define SS_NOTIFY 0x00000100L
#define SS_CENTERIMAGE 0x00000200L
#define SS_RIGHTJUST 0x00000400L
#define SS_REALSIZEIMAGE 0x00000800L
#define SS_SUNKEN 0x00001000L /* notimp*/
#define SS_ENDELLIPSIS 0x00004000L /* notimp*/
#define SS_PATHELLIPSIS 0x00008000L /* notimp*/
#define SS_WORDELLIPSIS 0x0000C000L /* notimp*/
#define SS_ELLIPSISMASK 0x0000C000L /* notimp*/
 
/* Combo Box styles*/
#define CBS_SIMPLE 0x0001L
#define CBS_DROPDOWN 0x0002L
#define CBS_DROPDOWNLIST 0x0003L
#define CBS_OWNERDRAWFIXED 0x0010L
#define CBS_OWNERDRAWVARIABLE 0x0020L
#define CBS_AUTOHSCROLL 0x0040L
#define CBS_OEMCONVERT 0x0080L
#define CBS_SORT 0x0100L
#define CBS_HASSTRINGS 0x0200L
#define CBS_NOINTEGRALHEIGHT 0x0400L
#define CBS_DISABLENOSCROLL 0x0800L
#define CBS_UPPERCASE 0x2000L
#define CBS_LOWERCASE 0x4000L
 
/* Combo box messages */
#define CB_GETEDITSEL 0xF140
#define CB_LIMITTEXT 0xF141
#define CB_SETEDITSEL 0xF142
#define CB_ADDSTRING 0xF143
#define CB_DELETESTRING 0xF144
#define CB_DIR 0xF145
#define CB_GETCOUNT 0xF146
#define CB_GETCURSEL 0xF147
#define CB_GETLBTEXT 0xF148
#define CB_GETLBTEXTLEN 0xF149
#define CB_INSERTSTRING 0xF14A
#define CB_RESETCONTENT 0xF14B
#define CB_FINDSTRING 0xF14C
#define CB_SELECTSTRING 0xF14D
#define CB_SETCURSEL 0xF14E
#define CB_SHOWDROPDOWN 0xF14F
#define CB_GETITEMDATA 0xF150
#define CB_SETITEMDATA 0xF151
#define CB_GETDROPPEDCONTROLRECT 0xF152
#define CB_SETITEMHEIGHT 0xF153
#define CB_GETITEMHEIGHT 0xF154
#define CB_SETEXTENDEDUI 0xF155
#define CB_GETEXTENDEDUI 0xF156
#define CB_GETDROPPEDSTATE 0xF157
#define CB_FINDSTRINGEXACT 0xF158
#define CB_SETLOCALE 0xF159 /* notimp*/
#define CB_GETLOCALE 0xF15A /* notimp*/
#define CB_GETTOPINDEX 0xF15b /* notimp*/
#define CB_SETTOPINDEX 0xF15c /* notimp*/
#define CB_GETHORIZONTALEXTENT 0xF15d /* notimp*/
#define CB_SETHORIZONTALEXTENT 0xF15e /* notimp*/
#define CB_GETDROPPEDWIDTH 0xF15f /* notimp*/
#define CB_SETDROPPEDWIDTH 0xF160 /* notimp*/
#define CB_INITSTORAGE 0xF161 /* notimp*/
#define CB_MSGMAX 0xF162
 
/* Combo box notification codes */
#define CBN_ERRSPACE (-1)
#define CBN_SELCHANGE 1
#define CBN_DBLCLK 2
#define CBN_SETFOCUS 3
#define CBN_KILLFOCUS 4
#define CBN_EDITCHANGE 5
#define CBN_EDITUPDATE 6
#define CBN_DROPDOWN 7
#define CBN_CLOSEUP 8
#define CBN_SELENDOK 9
#define CBN_SELENDCANCEL 10
 
/* Combo box message return values */
#define CB_OKAY 0
#define CB_ERR (-1)
#define CB_ERRSPACE (-2)
 
/* scroll bar control styles*/
#define SBS_HORZ 0x0000L
#define SBS_VERT 0x0001L
#define SBS_TYPEMASK 0x0001L
#define SBS_TOPALIGN 0x0002L
#define SBS_LEFTALIGN 0x0002L
#define SBS_BOTTOMALIGN 0x0004L
#define SBS_RIGHTALIGN 0x0004L
#define SBS_SIZEBOXTOPLEFTALIGN 0x0002L
#define SBS_SIZEBOXBOTTOMRIGHTALIGN 0x0004L
#define SBS_SIZEBOX 0x0008L
#define SBS_SIZEGRIP 0x0010L
 
/* scroll bar constants*/
#define SB_HORZ 0
#define SB_VERT 1
#define SB_CTL 2
#define SB_BOTH 3
 
/* scroll bar notify codes*/
#define SB_LINEUP 0
#define SB_LINELEFT 0
#define SB_LINEDOWN 1
#define SB_LINERIGHT 1
#define SB_PAGEUP 2
#define SB_PAGELEFT 2
#define SB_PAGEDOWN 3
#define SB_PAGERIGHT 3
#define SB_THUMBPOSITION 4
#define SB_THUMBTRACK 5
#define SB_TOP 6
#define SB_LEFT 6
#define SB_BOTTOM 7
#define SB_RIGHT 7
#define SB_ENDSCROLL 8
 
#define SIF_RANGE 0x0001
#define SIF_PAGE 0x0002
#define SIF_POS 0x0004
#define SIF_DISABLENOSCROLL 0x0008
#define SIF_TRACKPOS 0x0010
#define SIF_ALL (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS)
 
typedef struct tagSCROLLINFO {
UINT cbSize;
UINT fMask;
int nMin;
int nMax;
UINT nPage;
int nPos;
int nTrackPos;
} SCROLLINFO, *LPSCROLLINFO;
typedef SCROLLINFO CONST *LPCSCROLLINFO;
 
int WINAPI SetScrollInfo(HWND, int, LPCSCROLLINFO, BOOL);
BOOL WINAPI GetScrollInfo(HWND, int, LPSCROLLINFO);
/microwin/nano-X.h
0,0 → 1,858
#ifndef _NANO_X_H
#define _NANO_X_H
/* Copyright (c) 1999, 2000 Greg Haerr <greg@censoft.com>
* Copyright (c) 2000 Alex Holden <alex@linuxhacker.org>
* Copyright (c) 1991 David I. Bell
* Permission is granted to use, distribute, or modify this source,
* provided that this copyright notice remains intact.
*
* Nano-X public definition header file: user applications should
* include only this header file.
*/
#ifdef __cplusplus
extern "C" {
#endif
 
#ifdef __ECOS
#include <cyg/kernel/kapi.h>
#endif
 
#include "mwtypes.h" /* exported engine MW* types*/
 
/*
* The following typedefs are inherited from the Microwindows
* engine layer.
*/
typedef MWCOORD GR_COORD; /* coordinate value */
typedef MWCOORD GR_SIZE; /* size value */
typedef MWCOLORVAL GR_COLOR; /* full color value */
typedef MWPIXELVAL GR_PIXELVAL; /* hw pixel value*/
typedef MWIMAGEBITS GR_BITMAP; /* bitmap unit */
typedef MWUCHAR GR_CHAR; /* filename, window title */
typedef MWKEY GR_KEY; /* keystroke value*/
typedef MWSCANCODE GR_SCANCODE; /* oem keystroke scancode value*/
typedef MWKEYMOD GR_KEYMOD; /* keystroke modifiers*/
typedef MWSCREENINFO GR_SCREEN_INFO; /* screen information*/
typedef MWWINDOWFBINFO GR_WINDOW_FB_INFO; /* direct client-mapped window info*/
typedef MWFONTINFO GR_FONT_INFO; /* font information*/
typedef MWIMAGEINFO GR_IMAGE_INFO; /* image information*/
typedef MWIMAGEHDR GR_IMAGE_HDR; /* multicolor image representation*/
typedef MWLOGFONT GR_LOGFONT; /* logical font descriptor*/
typedef MWPALENTRY GR_PALENTRY; /* palette entry*/
typedef MWPOINT GR_POINT; /* definition of a point*/
typedef MWTIMEOUT GR_TIMEOUT; /* timeout value */
typedef MWFONTLIST GR_FONTLIST; /* list of fonts */
typedef MWKBINFO GR_KBINFO; /* keyboard information */
 
/* Basic typedefs. */
typedef int GR_COUNT; /* number of items */
typedef unsigned char GR_CHAR_WIDTH; /* width of character */
typedef unsigned int GR_ID; /* resource ids */
typedef GR_ID GR_DRAW_ID; /* drawable id */
typedef GR_DRAW_ID GR_WINDOW_ID; /* window or pixmap id */
typedef GR_ID GR_GC_ID; /* graphics context id */
typedef GR_ID GR_REGION_ID; /* region id */
typedef GR_ID GR_FONT_ID; /* font id */
typedef GR_ID GR_IMAGE_ID; /* image id */
typedef GR_ID GR_TIMER_ID; /* timer id */
typedef GR_ID GR_CURSOR_ID; /* cursor id */
typedef unsigned short GR_BOOL; /* boolean value */
typedef int GR_ERROR; /* error types*/
typedef int GR_EVENT_TYPE; /* event types */
typedef int GR_UPDATE_TYPE; /* window update types */
typedef unsigned long GR_EVENT_MASK; /* event masks */
typedef char GR_FUNC_NAME[25];/* function name */
typedef unsigned long GR_WM_PROPS; /* window property flags */
typedef unsigned long GR_SERIALNO; /* Selection request ID number */
typedef unsigned short GR_MIMETYPE; /* Index into mime type list */
typedef unsigned long GR_LENGTH; /* Length of a block of data */
typedef unsigned int GR_BUTTON; /* mouse button value*/
 
/* Nano-X rectangle, different from MWRECT*/
typedef struct {
GR_COORD x;
GR_COORD y;
GR_SIZE width;
GR_SIZE height;
} GR_RECT;
 
/* The root window id. */
#define GR_ROOT_WINDOW_ID ((GR_WINDOW_ID) 1)
 
/* GR_COLOR color constructor*/
#define GR_RGB(r,g,b) MWRGB(r,g,b)
 
/* Drawing modes for GrSetGCMode*/
#define GR_MODE_COPY MWMODE_COPY /* src*/
#define GR_MODE_SET MWMODE_COPY /* obsolete, use GR_MODE_COPY*/
#define GR_MODE_XOR MWMODE_XOR /* src ^ dst*/
#define GR_MODE_OR MWMODE_OR /* src | dst*/
#define GR_MODE_AND MWMODE_AND /* src & dst*/
#define GR_MODE_CLEAR MWMODE_CLEAR /* 0*/
#define GR_MODE_SETTO1 MWMODE_SETTO1 /* 11111111*/ /* will be GR_MODE_SET*/
#define GR_MODE_EQUIV MWMODE_EQUIV /* ~(src ^ dst)*/
#define GR_MODE_NOR MWMODE_NOR /* ~(src | dst)*/
#define GR_MODE_NAND MWMODE_NAND /* ~(src & dst)*/
#define GR_MODE_INVERT MWMODE_INVERT /* ~dst*/
#define GR_MODE_COPYINVERTED MWMODE_COPYINVERTED /* ~src*/
#define GR_MODE_ORINVERTED MWMODE_ORINVERTED /* ~src | dst*/
#define GR_MODE_ANDINVERTED MWMODE_ANDINVERTED /* ~src & dst*/
#define GR_MODE_ORREVERSE MWMODE_ORREVERSE /* src | ~dst*/
#define GR_MODE_ANDREVERSE MWMODE_ANDREVERSE /* src & ~dst*/
#define GR_MODE_NOOP MWMODE_NOOP /* dst*/
 
#define GR_MODE_DRAWMASK 0x00FF
#define GR_MODE_EXCLUDECHILDREN 0x0100 /* exclude children on clip*/
 
/* builtin font std names*/
#define GR_FONT_SYSTEM_VAR MWFONT_SYSTEM_VAR
#define GR_FONT_GUI_VAR MWFONT_GUI_VAR
#define GR_FONT_OEM_FIXED MWFONT_OEM_FIXED
#define GR_FONT_SYSTEM_FIXED MWFONT_SYSTEM_FIXED
 
/* GrText/GrGetTextSize encoding flags*/
#define GR_TFASCII MWTF_ASCII
#define GR_TFUTF8 MWTF_UTF8
#define GR_TFUC16 MWTF_UC16
#define GR_TFUC32 MWTF_UC32
#define GR_TFPACKMASK MWTF_PACKMASK
 
/* GrText alignment flags*/
#define GR_TFTOP MWTF_TOP
#define GR_TFBASELINE MWTF_BASELINE
#define GR_TFBOTTOM MWTF_BOTTOM
 
/* GrSetFontAttr flags*/
#define GR_TFKERNING MWTF_KERNING
#define GR_TFANTIALIAS MWTF_ANTIALIAS
#define GR_TFUNDERLINE MWTF_UNDERLINE
 
/* GrArc, GrArcAngle types*/
#define GR_ARC MWARC /* arc only*/
#define GR_ARCOUTLINE MWARCOUTLINE /* arc + outline*/
#define GR_PIE MWPIE /* pie (filled)*/
 
/* Booleans */
#define GR_FALSE 0
#define GR_TRUE 1
 
/* Loadable Image support definition */
#define GR_IMAGE_MAX_SIZE (-1)
 
/* Button flags */
#define GR_BUTTON_R MWBUTTON_R /* right button*/
#define GR_BUTTON_M MWBUTTON_M /* middle button*/
#define GR_BUTTON_L MWBUTTON_L /* left button */
#define GR_BUTTON_ANY (MWBUTTON_R|MWBUTTON_M|MWBUTTON_L) /* any*/
 
/* GrSetBackgroundPixmap flags */
#define GR_BACKGROUND_TILE 0 /* Tile across the window */
#define GR_BACKGROUND_CENTER 1 /* Draw in center of window */
#define GR_BACKGROUND_TOPLEFT 2 /* Draw at top left of window */
#define GR_BACKGROUND_STRETCH 4 /* Stretch image to fit window*/
#define GR_BACKGROUND_TRANS 8 /* Don't fill in gaps */
 
/* GrNewPixmapFromData flags*/
#define GR_BMDATA_BYTEREVERSE 01 /* byte-reverse bitmap data*/
#define GR_BMDATA_BYTESWAP 02 /* byte-swap bitmap data*/
 
#if 0 /* don't define unimp'd flags*/
/* Window property flags */
#define GR_WM_PROP_NORESIZE 0x04 /* don't let user resize window */
#define GR_WM_PROP_NOICONISE 0x08 /* don't let user iconise window */
#define GR_WM_PROP_NOWINMENU 0x10 /* don't display a window menu button */
#define GR_WM_PROP_NOROLLUP 0x20 /* don't let user roll window up */
#define GR_WM_PROP_ONTOP 0x200 /* try to keep window always on top */
#define GR_WM_PROP_STICKY 0x400 /* keep window after desktop change */
#define GR_WM_PROP_DND 0x2000 /* accept drag and drop icons */
#endif
 
/* Window properties*/
#define GR_WM_PROPS_NOBACKGROUND 0x00000001L/* Don't draw window background*/
#define GR_WM_PROPS_NOFOCUS 0x00000002L /* Don't set focus to this window*/
#define GR_WM_PROPS_NOMOVE 0x00000004L /* Don't let user move window*/
#define GR_WM_PROPS_NORAISE 0x00000008L /* Don't let user raise window*/
#define GR_WM_PROPS_NODECORATE 0x00000010L /* Don't redecorate window*/
#define GR_WM_PROPS_NOAUTOMOVE 0x00000020L /* Don't move window on 1st map*/
#define GR_WM_PROPS_NOAUTORESIZE 0x00000040L /* Don't resize window on 1st map*/
 
/* default decoration style*/
#define GR_WM_PROPS_APPWINDOW 0x00000000L /* Leave appearance to WM*/
#define GR_WM_PROPS_APPMASK 0xF0000000L /* Appearance mask*/
#define GR_WM_PROPS_BORDER 0x80000000L /* Single line border*/
#define GR_WM_PROPS_APPFRAME 0x40000000L /* 3D app frame (overrides border)*/
#define GR_WM_PROPS_CAPTION 0x20000000L /* Title bar*/
#define GR_WM_PROPS_CLOSEBOX 0x10000000L /* Close box*/
#define GR_WM_PROPS_MAXIMIZE 0x08000000L /* Application is maximized*/
 
/* Flags for indicating valid bits in GrSetWMProperties call*/
#define GR_WM_FLAGS_PROPS 0x0001 /* Properties*/
#define GR_WM_FLAGS_TITLE 0x0002 /* Title*/
#define GR_WM_FLAGS_BACKGROUND 0x0004 /* Background color*/
#define GR_WM_FLAGS_BORDERSIZE 0x0008 /* Border size*/
#define GR_WM_FLAGS_BORDERCOLOR 0x0010 /* Border color*/
 
/* Window manager properties used by the Gr[GS]etWMProperties calls. */
/* NOTE: this struct must be hand-packed to a DWORD boundary for nxproto.h*/
typedef struct {
GR_WM_PROPS flags; /* Which properties valid in struct for set*/
GR_WM_PROPS props; /* Window property bits*/
GR_CHAR *title; /* Window title*/
GR_COLOR background; /* Window background color*/
GR_SIZE bordersize; /* Window border size*/
GR_COLOR bordercolor; /* Window border color*/
} GR_WM_PROPERTIES;
 
/* Window properties returned by the GrGetWindowInfo call. */
typedef struct {
GR_WINDOW_ID wid; /* window id (or 0 if no such window) */
GR_WINDOW_ID parent; /* parent window id */
GR_WINDOW_ID child; /* first child window id (or 0) */
GR_WINDOW_ID sibling; /* next sibling window id (or 0) */
GR_BOOL inputonly; /* TRUE if window is input only */
GR_BOOL mapped; /* TRUE if window is mapped */
GR_COUNT unmapcount; /* reasons why window is unmapped */
GR_COORD x; /* absolute x position of window */
GR_COORD y; /* absolute y position of window */
GR_SIZE width; /* width of window */
GR_SIZE height; /* height of window */
GR_SIZE bordersize; /* size of border */
GR_COLOR bordercolor; /* color of border */
GR_COLOR background; /* background color */
GR_EVENT_MASK eventmask; /* current event mask for this client */
GR_WM_PROPS props; /* window properties */
GR_CURSOR_ID cursor; /* cursor id*/
unsigned long processid; /* process id of owner*/
} GR_WINDOW_INFO;
 
/* Graphics context properties returned by the GrGetGCInfo call. */
typedef struct {
GR_GC_ID gcid; /* GC id (or 0 if no such GC) */
int mode; /* drawing mode */
GR_REGION_ID region; /* user region */
int xoff; /* x offset of user region*/
int yoff; /* y offset of user region*/
GR_FONT_ID font; /* font number */
GR_COLOR foreground; /* foreground color */
GR_COLOR background; /* background color */
GR_BOOL usebackground; /* use background in bitmaps */
} GR_GC_INFO;
 
/* color palette*/
typedef struct {
GR_COUNT count; /* # valid entries*/
GR_PALENTRY palette[256]; /* palette*/
} GR_PALETTE;
 
/* Error codes */
#define GR_ERROR_BAD_WINDOW_ID 1
#define GR_ERROR_BAD_GC_ID 2
#define GR_ERROR_BAD_CURSOR_SIZE 3
#define GR_ERROR_MALLOC_FAILED 4
#define GR_ERROR_BAD_WINDOW_SIZE 5
#define GR_ERROR_KEYBOARD_ERROR 6
#define GR_ERROR_MOUSE_ERROR 7
#define GR_ERROR_INPUT_ONLY_WINDOW 8
#define GR_ERROR_ILLEGAL_ON_ROOT_WINDOW 9
#define GR_ERROR_TOO_MUCH_CLIPPING 10
#define GR_ERROR_SCREEN_ERROR 11
#define GR_ERROR_UNMAPPED_FOCUS_WINDOW 12
#define GR_ERROR_BAD_DRAWING_MODE 13
 
/* Event types.
* Mouse motion is generated for every motion of the mouse, and is used to
* track the entire history of the mouse (many events and lots of overhead).
* Mouse position ignores the history of the motion, and only reports the
* latest position of the mouse by only queuing the latest such event for
* any single client (good for rubber-banding).
*/
#define GR_EVENT_TYPE_ERROR (-1)
#define GR_EVENT_TYPE_NONE 0
#define GR_EVENT_TYPE_EXPOSURE 1
#define GR_EVENT_TYPE_BUTTON_DOWN 2
#define GR_EVENT_TYPE_BUTTON_UP 3
#define GR_EVENT_TYPE_MOUSE_ENTER 4
#define GR_EVENT_TYPE_MOUSE_EXIT 5
#define GR_EVENT_TYPE_MOUSE_MOTION 6
#define GR_EVENT_TYPE_MOUSE_POSITION 7
#define GR_EVENT_TYPE_KEY_DOWN 8
#define GR_EVENT_TYPE_KEY_UP 9
#define GR_EVENT_TYPE_FOCUS_IN 10
#define GR_EVENT_TYPE_FOCUS_OUT 11
#define GR_EVENT_TYPE_FDINPUT 12
#define GR_EVENT_TYPE_UPDATE 13
#define GR_EVENT_TYPE_CHLD_UPDATE 14
#define GR_EVENT_TYPE_CLOSE_REQ 15
#define GR_EVENT_TYPE_TIMEOUT 16
#define GR_EVENT_TYPE_SCREENSAVER 17
#define GR_EVENT_TYPE_CLIENT_DATA_REQ 18
#define GR_EVENT_TYPE_CLIENT_DATA 19
#define GR_EVENT_TYPE_SELECTION_CHANGED 20
#define GR_EVENT_TYPE_TIMER 21
#define GR_EVENT_TYPE_PORTRAIT_CHANGED 22
 
/* Event masks */
#define GR_EVENTMASK(n) (((GR_EVENT_MASK) 1) << (n))
 
#define GR_EVENT_MASK_NONE GR_EVENTMASK(GR_EVENT_TYPE_NONE)
#define GR_EVENT_MASK_ERROR 0x80000000L
#define GR_EVENT_MASK_EXPOSURE GR_EVENTMASK(GR_EVENT_TYPE_EXPOSURE)
#define GR_EVENT_MASK_BUTTON_DOWN GR_EVENTMASK(GR_EVENT_TYPE_BUTTON_DOWN)
#define GR_EVENT_MASK_BUTTON_UP GR_EVENTMASK(GR_EVENT_TYPE_BUTTON_UP)
#define GR_EVENT_MASK_MOUSE_ENTER GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_ENTER)
#define GR_EVENT_MASK_MOUSE_EXIT GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_EXIT)
#define GR_EVENT_MASK_MOUSE_MOTION GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_MOTION)
#define GR_EVENT_MASK_MOUSE_POSITION GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_POSITION)
#define GR_EVENT_MASK_KEY_DOWN GR_EVENTMASK(GR_EVENT_TYPE_KEY_DOWN)
#define GR_EVENT_MASK_KEY_UP GR_EVENTMASK(GR_EVENT_TYPE_KEY_UP)
#define GR_EVENT_MASK_FOCUS_IN GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_IN)
#define GR_EVENT_MASK_FOCUS_OUT GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_OUT)
#define GR_EVENT_MASK_FDINPUT GR_EVENTMASK(GR_EVENT_TYPE_FDINPUT)
#define GR_EVENT_MASK_UPDATE GR_EVENTMASK(GR_EVENT_TYPE_UPDATE)
#define GR_EVENT_MASK_CHLD_UPDATE GR_EVENTMASK(GR_EVENT_TYPE_CHLD_UPDATE)
#define GR_EVENT_MASK_CLOSE_REQ GR_EVENTMASK(GR_EVENT_TYPE_CLOSE_REQ)
#define GR_EVENT_MASK_TIMEOUT GR_EVENTMASK(GR_EVENT_TYPE_TIMEOUT)
#define GR_EVENT_MASK_SCREENSAVER GR_EVENTMASK(GR_EVENT_TYPE_SCREENSAVER)
#define GR_EVENT_MASK_CLIENT_DATA_REQ GR_EVENTMASK(GR_EVENT_TYPE_CLIENT_DATA_REQ)
#define GR_EVENT_MASK_CLIENT_DATA GR_EVENTMASK(GR_EVENT_TYPE_CLIENT_DATA)
#define GR_EVENT_MASK_SELECTION_CHANGED GR_EVENTMASK(GR_EVENT_TYPE_SELECTION_CHANGED)
#define GR_EVENT_MASK_TIMER GR_EVENTMASK(GR_EVENT_TYPE_TIMER)
#define GR_EVENT_MASK_PORTRAIT_CHANGED GR_EVENTMASK(GR_EVENT_TYPE_PORTRAIT_CHANGED)
#define GR_EVENT_MASK_ALL ((GR_EVENT_MASK) -1L)
 
/* update event types */
#define GR_UPDATE_MAP 1
#define GR_UPDATE_UNMAP 2
#define GR_UPDATE_MOVE 3
#define GR_UPDATE_SIZE 4
#define GR_UPDATE_UNMAPTEMP 5 /* unmap during window move/resize*/
#define GR_UPDATE_ACTIVATE 6 /* toplevel window [de]activate*/
#define GR_UPDATE_DESTROY 7
 
/* Event for errors detected by the server.
* These events are not delivered to GrGetNextEvent, but instead call
* the user supplied error handling function. Only the first one of
* these errors at a time is saved for delivery to the client since
* there is not much to be done about errors anyway except complain
* and exit.
*/
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_FUNC_NAME name; /* function name which failed */
GR_ERROR code; /* error code */
GR_ID id; /* resource id (maybe useless) */
} GR_EVENT_ERROR;
 
/* Event for a mouse button pressed down or released. */
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_WINDOW_ID wid; /* window id event delivered to */
GR_WINDOW_ID subwid; /* sub-window id (pointer was in) */
GR_COORD rootx; /* root window x coordinate */
GR_COORD rooty; /* root window y coordinate */
GR_COORD x; /* window x coordinate of mouse */
GR_COORD y; /* window y coordinate of mouse */
GR_BUTTON buttons; /* current state of all buttons */
GR_BUTTON changebuttons; /* buttons which went down or up */
GR_KEYMOD modifiers; /* modifiers (MWKMOD_SHIFT, etc)*/
GR_TIMEOUT time; /* tickcount time value*/
} GR_EVENT_BUTTON;
 
/* Event for a keystroke typed for the window with has focus. */
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_WINDOW_ID wid; /* window id event delived to */
GR_WINDOW_ID subwid; /* sub-window id (pointer was in) */
GR_COORD rootx; /* root window x coordinate */
GR_COORD rooty; /* root window y coordinate */
GR_COORD x; /* window x coordinate of mouse */
GR_COORD y; /* window y coordinate of mouse */
GR_BUTTON buttons; /* current state of buttons */
GR_KEYMOD modifiers; /* modifiers (MWKMOD_SHIFT, etc)*/
GR_KEY ch; /* 16-bit unicode key value, MWKEY_xxx */
GR_SCANCODE scancode; /* OEM scancode value if available*/
} GR_EVENT_KEYSTROKE;
 
/* Event for exposure for a region of a window. */
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_WINDOW_ID wid; /* window id */
GR_COORD x; /* window x coordinate of exposure */
GR_COORD y; /* window y coordinate of exposure */
GR_SIZE width; /* width of exposure */
GR_SIZE height; /* height of exposure */
} GR_EVENT_EXPOSURE;
 
/* General events for focus in or focus out for a window, or mouse enter
* or mouse exit from a window, or window unmapping or mapping, etc.
* Server portrait mode changes are also sent using this event to
* all windows that request it.
*/
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_WINDOW_ID wid; /* window id */
GR_WINDOW_ID otherid; /* new/old focus id for focus events*/
} GR_EVENT_GENERAL;
 
/* Events for mouse motion or mouse position. */
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_WINDOW_ID wid; /* window id event delivered to */
GR_WINDOW_ID subwid; /* sub-window id (pointer was in) */
GR_COORD rootx; /* root window x coordinate */
GR_COORD rooty; /* root window y coordinate */
GR_COORD x; /* window x coordinate of mouse */
GR_COORD y; /* window y coordinate of mouse */
GR_BUTTON buttons; /* current state of buttons */
GR_KEYMOD modifiers; /* modifiers (MWKMOD_SHIFT, etc)*/
} GR_EVENT_MOUSE;
 
/* GrRegisterInput event*/
typedef struct {
GR_EVENT_TYPE type; /* event type */
int fd; /* input fd*/
} GR_EVENT_FDINPUT;
 
/* GR_EVENT_TYPE_UPDATE */
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_WINDOW_ID wid; /* select window id*/
GR_WINDOW_ID subwid; /* update window id (=wid for UPDATE event)*/
GR_COORD x; /* new window x coordinate */
GR_COORD y; /* new window y coordinate */
GR_SIZE width; /* new width */
GR_SIZE height; /* new height */
GR_UPDATE_TYPE utype; /* update_type */
} GR_EVENT_UPDATE;
 
/* GR_EVENT_TYPE_SCREENSAVER */
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_BOOL activate; /* true = activate, false = deactivate */
} GR_EVENT_SCREENSAVER;
 
/* GR_EVENT_TYPE_CLIENT_DATA_REQ */
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_WINDOW_ID wid; /* ID of requested window */
GR_WINDOW_ID rid; /* ID of window to send data to */
GR_SERIALNO serial; /* Serial number of transaction */
GR_MIMETYPE mimetype; /* Type to supply data as */
} GR_EVENT_CLIENT_DATA_REQ;
 
/* GR_EVENT_TYPE_CLIENT_DATA */
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_WINDOW_ID wid; /* ID of window data is destined for */
GR_WINDOW_ID rid; /* ID of window data is from */
GR_SERIALNO serial; /* Serial number of transaction */
unsigned long len; /* Total length of data */
unsigned long datalen; /* Length of following data */
void *data; /* Pointer to data (filled in on client side) */
} GR_EVENT_CLIENT_DATA;
 
/* GR_EVENT_TYPE_SELECTION_CHANGED */
typedef struct {
GR_EVENT_TYPE type; /* event type */
GR_WINDOW_ID new_owner; /* ID of new selection owner */
} GR_EVENT_SELECTION_CHANGED;
 
/* GR_EVENT_TYPE_TIMER */
typedef struct {
GR_EVENT_TYPE type; /* event type, GR_EVENT_TYPE_TIMER */
GR_WINDOW_ID wid; /* ID of window timer is destined for */
GR_TIMER_ID tid; /* ID of expired timer */
} GR_EVENT_TIMER;
 
/*
* Union of all possible event structures.
* This is the structure returned by the GrGetNextEvent and similar routines.
*/
typedef union {
GR_EVENT_TYPE type; /* event type */
GR_EVENT_ERROR error; /* error event */
GR_EVENT_GENERAL general; /* general window events */
GR_EVENT_BUTTON button; /* button events */
GR_EVENT_KEYSTROKE keystroke; /* keystroke events */
GR_EVENT_EXPOSURE exposure; /* exposure events */
GR_EVENT_MOUSE mouse; /* mouse motion events */
GR_EVENT_FDINPUT fdinput; /* fd input events*/
GR_EVENT_UPDATE update; /* window update events */
GR_EVENT_SCREENSAVER screensaver; /* Screen saver events */
GR_EVENT_CLIENT_DATA_REQ clientdatareq; /* Request for client data events */
GR_EVENT_CLIENT_DATA clientdata; /* Client data events */
GR_EVENT_SELECTION_CHANGED selectionchanged; /* Selection owner changed */
GR_EVENT_TIMER timer;
} GR_EVENT;
 
typedef void (*GR_FNCALLBACKEVENT)(GR_EVENT *);
 
/* Pixel packings within words. */
#define GR_BITMAPBITS (sizeof(GR_BITMAP) * 8)
#define GR_ZEROBITS ((GR_BITMAP) 0x0000)
#define GR_ONEBITS ((GR_BITMAP) 0xffff)
#define GR_FIRSTBIT ((GR_BITMAP) 0x8000)
#define GR_LASTBIT ((GR_BITMAP) 0x0001)
#define GR_BITVALUE(n) ((GR_BITMAP) (((GR_BITMAP) 1) << (n)))
#define GR_SHIFTBIT(m) ((GR_BITMAP) ((m) << 1))
#define GR_NEXTBIT(m) ((GR_BITMAP) ((m) >> 1))
#define GR_TESTBIT(m) (((m) & GR_FIRSTBIT) != 0)
 
/* Size of bitmaps. */
#define GR_BITMAP_SIZE(width, height) ((height) * \
(((width) + sizeof(GR_BITMAP) * 8 - 1) / (sizeof(GR_BITMAP) * 8)))
 
#define GR_MAX_BITMAP_SIZE \
GR_BITMAP_SIZE(MWMAX_CURSOR_SIZE, MWMAX_CURSOR_SIZE)
 
/* GrGetSysColor colors*/
/* desktop background*/
#define GR_COLOR_DESKTOP 0
 
/* caption colors*/
#define GR_COLOR_ACTIVECAPTION 1
#define GR_COLOR_ACTIVECAPTIONTEXT 2
#define GR_COLOR_INACTIVECAPTION 3
#define GR_COLOR_INACTIVECAPTIONTEXT 4
 
/* 3d border shades*/
#define GR_COLOR_WINDOWFRAME 5
#define GR_COLOR_BTNSHADOW 6
#define GR_COLOR_3DLIGHT 7
#define GR_COLOR_BTNHIGHLIGHT 8
 
/* top level application window backgrounds/text*/
#define GR_COLOR_APPWINDOW 9
#define GR_COLOR_APPTEXT 10
 
/* button control backgrounds/text (usually same as app window colors)*/
#define GR_COLOR_BTNFACE 11
#define GR_COLOR_BTNTEXT 12
 
/* edit/listbox control backgrounds/text, selected highlights*/
#define GR_COLOR_WINDOW 13
#define GR_COLOR_WINDOWTEXT 14
#define GR_COLOR_HIGHLIGHT 15
#define GR_COLOR_HIGHLIGHTTEXT 16
#define GR_COLOR_GRAYTEXT 17
 
/* menu backgrounds/text*/
#define GR_COLOR_MENUTEXT 18
#define GR_COLOR_MENU 19
 
/* Error strings per error number*/
#define GR_ERROR_STRINGS \
"", \
"Bad window id: %d\n", \
"Bad graphics context: %d\n", \
"Bad cursor size\n", \
"Out of server memory\n", \
"Bad window size: %d\n", \
"Keyboard error\n", \
"Mouse error\n", \
"Input only window: %d\n", \
"Illegal on root window: %d\n", \
"Clipping overflow\n", \
"Screen error\n", \
"Unmapped focus window: %d\n", \
"Bad drawing mode gc: %d\n"
 
extern char *nxErrorStrings[];
 
/* Public graphics routines. */
void GrFlush(void);
int GrOpen(void);
void GrClose(void);
void GrDelay(GR_TIMEOUT msecs);
void GrGetScreenInfo(GR_SCREEN_INFO *sip);
GR_COLOR GrGetSysColor(int index);
GR_WINDOW_ID GrNewWindow(GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
GR_SIZE width, GR_SIZE height, GR_SIZE bordersize,
GR_COLOR background, GR_COLOR bordercolor);
GR_WINDOW_ID GrNewPixmap(GR_SIZE width, GR_SIZE height, void * addr);
GR_WINDOW_ID GrNewInputWindow(GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
GR_SIZE width, GR_SIZE height);
void GrDestroyWindow(GR_WINDOW_ID wid);
GR_GC_ID GrNewGC(void);
GR_GC_ID GrCopyGC(GR_GC_ID gc);
void GrGetGCInfo(GR_GC_ID gc, GR_GC_INFO *gcip);
void GrDestroyGC(GR_GC_ID gc);
GR_REGION_ID GrNewRegion(void);
GR_REGION_ID GrNewPolygonRegion(int mode, GR_COUNT count, GR_POINT *points);
void GrDestroyRegion(GR_REGION_ID region);
void GrUnionRectWithRegion(GR_REGION_ID region, GR_RECT *rect);
void GrUnionRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
GR_REGION_ID src_rgn2);
void GrIntersectRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
GR_REGION_ID src_rgn2);
void GrSubtractRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
GR_REGION_ID src_rgn2);
void GrXorRegion(GR_REGION_ID dst_rgn, GR_REGION_ID src_rgn1,
GR_REGION_ID src_rgn2);
void GrSetGCRegion(GR_GC_ID gc, GR_REGION_ID region);
void GrSetGCClipOrigin(GR_GC_ID gc, int x, int y);
GR_BOOL GrPointInRegion(GR_REGION_ID region, GR_COORD x, GR_COORD y);
int GrRectInRegion(GR_REGION_ID region, GR_COORD x, GR_COORD y,
GR_COORD w, GR_COORD h);
GR_BOOL GrEmptyRegion(GR_REGION_ID region);
GR_BOOL GrEqualRegion(GR_REGION_ID rgn1, GR_REGION_ID rgn2);
void GrOffsetRegion(GR_REGION_ID region, GR_SIZE dx, GR_SIZE dy);
int GrGetRegionBox(GR_REGION_ID region, GR_RECT *rect);
void GrMapWindow(GR_WINDOW_ID wid);
void GrUnmapWindow(GR_WINDOW_ID wid);
void GrRaiseWindow(GR_WINDOW_ID wid);
void GrLowerWindow(GR_WINDOW_ID wid);
void GrMoveWindow(GR_WINDOW_ID wid, GR_COORD x, GR_COORD y);
void GrResizeWindow(GR_WINDOW_ID wid, GR_SIZE width, GR_SIZE height);
void GrReparentWindow(GR_WINDOW_ID wid, GR_WINDOW_ID pwid,
GR_COORD x, GR_COORD y);
void GrGetWindowInfo(GR_WINDOW_ID wid, GR_WINDOW_INFO *infoptr);
void GrSetWMProperties(GR_WINDOW_ID wid, GR_WM_PROPERTIES *props);
void GrGetWMProperties(GR_WINDOW_ID wid, GR_WM_PROPERTIES *props);
GR_FONT_ID GrCreateFont(GR_CHAR *name, GR_COORD height,
GR_LOGFONT *plogfont);
void GrGetFontList(GR_FONTLIST ***fonts, int *numfonts);
void GrFreeFontList(GR_FONTLIST ***fonts, int num);
void GrSetFontSize(GR_FONT_ID fontid, GR_COORD size);
void GrSetFontRotation(GR_FONT_ID fontid, int tenthsdegrees);
void GrSetFontAttr(GR_FONT_ID fontid, int setflags, int clrflags);
void GrDestroyFont(GR_FONT_ID fontid);
void GrGetFontInfo(GR_FONT_ID font, GR_FONT_INFO *fip);
GR_WINDOW_ID GrGetFocus(void);
void GrSetFocus(GR_WINDOW_ID wid);
void GrClearArea(GR_WINDOW_ID wid, GR_COORD x, GR_COORD y, GR_SIZE width,
GR_SIZE height, GR_BOOL exposeflag);
void GrSelectEvents(GR_WINDOW_ID wid, GR_EVENT_MASK eventmask);
void GrGetNextEvent(GR_EVENT *ep);
void GrGetNextEventTimeout(GR_EVENT *ep, GR_TIMEOUT timeout);
void GrCheckNextEvent(GR_EVENT *ep);
int GrPeekEvent(GR_EVENT *ep);
void GrPeekWaitEvent(GR_EVENT *ep);
void GrLine(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x1, GR_COORD y1,
GR_COORD x2, GR_COORD y2);
void GrPoint(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y);
void GrPoints(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count,
GR_POINT *pointtable);
void GrRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE width, GR_SIZE height);
void GrFillRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE width, GR_SIZE height);
void GrPoly(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count,
GR_POINT *pointtable);
void GrFillPoly(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count,
GR_POINT *pointtable);
void GrEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE rx, GR_SIZE ry);
void GrFillEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
GR_COORD y, GR_SIZE rx, GR_SIZE ry);
void GrArc(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE rx, GR_SIZE ry, GR_COORD ax, GR_COORD ay,
GR_COORD bx, GR_COORD by, int type);
void GrArcAngle(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE rx, GR_SIZE ry, GR_COORD angle1,
GR_COORD angle2, int type); /* floating point required*/
void GrSetGCForeground(GR_GC_ID gc, GR_COLOR foreground);
void GrSetGCBackground(GR_GC_ID gc, GR_COLOR background);
void GrSetGCUseBackground(GR_GC_ID gc, GR_BOOL flag);
void GrSetGCMode(GR_GC_ID gc, int mode);
void GrSetGCFont(GR_GC_ID gc, GR_FONT_ID font);
void GrGetGCTextSize(GR_GC_ID gc, void *str, int count, int flags,
GR_SIZE *retwidth, GR_SIZE *retheight,GR_SIZE *retbase);
void GrReadArea(GR_DRAW_ID id, GR_COORD x, GR_COORD y, GR_SIZE width,
GR_SIZE height, GR_PIXELVAL *pixels);
void GrArea(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE width,GR_SIZE height,void *pixels,int pixtype);
void GrCopyArea(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE width, GR_SIZE height, GR_DRAW_ID srcid,
GR_COORD srcx, GR_COORD srcy, int op);
void GrBitmap(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
GR_SIZE width, GR_SIZE height, GR_BITMAP *imagebits);
void GrDrawImageBits(GR_DRAW_ID id,GR_GC_ID gc,GR_COORD x,GR_COORD y,
GR_IMAGE_HDR *pimage);
void GrDrawImageFromFile(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
GR_COORD y, GR_SIZE width, GR_SIZE height,
char *path, int flags);
GR_IMAGE_ID GrLoadImageFromFile(char *path, int flags);
void GrDrawImageFromBuffer(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
GR_COORD y, GR_SIZE width, GR_SIZE height,
void *buffer, int size, int flags);
GR_IMAGE_ID GrLoadImageFromBuffer(void *buffer, int size, int flags);
void GrDrawImageToFit(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x,
GR_COORD y, GR_SIZE width, GR_SIZE height,
GR_IMAGE_ID imageid);
void GrFreeImage(GR_IMAGE_ID id);
void GrGetImageInfo(GR_IMAGE_ID id, GR_IMAGE_INFO *iip);
void GrText(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,
void *str, GR_COUNT count, int flags);
GR_CURSOR_ID GrNewCursor(GR_SIZE width, GR_SIZE height, GR_COORD hotx,
GR_COORD hoty, GR_COLOR foreground, GR_COLOR background,
GR_BITMAP *fgbitmap, GR_BITMAP *bgbitmap);
void GrDestroyCursor(GR_CURSOR_ID cid);
void GrSetWindowCursor(GR_WINDOW_ID wid, GR_CURSOR_ID cid);
void GrMoveCursor(GR_COORD x, GR_COORD y);
void GrGetSystemPalette(GR_PALETTE *pal);
void GrSetSystemPalette(GR_COUNT first, GR_PALETTE *pal);
void GrFindColor(GR_COLOR c, GR_PIXELVAL *retpixel);
void GrReqShmCmds(long shmsize);
void GrInjectPointerEvent(MWCOORD x, MWCOORD y,
int button, int visible);
void GrInjectKeyboardEvent(GR_WINDOW_ID wid, GR_KEY keyvalue,
GR_KEYMOD modifiers, GR_SCANCODE scancode,
GR_BOOL pressed);
void GrCloseWindow(GR_WINDOW_ID wid);
void GrKillWindow(GR_WINDOW_ID wid);
void GrSetScreenSaverTimeout(GR_TIMEOUT timeout);
void GrSetSelectionOwner(GR_WINDOW_ID wid, GR_CHAR *typelist);
GR_WINDOW_ID GrGetSelectionOwner(GR_CHAR **typelist);
void GrRequestClientData(GR_WINDOW_ID wid, GR_WINDOW_ID rid,
GR_SERIALNO serial, GR_MIMETYPE mimetype);
void GrSendClientData(GR_WINDOW_ID wid, GR_WINDOW_ID did,
GR_SERIALNO serial, GR_LENGTH len, GR_LENGTH thislen,
void *data);
void GrBell(void);
void GrSetBackgroundPixmap(GR_WINDOW_ID wid, GR_WINDOW_ID pixmap,
int flags);
void GrQueryTree(GR_WINDOW_ID wid, GR_WINDOW_ID *parentid, GR_WINDOW_ID **children,
GR_COUNT *nchildren);
GR_TIMER_ID GrCreateTimer(GR_WINDOW_ID wid, GR_TIMEOUT period);
void GrDestroyTimer(GR_TIMER_ID tid);
void GrSetPortraitMode(int portraitmode);
 
void GrRegisterInput(int fd);
void GrUnregisterInput(int fd);
void GrMainLoop(GR_FNCALLBACKEVENT fncb);
GR_FNCALLBACKEVENT GrSetErrorHandler(GR_FNCALLBACKEVENT fncb);
void GrDefaultErrorHandler(GR_EVENT *ep);
 
/* passive library entry points - available with client/server only*/
void GrPrepareSelect(int *maxfd,void *rfdset);
void GrServiceSelect(void *rfdset, GR_FNCALLBACKEVENT fncb);
 
/* nxutil.c - utility routines*/
GR_WINDOW_ID GrNewWindowEx(GR_WM_PROPS props, GR_CHAR *title,
GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
GR_SIZE width, GR_SIZE height, GR_COLOR background);
void GrDrawLines(GR_DRAW_ID w, GR_GC_ID gc, GR_POINT *points,
GR_COUNT count);
GR_BITMAP * GrNewBitmapFromData(GR_SIZE width, GR_SIZE height, GR_SIZE bits_width,
GR_SIZE bits_height, void *bits, int flags);
GR_WINDOW_ID GrNewPixmapFromData(GR_SIZE width, GR_SIZE height,
GR_COLOR foreground, GR_COLOR background, void * bits,
int flags);
 
/* direct client-side framebuffer mapping routines*/
unsigned char * GrOpenClientFramebuffer(void);
void GrCloseClientFramebuffer(void);
void GrGetWindowFBInfo(GR_WINDOW_ID wid, GR_WINDOW_FB_INFO *fbinfo);
 
/* retrofit - no longer used*/
GR_CURSOR_ID GrSetCursor(GR_WINDOW_ID wid, GR_SIZE width, GR_SIZE height,
GR_COORD hotx, GR_COORD hoty, GR_COLOR foreground,
GR_COLOR background, GR_BITMAP *fbbitmap,
GR_BITMAP *bgbitmap);
#define GrSetBorderColor GrSetWindowBorderColor /* retrofit*/
#define GrClearWindow(wid,exposeflag) GrClearArea(wid,0,0,0,0,exposeflag) /* retrofit*/
 
/* useful function macros*/
#define GrSetWindowBackgroundColor(wid,color) \
{ GR_WM_PROPERTIES props; \
props.flags = GR_WM_FLAGS_BACKGROUND; \
props.background = color; \
GrSetWMProperties(wid, &props); \
}
#define GrSetWindowBorderSize(wid,width) \
{ GR_WM_PROPERTIES props; \
props.flags = GR_WM_FLAGS_BORDERSIZE; \
props.bordersize = width; \
GrSetWMProperties(wid, &props); \
}
#define GrSetWindowBorderColor(wid,color) \
{ GR_WM_PROPERTIES props; \
props.flags = GR_WM_FLAGS_BORDERCOLOR; \
props.bordercolor = color; \
GrSetWMProperties(wid, &props); \
}
#define GrSetWindowTitle(wid,name) \
{ GR_WM_PROPERTIES props; \
props.flags = GR_WM_FLAGS_TITLE; \
props.title = (GR_CHAR *)name; \
GrSetWMProperties(wid, &props); \
}
 
#ifdef __cplusplus
}
#endif
 
/* RTEMS requires rtems_main()*/
#if __rtems__
#define main rtems_main
#endif
 
/* client side event queue (client.c local)*/
typedef struct event_list EVENT_LIST;
struct event_list {
EVENT_LIST * next;
GR_EVENT event;
};
 
/* queued request buffer (nxproto.c local)*/
typedef struct {
unsigned char *bufptr; /* next unused buffer location*/
unsigned char *bufmax; /* max buffer location*/
unsigned char *buffer; /* request buffer*/
} REQBUF;
 
#ifdef __ECOS
#include <sys/select.h>
/*
* In a single process, multi-threaded environment, we need to keep
* all static data of shared code in a structure, with a pointer to
* the structure to be stored in thread-local storage
*/
typedef struct { // Init to:
int _nxSocket; // -1
int _storedevent; // 0
GR_EVENT _storedevent_data; // no init(0)
int _regfdmax; // -1
fd_set _regfdset; // FD_ZERO
GR_FNCALLBACKEVENT _GrErrorFunc; // GrDefaultErrorHandler
REQBUF _reqbuf;
EVENT_LIST *_evlist;
} ecos_nanox_client_data;
 
extern int ecos_nanox_client_data_index;
 
#define ACCESS_PER_THREAD_DATA() \
ecos_nanox_client_data *data = (ecos_nanox_client_data*) \
cyg_thread_get_data((cyg_ucount32)ecos_nanox_client_data_index);
 
#define INIT_PER_THREAD_DATA() \
{ \
ecos_nanox_client_data *dptr = malloc(sizeof(ecos_nanox_client_data)); \
ecos_nanox_client_data_index = data; \
dptr->_nxSocket = -1; \
dptr->_storedevent = 0; \
dptr->_regfdmax = -1; \
FD_ZERO(&dptr->_regfdset); \
dptr->_GrErrorFunc = GrDefaultErrorHandler; \
dptr->_reqbuf.bufptr = NULL; \
dptr->_reqbuf.bufmax = NULL; \
dptr->_reqbuf.buffer = NULL; \
dptr->_evlist = NULL; \
cyg_thread_set_data(ecos_nanox_client_data_index,(CYG_ADDRWORD)dptr); \
}
 
#define nxSocket (data->_nxSocket)
#define storedevent (data->_storedevent)
#define storedevent_data (data->_storedevent_data)
#define regfdmax (data->_regfdmax)
#define regfdset (data->_regfdset)
#define ErrorFunc (data->_GrErrorFunc)
#define reqbuf (data->_reqbuf)
#define evlist (data->_evlist)
 
#else
#define ACCESS_PER_THREAD_DATA()
#endif
 
#endif /* _NANO_X_H*/
/microwin/nxdraw.h
0,0 → 1,31
/*
* Copyright (c) 2000 Greg Haerr <greg@censoft.com>
*
* Nano-X Draw Library
* nxPaintNCArea - paint non-client area
* nxDraw3dShadow - draws a shadow with bottom-left and top-right missing
* nxDraw3dBox - draws a complete shadow
* nxDraw3dInset - draw a 2 line 3d inset
* nxDraw3dOutset - draw a 2 line 3d outset
*/
void nxPaintNCArea(GR_DRAW_ID id, int w, int h, GR_CHAR *title,
GR_BOOL active, GR_WM_PROPS props);
 
void nxInflateRect(GR_RECT *prc, GR_SIZE dx, GR_SIZE dy);
void nxDraw3dBox(GR_WINDOW_ID id,int x,int y,int w,int h,
GR_COLOR crTop,GR_COLOR crBottom);
void nxDraw3dInset(GR_DRAW_ID id,int x,int y,int w,int h);
void nxDraw3dOutset(GR_WINDOW_ID id,int x,int y,int w,int h);
void nxDraw3dPushDown(GR_DRAW_ID id, int x, int y, int w, int h);
void nxDraw3dUpDownState(GR_DRAW_ID id, int x, int y, int w, int h,
GR_BOOL fDown);
void nxDraw3dUpFrame(GR_DRAW_ID id, int l, int t, int r, int b);
 
/* nxPaintNCArea offsets*/
#define CXBORDER 3 /* 3d border width*/
#define CYBORDER 3 /* 3d border height*/
#define CYCAPTION 12 /* height of caption*/
#define CXCLOSEBOX 9 /* width of closebox*/
#define CYCLOSEBOX 9 /* height of closebox*/
#define CXFRAME (CXBORDER*2) /* width of frame*/
#define CYFRAME (CYBORDER*2) /* height of frame*/
/microwin/mwtypes.h
0,0 → 1,664
#ifndef _MWTYPES_H
#define _MWTYPES_H
/*
* Copyright (c) 1999, 2000, 2001 Greg Haerr <greg@censoft.com>
*
* Exported Microwindows engine typedefs and defines
*/
#define MWPACKED __attribute__ ((aligned(1), packed))
 
/* builtin font std names*/
#define MWFONT_SYSTEM_VAR "System" /* winSystem 14x16 (ansi)*/
#define MWFONT_GUI_VAR "Helvetica" /* winMSSansSerif 11x13 (ansi)*/
#define MWFONT_OEM_FIXED "Terminal" /* rom8x16 (oem)*/
#define MWFONT_SYSTEM_FIXED "SystemFixed" /* X6x13 (should be ansi)*/
 
/* Text/GetTextSize encoding flags*/
#define MWTF_ASCII 0x0000 /* 8 bit packing, ascii*/
#define MWTF_UTF8 0x0001 /* 8 bit packing, utf8*/
#define MWTF_UC16 0x0002 /* 16 bit packing, unicode 16*/
#define MWTF_UC32 0x0004 /* 32 bit packing, unicode 32*/
#define MWTF_PACKMASK 0x0007 /* packing mask*/
 
/* Text alignment flags*/
#define MWTF_TOP 0x0010 /* align on top*/
#define MWTF_BASELINE 0x0020 /* align on baseline*/
#define MWTF_BOTTOM 0x0040 /* align on bottom*/
 
/* SetFontAttr flags*/
#define MWTF_KERNING 0x1000 /* font kerning*/
#define MWTF_ANTIALIAS 0x2000 /* antialiased output*/
#define MWTF_UNDERLINE 0x4000 /* draw underline*/
 
/* Drawing modes*/
#define MWMODE_COPY 0 /* src*/
#define MWMODE_XOR 1 /* src ^ dst*/
#define MWMODE_OR 2 /* src | dst*/
#define MWMODE_AND 3 /* src & dst*/
#define MWMODE_CLEAR 4 /* 0*/
#define MWMODE_SETTO1 5 /* 11111111*/ /* obsolete name, will be MWMODE_SET*/
#define MWMODE_EQUIV 6 /* ~(src ^ dst)*/
#define MWMODE_NOR 7 /* ~(src | dst)*/
#define MWMODE_NAND 8 /* ~(src & dst)*/
#define MWMODE_INVERT 9 /* ~dst*/
#define MWMODE_COPYINVERTED 10 /* ~src*/
#define MWMODE_ORINVERTED 11 /* ~src | dst*/
#define MWMODE_ANDINVERTED 12 /* ~src & dst*/
#define MWMODE_ORREVERSE 13 /* src | ~dst*/
#define MWMODE_ANDREVERSE 14 /* src & ~dst*/
#define MWMODE_NOOP 15 /* dst*/
#define MWMODE_MAX 15
 
/* Mouse button bits*/
#define MWBUTTON_L 04
#define MWBUTTON_M 02
#define MWBUTTON_R 01
 
/* Color defines*/
#define MWRGB(r,g,b) ((MWCOLORVAL)(((unsigned char)(r)|\
((unsigned short)((unsigned char)(g))<<8))|\
(((unsigned long)(unsigned char)(b))<<16)))
#define MWF_PALINDEX 0x01000000
#define MWPALINDEX(x) ((MWCOLORVAL)MWF_PALINDEX | (x))
 
/*
* ROP blitter opcodes (extensions < 0x10000000 are MWMODE_xxx blit ops)
*/
#define MWROP_EXTENSION 0xff000000L /* rop extension bits*/
 
/* copy src -> dst except for transparent color in src*/
#define MWROP_SRCTRANSCOPY 0x11000000L
 
/* alpha blend src -> dst with constant alpha, alpha value in low 8 bits*/
#define MWROP_BLENDCONSTANT 0x12000000L
 
/* alpha blend fg/bg color -> dst with src as alpha channel*/
#define MWROP_BLENDFGBG 0x13000000L
 
/* alpha blend src -> dst with separate per pixel alpha channel*/
#define MWROP_BLENDCHANNEL 0x14000000L
 
/* stretch src -> dst*/
#define MWROP_STRETCH 0x15000000L
 
/* blits rops based on src/dst binary operations*/
#define MWROP_COPY (MWMODE_COPY << 24L)
#define MWROP_XOR (MWMODE_XOR << 24L)
#define MWROP_OR (MWMODE_OR << 24L)
#define MWROP_AND (MWMODE_AND << 24L)
#define MWROP_CLEAR (MWMODE_CLEAR << 24L)
#define MWROP_SET (MWMODE_SETTO1 << 24L)
#define MWROP_EQUIV (MWMODE_EQUIV << 24L)
#define MWROP_NOR (MWMODE_NOR << 24L)
#define MWROP_NAND (MWMODE_NAND << 24L)
#define MWROP_INVERT (MWMODE_INVERT << 24L)
#define MWROP_COPYINVERTED (MWMODE_COPYINVERTED << 24L)
#define MWROP_ORINVERTED (MWMODE_ORINVERTED << 24L)
#define MWROP_ANDINVERTED (MWMODE_ANDINVERTED << 24L)
#define MWROP_ORREVERSE (MWMODE_ORREVERSE << 24L)
#define MWROP_ANDREVERSE (MWMODE_ANDREVERSE << 24L)
#define MWROP_NOOP (MWMODE_NOOP << 24L)
 
#define MWROP_SRCCOPY MWROP_COPY /* obsolete*/
#define MWROP_SRCAND MWROP_AND /* obsolete*/
#define MWROP_SRCINVERT MWROP_XOR /* obsolete*/
#define MWROP_BLACKNESS MWROP_CLEAR /* obsolete*/
 
/* convert an MWROP to drawing mode MWMODE value*/
#define MWROP_TO_MODE(op) ((op) >> 24)
 
/*
* Pixel formats
* Note the two pseudo pixel formats are never returned by display drivers,
* but rather used as a data structure type in GrArea. The other
* types are both returned by display drivers and used as pixel packing
* specifiers.
*/
#define MWPF_RGB 0 /* pseudo, convert from packed 32 bit RGB*/
#define MWPF_PIXELVAL 1 /* pseudo, no convert from packed PIXELVAL*/
#define MWPF_PALETTE 2 /* pixel is packed 8 bits 1, 4 or 8 pal index*/
#define MWPF_TRUECOLOR0888 3 /* pixel is packed 32 bits 8/8/8 truecolor*/
#define MWPF_TRUECOLOR888 4 /* pixel is packed 24 bits 8/8/8 truecolor*/
#define MWPF_TRUECOLOR565 5 /* pixel is packed 16 bits 5/6/5 truecolor*/
#define MWPF_TRUECOLOR555 6 /* pixel is packed 16 bits 5/5/5 truecolor*/
#define MWPF_TRUECOLOR332 7 /* pixel is packed 8 bits 3/3/2 truecolor*/
 
/*
* MWPIXELVAL definition: changes based on target system
* Set using -DMWPIXEL_FORMAT=MWPF_XXX
*
* For the Nano-X server, it is important to use the correct MWPF_* value
* for the MWPIXEL_FORMAT macro in order to match the hardware,
* while the Nano-X clients that includes this file can get away with
* a default pixel format of 24-bit color as the client will either:
* 1) Use the MWPF_PIXELVAL native format when calling GrReadArea, in
* which case we have to have enough spare room to hold 32-bit
* pixlevalues (hence the default MWPF_TRUECOLOR0888 format), or
* 2) Will use some other PF_* format, in which case the application
* is well aware of which pixel-format it uses and can avoid the
* device specific RGB2PIXEL and use RGB2PIXEL565 etc. instead,
* and specifiy the pixel fomar as MWPF_TRUECOLOR565 etc. when
* calling the GrArea function(s).
*/
#ifndef MWPIXEL_FORMAT
#define MWPIXEL_FORMAT MWPF_TRUECOLOR0888
#endif
 
#if defined(__AS386_16__)
/* Force 8 bit palettized display for ELKS*/
#undef MWPIXEL_FORMAT
#define MWPIXEL_FORMAT MWPF_PALETTE
#endif
 
#if (MWPIXEL_FORMAT == MWPF_TRUECOLOR565) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR555)
typedef unsigned short MWPIXELVAL;
#else
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR332
typedef unsigned char MWPIXELVAL;
#else
#if MWPIXEL_FORMAT == MWPF_PALETTE
typedef unsigned char MWPIXELVAL;
#else
typedef unsigned long MWPIXELVAL;
#endif
#endif
#endif
 
/* portrait modes*/
#define MWPORTRAIT_NONE 0x00 /* hw framebuffer, no rotation*/
#define MWPORTRAIT_LEFT 0x01 /* rotate left*/
#define MWPORTRAIT_RIGHT 0x02 /* rotate right*/
#define MWPORTRAIT_DOWN 0x04 /* upside down*/
 
/*
* Type definitions
*/
typedef int MWCOORD; /* device coordinates*/
typedef int MWBOOL; /* boolean value*/
typedef unsigned char MWUCHAR; /* unsigned char*/
typedef unsigned long MWCOLORVAL; /* device-independent color value*/
typedef unsigned short MWIMAGEBITS; /* bitmap image unit size*/
typedef unsigned long MWTIMEOUT; /* timeout value */
 
/* dbl linked list data structure*/
typedef struct _mwlist { /* LIST must be first decl in struct*/
struct _mwlist *next; /* next item*/
struct _mwlist *prev; /* previous item*/
} MWLIST, *PMWLIST;
 
/* dbl linked list head data structure*/
typedef struct _mwlisthead {
struct _mwlist *head; /* first item*/
struct _mwlist *tail; /* last item*/
} MWLISTHEAD, *PMWLISTHEAD;
 
/* Keyboard state modifiers*/
typedef unsigned int MWKEYMOD;
 
/* GetScreenInfo structure*/
typedef struct {
MWCOORD rows; /* number of rows on screen */
MWCOORD cols; /* number of columns on screen */
int xdpcm; /* dots/centimeter in x direction */
int ydpcm; /* dots/centimeter in y direction */
int planes; /* hw # planes*/
int bpp; /* hw bpp*/
long ncolors; /* hw number of colors supported*/
int fonts; /* number of built-in fonts */
int buttons; /* buttons which are implemented */
MWKEYMOD modifiers; /* modifiers which are implemented */
int pixtype; /* format of pixel value*/
int portrait; /* current portrait mode*/
MWBOOL fbdriver; /* true if running mwin fb screen driver*/
unsigned long rmask; /* red mask bits in pixel*/
unsigned long gmask; /* green mask bits in pixel*/
unsigned long bmask; /* blue mask bits in pixel*/
MWCOORD xpos; /* current x mouse position*/
MWCOORD ypos; /* current y mouse position*/
 
/* items below are get/set by the window manager and not used internally*/
int vs_width; /* virtual screen width/height*/
int vs_height;
int ws_width; /* workspace width/height*/
int ws_height;
} MWSCREENINFO, *PMWSCREENINFO;
 
/* client side window framebuffer info*/
typedef struct {
unsigned char * physpixels; /* address of real framebuffer*/
/* note winpixels is only correct in non-portrait modes*/
unsigned char * winpixels; /* address of 0,0 this window in fb*/
int pixtype; /* MWPF_ pixel type*/
int bpp; /* bits per pixel*/
int bytespp; /* bytes per pixel*/
int pitch; /* bytes per scan line for window (=fb pitch)*/
int x, y; /* absolute virtual window coordinates*/
int portrait_mode; /* current portrait mode*/
MWCOORD xres; /* real framebuffer resolution*/
MWCOORD yres;
MWCOORD xvirtres; /* virtual framebuffer resolution*/
MWCOORD yvirtres;
} MWWINDOWFBINFO;
 
/* GetFontInfo structure*/
typedef struct {
int maxwidth; /* maximum width of any char */
int height; /* height of font in pixels*/
int baseline; /* baseline (ascent) of font */
int firstchar; /* first character in font*/
int lastchar; /* last character in font*/
MWBOOL fixed; /* TRUE if font is fixed width */
MWUCHAR widths[256]; /* table of character widths */
} MWFONTINFO, *PMWFONTINFO;
 
/* GetFontList structure */
typedef struct {
char *ttname; /* TrueType name, eg "Times New Roman Bold" */
char *mwname; /* microwin name, eg "timesb" */
} MWFONTLIST, *PMWFONTLIST;
 
/* logical font descriptor*/
 
/* font classes - used internally*/
#define MWLF_CLASS_BUILTIN 1 /* Builtin fonts (bitmaps) */
#define MWLF_CLASS_FREETYPE 2 /* FreeType fonts in TT format */
#define MWLF_CLASS_T1LIB 3 /* T1LIB outlined Adobe Type 1 fonts */
#define MWLF_CLASS_ANY 4 /* Any font*/
 
#define MWLF_FACESIZE 64 /* max facename size*/
 
/* font type selection - lfOutPrecision*/
#define MWLF_TYPE_DEFAULT 0 /* any font*/
#define MWLF_TYPE_SCALED 4 /* outlined font (tt or adobe)*/
#define MWLF_TYPE_RASTER 5 /* raster only*/
#define MWLF_TYPE_TRUETYPE 7 /* truetype only*/
#define MWLF_TYPE_ADOBE 10 /* adobe type 1 only*/
 
/* font weights - lfWeight*/
#define MWLF_WEIGHT_DEFAULT 0 /* any weight*/
#define MWLF_WEIGHT_THIN 100 /* thin*/
#define MWLF_WEIGHT_EXTRALIGHT 200
#define MWLF_WEIGHT_LIGHT 300 /* light */
#define MWLF_WEIGHT_NORMAL 400 /* regular*/
#define MWLF_WEIGHT_REGULAR 400
#define MWLF_WEIGHT_MEDIUM 500 /* medium */
#define MWLF_WEIGHT_DEMIBOLD 600
#define MWLF_WEIGHT_BOLD 700 /* bold*/
#define MWLF_WEIGTH_EXTRABOLD 800
#define MWLF_WEIGHT_BLACK 900 /* black */
 
/* font charset - lfCharSet*/
#define MWLF_CHARSET_ANSI 0 /* win32 ansi*/
#define MWLF_CHARSET_DEFAULT 1 /* any charset*/
#define MWLF_CHARSET_UNICODE 254 /* unicode*/
#define MWLF_CHARSET_OEM 255 /* local hw*/
 
/* font pitch - lfPitch */
#define MWLF_PITCH_DEFAULT 0 /* any pitch */
#define MWLF_PITCH_ULTRACONDENSED 10
#define MWLF_PITCH_EXTRACONDENSED 20
#define MWLF_PITCH_CONDENSED 30
#define MWLF_PITCH_SEMICONDENSED 40
#define MWLF_PITCH_NORMAL 50
#define MWLF_PITCH_SEMIEXPANDED 60
#define MWLF_PITCH_EXPANDED 70
#define MWLF_PITCH_EXTRAEXPANDED 80
#define MWLF_PITCH_ULTRAEXPANDED 90
 
/* flags for the GdAddFont function */
#define MWLF_FLAGS_ALIAS 1
 
typedef struct {
long lfHeight; /* desired height in pixels*/
long lfWidth; /* desired width in pixels or 0*/
long lfEscapement; /* rotation in tenths of degree*/
long lfOrientation; /* not used*/
long lfWeight; /* font weight*/
MWUCHAR lfItalic; /* =1 for italic */
MWUCHAR lfUnderline; /* =1 for underline */
MWUCHAR lfStrikeOut; /* not used*/
MWUCHAR lfCharSet; /* font character set*/
MWUCHAR lfOutPrecision; /* font type selection*/
MWUCHAR lfClipPrecision; /* not used*/
MWUCHAR lfQuality; /* not used*/
 
/* the following differs from windows font model*/
MWUCHAR lfRoman; /* =1 for Roman letters (upright) */
MWUCHAR lfSerif; /* =1 for Serifed font */
MWUCHAR lfSansSerif; /* =1 for Sans-serif font */
MWUCHAR lfModern; /* =1 for Modern font */
MWUCHAR lfMonospace; /* =1 for Monospaced font */
MWUCHAR lfProportional; /* =1 for Proportional font */
MWUCHAR lfOblique; /* =1 for Oblique (kind of Italic) */
MWUCHAR lfSmallCaps; /* =1 for small caps */
MWUCHAR lfPitch; /* font pitch (width) */
 
char lfFaceName[MWLF_FACESIZE]; /* font name, may be aliased*/
} MWLOGFONT, *PMWLOGFONT;
 
/*
* Macros to initialize the MWLOGFONT structure to the most common defaults
* needed by application programs and the nano-X server program.
*/
 
#define MWLF_Clear(lf) \
do { \
(lf)->lfHeight = 0; \
(lf)->lfWidth = 0; \
(lf)->lfEscapement = 0; \
(lf)->lfOrientation = 0; \
(lf)->lfWeight = MWLF_WEIGHT_REGULAR; \
(lf)->lfPitch = 0; \
(lf)->lfItalic = 0; \
(lf)->lfOblique = 0; \
(lf)->lfRoman = 0; \
(lf)->lfSerif = 0; \
(lf)->lfSansSerif = 0; \
(lf)->lfModern = 0; \
(lf)->lfMonospace = 0; \
(lf)->lfProportional = 0; \
(lf)->lfSmallCaps = 0; \
(lf)->lfUnderline = 0; \
(lf)->lfStrikeOut = 0; \
(lf)->lfCharSet = 0; \
(lf)->lfOutPrecision = 0; \
(lf)->lfClipPrecision = 0; \
(lf)->lfQuality = 0; \
(lf)->lfFaceName[0] = '\0'; \
} while (0)
 
#define MWLF_SetBold(lf) \
do { \
(lf)->lfWeight = MWLF_WEIGHT_BOLD; \
} while (0)
 
#define MWLF_SetRegular(lf) \
do { \
(lf)->lfWeight = MWLF_WEIGHT_REGULAR; \
} while (0)
 
#define MWLF_SetItalics(lf) \
do { \
(lf)->lfItalic = 1; \
(lf)->lfOblique = 0; \
(lf)->lfRoman = 0; \
} while (0)
 
#define MWLF_SetRoman(lf) \
do { \
(lf)->lfItalic = 0; \
(lf)->lfOblique = 0; \
(lf)->lfRoman = 1; \
} while (0)
 
/*
* Rectangle and point structures.
* These structures are "inherited" in wingdi.h for
* the Win32 RECT and POINT structures, so they must match
* Microsoft's definition.
*/
 
/* MWPOINT used in GdPoly, GdFillPoly*/
typedef struct {
MWCOORD x;
MWCOORD y;
} MWPOINT;
 
/* MWRECT used in region routines*/
typedef struct {
MWCOORD left;
MWCOORD top;
MWCOORD right;
MWCOORD bottom;
} MWRECT;
 
/* dynamically allocated multi-rectangle clipping region*/
typedef struct {
int size; /* malloc'd # of rectangles*/
int numRects; /* # rectangles in use*/
int type; /* region type*/
MWRECT *rects; /* rectangle array*/
MWRECT extents; /* bounding box of region*/
} MWCLIPREGION;
 
/* region types */
#define MWREGION_ERROR 0
#define MWREGION_NULL 1
#define MWREGION_SIMPLE 2
#define MWREGION_COMPLEX 3
 
/* GdRectInRegion return codes*/
#define MWRECT_OUT 0 /* rectangle not in region*/
#define MWRECT_ALLIN 1 /* rectangle all in region*/
#define MWRECT_PARTIN 2 /* rectangle partly in region*/
 
/* GdAllocPolyRegion types*/
#define MWPOLY_EVENODD 1
#define MWPOLY_WINDING 2
 
/* In-core color palette structure*/
typedef struct {
MWUCHAR r;
MWUCHAR g;
MWUCHAR b;
} MWPALENTRY;
 
/* In-core mono and color image structure*/
#define MWIMAGE_UPSIDEDOWN 01 /* compression flag: upside down image*/
#define MWIMAGE_BGR 00 /* compression flag: BGR byte order*/
#define MWIMAGE_RGB 02 /* compression flag: RGB not BGR bytes*/
 
typedef struct {
int width; /* image width in pixels*/
int height; /* image height in pixels*/
int planes; /* # image planes*/
int bpp; /* bits per pixel (1, 4 or 8)*/
int pitch; /* bytes per line*/
int bytesperpixel; /* bytes per pixel*/
int compression; /* compression algorithm*/
int palsize; /* palette size*/
long transcolor; /* transparent color or -1 if none*/
MWPALENTRY * palette; /* palette*/
MWUCHAR * imagebits; /* image bits (dword right aligned)*/
} MWIMAGEHDR, *PMWIMAGEHDR;
 
/* image information structure - returned by GdGetImageInfo*/
typedef struct {
int id; /* image id*/
int width; /* image width in pixels*/
int height; /* image height in pixels*/
int planes; /* # image planes*/
int bpp; /* bits per pixel (1, 4 or 8)*/
int pitch; /* bytes per line*/
int bytesperpixel; /* bytes per pixel*/
int compression; /* compression algorithm*/
int palsize; /* palette size*/
MWPALENTRY palette[256]; /* palette*/
} MWIMAGEINFO, *PMWIMAGEINFO;
 
#define MWMAX_CURSOR_SIZE 16 /* maximum cursor x and y size*/
 
/* In-core software cursor structure*/
typedef struct {
int width; /* cursor width in pixels*/
int height; /* cursor height in pixels*/
MWCOORD hotx; /* relative x pos of hot spot*/
MWCOORD hoty; /* relative y pos of hot spot*/
MWCOLORVAL fgcolor; /* foreground color*/
MWCOLORVAL bgcolor; /* background color*/
MWIMAGEBITS image[MWMAX_CURSOR_SIZE];/* cursor image bits*/
MWIMAGEBITS mask[MWMAX_CURSOR_SIZE];/* cursor mask bits*/
} MWCURSOR, *PMWCURSOR;
 
typedef struct _mwfont * PMWFONT;
 
/* outline and filled arc and pie types*/
#define MWARC 0x0001 /* arc*/
#define MWOUTLINE 0x0002
#define MWARCOUTLINE 0x0003 /* arc + outline*/
#define MWPIE 0x0004 /* pie (filled)*/
#define MWELLIPSE 0x0008 /* ellipse outline*/
#define MWELLIPSEFILL 0x0010 /* ellipse filled*/
 
#ifdef MWINCLUDECOLORS
/*
* Common colors - note any color including these may not be
* available on palettized systems, and the system will
* then use the nearest color already in the system palette,
* or allocate a new color entry.
* These colors are the first 16 entries in the std palette,
* and are written to the system palette if writable.
*/
#define BLACK MWRGB( 0 , 0 , 0 )
#define BLUE MWRGB( 0 , 0 , 128 )
#define GREEN MWRGB( 0 , 128, 0 )
#define CYAN MWRGB( 0 , 128, 128 )
#define RED MWRGB( 128, 0 , 0 )
#define MAGENTA MWRGB( 128, 0 , 128 )
#define BROWN MWRGB( 128, 64 , 0 )
#define LTGRAY MWRGB( 192, 192, 192 )
#define GRAY MWRGB( 128, 128, 128 )
#define LTBLUE MWRGB( 0 , 0 , 255 )
#define LTGREEN MWRGB( 0 , 255, 0 )
#define LTCYAN MWRGB( 0 , 255, 255 )
#define LTRED MWRGB( 255, 0 , 0 )
#define LTMAGENTA MWRGB( 255, 0 , 255 )
#define YELLOW MWRGB( 255, 255, 0 )
#define WHITE MWRGB( 255, 255, 255 )
 
/* other common colors*/
#define DKGRAY MWRGB( 32, 32, 32)
#endif /* MWINCLUDECOLORS*/
 
/* Keyboard values*/
typedef unsigned short MWKEY;
typedef unsigned char MWSCANCODE;
 
#define MWKEY_UNKNOWN 0
/* Following special control keysyms are mapped to ASCII*/
#define MWKEY_BACKSPACE 8
#define MWKEY_TAB 9
#define MWKEY_ENTER 13
#define MWKEY_ESCAPE 27
/* Keysyms from 32-126 are mapped to ASCII*/
 
#define MWKEY_NONASCII_MASK 0xFF00
/* Following keysyms are mapped to private use portion of Unicode-16*/
/* arrows + home/end pad*/
#define MWKEY_FIRST 0xF800
#define MWKEY_LEFT 0xF800
#define MWKEY_RIGHT 0xF801
#define MWKEY_UP 0xF802
#define MWKEY_DOWN 0xF803
#define MWKEY_INSERT 0xF804
#define MWKEY_DELETE 0xF805
#define MWKEY_HOME 0xF806
#define MWKEY_END 0xF807
#define MWKEY_PAGEUP 0xF808
#define MWKEY_PAGEDOWN 0xF809
 
/* Numeric keypad*/
#define MWKEY_KP0 0xF80A
#define MWKEY_KP1 0xF80B
#define MWKEY_KP2 0xF80C
#define MWKEY_KP3 0xF80D
#define MWKEY_KP4 0xF80E
#define MWKEY_KP5 0xF80F
#define MWKEY_KP6 0xF810
#define MWKEY_KP7 0xF811
#define MWKEY_KP8 0xF812
#define MWKEY_KP9 0xF813
#define MWKEY_KP_PERIOD 0xF814
#define MWKEY_KP_DIVIDE 0xF815
#define MWKEY_KP_MULTIPLY 0xF816
#define MWKEY_KP_MINUS 0xF817
#define MWKEY_KP_PLUS 0xF818
#define MWKEY_KP_ENTER 0xF819
#define MWKEY_KP_EQUALS 0xF81A
 
/* Function keys */
#define MWKEY_F1 0xF81B
#define MWKEY_F2 0xF81C
#define MWKEY_F3 0xF81D
#define MWKEY_F4 0xF81E
#define MWKEY_F5 0xF81F
#define MWKEY_F6 0xF820
#define MWKEY_F7 0xF821
#define MWKEY_F8 0xF822
#define MWKEY_F9 0xF823
#define MWKEY_F10 0xF824
#define MWKEY_F11 0xF825
#define MWKEY_F12 0xF827
 
/* Key state modifier keys*/
#define MWKEY_NUMLOCK 0xF828
#define MWKEY_CAPSLOCK 0xF829
#define MWKEY_SCROLLOCK 0xF82A
#define MWKEY_LSHIFT 0xF82B
#define MWKEY_RSHIFT 0xF82C
#define MWKEY_LCTRL 0xF82D
#define MWKEY_RCTRL 0xF82E
#define MWKEY_LALT 0xF82F
#define MWKEY_RALT 0xF830
#define MWKEY_LMETA 0xF831
#define MWKEY_RMETA 0xF832
#define MWKEY_ALTGR 0xF833
 
/* Misc function keys*/
#define MWKEY_PRINT 0xF834
#define MWKEY_SYSREQ 0xF835
#define MWKEY_PAUSE 0xF836
#define MWKEY_BREAK 0xF837
#define MWKEY_QUIT 0xF838 /* virtual key*/
#define MWKEY_MENU 0xF839 /* virtual key*/
#define MWKEY_REDRAW 0xF83A /* virtual key*/
 
/* Handheld function keys*/
#define MWKEY_RECORD 0xF840
#define MWKEY_PLAY 0xF841
#define MWKEY_CONTRAST 0xF842
#define MWKEY_BRIGHTNESS 0xF843
#define MWKEY_SELECTUP 0xF844
#define MWKEY_SELECTDOWN 0xF845
#define MWKEY_ACCEPT 0xF846
#define MWKEY_CANCEL 0xF847
#define MWKEY_APP1 0xF848
#define MWKEY_APP2 0xF849
#define MWKEY_LAST 0xF849
 
/* Keyboard state modifiers*/
#define MWKMOD_NONE 0x0000
#define MWKMOD_LSHIFT 0x0001
#define MWKMOD_RSHIFT 0x0002
#define MWKMOD_LCTRL 0x0040
#define MWKMOD_RCTRL 0x0080
#define MWKMOD_LALT 0x0100
#define MWKMOD_RALT 0x0200
#define MWKMOD_LMETA 0x0400 /* Windows key*/
#define MWKMOD_RMETA 0x0800 /* Windows key*/
#define MWKMOD_NUM 0x1000
#define MWKMOD_CAPS 0x2000
#define MWKMOD_ALTGR 0x4000
#define MWKMOD_SCR 0x8000
 
#define MWKMOD_CTRL (MWKMOD_LCTRL|MWKMOD_RCTRL)
#define MWKMOD_SHIFT (MWKMOD_LSHIFT|MWKMOD_RSHIFT)
#define MWKMOD_ALT (MWKMOD_LALT|MWKMOD_RALT)
#define MWKMOD_META (MWKMOD_LMETA|MWKMOD_RMETA)
 
#define MWKINFO_LED_MASK (1 << 0)
#define MWKINFO_LED_MODE_MASK (1 << 1)
 
/* Keyboard info values */
#define MWKINFO_LED_CAP (1 << 0)
#define MWKINFO_LED_NUM (1 << 1)
#define MWKINFO_LED_SCR (1 << 2)
 
#define MWKINFO_LED_MODE_ON (1 << 3)
#define MWKINFO_LED_MODE_OFF (1 << 4)
 
typedef struct {
int led;
int led_mode;
} MWKBINFO, *PMWKBINFO;
#endif /* _MWTYPES_H*/
/microwin/swap.h
0,0 → 1,30
/*
* Copyright (c) 2001 Greg Haerr <greg@censoft.com>
*
* Byte and word swapping header file for big/little endian mapping
*/
 
#ifdef __ECOS
// FIXME!
#define wswap(x) (x)
#define dwswap(x) (x)
#define dwread(addr) (*(unsigned long *)(addr))
#else
#include <endian.h>
#include <byteswap.h>
#if __BYTE_ORDER == __BIG_ENDIAN
#define wswap(x) bswap_16(x)
#define dwswap(x) bswap_32(x)
/* read little endian format from buffer*/
#define dwread(addr) ((*(unsigned char *)(addr)) | \
(*(unsigned char *)(addr+1) << 8) | \
(*(unsigned char *)(addr+2) << 16) | \
(*(unsigned char *)(addr+3) << 24))
#else
/* little endian - no action required*/
#define wswap(x) (x)
#define dwswap(x) (x)
#define dwread(addr) (*(unsigned long *)(addr))
#endif
#endif
 
/microwin/windef.h
0,0 → 1,177
/* windef.h*/
/*
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
*
* Win32 API base type definitions
*/
 
#define _WINDEF_H
 
 
#ifdef VXWORKS
/* Don't include the internal Tornado header file <ntcontext.h>, **
** as the definitions in it conflict with these definitions. */
#define __INCntcontexth
/* Bring in the core VxWorks definitions as they could conflict **
** with the ones below if they are brought in later. */
#include <vxWorks.h>
#endif
 
 
#ifndef NULL
#define NULL ((void *)0)
#endif
 
#ifndef FALSE
#define FALSE 0
#endif
 
#ifndef TRUE
#define TRUE 1
#endif
 
#ifndef NOMINMAX
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
 
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif /* NOMINMAX */
 
#define CALLBACK
#define WINAPI
#define WINAPIV
#define APIENTRY WINAPI
#define APIPRIVATE
#define PASCAL
 
#define FAR
#define NEAR
#define CONST const
#define CDECL
 
#define VOID void
typedef void *PVOID;
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
typedef SHORT *PSHORT;
typedef LONG *PLONG;
 
#ifndef VXWORKS
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
typedef unsigned int UINT;
 
#ifndef __ITRON_TYPES_h_ /* FIXME RTEMS hack*/
#ifndef COMMON_H /* MiniGUI hack*/
typedef int BOOL;
#endif
#endif
 
#endif /* !VXWORKS*/
 
typedef ULONG * PULONG;
typedef USHORT * PUSHORT;
typedef UCHAR * PUCHAR;
typedef char * PSZ;
typedef int INT;
typedef unsigned int *PUINT;
 
typedef unsigned long DWORD;
typedef unsigned char BYTE;
typedef unsigned short WORD;
 
typedef float FLOAT;
typedef FLOAT *PFLOAT;
typedef BOOL NEAR *PBOOL;
typedef BOOL FAR *LPBOOL;
typedef BYTE NEAR *PBYTE;
typedef BYTE FAR *LPBYTE;
typedef int NEAR *PINT;
typedef int FAR *LPINT;
typedef WORD NEAR *PWORD;
typedef WORD FAR *LPWORD;
typedef long FAR *LPLONG;
typedef DWORD NEAR *PDWORD;
typedef DWORD FAR *LPDWORD;
typedef void FAR *LPVOID;
typedef CONST void FAR *LPCVOID;
 
typedef unsigned short WCHAR;
typedef WCHAR *PWCHAR;
typedef WCHAR *LPWCH, *PWCH;
typedef CONST WCHAR *LPCWCH, *PCWCH;
typedef WCHAR *NWPSTR;
typedef WCHAR *LPWSTR, *PWSTR;
typedef CONST WCHAR *LPCWSTR, *PCWSTR;
 
typedef CHAR *PCHAR;
typedef CHAR *LPCH, *PCH;
typedef CONST CHAR *LPCCH, *PCCH;
typedef CHAR *NPSTR;
typedef CHAR *LPSTR, *PSTR;
typedef CONST CHAR *LPCSTR, *PCSTR;
typedef char TCHAR, *PTCHAR;
typedef unsigned char TBYTE , *PTBYTE ;
typedef LPSTR LPTCH, PTCH;
typedef LPSTR PTSTR, LPTSTR;
typedef LPCSTR LPCTSTR;
 
#define __TEXT(quote) quote
#define TEXT(quote) __TEXT(quote)
 
typedef int (FAR WINAPI *FARPROC)();
typedef int (NEAR WINAPI *NEARPROC)();
typedef int (WINAPI *PROC)();
 
typedef UINT WPARAM;
typedef LONG LPARAM;
typedef LONG LRESULT;
typedef LONG HRESULT;
 
#define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8))
#define MAKELONG(a, b) ((LONG)(((WORD)(a)) | ((DWORD)((WORD)(b))) << 16))
#define LOWORD(l) ((WORD)(l))
#define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
#define LOBYTE(w) ((BYTE)(w))
#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
 
#define PALETTEINDEX(i) ((COLORREF)(0x01000000 | (DWORD)(WORD)(i)))
 
typedef DWORD COLORREF;
typedef DWORD *LPCOLORREF;
 
/* handle typedef*/
typedef PVOID HANDLE;
 
typedef HANDLE *PHANDLE;
typedef HANDLE NEAR *SPHANDLE;
typedef HANDLE FAR *LPHANDLE;
typedef HANDLE HGLOBAL;
typedef HANDLE HLOCAL;
typedef HANDLE GLOBALHANDLE;
typedef HANDLE LOCALHANDLE;
 
typedef WORD ATOM;
 
typedef struct hwnd * HWND;
typedef struct hdc * HDC;
typedef struct hcursor *HCURSOR;
typedef struct hgdiobj *HGDIOBJ;
typedef struct hgdiobj *HBRUSH;
typedef struct hgdiobj *HPEN;
typedef struct hgdiobj *HFONT;
typedef struct hgdiobj *HBITMAP;
typedef struct hgdiobj *HRGN;
typedef struct hgdiobj *HPALETTE;
typedef HANDLE HICON;
typedef HANDLE HINSTANCE;
typedef HANDLE HMENU;
 
/* moved to winuser.h for resource compiler*/
/*typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);*/
 
/microwin/wintools.h
0,0 → 1,27
/*
* wintools.h - MS Windows tools library header
*
* WINGEN General Purpose Library
* WINMEM Windows Memory Mgmt Library
* WINFX Special Effects Library
* WINDRAW Draw Library
* WINCTL Custom Control Library
* WIN Class Procedures: ToolsTips, AutoMove, AutoEdit
* WINVID Windows Digital Video
*
* original version 1/6/95 by g haerr
*/
 
void WINAPI Draw3dShadow(HDC hDC,int x,int y,int w,int h,COLORREF crTop,
COLORREF crBottom);
void WINAPI Draw3dBox(HDC hDC,int x,int y,int w,int h,COLORREF crTop,
COLORREF crBottom);
void WINAPI Draw3dInset(HDC hDC,int x,int y,int w,int h);
void WINAPI Draw3dOutset(HDC hDC,int x,int y,int w,int h);
void WINAPI Draw3dPushDown(HDC hDC, int x, int y, int w, int h);
void WINAPI Draw3dUpDownState(HDC hDC, int x, int y, int w, int h,
BOOL fDown);
void WINAPI Draw3dUpFrame(HDC hDC, int l, int t, int r, int b);
void WINAPI FastFillRect(HDC hdc,LPRECT lprect,COLORREF cr);
void WINAPI InsetR(LPRECT lprc,int h,int v);
BOOL WINAPI PtInsideWindow(HWND hwnd,UINT x,UINT y);
/microwin/winkbd.h
0,0 → 1,128
/* winkbd.h*/
/*
* Copyright (c) 2000 Greg Haerr <greg@censoft.com>
*
* Win32 keyboard defines and API
*/
 
/* virtual key codes*/
#define VK_LBUTTON 0x01
#define VK_RBUTTON 0x02
#define VK_CANCEL 0x03 /* ctrl-break*/
#define VK_MBUTTON 0x04
#define VK_BACK 0x08 /* backspace*/
#define VK_TAB 0x09
#define VK_CLEAR 0x0C /* kp5 w/numlock off*/
#define VK_RETURN 0x0D
#define VK_SHIFT 0x10 /* either shift*/
#define VK_CONTROL 0x11 /* either control*/
#define VK_MENU 0x12 /* alt*/
#define VK_PAUSE 0x13
#define VK_CAPITAL 0x14 /* caps lock*/
#define VK_KANA 0x15
#define VK_HANGEUL VK_KANA
#define VK_HANGUL 0x15
#define VK_JUNJA 0x17
#define VK_FINAL 0x18
#define VK_HANJA 0x19
#define VK_KANJI 0x19
#define VK_ESCAPE 0x1B /* esc*/
#define VK_CONVERT 0x1C
#define VK_NONCONVERT 0x1D
#define VK_ACCEPT 0x1E
#define VK_MODECHANGE 0x1F
#define VK_SPACE 0x20 /* spacebar*/
#define VK_PRIOR 0x21 /* page up*/
#define VK_NEXT 0x22 /* page dn*/
#define VK_END 0x23
#define VK_HOME 0x24
#define VK_LEFT 0x25
#define VK_UP 0x26
#define VK_RIGHT 0x27
#define VK_DOWN 0x28
#define VK_SELECT 0x29
#define VK_PRINT 0x2A
#define VK_EXECUTE 0x2B
#define VK_SNAPSHOT 0x2C
#define VK_INSERT 0x2D
#define VK_DELETE 0x2E
#define VK_HELP 0x2F
 
/* 0x30 - 0x39 ASCII 0 - 9*/
/* 0x41 - 0x5a ASCII A - Z*/
 
#define VK_LWIN 0x5B
#define VK_RWIN 0x5C
#define VK_APPS 0x5D
 
/* numeric keypad keys*/
#define VK_NUMPAD0 0x60
#define VK_NUMPAD1 0x61
#define VK_NUMPAD2 0x62
#define VK_NUMPAD3 0x63
#define VK_NUMPAD4 0x64
#define VK_NUMPAD5 0x65
#define VK_NUMPAD6 0x66
#define VK_NUMPAD7 0x67
#define VK_NUMPAD8 0x68
#define VK_NUMPAD9 0x69
#define VK_MULTIPLY 0x6A /* kp * */
#define VK_ADD 0x6B /* kp + */
#define VK_SEPARATOR 0x6C
#define VK_SUBTRACT 0x6D /* kp - */
#define VK_DECIMAL 0x6E /* kp . */
#define VK_DIVIDE 0x6F /* kp / */
 
#define VK_F1 0x70
#define VK_F2 0x71
#define VK_F3 0x72
#define VK_F4 0x73
#define VK_F5 0x74
#define VK_F6 0x75
#define VK_F7 0x76
#define VK_F8 0x77
#define VK_F9 0x78
#define VK_F10 0x79
#define VK_F11 0x7A
#define VK_F12 0x7B
#define VK_F13 0x7C
#define VK_F14 0x7D
#define VK_F15 0x7E
#define VK_F16 0x7F
#define VK_F17 0x80
#define VK_F18 0x81
#define VK_F19 0x82
#define VK_F20 0x83
#define VK_F21 0x84
#define VK_F22 0x85
#define VK_F23 0x86
#define VK_F24 0x87
#define VK_NUMLOCK 0x90 /* num lock*/
#define VK_SCROLL 0x91 /* scroll lock*/
 
/* param to GetAsyncKeyState and GetKeyState only*/
#define VK_LSHIFT 0xA0
#define VK_RSHIFT 0xA1
#define VK_LCONTROL 0xA2
#define VK_RCONTROL 0xA3
#define VK_LMENU 0xA4
#define VK_RMENU 0xA5
 
#define VK_PROCESSKEY 0xE5
#define VK_ATTN 0xF6
#define VK_CRSEL 0xF7
#define VK_EXSEL 0xF8
#define VK_EREOF 0xF9
#define VK_PLAY 0xFA
#define VK_ZOOM 0xFB
#define VK_NONAME 0xFC
#define VK_PA1 0xFD
#define VK_OEM_CLEAR 0xFE
 
/* WM_KEYUP/WM_KEYDOWN/WM_CHAR hiword lparam flags*/
#define KF_EXTENDED 0x0100
#define KF_DLGMODE 0x0800
#define KF_MENUMODE 0x1000
#define KF_ALTDOWN 0x2000
#define KF_REPEAT 0x4000
#define KF_UP 0x8000
/microwin/XtoNX.h
0,0 → 1,164
#ifndef __XTONX_H
#define __XTONX_H
/*
* Copyright (c) 2001 by Greg Haerr <greg@centurysoftware.com>
*
* XtoNX.h - X to Nano-X macro conversion header file
*
* Yes, this is a vain attempt at making things easier when
* porting Xlib programs to Nano-X!
*/
 
#ifdef __cplusplus
extern "C" {
#endif
 
#define MWINCLUDECOLORS
#include "nano-X.h"
 
typedef GR_WINDOW_ID Window;
typedef GR_WINDOW_ID Pixmap;
typedef GR_GC_ID GC;
typedef GR_FONT_ID Font;
typedef GR_CURSOR_ID Cursor;
typedef GR_REGION_ID Region;
typedef unsigned long Time; /* change to GR_TIME*/
typedef GR_EVENT XEvent;
typedef GR_FONT_INFO XFontStruct;
typedef GR_POINT XPoint;
typedef GR_RECT XRectangle;
 
/* static display structed initialized by XOpenDisplay()*/
typedef struct {
GR_COORD display_width;
GR_COORD display_height;
int display_bpp;
} Display;
 
/* kluge structs*/
#define XCharStruct char
 
#define DisplayWidth(d,s) (_display.display_width)
#define DisplayHeight(d,s) (_display.display_height)
#define DefaultDepth(d,s) (_display.display_bpp)
#define DefaultScreen(d) 0
#define RootWindow(d,s) GR_ROOT_WINDOW_ID
#define BlackPixel(d,s) BLACK
#define WhitePixel(d,s) WHITE
#define False 0
#define True 1
 
#define None 0
#define RectangleOut MWRECT_OUT
#define RectangleIn MWRECT_ALLIN
#define RectanglePart MWRECT_PARTIN
 
/* events*/
#define EnterWindowMask GR_EVENT_MASK_MOUSE_ENTER
#define LeaveWindowMask GR_EVENT_MASK_MOUSE_EXIT
#define ButtonPressMask GR_EVENT_MASK_BUTTON_DOWN
#define ButtonReleaseMask GR_EVENT_MASK_BUTTON_UP
#define KeyPressMask GR_EVENT_MASK_KEY_DOWN
#define KeyReleaseMask GR_EVENT_MASK_KEY_UP
#define ExposureMask GR_EVENT_MASK_EXPOSURE
#define SubstructureNotifyMask GR_EVENT_MASK_CHLD_UPDATE
 
#define EnterNotify GR_EVENT_TYPE_MOUSE_ENTER
#define LeaveNotify GR_EVENT_TYPE_MOUSE_EXIT
#define ButtonPress GR_EVENT_TYPE_BUTTON_DOWN
#define ButtonRelease GR_EVENT_TYPE_BUTTON_UP
#define KeyPress GR_EVENT_TYPE_KEY_DOWN
#define KeyRelease GR_EVENT_TYPE_KEY_UP
#define Expose GR_EVENT_TYPE_EXPOSURE
#define ConfigureNotify GR_EVENT_TYPE_CHLD_UPDATE
 
#define XCloseDisplay(d) GrClose()
#define XNextEvent(d,ep) GrGetNextEvent(ep)
#define XSelectInput(d,w,m) GrSelectEvents(w,m)
#define XFlush(d) GrFlush()
#define XSync(d,f) GrFlush()
 
/* graphics functions*/
#define XCreateSimpleWindow(d,p,x,y,w,h,bw,bordc,backc) \
GrNewWindow(p,x,y,w,h,bw,backc,bordc)
#define XCreateWindow(d,p,x,y,w,h,bw,depth,cl,vis,vm,attr) \
GrNewWindow(p,x,y,w,h,bw,WHITE,BLACK)
#define XCreatePixmapFromBitmapData(d,w,bm,W,H,f,b,depth) \
GrNewPixmapFromData(W,H,f,b,(void *)bm, \
GR_BMDATA_BYTEREVERSE|GR_BMDATA_BYTESWAP)
#define XCreateBitmapFromData(d,w,bm,W,H) \
GrNewPixmapFromData(W,H,WHITE,BLACK,(void *)bm, \
GR_BMDATA_BYTEREVERSE|GR_BMDATA_BYTESWAP)
#define XDestroyWindow(d,w) GrDestroyWindow(w)
#define XReparentWindow(d,w,p,x,y) GrReparentWindow(w,p,x,y)
#define XMapWindow(d,w) GrMapWindow(w)
#define XUnmapWindow(d,w) GrUnmapWindow(w)
#define XClearWindow(d,w) GrClearArea(w,0,0,0,0,GR_FALSE)
#define XClearArea(d,w,X,Y,W,H,e) GrClearArea(w,X,Y,W,H,e)
#define XRaiseWindow(d,w) GrRaiseWindow(w)
#define XLowerWindow(d,w) GrLowerWindow(w)
#define XMoveWindow(d,w,x,y) GrMoveWindow(w,x,y)
#define XResizeWindow(d,w,W,H) GrResizeWindow(w,W,H)
 
#define XCreateGC(d,a,b,c) GrNewGC()
#define XSetFunction(d,g,f) GrSetGCMode(g,f)
#define GXxor GR_MODE_XOR
#define XSetForeground(d,g,c) GrSetGCForeground(g,c)
#define XSetWindowBackgroundPixmap(d,w,p) \
GrSetBackgroundPixmap(w,p,GR_BACKGROUND_TILE)
#define XSetWindowBackground(d,w,c) GrSetWindowBackgroundColor(w,c)
#define XSetWindowBorderWidth(d,w,bw) GrSetWindowBorderSize(w,bw)
#define XSetWindowBorder(d,w,c) GrSetWindowBorderColor(w,c)
#define XStoreName(d,w,n) GrSetWindowTitle(w,n)
#define XSetIconName(d,w,n) /* nyi*/
#define XDrawLines(d,w,g,ar,cnt,B) GrDrawLines(w,g,ar,cnt)
#define XFillRectangle(d,w,g,x,y,W,H) GrFillRect(w,g,x,y,W,H)
#define XDrawString(d,w,g,x,y,s,c) GrText(w,g,x,y,(void *)s,c,GR_TFASCII)
#define XSetFont(d,g,f) GrSetGCFont(g,f)
#define XLoadFont(d,f) GrCreateFont(0, 0, 0)
#define XDefineCursor(d,w,c) GrSetWindowCursor(w,c)
#define XUndefineCursor(d,w) GrSetWindowCursor(w,0)
 
#define XCreateRegion() GrNewRegion()
#define XUnionRectWithRegion(rect,sr,dr) GrUnionRectWithRegion(dr,rect) /* FIXME*/
#define XRectInRegion(r,x,y,w,h) GrRectInRegion(r,x,y,w,h)
#define XSubtractRegion(sra,srb,dr) GrSubtractRegion(dr,sra,srb)
#define XDestroyRegion(r) GrDestroyRegion(r)
 
#define XQueryTree(d,w,r,p,c,nc) GrQueryTree(w,p,c,nc)
#define XFree(p) free(p)
 
/* client-statically declared functions*/
#define STATIC_FUNCTIONS \
static Display _display; \
\
Display * \
XOpenDisplay(char *name) \
{ \
GR_SCREEN_INFO sinfo; \
\
if (GrOpen() < 0) \
return NULL; \
\
GrGetScreenInfo(&sinfo); \
_display.display_width = sinfo.cols; \
_display.display_height = sinfo.rows; \
_display.display_bpp = sinfo.bpp; \
\
return &_display; \
} \
\
int \
XPending(Display *d) \
{ \
GR_EVENT ev; \
\
GrFlush(); \
return GrPeekEvent(&ev); \
}
 
#ifdef __cplusplus
} /* extern "C"*/
#endif
 
#endif /* __XTONX_H*/
/microwin/wingdi.h
0,0 → 1,396
/* wingdi.h*/
/*
* Copyright (c) 1999,2000,2001 Greg Haerr <greg@censoft.com>
*
* Win32 GDI structures and API
*/
 
/* portable coordinate definition*/
typedef MWCOORD GDICOORD;
 
/* inherit RECT and POINT from mwtypes.h*/
typedef MWRECT RECT;
typedef MWPOINT POINT;
 
#if 0000
typedef struct tagRECT {
GDICOORD left;
GDICOORD top;
GDICOORD right;
GDICOORD bottom;
} RECT;
 
typedef struct tagPOINT {
GDICOORD x;
GDICOORD y;
} POINT;
#endif
 
typedef RECT NEAR *PRECT, FAR *LPRECT;
 
typedef POINT NEAR *PPOINT, FAR *LPPOINT;
 
typedef struct tagSIZE {
GDICOORD cx;
GDICOORD cy;
} SIZE, NEAR *PSIZE, FAR *LPSIZE;
 
/* GetDCEx flags*/
#define DCX_WINDOW 0x00000001L
#define DCX_CACHE 0x00000002L
#define DCX_NORESETATTRS 0x00000004L
#define DCX_CLIPCHILDREN 0x00000008L
#define DCX_CLIPSIBLINGS 0x00000010L
#define DCX_PARENTCLIP 0x00000020L
#define DCX_EXCLUDERGN 0x00000040L
#define DCX_INTERSECTRGN 0x00000080L
#define DCX_EXCLUDEUPDATE 0x00000100L
#define DCX_INTERSECTUPDATE 0x00000200L
#define DCX_LOCKWINDOWUPDATE 0x00000400L
#define DCX_VALIDATE 0x00200000L
#define DCX_DEFAULTCLIP 0x80000000L /* microwin only*/
 
HDC WINAPI GetDCEx(HWND hwnd,HRGN hrgnClip,DWORD flags);
HDC WINAPI GetDC(HWND hWnd);
HDC WINAPI GetWindowDC(HWND hWnd);
int WINAPI ReleaseDC(HWND hWnd, HDC hDC);
BOOL WINAPI DeleteDC(HDC hdc);
 
typedef struct tagPAINTSTRUCT {
HDC hdc;
BOOL fErase; /* indicates bkgnd needs erasing*/
RECT rcPaint; /* nyi*/
BOOL fRestore; /* nyi*/
BOOL fIncUpdate; /* nyi*/
BYTE rgbReserved[32];
} PAINTSTRUCT, *PPAINTSTRUCT, *NPPAINTSTRUCT, FAR *LPPAINTSTRUCT;
 
HDC WINAPI BeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
BOOL WINAPI EndPaint(HWND hWnd, CONST PAINTSTRUCT *lpPaint);
 
#define RGB(r,g,b) MWRGB(r,g,b)
#define GetRValue(rgb) ((BYTE)(rgb))
#define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8))
#define GetBValue(rgb) ((BYTE)((rgb)>>16))
 
/* Background Modes */
#define TRANSPARENT 1
#define OPAQUE 2
 
/* Text Alignment*/
#define TA_NOUPDATECP 0
#define TA_UPDATECP 1
 
#define TA_LEFT 0
#define TA_RIGHT 2
#define TA_CENTER 6
 
#define TA_TOP 0
#define TA_BOTTOM 8
#define TA_BASELINE 24
#define TA_RTLREADING 256
#define TA_MASK (TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING)
 
COLORREF WINAPI SetTextColor(HDC, COLORREF);
COLORREF WINAPI SetBkColor(HDC, COLORREF);
int WINAPI SetBkMode(HDC, int);
UINT WINAPI SetTextAlign(HDC hdc, UINT fMode);
 
/* Binary raster ops*/
#define R2_BLACK (MWMODE_CLEAR+1) /* 0 */
#define R2_NOTMERGEPEN (MWMODE_NOR+1) /* DPon */
#define R2_MASKNOTPEN (MWMODE_ANDINVERTED+1) /* DPna */
#define R2_NOTCOPYPEN (MWMODE_COPYINVERTED+1) /* Pn */
#define R2_MASKPENNOT (MWMODE_ANDREVERSE+1) /* PDna */
#define R2_NOT (MWMODE_INVERT+1) /* Dn */
#define R2_XORPEN (MWMODE_XOR+1) /* DPx */
#define R2_NOTMASKPEN (MWMODE_NAND+1) /* DPan */
#define R2_MASKPEN (MWMODE_AND+1) /* DPa */
#define R2_NOTXORPEN (MWMODE_EQUIV+1) /* DPxn */
#define R2_NOP (MWMODE_NOOP+1) /* D */
#define R2_MERGENOTPEN (MWMODE_ORINVERTED+1) /* DPno */
#define R2_COPYPEN (MWMODE_COPY+1) /* P */
#define R2_MERGEPENNOT (MWMODE_ORREVERSE+1) /* PDno */
#define R2_MERGEPEN (MWMODE_OR+1) /* DPo */
#define R2_WHITE (MWMODE_SETTO1+1) /* 1 */
#define R2_LAST 16
 
int WINAPI SetROP2(HDC hdc, int fnDrawMode);
 
#define GDI_ERROR (0xFFFFFFFFL)
#define CLR_INVALID 0xFFFFFFFF
 
COLORREF WINAPI GetPixel(HDC hdc, int x, int y);
COLORREF WINAPI SetPixel(HDC hdc, int x, int y, COLORREF crColor);
BOOL WINAPI MoveToEx(HDC hdc, int x, int y, LPPOINT lpPoint);
BOOL WINAPI LineTo(HDC hdc, int x, int y);
BOOL WINAPI Polyline(HDC hdc, CONST POINT *lppt, int cPoints);
BOOL WINAPI PolyPolygon(HDC hdc, CONST POINT *lpPoints, LPINT lpPolyCounts,
int nCount);
BOOL WINAPI Rectangle(HDC hdc, int nLeft, int nTop, int nRight,int nBottom);
BOOL WINAPI Ellipse(HDC hdc, int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
BOOL WINAPI Arc(HDC hdc, int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect, int nXStartArc, int nYStartArc,
int nXEndArc, int nYEndArc);
BOOL WINAPI Pie(HDC hdc, int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect, int nXRadial1, int nYRadial1,
int nXRadial2, int nYRadial2);
BOOL WINAPI Polygon(HDC hdc, CONST POINT *lpPoints, int nCount);
int WINAPI FillRect(HDC hDC, CONST RECT *lprc, HBRUSH hbr);
 
/* ExTextOut options*/
#define ETO_OPAQUE 0x0002
#define ETO_CLIPPED 0x0004 /* nyi*/
 
BOOL WINAPI TextOut(HDC hdc, int x, int y, LPCSTR lpszString, int cbString);
BOOL WINAPI ExtTextOut(HDC hdc, int x, int y, UINT fuOptions,
CONST RECT *lprc, LPCSTR lpszString, UINT cbCount,
CONST INT *lpDx);
BOOL WINAPI ExtTextOutW(HDC hdc, int x, int y, UINT fuOptions,
CONST RECT *lprc, LPCWSTR lpszString, UINT cbCount,
CONST INT *lpDx);
 
/* DrawText options*/
#define DT_TOP 0x00000000
#define DT_LEFT 0x00000000
#define DT_CENTER 0x00000001
#define DT_RIGHT 0x00000002
#define DT_VCENTER 0x00000004
#define DT_BOTTOM 0x00000008
#define DT_WORDBREAK 0x00000010
#define DT_SINGLELINE 0x00000020
#define DT_EXPANDTABS 0x00000040
#define DT_TABSTOP 0x00000080
#define DT_NOCLIP 0x00000100
#define DT_EXTERNALLEADING 0x00000200
#define DT_CALCRECT 0x00000400
#define DT_NOPREFIX 0x00000800
#define DT_INTERNAL 0x00001000
#define DT_EDITCONTROL 0x00002000
#define DT_PATH_ELLIPSIS 0x00004000
#define DT_END_ELLIPSIS 0x00008000
#define DT_MODIFYSTRING 0x00010000
#define DT_RTLREADING 0x00020000
#define DT_WORD_ELLIPSIS 0x00040000
 
int WINAPI DrawTextA(HDC hdc, LPCSTR lpString, int nCount, LPRECT lpRect,
UINT uFormat);
int WINAPI DrawTextW(HDC hdc, LPCWSTR lpString, int nCount, LPRECT lpRect,
UINT uFormat);
#define DrawText DrawTextA
 
BOOL WINAPI DrawDIB(HDC hdc,int x, int y,PMWIMAGEHDR pimage); /* microwin*/
 
/* GetSysColor, FillRect colors*/
#define COLOR_SCROLLBAR 0
#define COLOR_BACKGROUND 1
#define COLOR_ACTIVECAPTION 2
#define COLOR_INACTIVECAPTION 3
#define COLOR_MENU 4
#define COLOR_WINDOW 5
#define COLOR_WINDOWFRAME 6
#define COLOR_MENUTEXT 7
#define COLOR_WINDOWTEXT 8
#define COLOR_CAPTIONTEXT 9
#define COLOR_ACTIVEBORDER 10
#define COLOR_INACTIVEBORDER 11
#define COLOR_APPWORKSPACE 12
#define COLOR_HIGHLIGHT 13
#define COLOR_HIGHLIGHTTEXT 14
#define COLOR_BTNFACE 15
#define COLOR_BTNSHADOW 16
#define COLOR_GRAYTEXT 17
#define COLOR_BTNTEXT 18
#define COLOR_INACTIVECAPTIONTEXT 19
#define COLOR_BTNHIGHLIGHT 20
#define COLOR_3DDKSHADOW 21
#define COLOR_3DLIGHT 22
#define COLOR_INFOTEXT 23
#define COLOR_INFOBK 24
#define COLOR_DESKTOP COLOR_BACKGROUND
#define COLOR_3DFACE COLOR_BTNFACE
#define COLOR_3DSHADOW COLOR_BTNSHADOW
#define COLOR_3DHIGHLIGHT COLOR_BTNHIGHLIGHT
#define COLOR_3DHILIGHT COLOR_BTNHIGHLIGHT
#define COLOR_BTNHILIGHT COLOR_BTNHIGHLIGHT
#define COLOR_ALTERNATEBUTTONFACE 25
#define COLOR_HOTLIGHT 26
#define COLOR_GRADIENTACTIVECAPTION 27
#define COLOR_GRADIENTINACTIVECAPTION 28
 
DWORD WINAPI GetSysColor(int nIndex);
COLORREF WINAPI SetSysColor(int nIndex, COLORREF crColor);/* Microwindows only*/
 
/* Stock Logical Objects */
#define WHITE_BRUSH 0
#define LTGRAY_BRUSH 1
#define GRAY_BRUSH 2
#define DKGRAY_BRUSH 3
#define BLACK_BRUSH 4
#define NULL_BRUSH 5
#define HOLLOW_BRUSH NULL_BRUSH
#define WHITE_PEN 6
#define BLACK_PEN 7
#define NULL_PEN 8
#define OEM_FIXED_FONT 10
#define ANSI_FIXED_FONT 11
#define ANSI_VAR_FONT 12
#define SYSTEM_FONT 13
#define DEVICE_DEFAULT_FONT 14
#define DEFAULT_PALETTE 15
#define SYSTEM_FIXED_FONT 16
#define DEFAULT_GUI_FONT 17
#define DC_BRUSH 18
#define DC_PEN 19
#define STOCK_LAST 19
 
/* Object types*/
#define OBJ_PEN 1
#define OBJ_BRUSH 2
#define OBJ_DC 3
#define OBJ_METADC 4
#define OBJ_PAL 5
#define OBJ_FONT 6
#define OBJ_BITMAP 7
#define OBJ_REGION 8
#define OBJ_METAFILE 9
#define OBJ_MEMDC 10
#define OBJ_EXTPEN 11
#define OBJ_ENHMETADC 12
#define OBJ_ENHMETAFILE 13
 
HGDIOBJ WINAPI GetStockObject(int nObject);
HGDIOBJ WINAPI SelectObject(HDC hdc, HGDIOBJ hObject);
BOOL WINAPI DeleteObject(HGDIOBJ hObject);
int WINAPI SelectClipRgn(HDC hdc, HRGN hrgn);
int WINAPI ExtSelectClipRgn(HDC hdc, HRGN hrgn, int fnMode);
int WINAPI GetUpdateRgn(HWND hwnd, HRGN hrgn, BOOL bErase);
BOOL WINAPI GetUpdateRect(HWND hwnd, LPRECT lpRect, BOOL bErase);
 
/* Brush Styles */
#define BS_SOLID 0
#define BS_NULL 1
#define BS_HOLLOW BS_NULL
 
HBRUSH WINAPI CreateSolidBrush(COLORREF crColor);
 
/* Pen Styles */
#define PS_SOLID 0
#define PS_NULL 5
 
HPEN WINAPI CreatePen(int nPenStyle, int nWidth, COLORREF crColor);
 
HBITMAP WINAPI CreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight);
HDC WINAPI CreateCompatibleDC(HDC hdc);
 
/* BitBlit raster opcodes*/
#define SRCCOPY (DWORD)MWROP_COPY /* source */
#define SRCPAINT (DWORD)MWROP_OR /* source OR dest */
#define SRCAND (DWORD)MWROP_AND /* source AND dest */
#define SRCINVERT (DWORD)MWROP_XOR /* source XOR dest */
#define SRCERASE (DWORD)MWROP_ANDREVERSE /* source AND (NOT dest ) */
#define NOTSRCCOPY (DWORD)MWROP_COPYINVERTED /* (NOT source) */
#define NOTSRCERASE (DWORD)MWROP_NOR /* (NOT src) AND (NOT dest) */
#define MERGEPAINT (DWORD)MWROP_ORINVERTED /* (NOT source) OR dest */
#define DSTINVERT (DWORD)MWROP_INVERT /* (NOT dest) */
#define BLACKNESS (DWORD)MWROP_CLEAR /* BLACK */
#define WHITENESS (DWORD)MWROP_SET /* WHITE */
#if 0
#define MERGECOPY (DWORD)0x00C000CA /* (source AND pattern) */
#define PATCOPY (DWORD)0x00F00021 /* pattern */
#define PATPAINT (DWORD)0x00FB0A09 /* DPSnoo */
#define PATINVERT (DWORD)0x005A0049 /* pattern XOR dest */
#endif
 
BOOL WINAPI BitBlt(HDC hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,
HDC hdcSrc,int nXSrc,int nYSrc,DWORD dwRop);
BOOL WINAPI StretchBlt(HDC hdcDest,int nXOriginDest,int nYOriginDest,
int nWidthDest,int nHeightDest,HDC hdcSrc,
int nXOriginSrc,int nYOriginSrc,int nWidthSrc,
int nHeightSrc, DWORD dwRop);
 
/* Palette entry flags*/
#define PC_RESERVED 0x01
#define PC_EXPLICIT 0x02
#define PC_NOCOLLAPSE 0x04
 
typedef struct tagPALETTEENTRY {
BYTE peRed;
BYTE peGreen;
BYTE peBlue;
BYTE peFlags;
} PALETTEENTRY, *PPALETTEENTRY, FAR *LPPALETTEENTRY;
 
UINT WINAPI GetSystemPaletteEntries(HDC hdc,UINT iStartIndex,UINT nEntries,
LPPALETTEENTRY lppe);
 
/* GetDeviceCaps parameters*/
#define HORZRES 8 /* Horizontal width in pixels */
#define VERTRES 10 /* Vertical height in pixels */
#define BITSPIXEL 12 /* Number of bits per pixel */
#define PLANES 14 /* Number of planes */
#define LOGPIXELSX 88 /* Logical pixels/inch in X */
#define LOGPIXELSY 90 /* Logical pixels/inch in Y */
#define SIZEPALETTE 104 /* Number of entries in physical palette */
 
int WINAPI GetDeviceCaps(HDC hdc, int nIndex);
 
/* Region flags*/
#define ERRORREGION MWREGION_ERROR
#define NULLREGION MWREGION_NULL
#define SIMPLEREGION MWREGION_SIMPLE
#define COMPLEXREGION MWREGION_COMPLEX
/* kluge for VxWorks*/
#ifdef ERROR
#undef ERROR
#endif
#define ERROR ERRORREGION
#define RGN_ERROR ERRORREGION
 
/* CombineRgn() Styles */
#define RGN_AND 1
#define RGN_OR 2
#define RGN_XOR 3
#define RGN_DIFF 4
#define RGN_COPY 5
#define RGN_MIN RGN_AND
#define RGN_MAX RGN_COPY
 
/* GetRegionData/ExtCreateRegion */
#define RDH_RECTANGLES 1
typedef struct _RGNDATAHEADER {
DWORD dwSize;
DWORD iType;
DWORD nCount;
DWORD nRgnSize;
RECT rcBound;
} RGNDATAHEADER, *PRGNDATAHEADER;
 
typedef struct _RGNDATA {
RGNDATAHEADER rdh;
char Buffer[1];
} RGNDATA, *PRGNDATA, *NPRGNDATA, *LPRGNDATA;
 
/* Region entry points*/
INT WINAPI OffsetRgn(HRGN hrgn, INT x, INT y );
INT WINAPI GetRgnBox(HRGN hrgn, LPRECT rect );
HRGN WINAPI CreateRectRgn(INT left, INT top, INT right, INT bottom);
HRGN WINAPI CreateRectRgnIndirect(const RECT* rect );
VOID WINAPI SetRectRgn(HRGN hrgn, INT left, INT top, INT right, INT bottom );
HRGN WINAPI CreateRoundRectRgn(INT left, INT top, INT right, INT bottom,
INT ellipse_width, INT ellipse_height );
HRGN WINAPI CreateEllipticRgn(INT left, INT top, INT right, INT bottom );
HRGN WINAPI CreateEllipticRgnIndirect(const RECT *rect );
DWORD WINAPI GetRegionData(HRGN hrgn, DWORD count, LPRGNDATA rgndata);
BOOL WINAPI PtInRegion(HRGN hrgn, INT x, INT y );
BOOL WINAPI RectInRegion(HRGN hrgn, const RECT *rect );
BOOL WINAPI EqualRgn(HRGN hrgn1, HRGN hrgn2 );
INT WINAPI CombineRgn(HRGN hDest, HRGN hSrc1, HRGN hSrc2, INT mode);
 
/* Rect entry points*/
BOOL WINAPI IntersectRect(LPRECT dest, const RECT *src1, const RECT *src2 );
BOOL WINAPI UnionRect(LPRECT dest, const RECT *src1, const RECT *src2 );
BOOL WINAPI EqualRect(const RECT* rect1, const RECT* rect2 );
BOOL WINAPI SubtractRect(LPRECT dest, const RECT *src1, const RECT *src2 );
 
/microwin/windowsx.h
0,0 → 1,55
#define HANDLE_WM_COMMAND(hwnd, wParam, lParam, fn) \
((fn)((hwnd), (int)(LOWORD(wParam)), (HWND)(lParam), (UINT)HIWORD(wParam)), 0L)
#define FORWARD_WM_COMMAND(hwnd, id, hwndCtl, codeNotify, fn) \
(void)(fn)((hwnd), WM_COMMAND, MAKEWPARAM((UINT)(id),(UINT)(codeNotify)), (LPARAM)(HWND)(hwndCtl))
 
#define HANDLE_WM_CREATE(hwnd, wParam, lParam, fn) \
((fn)((hwnd), (LPCREATESTRUCT)(lParam)) ? 0L : (LRESULT)-1L)
#define FORWARD_WM_CREATE(hwnd, lpCreateStruct, fn) \
(BOOL)(DWORD)(fn)((hwnd), WM_CREATE, 0L, (LPARAM)(LPCREATESTRUCT)(lpCreateStruct))
 
#define HANDLE_WM_DESTROY(hwnd, wParam, lParam, fn) \
((fn)(hwnd), 0L)
#define FORWARD_WM_DESTROY(hwnd, fn) \
(void)(fn)((hwnd), WM_DESTROY, 0L, 0L)
 
#define HANDLE_WM_ERASEBKGND(hwnd, wParam, lParam, fn) \
(LRESULT)(DWORD)(BOOL)(fn)((hwnd), (HDC)(wParam))
#define FORWARD_WM_ERASEBKGND(hwnd, hdc, fn) \
(BOOL)(DWORD)(fn)((hwnd), WM_ERASEBKGND, (WPARAM)(HDC)(hdc), 0L)
 
#define HANDLE_WM_LBUTTONDOWN(hwnd, wParam, lParam, fn) \
((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
#define FORWARD_WM_LBUTTONDOWN(hwnd, fDoubleClick, x, y, keyFlags, fn) \
(void)(fn)((hwnd), (fDoubleClick) ? WM_LBUTTONDBLCLK : WM_LBUTTONDOWN, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
 
#define HANDLE_WM_LBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
 
#define HANDLE_WM_LBUTTONUP(hwnd, wParam, lParam, fn) \
((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
#define FORWARD_WM_LBUTTONUP(hwnd, x, y, keyFlags, fn) \
(void)(fn)((hwnd), WM_LBUTTONUP, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
 
#define HANDLE_WM_MOUSEMOVE(hwnd, wParam, lParam, fn) \
((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
#define FORWARD_WM_MOUSEMOVE(hwnd, x, y, keyFlags, fn) \
(void)(fn)((hwnd), WM_MOUSEMOVE, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
 
#define HANDLE_WM_SETFOCUS(hwnd, wParam, lParam, fn) \
((fn)((hwnd), (HWND)(wParam)), 0L)
#define FORWARD_WM_SETFOCUS(hwnd, hwndOldFocus, fn) \
(void)(fn)((hwnd), WM_SETFOCUS, (WPARAM)(HWND)(hwndOldFocus), 0L)
 
#define HANDLE_WM_KILLFOCUS(hwnd, wParam, lParam, fn) \
((fn)((hwnd), (HWND)(wParam)), 0L)
#define FORWARD_WM_KILLFOCUS(hwnd, hwndNewFocus, fn) \
(void)(fn)((hwnd), WM_KILLFOCUS, (WPARAM)(HWND)(hwndNewFocus), 0L)
 
#define HANDLE_WM_SETTEXT(hwnd, wParam, lParam, fn) \
((fn)((hwnd), (LPCTSTR)(lParam)), 0L)
#define FORWARD_WM_SETTEXT(hwnd, lpszText, fn) \
(void)(fn)((hwnd), WM_SETTEXT, 0L, (LPARAM)(LPCTSTR)(lpszText))
 
#define HANDLE_MSG(hwnd, message, fn) \
case (message): return HANDLE_##message((hwnd), (wParam), (lParam), (fn))
/microwin/winfont.h
0,0 → 1,156
/* winfont.h*/
/*
* Copyright (c) 2000 Greg Haerr <greg@censoft.com>
*
* Win32 font structures and API
*/
 
/* tmPitchAndFamily flags*/
#define TMPF_FIXED_PITCH 0x01 /* win32 bug: means variable*/
#define TMPF_VECTOR 0x02
#define TMPF_TRUETYPE 0x04
#define TMPF_DEVICE 0x08
 
typedef struct tagTEXTMETRIC {
LONG tmHeight;
LONG tmAscent;
LONG tmDescent;
LONG tmInternalLeading;
LONG tmExternalLeading;
LONG tmAveCharWidth;
LONG tmMaxCharWidth;
LONG tmWeight;
LONG tmOverhang;
LONG tmDigitizedAspectX;
LONG tmDigitizedAspectY;
BYTE tmFirstChar;
BYTE tmLastChar;
BYTE tmDefaultChar;
BYTE tmBreakChar;
BYTE tmItalic;
BYTE tmUnderlined;
BYTE tmStruckOut;
BYTE tmPitchAndFamily;
BYTE tmCharSet;
} TEXTMETRIC, *PTEXTMETRIC, NEAR *NPTEXTMETRIC, FAR *LPTEXTMETRIC;
 
BOOL WINAPI GetTextMetrics(HDC hdc, LPTEXTMETRIC lptm);
BOOL WINAPI GetCharWidth(HDC hdc,UINT iFirstChar,UINT iLastChar,LPINT lpBuffer);
BOOL WINAPI GetTextExtentPoint(HDC hdc,LPCTSTR lpszStr,int cchString,
LPSIZE lpSize);
BOOL WINAPI GetTextExtentExPoint(HDC hdc,LPCTSTR lpszStr,int cchString,
int nMaxExtent,LPINT lpnFit,LPINT alpDx,LPSIZE lpSize);
 
/* inherit logical font descriptor from engine*/
 
typedef struct {
LONG lfHeight; /* desired height in pixels*/
LONG lfWidth; /* desired width in pixels or 0*/
LONG lfEscapement; /* rotation in tenths of degree*/
LONG lfOrientation; /* not used*/
LONG lfWeight; /* font weight*/
BYTE lfItalic; /* =1 for italic*/
BYTE lfUnderline; /* =1 for underline*/
BYTE lfStrikeOut; /* not used*/
BYTE lfCharSet; /* font character set*/
BYTE lfOutPrecision; /* font type selection*/
BYTE lfClipPrecision; /* not used*/
BYTE lfQuality; /* not used*/
BYTE lfPitchAndFamily; /* font pitch and family*/
CHAR lfFaceName[MWLF_FACESIZE]; /* font name, may be aliased*/
} LOGFONT, *PLOGFONT, NEAR *NPLOGFONT, FAR *LPLOGFONT;
 
#define LF_FACESIZE MWLF_FACESIZE
 
/* font weights*/
#define FW_DONTCARE MWLF_WEIGHT_DEFAULT
#define FW_THIN MWLF_WEIGHT_THIN
#define FW_EXTRALIGHT MWLF_WEIGHT_EXTRALIGHT
#define FW_LIGHT MWLF_WEIGHT_LIGHT
#define FW_NORMAL MWLF_WEIGHT_NORMAL
#define FW_MEDIUM MWLF_WEIGHT_MEDIUM
#define FW_SEMIBOLD MWLF_WEIGHT_DEMIBOLD
#define FW_BOLD MWLF_WEIGHT_BOLD
#define FW_EXTRABOLD MWLF_WEIGHT_EXTRABOLD
#define FW_HEAVY MWLF_WEIGHT_BLACK
#define FW_ULTRALIGHT FW_EXTRALIGHT
#define FW_REGULAR FW_NORMAL
#define FW_DEMIBOLD FW_SEMIBOLD
#define FW_ULTRABOLD FW_EXTRABOLD
#define FW_BLACK FW_HEAVY
 
/* output precision - used for font selection*/
#define OUT_DEFAULT_PRECIS MWLF_TYPE_DEFAULT
#define OUT_STRING_PRECIS 1
#define OUT_CHARACTER_PRECIS 2
#define OUT_STROKE_PRECIS 3
#define OUT_TT_PRECIS MWLF_TYPE_SCALED
#define OUT_DEVICE_PRECIS MFLF_TYPE_RASTER
#define OUT_RASTER_PRECIS MFLF_TYPE_RASTER
#define OUT_TT_ONLY_PRECIS MWLF_TYPE_TRUETYPE
#define OUT_OUTLINE_PRECIS 8
#define OUT_SCREEN_OUTLINE_PRECIS 9
 
/* clip precision - unused*/
#define CLIP_DEFAULT_PRECIS 0
#define CLIP_CHARACTER_PRECIS 1
#define CLIP_STROKE_PRECIS 2
#define CLIP_MASK 0xf
#define CLIP_LH_ANGLES (1<<4)
#define CLIP_TT_ALWAYS (2<<4)
#define CLIP_EMBEDDED (8<<4)
 
/* output quality - unused*/
#define DEFAULT_QUALITY 0
#define DRAFT_QUALITY 1
#define PROOF_QUALITY 2
#define NONANTIALIASED_QUALITY 3
#define ANTIALIASED_QUALITY 4
 
/* font charset*/
#define ANSI_CHARSET MWLF_CHARSET_ANSI
#define DEFAULT_CHARSET MWLF_CHARSET_DEFAULT
#define SYMBOL_CHARSET 2
#define OEM_CHARSET MWLF_CHARSET_OEM
 
/* font pitch - lfPitchAndFamily*/
#define MWLF_PITCH_DEFAULT 0 /* any pitch*/
#define MWLF_PITCH_FIXED 1 /* fixed pitch*/
#define MWLF_PITCH_VARIABLE 2 /* variable pitch*/
 
/* font pitch*/
#define DEFAULT_PITCH MWLF_PITCH_DEFAULT
#define FIXED_PITCH MWLF_PITCH_FIXED
#define VARIABLE_PITCH MWLF_PITCH_VARIABLE
#define MONO_FONT 8
 
/*
* font family - lfPitchAndFamily
*
* MWF_FAMILY_SERIF - Times Roman, Century Schoolbook
* MWF_FAMILY_SANSSERIF - Helvetica, Swiss
* MWF_FAMILY_MODERN - Pica, Elite, Courier
*/
#define MWLF_FAMILY_DEFAULT (0<<4) /* any family*/
#define MWLF_FAMILY_SERIF (1<<4) /* variable stroke width, serif*/
#define MWLF_FAMILY_SANSSERIF (2<<4) /* variable stroke width, sans-serif*/
#define MWLF_FAMILY_MODERN (3<<4) /* constant stroke width*/
 
/* add definitions here for font mapper extensions*/
#define MWLF_FAMILY_BITSTREAM (6<<4) /* bitstream*/
#define MWLF_FAMILY_ADOBE (7<<4) /* adobe*/
 
/* font family*/
#define FF_DONTCARE MWLF_FAMILY_DEFAULT
#define FF_ROMAN MWLF_FAMILY_SERIF
#define FF_SWISS MWLF_FAMILY_SANSSERIF
#define FF_MODERN MWLF_FAMILY_MODERN
#define FF_SCRIPT (4<<4) /* Cursive, etc. */
#define FF_DECORATIVE (5<<4) /* Old English, etc. */
 
HFONT WINAPI CreateFont(int nHeight, int nWidth, int nEscapement,
int nOrientation, int fnWeight, DWORD fdwItalic,
DWORD fdwUnderline, DWORD fdwStrikeOut,DWORD fdwCharSet,
DWORD fdwOutputPrecision,DWORD fdwClipPrecision,
DWORD fdwQuality, DWORD fdwPitchAndFamily, LPCSTR lpszFace);
HFONT WINAPI CreateFontIndirect(CONST LOGFONT *lplf);
/microwin/wintern.h
0,0 → 1,134
/* wintern.h*/
/*
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
*
* Microwindows internal routines header file
*/
#include <string.h>
 
#if (UNIX | DOS_DJGPP)
#define strcmpi strcasecmp
#elif (VXWORKS)
int strcmpi(const char *s1, const char *s2);
#endif
 
#ifdef __PACIFIC__
#define strcmpi stricmp
#endif
 
#define DBLCLICKSPEED 750 /* mouse dblclik speed msecs (was 450)*/
 
/* gotPaintMsg values*/
#define PAINT_PAINTED 0 /* WM_PAINT msg has been processed*/
#define PAINT_NEEDSPAINT 1 /* WM_PAINT seen, paint when can*/
#define PAINT_DELAYPAINT 2 /* WM_PAINT seen,paint after user move*/
 
/* non-win32 api access for microwin*/
BOOL MwSetDesktopWallpaper(PMWIMAGEHDR pImage);
void MwRegisterFdInput(HWND hwnd,int fd);
void MwUnregisterFdInput(HWND hwnd,int fd);
void MwRegisterFdOutput(HWND hwnd,int fd);
void MwUnregisterFdOutput(HWND hwnd,int fd);
void MwRegisterFdExcept(HWND hwnd,int fd);
void MwUnregisterFdExcept(HWND hwnd,int fd);
 
/* internal routines*/
 
/* winuser.c*/
PWNDCLASS MwFindClassByName(LPCSTR lpClassName);
void MwDestroyWindow(HWND hwnd,BOOL bSendMsg);
HWND MwGetTopWindow(HWND hwnd);
void MwCalcClientRect(HWND hwnd);
void MwSendSizeMove(HWND hwnd, BOOL bSize, BOOL bMove);
void MwSetCursor(HWND wp, PMWCURSOR pcursor);
 
/* wingdi.c*/
#define MwIsClientDC(hdc) (((hdc)->flags & DCX_WINDOW) == 0)
#define MwIsMemDC(hdc) ((hdc)->psd->flags == PSF_MEMORY)
void MwPaintNCArea(HWND hwnd);
HWND MwPrepareDC(HDC hdc);
void MwSetClipWindow(HDC hdc);
 
/* winsbar.c*/
void MwAdjustNCScrollbars(HWND hwnd);
void MwPaintNCScrollbars(HWND hwnd, HDC hdc);
void MwHandleNCMessageScrollbar(HWND hwnd, UINT msg, WPARAM hitcode,
LPARAM lParam);
 
/* winexpos.c*/
void MwRedrawScreen(void);
void MwHideWindow(HWND hwnd,BOOL bChangeFocus,BOOL bSendMsg);
void MwShowWindow(HWND hwnd,BOOL bSendMsg);
void MwRaiseWindow(HWND hwnd);
void MwLowerWindow(HWND hwnd);
BOOL MwCheckOverlap(HWND topwp, HWND botwp);
void MwClearWindow(HWND wp,MWCOORD x,MWCOORD y,MWCOORD width,
MWCOORD height,BOOL exposeflag);
void MwExposeArea(HWND wp, MWCOORD rootx,MWCOORD rooty,
MWCOORD width,MWCOORD height);
/* winevent.c*/
BOOL MwCheckMouseEvent(void);
BOOL MwCheckKeyboardEvent(void);
void MwHandleMouseStatus(MWCOORD newx, MWCOORD newy, int newbuttons);
void MwTranslateMouseMessage(HWND hwnd,UINT msg,int hittest);
void MwDeliverMouseEvent(int buttons, int changebuttons,
MWKEYMOD modifiers);
void MwDeliverKeyboardEvent(MWKEY keyvalue, MWKEYMOD modifiers,
MWSCANCODE scancode, BOOL pressed);
void MwDeliverExposureEvent(HWND wp, MWCOORD x, MWCOORD y,
MWCOORD width,MWCOORD height);
void MwUnionUpdateRegion(HWND wp, MWCOORD x, MWCOORD y,
MWCOORD width,MWCOORD height, BOOL bUnion);
void MwMoveCursor(MWCOORD x, MWCOORD y);
void MwCheckCursor(void);
HWND MwFindVisibleWindow(MWCOORD x, MWCOORD y);
void MwCheckMouseWindow(void);
int strzcpy(char *dst,const char *src,int dstsiz);
 
/* winuser.c*/
extern int mwSYSMETRICS_CYCAPTION;
extern int mwSYSMETRICS_CXBORDER;
extern int mwSYSMETRICS_CYBORDER;
extern int mwSYSMETRICS_CXFRAME;
extern int mwSYSMETRICS_CYFRAME;
extern int mwSYSMETRICS_CXDOUBLECLK;
extern int mwSYSMETRICS_CYDOUBLECLK;
extern int mwSYSMETRICS_CYHSCROLL;
extern int mwSYSMETRICS_CXHSCROLL;
extern int mwSYSMETRICS_CXVSCROLL;
extern int mwSYSMETRICS_CYVSCROLL;
 
/* wingdi.c*/
extern BOOL mwERASEMOVE; /* default repaint algorithm*/
 
/* winmain.c*/
int MwOpen(void);
void MwClose(void);
void MwSelect(void);
int MwInitialize(void);
void MwTerminate(void);
extern HWND listwp; /* list of all windows */
extern HWND rootwp; /* root window pointer */
extern HWND focuswp; /* focus window for keyboard */
extern HWND mousewp; /* window mouse is currently in */
extern HWND capturewp; /* capture window*/
extern HWND dragwp; /* window user is dragging*/
extern HCURSOR curcursor; /* currently enabled cursor */
extern MWCOORD cursorx; /* x position of cursor */
extern MWCOORD cursory; /* y position of cursor */
extern MWSCREENINFO sinfo; /* screen information */
extern DWORD startTicks; /* tickcount on startup */
extern int mwpaintNC; /* experimental nonclient regions*/
extern BOOL mwforceNCpaint; /* force NC paint for alphablend*/
 
#if VTSWITCH
/* temp framebuffer vt switch stuff at upper level
* this should be handled at the lower level, just like vgalib does.
*/
void MwInitVt(void);
int MwCurrentVt(void);
int MwCheckVtChange(void);
void MwRedrawVt(int t);
void MwExitVt(void);
extern int mwvterm;
#endif /* VTSWITCH*/
/microwin/graph3d.h
0,0 → 1,47
/*
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
*
* 3D Graphics Library for Micro-Windows
*/
 
#ifndef _GRAPH3D_H_
#define _GRAPH3D_H_
 
#include <math.h>
 
#define pi 3.1415926535
#define epsilon 0.000001
#define MAXPOLY 32 /* max polygon points*/
 
typedef FLOAT vec1;
 
typedef struct {
FLOAT x, y;
} vec2;
 
typedef struct {
FLOAT x, y, z;
} vec3;
 
/* entry points*/
void init3(HDC hDC,HWND hwndmem);
void paint3(HDC hDC);
void setcolor3(MWCOLORVAL c);
void moveto3(vec2 pt);
void lineto3(vec2 pt);
void polyfill(int n, vec2 points[]);
void square(void);
void circle3(vec1 r);
void daisy(vec1 r,int points);
void rose(vec1 r,int levels,int points);
void triangle(vec2 v0, vec2 v1, vec2 v2);
void quadrilateral(vec2 v0, vec2 v1, vec2 v2, vec2 v3);
void look3(vec1 x, vec1 y, vec1 z);
void drawgrid(vec1 xmin, vec1 xmax, int nx, vec1 zmin, vec1 zmax, int nz);
void scale3(vec1 sx, vec1 sy, vec1 sz, double A[][5]);
void tran3(vec1 tx, vec1 ty, vec1 tz, double A[][5]);
void rot3(int m, vec1 theta, double A[][5]);
void mult3(double A[][5], double B[][5], double C[][5]);
void findQ(void);
 
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.