//---------------------------------文本篇--------------------------------
GUI_Init();
//----基本显示函数-------
GUI_DispChar('w');
GUI_GotoXY(0,10);
GUI_DispString("\n123456789\n123456789\n");
GUI_DispChar('C');
GUI_DispCharAt('A',100,50);
GUI_DispChars('*', 30);
GUI_DispStringAt("P=150,20", 150, 20);
GUI_DispStringAtCEOL("0",120,50);
GUI_Delay(1000);
GUI_Clear();
//------显示数值---------
GUI_DispDec(12 ,5); //显示:00012 void GUI_DispDec(I32 v, U8 Len); Len<=9
GUI_DispDec(123456,5); //显示:99999
GUI_DispDecAt(123,100,100,5); // void GUI_DispDecAt(I32 v, I16P x, I16P y, U8 Len);
GUI_DispDecMin(12); //显示:12 void GUI_DispDecMin(I32 v); 当前坐标左对齐
GUI_GotoXY(50,50);
GUI_DispDecShift(12345,7,3); //显示:012.45 void GUI_DispDecShift(I32 v, U8 Len, U8 Shift);
GUI_DispDecSpace(12,5); //显示:___12 void GUI_DispDecSpace(I32 v, U8 MaxDigits); 前边的0用空格代替
//------基本绘图---------
GUI_ClearRect(50,50,70,70); // void GUI_ClearRect(int x0, int y0, int x1, int y1); 背景色填充矩形区域
GUI_DrawPixel(80,80); //显示:白点 void GUI_DrawPixel(int x, int y); 在当前视窗的指定坐标绘一个像素点。
GUI_DrawPoint(10,10); //显示:白点 void GUI_DrawPoint(int x, int y);
GUI_InvertRect(90,90,150,150); //反色 void GUI_InvertRect(int x0, int y0, int x1, int y1); 指定区域反色
//--------显示JPEG图片-------
#include "jpeglib.h"
unsigned char aczdjpeg[] = { .... };
GUI_JPEG_GetInfo(aczdjpeg,sizeof(aczdjpeg),&jpeginfo); //获取JPEG图片信息
GUI_GotoXY(100,100);
GUI_DispDecMin(jpeginfo.XSize);
GUI_DispDecMin(jpeginfo.YSize);
GUI_JPEG_Draw(aczdjpeg,sizeof(aczdjpeg),0,0); //显示JPEG图片 int GUI_JPEG_Draw(const void * pFileData, int DataSize, int x0, int y0)
pBitmap = &bmzd3;
GUI_DrawBitmap(pBitmap,0,0); //显示BMP图片
//-------WM窗口------------------
//-----------------------------------------------------------子窗口的回调函数-----------------------------------
static void cbForegroundWin1(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(0xdda0a0); //窗口背景色(绿)
GUI_Clear(); //有此句才会显示窗口
GUI_DispString("Foregchild"); //绿背景显示
break;
default:
WM_DefaultProc(pMsg);
}
}
static void cbBackgroundWin1(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_Clear();
default:
WM_DefaultProc(pMsg);
}
}
//-----------------------------------------------------------父窗口的回调函数-----------------------------------
static void cbForegroundWin(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(0xdd8080); //窗口背景色(绿)
GUI_Clear(); //有此句才会显示窗口
GUI_DispString("Foreground"); //绿背景显示
break;
default:
WM_DefaultProc(pMsg);
}
}
static void cbBackgroundWin(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_Clear();
default:
WM_DefaultProc(pMsg);
}
}
void WMtest(void)
{
GUI_HWIN hWnd;
GUI_HWIN hWnd1;
const GUI_BITMAP *pBitmap;
//---------设置桌面窗口颜色------绯红
WM_SetDesktopColor(0xdd80ff);
GUI_Delay(1000);
//---------显示图片--------------百度知道
pBitmap = &bmzd3;
GUI_DrawBitmap(pBitmap,0,0);
//---------创建父窗口------------显示前景窗口
hWnd = WM_CreateWindow( 10, 10,200,100, WM_CF_SHOW, cbForegroundWin, 0);
GUI_Delay(1000);
//---------创建子窗口------------
hWnd1 = WM_CreateWindowAsChild( 50,10, 50, 50, hWnd, WM_CF_SHOW, cbForegroundWin1, 0);
GUI_Delay(1000);
WM_ClrHasTrans(hWnd1); //使窗口透明,不行呢
GUI_Delay(1000);
WM_MoveTo(hWnd,50,50); //移动窗口,OK
GUI_Delay(1000);
//WM_DeleteWindow(hWnd1);
GUI_Delay(1000);
//WM_MoveTo(hWnd,50,50); //不能移动父窗口
WM_DeleteWindow(hWnd); //为什么删不掉父窗口
GUI_Delay(1000);
//WM_Paint(hWnd1); //报错
GUI_Delay(1000);
}
//---------------字体及颜色-----------------------
void font(void)
{
GUI_SetFont(&GUI_Font6x8); //字体
GUI_DispStringAt("This text is 6 by 8 pixels", 20, 20); //字体=白色
GUI_SetBkColor(GUI_LIGHTBLUE); //设置背景色
GUI_SetColor(GUI_CYAN ); //设置前景色
GUI_SetFont(&GUI_FontD32); //字体名,见GUI\Font\xx.c文件末尾 字体=白色
GUI_DispStringAt("12345", 20, 80); //
}
//========文本编辑框==========
void text(void)
{
//通常用作文本输入主要的用户接口
int Key;
EDIT_Handle hEdit;
char aBuffer[28] ;
GUI_SetFont(&GUI_Font8x16);
hEdit = EDIT_Create(40,20,300,50,' ', sizeof(aBuffer),WM_CF_SHOW); //创建
EDIT_SetBkColor(hEdit,0,0xa0a0a0); //编辑区颜色
GUI_Delay(10);
EDIT_SetText(hEdit, "Press entrn"); //文本
EDIT_SetTextColor(hEdit, 0, GUI_RED); //文本颜色
do
{
Key = GUI_WaitKey();
switch(Key)
{
case '1':
case '2':
break;
default:
EDIT_AddKey(hEdit, Key); //有时候出现双字
Key = 0;
}
}while( (Key != '3') && (Key != '4') && (Key != '5'));
EDIT_Delete(hEdit);
}
//=========框架窗口======
void text(void)
{
FRAMEWIN_Handle hFrame;
hFrame = FRAMEWIN_Create("Frame window", NULL, WM_CF_SHOW, 10, 10, 150, 60);
GUI_Delay(500);
FRAMEWIN_SetFont(hFrame, &GUI_Font16B_ASCII);
GUI_Delay(500);
FRAMEWIN_SetTextColor(hFrame, GUI_GREEN);
GUI_Delay(500);
FRAMEWIN_SetBarColor(hFrame,0,0x585ae8);
GUI_Delay(500);
FRAMEWIN_SetTextAlign(hFrame, GUI_TA_HCENTER);
}
//=========框架窗口======
const GUI_ConstString ListBox[] = { "English", "Deutsch","Franais", "Japanese","Italiano", NULL};
#define countof(Array)(sizeof(Array) / sizeof(Array[0] ) )
void text(void)
{
int i;
int Entries =countof(ListBox) - 1;
FRAMEWIN_Handle hFrame;
LISTBOX_Handle hListBox;
int ySize = 200;//GUI_GetFontSizeYOf(&GUI_Font13B_1) * Entries;
hListBox = LISTBOX_Create(ListBox, 10, 10, 120, ySize, WM_CF_SHOW);
GUI_Delay(500);
LISTBOX_SetFont(hListBox, &GUI_Font13B_1);
GUI_Delay(500);
LISTBOX_SetBackColor(hListBox, 0, GUI_BLUE);
GUI_Delay(500);
LISTBOX_SetTextColor(hListBox, 0, GUI_WHITE);
GUI_Delay(500);
LISTBOX_SetTextColor(hListBox, 1, GUI_BLACK);
GUI_Delay(500);
for(i = 0; i < Entries - 1; i++)
{
LISTBOX_IncSel(hListBox);
GUI_Delay(500);
}
for(i = 0; i < Entries - 1; i++)
{
LISTBOX_DecSel(hListBox);
GUI_Delay(500);
}
LISTBOX_Delete(hListBox);
GUI_Clear();
}

319

被折叠的 条评论
为什么被折叠?



