⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guimsg.h

📁 基于NuCleus操作系统下的一个GUI界面
💻 H
字号:
#ifndef __GUIMSG
#define  __GUIMSG

#include "sys\types.h"
#include  "..\NUCLEUS\mcf5307.h"

#ifndef NULL
#define NULL	0
#endif
typedef int BOOL;
#ifndef FALSE    
	#define FALSE       0
#endif
#ifndef TRUE    
	#define TRUE        1
#endif

#ifndef  BMPW
	#define BMPW	14
#endif
#ifndef  BMPH
	#define BMPH		7
#endif

#define  MAXH_DEVICE   22

#define 	FontsW		16//字体大小

#define	GUI_FOCUS_GAP		2
#define	GUI_WINCONTROL_SHAPE		2
#define	MSG_MAX		40
//定义文字对齐方式
#define	GT_CENTER		0x01
#define	GT_LEFT			0x02
//定义系统消息
#define   GMSG_SYS_CLASS	0x10
#define	GMSG_UPDATE	(0x01+GMSG_SYS_CLASS)
#define	GMSG_TIMER		(0x02+GMSG_SYS_CLASS)


#define    GMSG_KEY_CLASS  0x40
#define	GMSG_KEY_F1	(0x01+GMSG_KEY_CLASS)
#define	GMSG_KEY_F2	(0x02+GMSG_KEY_CLASS)
#define	GMSG_KEY_F3	(0x03+GMSG_KEY_CLASS)
#define	GMSG_KEY_F4	(0x04+GMSG_KEY_CLASS)
#define	GMSG_KEY_F5	(0x05+GMSG_KEY_CLASS)
#define	GMSG_KEY_F6	(0x06+GMSG_KEY_CLASS)
#define	GMSG_KEY_F7	(0x07+GMSG_KEY_CLASS)
#define	GMSG_KEY_F8       (0x08+GMSG_KEY_CLASS)



//定义已被废弃的消息
#define	GMSG_DISCARD_CLASS	0x80
#define	GMSG_DISCARD_KEY_F1	(0x01+GMSG_DISCARD_CLASS)
#define	GMSG_DISCARD_KEY_F2	(0x02+GMSG_DISCARD_CLASS)
#define	GMSG_DISCARD_KEY_F3	(0x03+GMSG_DISCARD_CLASS)
#define	GMSG_DISCARD_KEY_F4	(0x04+GMSG_DISCARD_CLASS)
#define	GMSG_DISCARD_KEY_F5	(0x05+GMSG_DISCARD_CLASS)
#define	GMSG_DISCARD_KEY_F6	(0x06+GMSG_DISCARD_CLASS)
#define	GMSG_DISCARD_KEY_F7	(0x07+GMSG_DISCARD_CLASS)

//定义系统错误消息,GUI_SUCCESS为成功消息
#define	GUI_SUCCESS			0
#define	ERR_CLASS				0x200
#define	ERR_MSGINPUTQ_FULL	(0x01+ERR_CLASS)
#define	ERR_MSGINPUTQ_EMPTY	(0x02+ERR_CLASS)

#define	ERR_MSGLCD_FULL		(0x03+ERR_CLASS)
#define	ERR_MSGLCD_EMPTY		(0x04+ERR_CLASS)

#define	ERR_POINTER_EMPTY		(0x10+ERR_CLASS)
#define	ERR_OVER_RANGE			(0x11+ERR_CLASS)

//定义屏幕宽度和高度
#ifndef    SCR_WIDTH
  #define	SCR_WIDTH		800	
#endif
#ifndef    SCR_HEIGHT
  #define	SCR_HEIGHT		600
#endif

//定义控件(GuiWinControl)类型
#define	GWC_CLASS			0x100
#define	GWC_BUTTON		(0x01+GWC_CLASS)
#define	GWC_TEXT			(0x02+GWC_CLASS)
#define	GWC_EDIT			(0x03+GWC_CLASS)
//以下两个为Edit控件的子类
#define	GWC_INT_EDIT		(0x04+GWC_CLASS)
#define	GWC_FLOAT_EDIT		(0x05+GWC_CLASS)	
//定义两个直线控件
#define	GWC_HLINE			(0x06+GWC_CLASS)
#define	GWC_VLINE			(0x07+GWC_CLASS)   // 可以定义一个实心矩形
#define    GWC_BMP                      (0x08+GWC_CLASS)
#define    GWC_CIRCLE			(0x09+GWC_CLASS)
#define    GWC_RES		  	(0x0a+GWC_CLASS)
#define	GWC_GROUP			(0x14+GWC_CLASS)  //group box
#define	GWC_PROGRESS		(0x15+GWC_CLASS)

//默认BODCOM和GWC_BODCOM_MONITOR控件宽度为MAXH_DEVICE*BMPW,高度为3*BMPW
#define	GWC_BODCOM		(0x16+GWC_CLASS)
#define	GWC_BODCOM_MONITOR		(0x17+GWC_CLASS)
#define	GWC_SORT_TEXT		(0x18+GWC_CLASS)

#define   GWC_LINE	(0x19+GWC_CLASS)
#define   GWC_HOOK	(0x1A+GWC_CLASS)
#define   GWC_CIRCLE_ALL  (0x1B+GWC_CLASS)
#define   GWC_RECT 	(0x1C+GWC_CLASS)
//定义控件的一些属性
#define	PROGRESS_MAXLEN	1000

//定义表单类型
#define	GF_FORM			0x150
#define	GF_COMMON			(0x01+GF_FORM)
#define	GF_NOT_SWITCH		(0x02+GF_FORM)//不可切换窗口



//定义颜色结构
typedef	struct	S_RGB
{
	BYTE	R;
	BYTE	G;
	BYTE	B;
} RGB;

#define rgbEdge  	{0,0,0}
#define rgbBlack     {0,0,0}
#define rgbWhite    {0xff,0xff,0xff}
#define rgbFormBk {0xff,0xff,0xff}
#define rgbRed     {0x1f,0x00,0x00}
#define rgbGreen {0x00,0x20,0x00}
//#define rgbGreen {0x00,0x3f,0x00}
#define rgbBlue    {0x00,0x00,0x1f}
#define rgblightBlue    {0x00,0xff,0x1f}
#define rgbYellow {0x15,0x20,0x00}
#define rgbPurple    {182 ,88 ,157}

//#define rgbYellow {0x15,0x20,0x00}
#define ALLREVERSE 1000

extern RGB  RGB_LightBlue ;

//#define rgbYellow {0x1f,0x3f,0x00}

/*
#define rgbRed     {0x1f,0x00,0x00}
#define rgbGreen {0x00,0x3f,0x00}
#define rgbBlue    {0x00,0x00,0x1f}
#define rgbYellow {0x1f,0x3f,0x00}*/


typedef struct  SG_WINCONTROL
{
	char		name[12];
	unsigned  int		type;
	uint		left;
	uint		top;
	uint		width;
	uint		height;

	char		text[100];//modified by zzm
	BOOL	canFocus;
	BOOL	visibled;
	int		tag;
	RGB		backcolor;

	//文本对齐方式--GT_CENTER、GT_LEFT
	uint		alligntype;
	
	uint		fonttype;
	uint		fontsize;
	RGB		fontcolor;

	//char*	pcValues;
	char**	pcValues; //modified by nhj
	uint		valuecount;
	void*	pOwner;	
	struct  SG_WINCONTROL*	pNext;
	struct  SG_WINCONTROL*	pPrev;	
}GUI_WINCONTROL;
/*控件有一个所有者,pOwner,它指明了控件从属于那个窗体,同一个窗体的控件以双向链表进行组织*/


typedef	GUI_WINCONTROL*	HWND; 

typedef	struct  SG_FORM
{
	char		name[12];
	uint		type;
	uint		left;
	uint		top;
	uint		width;	
	uint		height;
	char		text[48];
	BOOL	visibled;
	uint		tag;
	RGB		backcolor;

	GUI_WINCONTROL*	pFirstChild;
	GUI_WINCONTROL*	pLastChild;
	GUI_WINCONTROL*	pFocusChild;	
	struct  SG_FORM*	pNextForm;
	struct  SG_FORM*	pPrevForm;	
	//属于哪一个屏
	void*	pScreen;
} GUI_FORM;


//输入设备的消息
typedef	struct SG_MSG 
{
	HWND	handle;//该消息的发送对象,对应于一个控件
	int	msgtype;//消息类型
	int	wParam;
	int	lParam;
} GUI_MSG;

typedef	GUI_MSG*	PGUI_MSG;

typedef struct	SQ_INPUTMSG//所有的输入消息组成一个环形缓冲队列
                                           //与该环形缓冲队列有一个信号量与其关联
{
	GUI_MSG		GMSG_ARRAY[MSG_MAX];
	//iMsgInputLast 指向最后一个记录的下一个
	 //地址,当iMsgInputFirst ==iMsgInputLast时队列为空

	int	iMsgInputFirst;
	int	iMsgInputLast; 

	NU_SEMAPHORE*	pSema_input;
} Q_INPUTMSG;

//输出设备消息
typedef	struct	SLCD_MSG
{
	uint	left;
	uint	top;
	uint	width;
	uint	height;
} LCD_MSG;
/*每条LCD_MSG给出了需要显示的区域的坐标。
与GUI_MSG一样,LCD_MSG也是被组织成一个环形缓冲队列,
与该环形缓冲队列也有一个信号量与其关联。
*/

typedef struct SFORM_LINK
{
	GUI_FORM*	pFirstForm;
	GUI_FORM*	pLastForm;	
	//当前显示的窗口
	GUI_FORM*	pCurrentForm;		
} FORM_LINK;

//定义屏幕结构,将屏幕消息队列和framebuffer
//以及formlink结合在一起
typedef	struct	S_SCR
{
	LCD_MSG	LMSG_ARRAY[MSG_MAX];
	int	iMsgLcdFirst;
	int	iMsgLcdLast;
	NU_SEMAPHORE*	pSema_lcd;

	RGB	framebuffer[SCR_WIDTH*SCR_HEIGHT];	
	FORM_LINK	formlink;
} SCR;

typedef struct S_BODCOM
{
	char  com[2][22];
	char  bod[2][22];
} BOD_COM;


//全局变量bMessage表明当前是否有阻塞式messagebox存在
//FALSE = 无TRUE= 有,在MsgBox函数中要把它置为TRUE,在相应
//的消息预处理函数PreProcessMsg中,在相应的按键消息处理
//中将其置为FALSE.全局变量mbResult表明MessageBox返回的变量
//其值要么为MB_OK,要么MB_CANCEl

//BOOL	bMessage = FALSE;
//uint		mbResult;

#define	MB_OK		0x01
#define	MB_CANCEL	0x02

#define	MSGBOX_WIDTH  120
#define	MSGBOX_HEIGHT	80


//全局变量bMessage表明当前是否有阻塞式messagebox存在
//FALSE = 无TRUE= 有,在MsgBox函数中要把它置为TRUE,在相应
//的消息预处理函数PreProcessMsg中,在相应的按键消息处理
//中将其置为FALSE.全局变量mbResult表明MessageBox返回的变量
//其值要么为MB_OK,要么MB_CANCEl
/*
BOOL	bMessage = FALSE;
uint		mbResult;
*/
int	MsgBox(SCR* pScr,const char* pText,uint iType);

void SetSystemRegister(unsigned short sSetBit);
void ClrSystemRegister(unsigned short sClrBit);

void Dot1335_1(unsigned short x, unsigned short y, unsigned char Mode, unsigned char Layer, unsigned char DotValue);
void Draw1335_1(const SCR* pScr,uint  x, uint y,uint iWidth, uint iHeight);
void Draw1335_2(const SCR* pScr,uint  x, uint y,uint iWidth, uint iHeight);
void Init1335_1(void);

void Delay(uint iMax);
void Delay1335();


int ShowFrameBufferDotToLcd_1(SCR* pScr,int x,int y);

int	InitInputMsgQueue(Q_INPUTMSG* pQ_Msg,NU_SEMAPHORE* pSema_in);
int	SendGMessage(Q_INPUTMSG* pQ_Msg,HWND handle,int iMsgType,int wParam,int lParam);
int	GetGMessage(PGUI_MSG pmsg,Q_INPUTMSG* pQ_Msg);

int	InitScr(SCR* pScr,NU_SEMAPHORE* pSema_Lcd);
int	SendLcdMessage(SCR* pScr,uint iLeft,uint iTop,uint iWidth,uint iHeight);
int	GetLcdMessage(LCD_MSG* pmsg,SCR* pScr);

int	AddFormToScreen(GUI_FORM* pForm,SCR* pScreen);
int	AddControlToForm(GUI_FORM* pForm,HWND hwnd);
int	DrawDot_IO(SCR* pScreen,uint x,uint y,RGB* pRgb);

int	DrawDot(SCR* pScreen,uint x,uint y,RGB* pRgb);
int	DrawHLine(SCR* pScreen,uint x,uint y,uint iLen,RGB* pRgb);
int	DrawVLine(SCR* pScreen,uint x,uint y,uint iLen,RGB* pRgb);
int	DrawRect(SCR* pScreen,uint x,uint y,uint iWidth,uint iHeight,RGB* pRgb);
int	FillRect(SCR* pScreen,uint x,uint y,uint iWidth,uint iHeight,RGB* pRgb);
int  DrawCircleAll(SCR* pScreen,int cX,int cY,uint iWidth,uint iHeight,RGB*bRgb, RGB* pRgb);
unsigned int GetOffetGBK(unsigned char Qh, unsigned char Wh);
void WriteAsci(SCR* pScreen,RGB* pRgbFont,uint fontsize,uint x, uint y , unsigned char CharIndex);
void WriteChinese(SCR* pScreen,RGB* pRgbFont,uint fontsize,uint x, uint y , unsigned char CharIndexH, unsigned char CharIndexL);
char *TextWindowOut(SCR* pScreen,RGB* pRgbFont,uint fontsize,uint LeftTopX,uint LeftTopY, uint BottomRightX,uint BottomRightY, char *RawText, uint iReverseNo);
//int DrawText(SCR* pScreen,uint iTextMode,RGB* pRgbFont,uint fontsize,uint LeftTopX,uint LeftTopY, uint BottomRightX,uint BottomRightY, char *pRawText, uint iReverseNo);
int DrawText(SCR* pScreen,uint iTextMode,RGB* pRgbFont,uint fontsize,uint LeftTopX,uint LeftTopY, uint BottomRightX,uint BottomRightY, char *pRawText ,uint iReverseNo);
void ClrScreen();



//注意控件的坐标是针对form的左上角的坐标,
//因此要加上form的起始坐标
//int  DrawControlBOD_COM(HWND hwnd);
//int  DrawControlBOD_COM_MONITOR(HWND hwnd);
int  DrawControlSortText(HWND hwnd);

int  DrawControlButton(HWND hwnd);
int  DrawControlEdit(HWND hwnd);
int  DrawControlText(HWND hwnd);
int  DrawControlProgress(HWND hwnd);
int  DrawControlGroup(HWND hwnd);

int  DrawControlHLine(HWND hwnd);
int  DrawControlVLine(HWND hwnd);
int  DrawControlLine(HWND hwnd);
int  DrawControlHOOK(HWND hwnd);
int   DrawBmp(SCR* pScreen,uint x,uint y,RGB* pRgb,unsigned char  (*pBmp)[2]);
int   DrawControlBmp(HWND hwnd);
int  DrawLine(SCR* pScreen,int x1,int y1,int x2,int y2,RGB* pRgb);
int  DrawControlRect(HWND hwnd);
BOOL  IsOne(unsigned char uNum,int iIdex);
int  DrawCircle(SCR* pScreen,int cX,int cY,RGB*bRgb, RGB* pRgb);
int  DrawControlCircleAll(HWND hwnd);
//int  DrawCircle(int cX,int cY);
int  DrawControlCircle(HWND hwnd);


//WinControlShow 是写完framebuffer后紧接着给LCD发消息
int WinControlShow(HWND handle);
//WinControlShow 是写完framebuffer后不给LCD发消息
int WinControlShowWithoutUpdate(HWND handle);

GUI_WINCONTROL* SwitchToNextFocus(SCR* pScreen);
GUI_WINCONTROL* SwitchToPrevFocus(SCR* pScreen);

//专门为mssagebox写的函数
GUI_WINCONTROL* FormSwitchToNextFocus(GUI_FORM* pForm);

GUI_WINCONTROL* FormSwitchToPrevFocus(GUI_FORM* pForm);

int	SwitchToForm(SCR* pscr,GUI_FORM* pForm);
int	SwitchToNextForm(SCR* pScr);
int	SwitchToPrevForm(SCR* pScr);

int	FormShow(GUI_FORM*	pForm);
int	AllVisableShow(SCR* pScr);

GUI_FORM*	GetCurrentForm(SCR* pScr);
GUI_WINCONTROL*	GetCurrentFocus(SCR* pScr);

void PreProcessMsg(SCR* pScr,GUI_MSG* pMsg);

//pBodCom->tag必须在FlashBodCom中实现0<->1的转换
void FlashBodCom(GUI_WINCONTROL*  pBodCom);

void MoveEditCursor(GUI_WINCONTROL* pControl);
void MoveEditCursorExam(GUI_FORM* pForm,GUI_WINCONTROL* pControl);
int  DecreaseEditValue(GUI_WINCONTROL* pControl);
int  DecreaseEditValueExam(GUI_FORM* pForm,GUI_WINCONTROL* pControl);
int  IncreaseEditValue(GUI_WINCONTROL* pControl);
int  IncreaseEditValueExam(GUI_FORM* pForm,GUI_WINCONTROL* pControl);
int  DecreaseEditValueWithoutUpdate(GUI_WINCONTROL* pControl);
int  IncreaseEditValueWithoutUpdate(GUI_WINCONTROL* pControl);
void FullScreen(RGB *pRgb);
void WriteChinese_set(SCR* pScreen,RGB* pRgbFont,uint fontsize,uint x, uint y , unsigned char CharIndexH, unsigned char CharIndexL);
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -