📄 mcugui.h
字号:
/*
* Filename : mcugui.h
* Author : Li Dawen
* Copyright (c): Coslight Group .co
* Create Date : 2002.04.27
* Version : 0.1.0
*/
/*
__BORLANDC__
control box
1 button to next win or run command
2 edit edit text or number or hex number
3 list edit enum data
4 grid show many data of alike format
dialog box
1 messege box
2 input box
3 help box
4 error box
5 login box
*/
#ifndef MCUGUI_H
#define MCUGUI_H
//#include "includes.h"
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef uint
#define uint unsigned int
#endif
#ifndef ulong
#define ulong unsigned long
#endif
#ifndef byte
#define byte unsigned char
#endif
#ifndef word16
#define uint unsigned int
#endif
#ifndef word32
#define ulong unsigned long
#endif
#ifndef NULL
#define NULL 0
#endif
#define TRUE 1
#define FALSE 0
#define BEEP_HZ 500
#define KEY_F4 0x3E /* PC DEMO EXIT */
/* 用数字小键盘仿系统的7个键 */
/*
7 8 9 H ^ E
4 5 6 < O >
1 2 3 R v C
*/
#define KEY_ESC 57 /* E ESC 9 */
#define KEY_HELP 55 /* H HELP 7 */
#define KEY_UP 56 /* ^ UP 8 */
#define KEY_DOWN 50 /* v DOWN 2 */
#define KEY_LEFT 52 /* < LEFT 4 */
#define KEY_RIGHT 54 /* > RIGHT 6 */
#define KEY_OK 53 /* O OK 5 */
#define KEY_DATA 1 /* */
#define KEY_COM 2 /* */
/* control box type */
#define MASK_CTRLTYPE 0x7F
#define CTRL_END 0x80
#define CTRL_MENU 0x01
#define CTRL_BUTTON 0x02
#define CTRL_EDIT 0x03
#define CTRL_LIST 0x04
#define CTRL_GRID 0x05
#define CTRL_BMP 0x06
#define CTRL_CHART 0x07
#define CTRL_TIMER 0x08
#define CTRL_CLOCK 0x09
#define CTRL_WIN 0x0A
#define GUI_NULL 0x00
#define STYLE_NULL 0x00
/* CLOCK STYLE*/
#define CS_TIME 0x01
#define CS_DATE 0x02
#define CS_TIMEDATE 0x03
/* BUTTON STYLE*/
#define BS_NULL 0x00
#define BS_NOFOCUS 0x20
#define BS_HIDE 0x10
#define BS_PASSWORD1 0x01
#define BS_PASSWORD2 0x02
#define BS_PASSWORD3 0x03
#define BS_INPUTNUM 0x04
#define BS_INPUTNUMC 0x0C
#define MB_OK 0x00
#define MB_OKCANCEL 0x40
#define BS_CMDSYNC 0x08
/* EDIT STYLE*/
#define ES_NOCAPTION 0x01
#define ES_NODATA 0x02
#define ES_READONLY 0x08
/* EDIT FORMAT*/
#define EF_HEX 0x01
#define EF_TEXT 0x02
#define EF_NUM 0x03
/* TIMER STYLE*/
#define TS_ONCE 0x10
#define TS_LOOP 0x80
#define TS_STOP 0x00
#define TS_SECOND 0x01
#define TS_MINUTE 0x02
#define TS_HOUR 0x03
/*
#define TS_DAY 0x04
#define TS_MONTH 0x05
#define TS_YEAR 0x06
*/
/* FONT STYLE */
#define FONT_DEFAULT 0x00
#define FONT_SMALL 0x40
#define FONT_BRIGHT 0x80
#define FONT_HIDE 0x10
/* COMMAND TYPE */
#define CMD_LOADWIN 0xA0
#define CMD_COMMAND 0xB0
#define CMD_NONE 0xC0
/* DATA TYPE */
/**
1000 8 8
1001 9 9
1010 A 10
1011 B 11
1100 C 12
1101 D 13
1110 E 14
1111 F 15
**/
/*
BOTTON
|<- user define style ->|<- ctrl show style ->|
+-------+-------+-------+-------+-------+-------+-------+-------+
|BRIGHT |SM FONT|NOFOCUS| HIDE | | INPUT |PW SET |PW USER| LODWIN
+-------+-------+-------+-------+-------+-------+-------+-------+
+-------+-------+-------+-------+-------+-------+-------+-------+
|BRIGHT |SM FONT|NOFOCUS| HIDE | SYNC | | | | CMD
+-------+-------+-------+-------+-------+-------+-------+-------+
EDIT LIST
ctrl style
|<- user define style ->|<- ctrl show style ->|
+-------+-------+-------+-------+-------+-------+-------+-------+
|BRIGHT |SM FONT|NOFOCUS| HIDE |ONLY R | |NO DATA|NO CAPT|
+-------+-------+-------+-------+-------+-------+-------+-------+
ctrl data_type
+-------+-------+-------+-------+-------+-------+-------+-------+
| MODULE TYPE | VALUE TYPE |
+-------+-------+-------+-------+-------+-------+-------+-------+
*/
/* design time init*/
typedef struct
{
/* design init*/
uchar x, y, w, h;
uchar type;
uchar style;
uchar data_type;
uchar data_index;
char *caption;
char *tag;
} CONTROL;
/*
example:
type = text contrl
|<-------- w -------->|
+----------+------------+--
| caption | data | h
+----------+------------+--
format = [%m][%b][%d][%x][%s]
223.5V "%100m%200.300b%3.1DV\0"
%m 定点数倍数 multiple
%b bound 存储值编辑范围 bounddown.boundup
%d 整数 integer part.decimal part
%x 16进制数 width
%s 字符串 width
*/
/* active page in active win */
typedef struct
{
uchar style;
int *colw[2];
uchar *colb[2];
char *format[2+1];
} GRIDEX;
#define WS_PAGESCROLL 0x10
#define WS_PAGENUM_HIDE 0x60
#define WS_READONLY 0x08
#define WS_NOCAPTION 0x01
#define WS_NODATA 0x02
#define WS_NOFOCUS 0x20
#define GUI_MUDULE_ERR 0x80
#define WS_EDITON 0x02
#define WS_CHANGE 0x01
/*
ctrl style
|<- user define style ->|<- ctrl show style ->|
+-------+-------+-------+-------+-------+-------+-------+-------+
|BRIGHT |SM FONT|NOFOCUS| HIDE |ONLY R |NO CAPT|NO DATA|NO UNIT|
+-------+-------+-------+-------+-------+-------+-------+-------+
win style
+-------+-------+-------+-------+-------+-------+-------+-------+
|USE |SET |NOFOCUS|PSCROLL|ONLY R |NO CAPT|ON EDIT|CHANGE |
+-------+-------+-------+-------+-------+-------+-------+-------+
*/
/* design time init*/
typedef struct
{
uchar data_type;
uchar style;
const CONTROL *controls;
void (*proc)(uchar, uchar);
char *caption;
char *tag;
} WINDOW;
/* msg type define */
#define MSG_IDLE 0x00
#define MSG_CLS 0x0D
#define MSG_NULL 0x0E
#define MSG_QUIT 0x0F
#define MSG_KEY 0x01
#define MSG_INIT 0x02
#define MSG_LOAD 0x03
#define MSG_CLOSE 0x04
#define MSG_PAINT 0x05 //all
#define MSG_UPDATA 0x06 //oly data
#define MSG_ERR 0x07
#define MSG_COMMAND 0x08
#define MSG_SAVE 0x09
#define MSG_BEEP 0x0A
#define MSG_TIMER 0x0B
#define MSG_DLGINIT 0x0C
#define MSG_SCROLLUP 0x11
#define MSG_SCROLLDOWN 0x12
#define MSG_FOCUSMOVE 0x13
#define MSG_TPLAY 0x21
#define MSG_TSTART 0x22
#define MSG_TSTOP 0x23
#define MSG_TPAUSE 0x24
#define MSG_TOUT 0x25
#define MSG_TRELOAD 0x26
#define MSG_TSAFE 0x27
#define MSG_SREAD 0x35
#define MSG_SWRITE 0x36
/*
#define SAVE_ACTIVE 0x00;
#define SAVE_ALARM 0x01;
#define SAVE_DATA24 0x02;
#define SAVE_DATA72 0x03;
*/
/* GUI error */
#define ERR_MSGBUFOVER 0x01
#define ERR_TIMEOUT 0x02
#define ERR_GUISTACKOVER 0x03
/*
B7 B6 B5 B4 B3 B2 B1 B0
+--+--+--+--+--+--+--+--+
| ID | TYPE |
+--+--+--+--+--+--+--+--+
*/
typedef struct
{
uchar type;
uchar data;
} GUIMSG;
#define TIMER_COUNT 2
#define GUIMSG_SIZE 3
#define GUIMSG_COUNT 16
#define GUIMSGBUF_SIZE GUIMSG_SIZE * GUIMSG_COUNT
typedef struct GUIMSGQUEUEINFO
{
uchar *msgbuf;
uchar head;
uchar tail;
uchar count;
uchar last_type;
uchar last_data;
}GUIMSGQ;
#define TIME_SEC 0
#define TIME_MIN 1
#define TIME_HOUR 2
#define TIME_DAY 3
#define TIME_MON 4
#define TIME_YEAR 5
#define TIME_CHANGE_SEC 0x01
#define TIME_CHANGE_MIN 0x02
#define TIME_CHANGE_HOUR 0x04
#define TIME_CHANGE_DAY 0x08
#define TIME_CHANGE_MON 0x10
#define TIME_CHANGE_YEAR 0x20
#define FOCUS_HOME 0x0
#define FOCUS_END 0x01
#define FOCUS_PREV 0x02
#define FOCUS_NEXT 0x03
typedef struct
{
/* push win stack data is updata win user */
uchar active_win;
uchar active_ctrl;
uchar win_status;
uchar page_topy; /* top y*/
uchar module;
uchar ctrl_top; /*page top ctrl*/
uchar ctrl_bottom; /*page bottom ctrl*/
uchar ctrl_last; /*win last ctrl*/
uchar ctrl_total; /*win ctrl total*/
uchar page;
uchar max_page;
/* end push */
uchar max_win;
/* FOCUS EDIT CTRL */
uchar focus_format;
uchar focus_cursor;
uchar focus_len;
uint focus_value;
char focus_buf[16];
char time_buf[6];
/* SHOW FORMAT TEXT */
char data_buf[16];
char text_buf[100];
uchar stack_top;
uchar stack_buf[255];
uint idle_count;
// d_year, d_mon, d_day, t_hour, t_min, t_sec;
uchar quit;
uchar err;
uchar volt_class; //0 is 220V 1 is 110V
/* */
uchar tick;
int beep;
uint wait;
} GUISYS;
typedef struct
{
int max_count;
int count;
void (*proc)(void); //time out
}TIMECONTROL;
/*****************************************************************************/
/*****************************************************************************/
/* init and quit function */
void InitGUI(void);
void QuitGUI(void);
void GuiIdle(void);
/* message manage function*/
uchar GetMsg(GUIMSG *msg);
void PostMsg(uchar msg_type, uchar msg_data);
void SendMsg(uchar msg_type, uchar msg_data);
/* window manage function */
int GuiStack(void);
int GuiPop(void);
void GuiPush(int value);
void LoadWin(int index);
void CloseWin(void);
void MainGUIProc(void);
void DefaultGUIProc(uchar msg_type, uchar msg_data);
/* window page manage function*/
void SrcollUp(void);
void SrcollDown(void);
void PageUp(void);
void PageDown(void);
void FocusPrev(void);
void FocusNext(void);
void MoveFocus(uchar act);
/* edit ctrl edit function*/
void CursorSize(uchar size);
uchar CursorLeft(void);
uchar CursorRight(void);
void TextChangeUp(void);
void TextChangeDown(void);
/* contrl manage function */
//uchar MenuCtrlProc(int index, uchar msg_type, uchar msg_data);
void DefaultWinProc(uchar msg_type, uchar msg_data);
void ButtonCtrlProc(int index, uchar msg_type, uchar msg_data);
void EditCtrlProc(int index, uchar msg_type, uchar msg_data);
void ListCtrlProc(int index, uchar msg_type, uchar msg_data);
void GridCtrlProc(int index, uchar msg_type, uchar msg_data);
void PwtextCtrlProc(int index, uchar msg_type, uchar msg_data);
void ClockCtrlProc(int index, uchar msg_type, uchar msg_data);
void BmpCtrlProc(int index, uchar msg_type, uchar msg_data);
void WinPaint(uchar msg_type, uchar msg_data);
//void DrawTempCtrl(uchar type, uchar style, uchar x, uchar y, uchar w, uchar h,
// uchar data_type, uchar data_index, uchar *caption, uchar *tag);
//void DrawTempCtrlCaption(uchar *caption, uchar x, uchar y, int len, uchar style);
//void DrawTempCtrlData(int data, uchar x, uchar y, int len, uchar style, uchar *tag);
void EditOn(int index);
void EditOff(int index);
uchar EditSafe(char *buf, char *fmt, int value);
/* dialog box manage function*/
void HelpBox( char *caption, const char *text, uchar style);
int MsgBox( char *caption, char *text, uchar style);
int InputBox(char *caption, uchar style, int min_v, int max_v);
int PasswordBox(char *caption, uchar style);
int RepasswordBox(char *caption, uchar style);
/* text and graphics function*/
uchar GetFormat(char *tag);
/* text mem fuction*/
void DrawCtrlBMP(int index);
void DrawBmp(uchar x, uchar y, uchar w, uchar h, uchar *buf, uchar style);
void DrawDrid(uchar type, uchar top);
/* string manage function*/
/*time function*/
void TimeTick(void);
void TimerAct(uchar index, uchar action);
void TimerProc(uchar event);
void TimerInit(void);
void GetTime(uchar *buf);
void SetDate(uchar yy, uchar mm, uchar dd);
void SetTime(uchar hh, uchar mm, uchar ss);
void BeepPlay(void);
void BeepOff(void);
void BeepSet(uint value);
uint BeepGet(void);
int GetGuiModule(void);
void SetGuiModule(int value);
void PageNumPut(void);
void PageNumHome(void);
void PageNumEnd(void);
void PageNumPrev(void);
void PageNumNext(void);
void PageNumMax(int value);
int PageNum(void);
uchar GetWinStyle(int index);
#ifdef MCUGUI_MODULE
GUISYS Gui;
#else
extern GUISYS Gui;
#endif
int getch(void);
int kbhit(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -