📄 nano-x.h
字号:
#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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -