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

📄 scheventtype.c

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

#include "SchEventType.h"

/**************************************************************************
*	Function Name	 :	CEventTWin_New                                            
*	Description		 :	This function constructs menue window.
*	Input Parameters :	Schedule* 								
*	Output Parameters:	None												
*	Return Value	 :	IWindow *			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
IWindow *  CEventTWin_New(Schedule * pOwner)
{
	CEventTypeWin *        pMe;
    VTBL(IWindow)          vtbl;

	SH_IWINDOW_SETVTBL(&vtbl, CEventTWin_Enable, CEventTWin_Redraw, CEventTWin_HandleEvent, CEventTWin_Delete);
	pMe = (CEventTypeWin *)CWindow_New(sizeof(CEventTypeWin), pOwner, &vtbl);	
	if(NULL == pMe)
	{
		return FALSE;
	}
	/*初始化菜单*/
	if((ISHELL_CreateInstance
		(
		 pOwner->a.m_pIShell, 
		 AEECLSID_MENUCTL, 
		 (void**)(&pMe->m_pMenuCtl)
		) != SUCCESS)
	  )
	  return FALSE;
	/*初始化矩形变量*/
	SETAEERECT( &pMe->m_rMenuRect, 0, 20, pOwner->m_width, pOwner->m_height  );

	if(!ScheTypeMenu_InitMainMenu(pMe))
		return FALSE;
	/*初始化菜单状态*/
	pMe->m_eMenuState = APP_MAIN_MENU;
	
	/*返回窗体接口*/
    return (IWindow *)pMe;
}

/**************************************************************************
*	Function Name	 :	CEventTWin_Delete                                            
*	Description		 :	释放资源
*	Input Parameters :	IWindow* 								
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void CEventTWin_Delete(IWindow * po)
{
	CEventTypeWin *  pme = (CEventTypeWin *)po;
    ReleaseObj((void**)&pme->m_pMenuCtl);   
    
	FREEIF(pme);
}

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

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

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

   if (!pme->m_bActive)
      return;

   IDISPLAY_ClearScreen(pme->m_pIDisplay);

   SH_DRAWHEADER(pme);   
   IMENUCTL_Redraw(pme->m_pMenuCtl);

   IDISPLAY_Update(pme->m_pIDisplay);
}

/**************************************************************************
*	Function Name	 :	CEventTWin_HandleEvent                                            
*	Description		 :	handle current window events
*	Input Parameters :	IWindow * , AEEEvent , uint16 , uint32 							
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean CEventTWin_HandleEvent(IWindow * po, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
   CEventTypeWin *  pme = (CEventTypeWin *)po;
   /*返回目录窗口 date select...*/
   if ( SH_ISCLR(eCode) )
   {
      Schedule_SetWindow(pme->m_pOwner, APP_STATE_MENUDISP, 0);
      return TRUE;
   }
   if (SH_ISEVTKEY(eCode));
      IMENUCTL_HandleEvent(pme->m_pMenuCtl, eCode, wParam, dwParam);  

   if (!SH_ISEVTCMD(eCode))
      return FALSE;
   else
   {	   
	   pme->m_pOwner->eventType = wParam;
	   /*转到事件创建窗口*/
	   Schedule_SetWindow(pme->m_pOwner, APP_STATE_CREATEVT, 0);
   }

	return FALSE;
}

/**************************************************************************
*	Function Name	 :	ScheMenu_InitMainMenu                                            
*	Description		 :	add item into menu
*	Input Parameters :	CEventTypeWin* 								
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/13											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean ScheTypeMenu_InitMainMenu(CEventTypeWin* pme)
{   
   /*设置菜单外观属性*/
   SH_SetMenuAttr(
		             pme->m_pMenuCtl, 
		             AEECLSID_MENUCTL, 
		             MAKE_RGB(255,0,0),
		             &pme->m_rMenuRect, 
		             MP_MAXSOFTKEYITEMS
		         );
   SH_AddMenuItem( pme->m_pMenuCtl, IDS_EVTY_CANLEN,  NULL, IDI_EVTY_CANLEN , IDS_EVTY_CANLEN, 0);
   SH_AddMenuItem( pme->m_pMenuCtl, IDS_EVTY_ANNIVER, NULL, IDI_EVTY_ANNIVER, IDS_EVTY_ANNIVER,0);
   SH_AddMenuItem( pme->m_pMenuCtl, IDS_EVTY_MEMO,    NULL, IDI_EVTY_MEMO   , IDS_EVTY_MEMO,   0);
   SH_AddMenuItem( pme->m_pMenuCtl, IDS_EVTY_OTHER,   NULL, IDI_EVTY_OTHER  , IDS_EVTY_OTHER,  0);

   IMENUCTL_SetProperties( pme->m_pMenuCtl,MP_WRAPSCROLL); 
   IMENUCTL_SetActive(pme->m_pMenuCtl,TRUE); 

   return TRUE;
}

/**************************************************************************
*	Function Name	 :	ReleaseObj                                            
*	Description		 :	释放资源
*	Input Parameters :	void *** 								
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
static void ReleaseObj(void ** ppObj)
{
   if ( ppObj && *ppObj ) 
   {
      (void)IBASE_Release(((IBase *)*ppObj));
      *ppObj = NULL;
   }
}

⌨️ 快捷键说明

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