本帖最后由 zhanghuichun 于 2014-11-15 19:40 编辑
智能手表端,采用STM公司的emWin人机交互界面,并模拟了手机app应用,编写成一个比较美观的界面。
代码量多,以下是部分代码:
/*
描述:创建桌面
*/
void GUI_CreatDeskTop( void )
{
WinPara.xSizeLCD = LCD_GetXSize(); //LCD屏幕尺寸
WinPara.ySizeLCD = LCD_GetYSize(); //LCD屏幕尺寸
WinPara.xSizeWin = WinPara.xSizeLCD; //窗口尺寸
WinPara.ySizeWin = WinPara.ySizeLCD -20; //窗口尺寸 屏幕大小减去状态栏和控制栏
WinPara.xPosWin = 0; //窗口的起始位置
WinPara.yPosWin = 20; //窗口的起始位置
WinPara.xSizeWinVirtual = WinPara.xSizeWin * VIRTUAL_WIN_NUM; //虚拟窗口尺寸,用于桌面
SetDefaultSkin(); //设置默认win7皮肤和字体
WM_MOTION_Enable(1);
WM_MOTION_SetDefaultPeriod(1000);
WM_EnableMemdev(WM_HBKWIN); //使用储存设备来重绘窗口
WM_SetCallback(WM_HBKWIN, _cbBKWin); //设置回调函数
/* 创建窗口 状态栏、主窗口*/
CreatStatusWin();
CreatMainWin();
}
/*
描述:创建顶部状态栏
*/
static void CreatStatusWin( void )
{
OS_ERR err;
int i= 0;
WM_HWIN hText1;
WinPara.hWinStatus = WM_CreateWindowAsChild(
0, //窗口位置、大小
0,
WinPara.xSizeLCD,
WinPara.yPosWin,
WM_HBKWIN, WM_CF_SHOW ,
_cbStatusWin,
sizeof(WIN_PARA *)
);
hText1 = TEXT_CreateEx(0, 0,
60, 20,
WinPara.hWinStatus,
WM_CF_SHOW,
GUI_TA_LEFT|TEXT_CF_VCENTER,
GUI_ID_TEXT1,
" ");
TEXT_SetTextColor(hText1, GUI_BLUE);
}
/*
描述:创建主窗口
*/
static void CreatMainWin(void)
{
WM_HWIN hText_time;
WM_HWIN hText_date;
WM_HWIN hText_wday;
WM_HWIN hText_GPS;
WM_HWIN hWin;
WinPara.hWinMain = WM_CreateWindowAsChild(
WinPara.xPosWin ,
WinPara.yPosWin , //位置
WinPara.xSizeWin,
WinPara.ySizeWin, //底部剩余宽度
WM_HBKWIN,
WM_CF_SHOW | WM_CF_MEMDEV,
_cbMainWin,
sizeof(WIN_PARA *)
);
hText_time= TEXT_CreateEx(0, 0,
WinPara.xSizeLCD, 60,
WinPara.hWinMain,
WM_CF_SHOW,
GUI_TA_HCENTER|TEXT_CF_VCENTER,
GUI_ID_TEXT1,
" "
);
hText_date= TEXT_CreateEx(0, 60,
130, 40,
WinPara.hWinMain,
WM_CF_SHOW,
GUI_TA_HCENTER|TEXT_CF_VCENTER,
GUI_ID_TEXT2,
" "
);
hText_wday= TEXT_CreateEx(130, 60,
90, 40,
WinPara.hWinMain,
WM_CF_SHOW,
GUI_TA_HCENTER|TEXT_CF_VCENTER,
GUI_ID_TEXT3,
" "
);
hText_GPS = TEXT_CreateEx(0, 100,
WinPara.xSizeWin, 20,
WinPara.hWinMain,
WM_CF_SHOW,
GUI_TA_HCENTER|TEXT_CF_VCENTER,
GUI_ID_TEXT4,
"NO GPS INFORMATION"
);
TEXT_SetFont(hText_time, GUI_FONT_D36X48);
TEXT_SetTextColor(hText_time, GUI_BLUE);
TEXT_SetTextColor(hText_date, GUI_BLUE);
TEXT_SetTextColor(hText_wday, GUI_BLUE);
TEXT_SetTextColor(hText_GPS, GUI_BLUE);
hWin=ICONVIEW_CreateEx(0,
130,
WinPara.xSizeWin,
WinPara.ySizeLCD,
WinPara.hWinMain,
WM_CF_SHOW | WM_CF_HASTRANS,
0,
GUI_ID_ICONVIEW0,
70, 70);
ICONVIEW_SetBkColor(hWin, ICONVIEW_CI_SEL, GUI_BLUE | 0xC0000000);
ICONVIEW_SetFont(hWin, &SDFont.XFont); //设置图标字体
ICONVIEW_SetTextColor(hWin,ICONVIEW_CI_UNSEL,GUI_LIGHTBLUE);
// ICONVIEW_SetTextAlign(hWin,GUI_TA_RIGHT);
ICONVIEW_SetSel(hWin, -1);
ICONVIEW_AddBitmapItem(hWin, &bmCall, "电话");
ICONVIEW_AddBitmapItem(hWin, &bmMessage, "短信");
ICONVIEW_AddBitmapItem(hWin, &bmclock, "时钟");
ICONVIEW_AddBitmapItem(hWin, &bmwifi, "无线");
ICONVIEW_AddBitmapItem(hWin, &bmCamera, "相机");
ICONVIEW_AddBitmapItem(hWin, &bmAdd, "添加");
}
效果图如下: