📄 engine.h
字号:
/*
*******************************************************************************
* The views manager engine *
* Copyright 2005 taowentao, allrights reserved. *
* File : Engine.h *
* By : taowentao 2006-09-02, 2007-05-12 *
*******************************************************************************
*/
#if !defined(ENGINE_H)
#define ENGINE_H
#if !defined(MCCLIB_H)
#include "giCell\Engine\mcCLib.h"
#endif
/*
*******************************************************************************
* *
*******************************************************************************
*/
#define GD_BLACK (0x00000000L)
#define GD_BLUE (0x00FF0000L)
#define GD_GREEN (0x0000ff00L)
#define GD_CYAN (0x00ffff00L)
#define GD_RED (0x000000FFL)
#define GD_MAGENTA (0x008b008bL)
#define GD_BROWN (0x002a2aa5L)
#define GD_DARKGRAY (0x00404040L)
#define GD_GRAY (0x00808080L)
#define GD_LIGHTGRAY (0x00d3d3d3L)
#define GD_LIGHTBLUE (0x00ff8080L)
#define GD_LIGHTGREEN (0x0080ff80L)
#define GD_LIGHTCYAN (0x0080ffffL)
#define GD_LIGHTRED (0x008080ffL)
#define GD_LIGHTMAGENTA (0x00ff80ffL)
#define GD_YELLOW (0x0000ffffL)
#define GD_WHITE (0x00ffffffL)
#define GD_TRANS (1) /* 透明模式 : 无填充内容 */
#define GD_SOLID (0) /* 实体模式 : 按要求填充 */
/*
*******************************************************************************
* *
*******************************************************************************
*/
/* 鼠标光标类型 */
#define ARROW (0)
#define SIZE_V (1)
#define SIZE_H (2)
#define SIZE_HV45 (3)
#define SIZE_HV135 (4)
#define MOVE (5)
#define TEXT (6)
/*
*******************************************************************************
* *
*******************************************************************************
*/
struct _rect {
int left;
int top;
int right;
int bottom;
};
typedef struct _rect RECT;
struct _residue
{
int rcNum;
RECT rect[4];
};
typedef struct _residue RESIDUE;
/*
*******************************************************************************
* *
*******************************************************************************
*/
struct _point {
int x;
int y;
};
typedef struct _point POINT;
/******************************************************************************/
struct _cell {
void *pPrev;
void *pNext;
};
typedef struct _cell CELL;
/******************************************************************************/
struct _list {
void *pFirst;
void *pLast;
};
typedef struct _list LIST;
/*
*******************************************************************************
* *
*******************************************************************************
*/
#define VS_RESIZABLE (0x01)
#define VS_STAYONTOP (0x02)
#define VS_HASTRANS (0x04)
#define VS_SHOWVIEW (0x08)
#define VS_VISIBLE (0x10)
#define VS_MOVABLE (0x20)
#define VS_FORMVIEW (0x40)
#define VMSG_PAINT (0x0001)
#define VMSG_TOUCH (0x0002)
/******************************************************************************/
typedef struct _view* PVIEW;
typedef DWORD COLOR;
struct _vmsg {
PVIEW pView; /* destination view */
CWORD MsgID; /* view message ID */
DWORD vParam; /* view message param */
DWORD lParam; /* long message param */
DWORD time; /* timer ... */
POINT pt; /* point ... */
};
typedef struct _vmsg VMSG;
typedef void (_cdecl_ *PCURSORFUN)(void);
typedef CBOOL (_cdecl_ *PVIEWFUN)(VMSG *pMsg); /* pointer to view's procedure */
/******************************************************************************/
struct _view {
RECT viewRect; /* view rect, all inside */
RECT paintRect; /* invalid rect for paint */
CELL ZOrder; /* this is the "Z" order */
PVIEW pParent; /* point to parent view */
LIST ctrlList; /* list of children views */
PVIEWFUN pViewProc; /* msg processing function */
WORD wdStatus; /* view status */
};
typedef struct _view VIEW;
#define OBJ_FROM_VIEW(p) ((void *)(((VIEW *)(p))+1))
#define VIEW_FROM_OBJ(p) ((VIEW *)(((VIEW *)(p))-1))
/*
*******************************************************************************
* *
*******************************************************************************
*/
struct _gdc {
int width, height;
int BytesPerLine;
BYTE *pMem;
};
typedef struct _gdc GDC;
/*
*******************************************************************************
* *
*******************************************************************************
*/
/* 内存分配和释放 */
void * _cdecl_ GUIAlloc(size_t Size);
void _cdecl_ GUIFree(void *pMem);
/*
*******************************************************************************
* *
*******************************************************************************
*/
/* 锁定函数,用于和GUI引擎实现数据同步 */
void _cdecl_ GUILock(void);
void _cdecl_ GUIUnLock(void);
void _cdecl_ GUIInitEngine(void);
/*
*******************************************************************************
* *
*******************************************************************************
*/
/* 视口管理函数 */
void _cdecl_ SetMouseCursor(const int cs_id);
void _cdecl_ RepaintRect(const RECT *pRect);
const VIEW * _cdecl_ GetFormView(VIEW *pView);
CBOOL _cdecl_ IsFormView(VIEW *pView);
void _cdecl_ SetTopView(VIEW *pView);
CWORD _cdecl_ SendViewMsg(VIEW *pView, VMSG *pMsg);
void _cdecl_ UpdateViewRect(VIEW *pView, const RECT *pRect);
void _cdecl_ UpdateView(VIEW *pView);
void _cdecl_ ShowView(VIEW *pView);
CBOOL _cdecl_ IsViewVisible(VIEW *pView);
void _cdecl_ SetViewVisible(VIEW *pView, const CBOOL setVisible);
void _cdecl_ SetViewStayOnTop(VIEW *pView, const CBOOL setStayOnTop);
void _cdecl_ SetViewTrans(VIEW *pView, const CBOOL setTrans);
void _cdecl_ HideView(VIEW *pView);
VIEW* _cdecl_ GetScreenView(void);
VIEW* _cdecl_ GetActiveView(void);
void _cdecl_ InitChildView(VIEW *pView, int left, int top, int width, int height,
VIEW *pParent, WORD Style, PVIEWFUN pViewFun);
VIEW* _cdecl_ CreateSubView(int left, int top, int width, int height, VIEW *pParent,
WORD Style, PVIEWFUN pViewFun, CWORD nBytes);
VIEW* _cdecl_ CreateView(int left, int top, int width, int height,
WORD Style, PVIEWFUN pViewFun, CWORD nBytes);
void _cdecl_ DeleteView(VIEW *pView);
void _cdecl_ MoveView(VIEW *pView, const int dx, const int dy);
void _cdecl_ MoveViewTo(VIEW *pView, int x, int y);
void _cdecl_ MoveAllChildViews(VIEW *pView, const int dx, const int dy);
void _cdecl_ MergeAllChildViewsRect(VIEW *pView, RECT *pRect);
void _cdecl_ ResizeView(VIEW *pView, const int dx, const int dy);
void _cdecl_ SetViewSize(VIEW *pView, const int xSize, const int ySize);
void _cdecl_ SetViewRectOffset(VIEW *pView, int dx, int dy, int dxSize, int dySize);
void _cdecl_ SetViewRect(VIEW *pView, int left, int top, int xSize, int ySize);
/*
*******************************************************************************
* *
*******************************************************************************
*/
VIEW* _cdecl_ GetTopestViewOfPoint(const int x, const int y);
void _cdecl_ SetScreenColor(const COLOR clr);
/*
*******************************************************************************
* *
*******************************************************************************
*/
/* 区域管理函数 */
CBOOL _cdecl_ IsInRect(const int x, const int y, const RECT* pRect);
void _cdecl_ MoveRect(RECT *pRect, const int dx, const int dy);
void _cdecl_ MoveRectTo(RECT *pRect, const int x, const int y);
CBOOL _cdecl_ IsValidRect(const RECT* pRect);
CBOOL _cdecl_ RectsDoIntersect(const RECT* psrc1, const RECT* psrc2);
CBOOL _cdecl_ GetIntersectRect(RECT* psrc1, const RECT* psrc2);
CBOOL _cdecl_ GetIntersectRects(RECT* pdrc, const RECT* psrc1, const RECT* psrc2);
void _cdecl_ MergeRect(RECT* pdrc, const RECT* psrc1, const RECT* psrc2);
void _cdecl_ ResidueRects(RESIDUE* pResRng, const RECT* pAll, const RECT* PSub);
/*
*******************************************************************************
* *
*******************************************************************************
*/
/* 图形设备及其区域管理函数 */
CBOOL _cdecl_ SetClipRect(const RECT *pRect);
CBOOL _cdecl_ SetPartClipRect(RECT *pPart);
void _cdecl_ RestoreClipRect(const RECT *pSave);
const RECT * _cdecl_ GetClipRect(void);
void _cdecl_ SetDrawMode(CWORD cwMode);
void _cdecl_ GetScreenRect(RECT *pRect);
#define GetRect GetScreenRect
CWORD _cdecl_ GetWidth(void);
CWORD _cdecl_ GetHeight(void);
CWORD _cdecl_ GetBPP(void);
DWORD _cdecl_ GetColor(COLOR clr);
void _cdecl_ DrawLine(int x0, int y0, int x1, int y1, COLOR clr);
void _cdecl_ DrawHLine(int y, int x0, int x1, COLOR clr);
void _cdecl_ DrawVLine(int x, int y0, int y1, COLOR clr);
void _cdecl_ SetPixel(int x, int y, COLOR clr);
void _cdecl_ XorPixel(int x, int y, COLOR clr);
DWORD _cdecl_ GetPixel(int x, int y);
void _cdecl_ DrawRect(RECT *pRect, COLOR clr);
void _cdecl_ FillRect(RECT *pRect, COLOR clr);
void _cdecl_ FillRectColor2(RECT *pRect, COLOR clr1, COLOR clr2);
void _cdecl_ DrawMatrix(int left, int top, int xsize, int ysize,
const BYTE *pPixel, COLOR clr);
/* 特定图形设备相关函数 */
void _cdecl_ DrawGDCHLine(GDC *pGdc, int y, int left, int right, COLOR clr);
void _cdecl_ DrawGDCVLine(GDC *pGdc, int x, int top, int bottom, COLOR clr);
void _cdecl_ DrawGDCLine(GDC *pGdc, int x0, int y0, int x1, int y1, COLOR clr);
void _cdecl_ DrawGDCMatrix(GDC *pGdc, int left, int top, int xsize,
int ysize, const BYTE *pPixel, COLOR clr);
const GDC * _cdecl_ CreateGDC(int width, int height);
CBOOL _cdecl_ GetGDCPixel(GDC *pGdc, int x, int y, COLOR *clr);
void _cdecl_ SetGDCPixel(GDC *pGdc, int x, int y, COLOR c);
void _cdecl_ GDCToScreen(GDC *pGdc, const POINT *org, const RECT *rect);
void _cdecl_ DrawGDCText(GDC *pGdc, const int x, const int y, const BYTE *s, COLOR clr);
/*
*******************************************************************************
* *
*******************************************************************************
*/
/* 英文字符串函数 */
void _cdecl_ DrawText(const int x, const int y , const BYTE *s, COLOR clr);
CWORD _cdecl_ TextWidth(const BYTE *s);
CWORD _cdecl_ TextHeight(const BYTE *s);
CWORD _cdecl_ CharWidth(const BYTE s);
CWORD _cdecl_ CharHeight(const BYTE s);
/*
*******************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -