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

📄 schcreateevent.c

📁 brew开发的日历程序 完全模仿mediaplayer的结构设计 值得初学者学习
💻 C
📖 第 1 页 / 共 2 页
字号:
/**
 * File Name    : SchCreateEvent.c                                                                
 * Created      : 07/04/13                                                                        
 * Author       : ZhongNingLin@neusoft.com                                                                    
 * Model        : 05YOP                                                                           
 * Description  : [[CN]] 此文件的职责是: [[CN]]                           
**/

#include "SchCreateEvent.h"

/**************************************************************************
*	Function Name	 :	CWeekWin_New                                            
*	Description		 :	This function constructs weekly window.
*	Input Parameters :	Schedule* 								
*	Output Parameters:	None												
*	Return Value	 :	IWindow *			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
IWindow* CCEventWin_New(Schedule * pOwner)
{
	CreateEventWin*        pMe;
    VTBL(IWindow)          vtbl;
	
	SH_IWINDOW_SETVTBL(&vtbl, CCEventWin_Enable, CCEventWin_Redraw, CCEventWin_HandleEvent, CCEventWin_Delete);
	pMe = (CreateEventWin *)CWindow_New(sizeof(CreateEventWin), pOwner, &vtbl);	
	/*分配空间失败*/
	if(NULL == pMe)
	{
		return FALSE;
	}
    /*组建分配空间失败*/
	if( !SCEvent_CreateMainControls( pMe ) )
	{
		/*释放所有已经分配的空间*/
		SCEvent_ReleaseMainControls( pMe );
		return FALSE;
	}
	
	/*返回窗体接口*/
    return (IWindow *)pMe;
}
 
/**************************************************************************
*	Function Name	 :	CCEventWin_InitData                                            
*	Description		 :	释放资源
*	Input Parameters :	IWindow* 								
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/12											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void CCEventWin_InitData(CreateEventWin* pme)
{	 
}

/**************************************************************************
*	Function Name	 :	CWeekWin_Delete                                            
*	Description		 :	释放资源
*	Input Parameters :	IWindow* 								
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/12											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void CCEventWin_Delete(IWindow * po)
{
    CreateEventWin *  pme = (CreateEventWin *)po;
	/*Realese of control*/
	SCEvent_ReleaseMainControls(pme);   
	FREEIF(pme);	
}

/**************************************************************************
*	Function Name	 :	CWeekWin_Enable                                            
*	Description		 :	enable current window
*	Input Parameters :	IWindow * po, boolean bEnable						
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/12											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void CCEventWin_Enable(IWindow * po, boolean bEnable)
{
   CreateEventWin *  pme = (CreateEventWin *)po;

   if (!CWindow_ProcessEnable(po, bEnable))
      return;
   /*判断当前窗口是否为激活状态*/
   if (!pme->m_bActive)
   {      
      return;
   }
}

/**************************************************************************
*	Function Name	 :	CWeekWin_Redraw                                            
*	Description		 :	This function redraws the menu window.
*	Input Parameters :	IWindow* 								
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/12											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void  CCEventWin_Redraw(IWindow * po)
{
   CreateEventWin *  pme = (CreateEventWin *)po;

   if (!pme->m_bActive)
      return;

   IDISPLAY_ClearScreen(pme->m_pIDisplay);  
   
   SCEvent_CreateScreen(pme);

   SH_DRAWHEADER(pme);   

   IDISPLAY_Update(pme->m_pIDisplay);
}

/**************************************************************************
*	Function Name	 :	SCEvent_CreateScreen                                            
*	Description		 :	This function redraws the menu window.
*	Input Parameters :	IWindow* 								
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/12											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
static void SCEvent_CreateScreen(CreateEventWin* pMe)
{
   int yLoc = 25;  
   // display event text 
   SCEvent_InitTextCtl(pMe,yLoc);
   // display the current time
   SCEvent_DrawCurrentTime( pMe, yLoc);
   // display the state list menu
   yLoc += 12+ 2;
   SCEvent_InitMenuCtl(pMe,yLoc);
   // display Start date and time
   yLoc += 14 + 4;
   SCEvent_InitDateCtl(pMe,yLoc);
   // diaplay the operation tips
   //ScheEvtDisp_DispTips(pMe);
   // set the state list to active state
   IMENUCTL_SetActive(pMe->m_pStateList,TRUE);
   // get the event type and show it on the screen
   SCEvent_DispEvtType(pMe); 
   /*redarw all control*/
   SCEvent_RedrawAllCtl(pMe);
   
}

/**************************************************************************
*	Function Name	 :	SCEvent_RedrawAllCtl                                            
*	Description		 :	重绘所有控件
*	Input Parameters :	CreateEventWin* 								
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/13											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
static void SCEvent_RedrawAllCtl(CreateEventWin* pMe)
{
	ITEXTCTL_Redraw(pMe->m_pTitleText);
    ITEXTCTL_Redraw(pMe->m_pDetailText);

	ITIMECTL_Redraw(pMe->m_pStartTime);
    IDATECTL_Redraw(pMe->m_pStartDate);
	IMENUCTL_Redraw(pMe->m_pStateList);  
}
/**************************************************************************
*	Function Name	 :	SCEvent_InitTextCtl                                          
*	Description		 :	init TextControl
*	Input Parameters :	CreateEventWin *pMe,int yLoc						
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/13											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
static void SCEvent_InitTextCtl(CreateEventWin *pMe,int yLoc)
{
   // Display title text control
   ITEXTCTL_Reset( pMe->m_pTitleText);
   ITEXTCTL_SetProperties( pMe->m_pTitleText, TP_FRAME);
   ITEXTCTL_SetInputMode( pMe->m_pTitleText, AEE_TM_LETTERS );
   ITEXTCTL_SetMaxSize( pMe->m_pTitleText, MAX_DESC_SIZE );
   ITEXTCTL_SetRect( pMe->m_pTitleText, &pMe->m_titleRect);
   // Display detail text control
   ITEXTCTL_Reset( pMe->m_pDetailText);
   ITEXTCTL_SetProperties( pMe->m_pDetailText,TP_MULTILINE);
   ITEXTCTL_SetInputMode( pMe->m_pDetailText, AEE_TM_LETTERS );
   ITEXTCTL_SetMaxSize( pMe->m_pDetailText, MAX_DESC_SIZE );
   ITEXTCTL_SetRect( pMe->m_pDetailText, &pMe->m_detailRect);
   
}

/**************************************************************************
*	Function Name	 :	SCEvent_InitDateCtl                                          
*	Description		 :	init m_pStartDate
*	Input Parameters :	CreateEventWin *pMe,int yLoc						
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/13											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
static void  SCEvent_InitDateCtl(CreateEventWin* pMe,int yLoc)
{
   JulianType rJulianDate;
   dword nDate=0;
   // event date and time
   AECHAR StDate[30]={' ','\0'};
   AECHAR StTime[30]={' ','\0'};
   // set Start date and time
   STRTOWSTR("Start Date :",StDate,30);
   STRTOWSTR("Start Time :",StTime,30);

   IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,StDate,-1,0,yLoc,NULL,IDF_TEXT_TRANSPARENT);
   IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,StTime,-1,0,yLoc+16,NULL,IDF_TEXT_TRANSPARENT); 
   
   GETJULIANDATE( nDate, &rJulianDate );
   rJulianDate.wSecond = 0;

   IDATECTL_SetDate( pMe->m_pStartDate, rJulianDate.wYear, rJulianDate.wMonth, rJulianDate.wDay );
   IDATECTL_SetRect( pMe->m_pStartDate, &pMe->m_dateRect);   
   ITIMECTL_SetTime( pMe->m_pStartTime, 0 );
   ITIMECTL_SetRect( pMe->m_pStartTime, &pMe->m_timeRect);
   
}

/**************************************************************************
*	Function Name	 :	SCEvent_DrawCurrentTime                                          
*	Description		 :	draw the current time
*	Input Parameters :	CreateEventWin *pMe,int yLoc						
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/13											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
static void SCEvent_DrawCurrentTime(CreateEventWin* pMe,int yLoc)
{
	JulianType rJulianDate;
	AECHAR Hour[10]={' ','\0'};
	AECHAR Minute[10]={' ','\0'};
    AECHAR sHour[10]={' ','\0'};
    AECHAR sMinute[10]={' ','\0'};
    AECHAR space[4]={' ','\0'}; 
	AECHAR eventT[30] = {' ','\0'};
    dword nDate=0;
	int   fontWi = 0;
    /*load the event tye string*/
	ISHELL_LoadResString(pMe->m_pIShell,SCHEDULE_RES_FILE,pMe->m_pOwner->eventType,
		                 eventT,30); 
    //get current time
    GETJULIANDATE( nDate, &rJulianDate ); 
	if(rJulianDate.wHour<10)
	{
		WWRITELONG(sHour, 0);
		WWRITELONG(Hour, rJulianDate.wHour);
		WSTRCAT(sHour,Hour);
	}
	else WWRITELONG(sHour, rJulianDate.wHour);
	if(rJulianDate.wMinute<10)
	{
   	    WWRITELONG(sMinute, 0); 
		WWRITELONG(Minute, rJulianDate.wMinute);
		WSTRCAT(sMinute,Minute);
	}
	else  WWRITELONG(sMinute, rJulianDate.wMinute);
    STRTOWSTR(":",space,4);
    // Display the current time
   IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,sHour,  -1,0, yLoc,NULL,IDF_TEXT_TRANSPARENT);
   IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,space,  -1,18,yLoc,NULL,IDF_TEXT_TRANSPARENT);
   IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,sMinute,-1,24,yLoc,NULL,IDF_TEXT_TRANSPARENT);
   //get the string lenth
   fontWi  = IDISPLAY_MeasureText( pMe->m_pIDisplay, AEE_FONT_BOLD, eventT ); 
   //display the type of event pMe->m_pOwner->
   IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,
	                 eventT,-1,
					 pMe->m_pOwner->m_width - fontWi,
					 yLoc,NULL,IDF_TEXT_TRANSPARENT
					); 
   
}

/**************************************************************************
*	Function Name	 :	SCEvent_InitMenuCtl                                          
*	Description		 :	draw the current time

⌨️ 快捷键说明

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