📄 schedatedisp.c
字号:
/**
* File Name : ScheDate.cpp
* Created : 07/03/22
* Author : ZhongNingLin@neusoft.com
* Model : 05YOP
* Description : [[CN]] 此文件的职责是: [[CN]]
**/
#include "ScheDateDisp.h"
/**************************************************************************
* Function Name : CMainWin_New
* Description : This function constucts the main window.
* Input Parameters : Schedule *
* Output Parameters: None
* Return Value : IWindow *
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
IWindow * CMainWin_New(Schedule * pOwner)
{
CMainWin * pMe;
VTBL(IWindow) vtbl;
SH_IWINDOW_SETVTBL(&vtbl, CMainWin_Enable, CMainWin_Redraw, CMainWin_HandleEvent, CMainWin_Delete);
pMe = (CMainWin *)CWindow_New(sizeof(CMainWin), pOwner, &vtbl);
if(NULL == pMe)
{
return FALSE;
}
/*初始化屏幕中的三个矩形*/
if( !ScheExt_InitClassData(&pMe->set,pMe->m_pOwner) )
return FALSE;
/*初始化整个屏幕矩形变量*/
SETAEERECT( &pOwner->m_rScreenRect, 0, 20, pOwner->DeviceInfo.cxScreen, pOwner->DeviceInfo.cyScreen - 20 );
CMainWin_InitData(pMe);
/*返回窗体接口*/
return (IWindow *)pMe;
}
/**************************************************************************
* Function Name : CMainWin_InitData
* Description : This function init main window.
* Input Parameters : CMainWin *
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
void CMainWin_InitData(CMainWin *pMe)
{
pMe->h_distance=(int)pMe->m_pOwner->DeviceInfo.cxScreen/7;
pMe->v_distance=(int)(pMe->m_pOwner->DeviceInfo.cyScreen-30)/7;
pMe->h_startPos=0;
pMe->v_startPos=pMe->v_distance*2;
}
/**************************************************************************
* Function Name : CMainWin_Delete
* Description : This function deletes the main window.
* Input Parameters : IWindow *
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
void CMainWin_Delete(IWindow * po)
{
CMainWin * pme = (CMainWin *)po;
release_ScheExt(pme->set);
FREEIF(pme);
}
/**************************************************************************
* Function Name : CMainWin_Delete
* Description : This function enables/disables the main window.
* Input Parameters : IWindow * ;boolean
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
void CMainWin_Enable(IWindow * po, boolean bEnable)
{
CMainWin * pme = (CMainWin *)po;
if (!CWindow_ProcessEnable(po, bEnable))
return;
/*判断当前窗口是否为激活状态*/
if (!pme->m_bActive)
{
return;
}
//IMENUCTL_SetActive(pme->m_pMainMenu, TRUE);
//IMENUCTL_SetSel(pme->m_pMainMenu, pme->m_pOwner->m_wMainWin);
//SH_DrawImage(pme->m_pLogo, &pme->m_rectLogo, TRUE);
}
/**************************************************************************
* Function Name : CMainWin_Redraw
* Description : This function redraws the main window.
* Input Parameters : IWindow *
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
void CMainWin_Redraw(IWindow * po)
{
CMainWin * pme = (CMainWin *)po;
/*窗口不是激活状态直接返回*/
if (!pme->m_bActive)
return;
/*清屏*/
IDISPLAY_ClearScreen(pme->m_pIDisplay);
ScheDateDisp_Disp(pme);
/*刷屏*/
IDISPLAY_Update(pme->m_pIDisplay);
}
/**************************************************************************
* Function Name : CMainWin_HandleEvent
* Description : This function processes events routed to main window.
* Input Parameters : IWindow * , AEEEvent , uint16 , uint32
* Output Parameters: None
* Return Value : boolean
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
boolean CMainWin_HandleEvent(IWindow * po, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
CMainWin * pme = (CMainWin *)po;
if (eCode == EVT_COPYRIGHT_END )
{
Schedule_Redraw(pme->m_pOwner, TRUE);
return TRUE;
}
/*判断是否是KEY事件*/
if (SH_ISEVTKEY(eCode))
{
switch(eCode)
{
case EVT_KEY:
switch(wParam)
{
case AVK_LEFT:
ScheDateDisp_UpdateScreen(pme,LEFT);
return TRUE;
case AVK_RIGHT:
ScheDateDisp_UpdateScreen(pme,RIGHT);
return TRUE;
case AVK_UP:
ScheDateDisp_UpdateScreen(pme,UP);
return TRUE;
case AVK_DOWN:
ScheDateDisp_UpdateScreen(pme,DOWN);
return TRUE;
case AVK_SOFT1:
//APP_STATE_MENUDISP date select /event view /event creat
Schedule_SetWindow(pme->m_pOwner, APP_STATE_MENUDISP, 0);
return TRUE;
case AVK_SOFT2:
//APP_WEEKDATEDISP_WIN week view
Schedule_SetWindow(pme->m_pOwner, APP_WEEKDATEDISP_WIN, 0);
return TRUE;
case AVK_SELECT:
/*back to oneday event window*/
Schedule_SetWindow(pme->m_pOwner, APP_STATE_ONEDAYDISP, 0);
return TRUE;
default:
return (FALSE);
}
}
}
return FALSE;
}
/**************************************************************************
* Function Name : ScheDateDisp_DrawGround
* Description : This function draw ground of main window.
* Input Parameters : CMainWin *
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
void ScheDateDisp_DrawGround (CMainWin* pMe)
{
/*字符串星期天到星期六*/
const AECHAR sun[] = { 0x65e5, 0 }; //日
const AECHAR mon[] = { 0x4e00, 0 }; //一
const AECHAR tue[] = { 0x4e8c, 0 }; //二
const AECHAR wed[] = { 0x4e09, 0 }; //三
const AECHAR thu[] = { 0x56db, 0 }; //四
const AECHAR fri[] = { 0x4e94, 0 }; //五
const AECHAR sat[] = { 0x516d, 0 }; //六
/*两个字符串 option switch*/
const AECHAR tip1[] = { 0x64cd, 0x4f5c, 0 }; //操作
const AECHAR tip2[] = { 0x663e, 0x793a, 0 }; //显示
const AECHAR header[] = { 0x65e5, 0x7a0b, 0x8868, 0 }; //日程表
int h_distance=0;
int v_distance=0;
int temp=0;
h_distance = pMe->h_distance;
v_distance = pMe->v_distance;
// draw the seven days from sunday to saterday
IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,sun,-1,h_distance*0+2,v_distance+5,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,mon,-1,h_distance*1+2,v_distance+5,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,tue,-1,h_distance*2+2,v_distance+5,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,wed,-1,h_distance*3+2,v_distance+5,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,thu,-1,h_distance*4+2,v_distance+5,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,fri,-1,h_distance*5+2,v_distance+5,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,sat,-1,h_distance*6+2,v_distance+5,NULL,IDF_TEXT_TRANSPARENT);
// draw operation tips on the screen
IDISPLAY_SetColor(pMe->m_pOwner->a.m_pIDisplay,CLR_USER_TEXT,MAKE_RGB(255,255,255));
IDISPLAY_DrawText(pMe->m_pOwner->a.m_pIDisplay,(AEE_FONT_BOLD+1),header,-1,0,2,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_SetColor(pMe->m_pOwner->a.m_pIDisplay,CLR_USER_TEXT,MAKE_RGB(0,0,0));
IDISPLAY_DrawText(pMe->m_pOwner->a.m_pIDisplay,(AEE_FONT_BOLD+1),tip1,-1,0,
pMe->m_pOwner->DeviceInfo.cyScreen-15,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_DrawText(pMe->m_pOwner->a.m_pIDisplay,(AEE_FONT_BOLD+1),tip2,-1,
pMe->m_pOwner->DeviceInfo.cxScreen-30,
pMe->m_pOwner->DeviceInfo.cyScreen-15,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_Update(pMe->m_pOwner->a.m_pIDisplay);
}
/**************************************************************************
* Function Name : ScheDateDisp_CusorMove
* Description : 移动屏幕上选中的时间小矩形.
* Input Parameters : CMainWin * ,int
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
static void ScheDateDisp_CusorMove(CMainWin* pMe,int direction)
{
switch(direction)
{
case UP:
/*天数减7*/
pMe->m_pOwner->m_day -= 7;
if(pMe->m_pOwner->m_day < 1)
{
pMe->m_pOwner->m_month--;
if(pMe->m_pOwner->m_month==0)
{
pMe->m_pOwner->m_year--;
pMe->m_pOwner->m_month = 12;
}
pMe->m_pOwner->m_day = pMe->m_pOwner->m_day + pMe->m_days;
ScheExt_SetMonthProperties( pMe->m_pOwner );
}
break;
case DOWN:
pMe->m_pOwner->m_day += 7;
if(pMe->m_pOwner->m_day>pMe->m_pOwner->m_days)
{
pMe->m_pOwner->m_month++;
if(pMe->m_pOwner->m_month==13)
{
pMe->m_pOwner->m_year++;
pMe->m_pOwner->m_month=1;
}
pMe->m_pOwner->m_day = pMe->m_pOwner->m_day - pMe->m_pOwner->m_days;
ScheExt_SetMonthProperties(pMe->m_pOwner);
}
break;
case LEFT:
pMe->m_pOwner->m_day--;
if(pMe->m_pOwner->m_day < 1)
{
pMe->m_pOwner->m_month--;
if(pMe->m_pOwner->m_month==0)
{
pMe->m_pOwner->m_year--;
pMe->m_pOwner->m_month=12;
}
ScheExt_SetMonthProperties(pMe->m_pOwner);
pMe->m_pOwner->m_day = pMe->m_pOwner->m_days;
}
break;
case RIGHT:
pMe->m_pOwner->m_day++;
if(pMe->m_pOwner->m_day > pMe->m_pOwner->m_days)
{
pMe->m_pOwner->m_month++;
if(pMe->m_pOwner->m_month==13)
{
pMe->m_pOwner->m_year++;
pMe->m_pOwner->m_month=1;
}
ScheExt_SetMonthProperties(pMe->m_pOwner);
pMe->m_pOwner->m_day=1;
}
break;
}
/*用颜色填充小方格*/
IDISPLAY_FillRect (pMe->m_pOwner->a.m_pIDisplay,&pMe->m_rGridRect, MAKE_RGB(255,255,255));
}
/**************************************************************************
* Function Name : ScheDateDisp_DrawDate
* Description : 在屏幕上绘出一个月的所有天.
* Input Parameters : CMainWin *
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
static void ScheDateDisp_DrawDate(CMainWin* pMe)
{
int v_temp=0;
int h_temp=0;
int x_dayPos=0;
int y_dayPos=0;
dword nDate=0;
int date=1;
/*在屏幕的上方绘制日期 YYYY/MM/DD*/
AECHAR szDate[6]={' ','\0'};
AECHAR space[4]={' ','\0'};
AECHAR sYear[10]={' ','\0'};
AECHAR sMonth[10]={' ','\0'};
WWRITELONG(sYear, pMe->m_pOwner->m_year);
STRTOWSTR("/",space,4);
WWRITELONG(sMonth, pMe->m_pOwner->m_month);
IDISPLAY_SetColor(pMe->m_pOwner->a.m_pIDisplay,CLR_USER_TEXT,MAKE_RGB(255,255,255));
IDISPLAY_DrawText(pMe->m_pOwner->a.m_pIDisplay,AEE_FONT_BOLD+1,sYear,-1,75,2,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_DrawText(pMe->m_pOwner->a.m_pIDisplay,AEE_FONT_BOLD+1,space,-1,106,2,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_DrawText(pMe->m_pOwner->a.m_pIDisplay,AEE_FONT_BOLD+1,sMonth,-1,112,2,NULL,IDF_TEXT_TRANSPARENT);
IDISPLAY_SetColor(pMe->m_pOwner->a.m_pIDisplay,CLR_USER_TEXT,MAKE_RGB(0,0,0));
// set the days of one month and set the date of the first day of one month
// draw the month's days on the screen
for(v_temp=0;v_temp<6;v_temp++)
{
h_temp=0;
if(v_temp==0) h_temp=pMe->m_firstPos;
for(;h_temp<7;h_temp++)
{
if( date > pMe->m_pOwner->m_days) break;
x_dayPos = h_temp*pMe->h_distance + pMe->h_startPos+2;
y_dayPos = v_temp*pMe->v_distance + pMe->v_startPos+1;
WWRITELONG(szDate, date);
IDISPLAY_DrawText(pMe->m_pOwner->a.m_pIDisplay,
AEE_FONT_BOLD+1, /*字体*/
szDate, /*绘制的日期*/
-1, /*绘制整个字符串*/
x_dayPos, /*绘制字符的X坐标*/
y_dayPos, /*绘制字符的Y坐标*/
NULL,
IDF_TEXT_TRANSPARENT /*绘制的方式*/
);
date++;
}
}
IDISPLAY_Update(pMe->m_pOwner->a.m_pIDisplay);
}
/**************************************************************************
* Function Name : ScheDateDisp_UpdateScreen
* Description : 接收到不同的事件后重绘屏幕.
* Input Parameters : CMainWin * ,int
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
static void ScheDateDisp_UpdateScreen(CMainWin* pMe,int direction)
{
ScheExt_Reset((Schedule *)pMe->m_pOwner ,pMe->set);
ScheDateDisp_DrawGround(pMe);
ScheDateDisp_CusorMove(pMe,direction);
ScheDateDisp_DrawCusor(pMe);
ScheDateDisp_DrawDate(pMe);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -