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

📄 statictext.c

📁 Very very small GUI. Usefull for small system, without OS or small OS. Event driven, support user m
💻 C
字号:
#include <membox.h>
#include <stdio.h>
#include "GUI.h"
#include "Globalvars.h"
#include "pwin.h"
#include "guidebug.h"

void SendToHost(char * str, INT16U t);

#define STATICTEXT_DEFAULT_FONT			F9x15_pwf
extern unsigned char xhuge _HeapGUI[GUI_HEAP_SIZE];

void cbPaintStaticText (Pw_GC * gc) {
Pw_Window* win;
Pw_Coord w, h, x, y, wt;
char * data;
   win = Pw_GCGetWindow(gc);
   Pw_WindowGetSize(win, &w, &h);
   Pw_GCSetFont(gc, STATICTEXT_DEFAULT_FONT); 			 	
//   Pw_DrawFrameRect(gc, 0, 0, w, h, 1, NULL);	
   data = (char *) Pw_WindowGetClientData(win);
   wt = Pw_FontGetStringWidth(gc->font, data);		
   x = 0; //(w - wt)/2;  
   y = Pw_GCGetFontHeight(gc)+(h - Pw_GCGetFontHeight(gc))/2 - Pw_FontGetDescent(gc->font)+1;
	Pw_GCSetColor(gc, pw_white_pixel);
   Pw_DrawString(gc, x, y, (Pw_Char *) data);		
}

int cbStaticText(Pw_Event * ev) {
Pw_Window * win;
//int CtrlType;
//struct TInputLineData * data;
	win = Pw_EventGetWindow(ev); 
//	CtrlType = Pw_WindowGetClientDataId(win);
//	data = (struct TInputLineData *) Pw_WindowGetClientData(win);
	switch (Pw_EventGetType(ev)) {
			case Pw_DestroyEventType :
//				GUI_Log1("destroy STATIC TEXT", (unsigned long)Pw_EventGetWindow(ev));
				_free_boxh (_HeapGUI, Pw_EventGetWindow(ev));
				return TRUE;
	}
	return FALSE;
}

Pw_Window * CreateStaticText(const CONTROL_CREATE_INFO *info_struct , 
							 Pw_Window * Parent, Pw_EventCb cb) {
Pw_Window * StaticTextWin;
//char * data;

	 	StaticTextWin = _calloc_boxh (_HeapGUI);
		cb = cb;
	 	Pw_WindowCreate(Parent, info_struct->x0, info_struct->y0, 
								info_struct->xSize, info_struct->ySize, StaticTextWin);	
		Pw_WindowSetClientDataId(StaticTextWin, info_struct->ID); 
		Pw_WindowSetClientData(StaticTextWin, info_struct->Data); 		
		Pw_WindowSetRepaintCallback(StaticTextWin, cbPaintStaticText);
		Pw_WindowSetEventCallback(StaticTextWin, cbStaticText);
		Pw_WindowSetFocusAccept(StaticTextWin, FALSE);
		Pw_WindowMap(StaticTextWin);
	return StaticTextWin;
}

⌨️ 快捷键说明

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