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

📄 schedule.c

📁 brew开发的日历程序 完全模仿mediaplayer的结构设计 值得初学者学习
💻 C
📖 第 1 页 / 共 2 页
字号:
   FREEIF( pme );
}

/**************************************************************************
*	Function Name	 :	Schedule_SetWindow                                            
*	Description		 :	This function switches from one window to another:
*                       (1) Releases all the resources associated with the current window
*                       (2) Contructs the new window, if any
*                       (3) Enables and redraws the new window, if any
*	Input Parameters :	Schedule * pme, WinType eWin, uint32 dwParam						
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean Schedule_SetWindow(Schedule * pme, WinType eWin, uint32 dwParam)
{
   /* If same window, then redraw and return.*/
   if (pme->m_pWin && pme->m_eActiveWin == eWin && eWin != APP_NONE)
   {
      Schedule_Redraw(pme, TRUE);
      return TRUE;
   }
   /*释放当前窗口*/
   SH_RELEASEWIN(pme->m_pWin);

   switch (eWin)
   {
	  /*主窗口*/
      case APP_MAIN_WIN:       
         pme->m_pWin = Calendar_New(pme); 
         break;
	  /*主目录窗口*/
	  case APP_STATE_MENUDISP:
		 pme->m_pWin = CMenuWin_New(pme);
		 break;
	  /*星期显示窗口*/
      case APP_WEEKDATEDISP_WIN:   
         pme->m_pWin = CWeekWin_New(pme); 
         break;
	  /*事件类型显示窗口*/
	  case APP_STATE_EVTTYPE:
		 pme->m_pWin = CEventTWin_New(pme);
         break;
	  /*创建事件窗口*/
	  case APP_STATE_CREATEVT:
		 pme->m_pWin = CCEventWin_New(pme);
		 break;
      /*创建一日事件窗口*/
	  case APP_STATE_ONEDAYDISP:
		  pme->m_pWin = CExamineEventWin_New(pme);
		  break;
      /*创建日期选择窗口*/
	  case APP_DATESEL_WIN:
		  pme->m_pWin = CSelectDWin_New(pme);
		  break;

      default: 
         break;
   }

   if (!pme->m_pWin)
   {
      eWin = APP_NONE;
      return FALSE;
   }

   pme->m_eActiveWin = eWin;

   Schedule_Redraw(pme, TRUE);

   return TRUE;
}

/**************************************************************************
*	Function Name	 :	Schedule_Redraw                                            
*	Description		 :	This function schedules an aynchronous redraw if 
*                       bDefer is TRUE else it redras immediately.
*	Input Parameters :	Schedule * ,boolean						
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void Schedule_Redraw(Schedule * pme, boolean bDefer)
{
   if (pme->m_bRedraw)
      return;

   pme->m_bRedraw = TRUE;

   if (bDefer)
      ISHELL_Resume(pme->a.m_pIShell, &pme->m_cbRedraw);
   else
      Schedule_RedrawNotify(pme);
}

/**************************************************************************
*	Function Name	 :	Schedule_Redraw                                            
*	Description		 :	This function redraws the current window.
*                       This function is called either by IShell in response to the resume scheduled
*                       in Schedule_Redraw() or by Schedule_Redraw() directly.
*	Input Parameters :	Schedule * pme					
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void Schedule_RedrawNotify(Schedule * pme)
{
   if (!pme->m_bRedraw)
      return;

   pme->m_bRedraw = FALSE;

   if (pme->m_pWin)
   {
      IWINDOW_Enable(pme->m_pWin);
      IWINDOW_Redraw(pme->m_pWin);
   }
}


/**************************************************************************
*	Function Name	 :	SH_DrawImage                                            
*	Description		 :	draw image fill in the rect
*	Input Parameters :	IImage * pImage, AEERect * pRect, boolean bCenter				
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void SH_DrawImage(IImage * pImage, AEERect * pRect, boolean bCenter)
{
   AEEImageInfo   ii;
   int            x;
   int            y;

   IIMAGE_GetInfo(pImage, &ii);

   // Do not display if image does not fit in the allocated rectangle.
   //if (ii.cx > pRect->dx || ii.cy > pRect->dy)
    //  return;

   if (bCenter)
   {
      x = pRect->x + (pRect->dx / 2) - (ii.cxFrame / 2);
      y = pRect->y + (pRect->dy / 2) - (ii.cy / 2);
   }
   else
   {
      x = pRect->x;
      y = pRect->y;
   }

   IIMAGE_Start(pImage, x, y);
}

/**************************************************************************
*	Function Name	 :	SH_AddMenuItem                                            
*	Description		 :	This function adds one item to the specified IMenuCtl.
*	Input Parameters :	IMenuCtl *,uint16 , AECHAR * , uint16 ,uint16 ,uint32 				
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean SH_AddMenuItem(IMenuCtl * pMenu, uint16 wTextID, AECHAR * pText, uint16 wImageID, uint16 wItemID, uint32 dwData)
{
   CtlAddItem  ai;

   // Fill in the CtlAddItem structure values
   ai.pText = pText;
   ai.pImage = NULL;
   ai.pszResImage = SCHEDULE_RES_FILE;
   ai.pszResText  = SCHEDULE_RES_FILE;
   ai.wText = wTextID;
   ai.wFont = AEE_FONT_NORMAL;
   ai.wImage = wImageID;
   ai.wItemID = wItemID;
   ai.dwData = dwData;

   // Add the item to the menu control
   return IMENUCTL_AddItemEx( pMenu, &ai );
}
/**************************************************************************
*	Function Name	 :	SH_SetMenuAttr                                            
*	Description		 :	This function sets the menu attributes based 
*                       on BREW Style Sheet for menu control.
*	Input Parameters :	IMenuCtl *,uint16 , AECHAR * , uint16 ,uint16 ,uint32 				
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/11											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void SH_SetMenuAttr(IMenuCtl * pMenu, AEECLSID clsMenu, uint16 nColorDepth, AEERect * pRect, uint32 dwProps)
{
	AEEItemStyle		sel, normal;
	AEEMenuColors		col;

	// Menu Style
	normal.ft = MENU8_FT;
	normal.xOffset = 0;
	normal.yOffset = 0;
	normal.roImage = MENU8_RO;

   sel.ft = MENU8_SELECT_FT;
	sel.xOffset = 0;
	sel.yOffset = 0;
	sel.roImage = MENU8_SELECT_RO;

	// Menu Colors
   col.cSelText = MENU8_SELECT_TEXT;
	col.wMask = MENU8_COLOR_MASK;

   if (clsMenu == AEECLSID_MENUCTL)
   {
	   col.cBack = MENU8_BACKGROUND;
	   col.cSelBack = MENU8_SELECT_BACKGROUND;

      dwProps |= IMENUCTL_GetProperties(pMenu);
   }
   else if (clsMenu == AEECLSID_SOFTKEYCTL || clsMenu == AEECLSID_ICONVIEWCTL)
   {
	   col.cBack = TB8_BACKGROUND;
	   col.cSelBack = TB8_SELECT_BACKGROUND;

      dwProps |= MP_ICON_TEXT_TOP | MP_NO_ARROWS;
   }

   if (clsMenu == AEECLSID_MENUCTL || clsMenu == AEECLSID_SOFTKEYCTL || clsMenu == AEECLSID_ICONVIEWCTL)
   {
	   IMENUCTL_SetStyle(pMenu, &normal, &sel);
	   IMENUCTL_SetColors(pMenu, &col);
	   IMENUCTL_SetProperties(pMenu, dwProps);
      if (pRect)
         IMENUCTL_SetRect(pMenu, pRect);
   }
}

void Schedule_GetDateString(Schedule * pme, AECHAR *date)
{
	AECHAR space[4]={' ','\0'};
    AECHAR sYear[10]={' ','\0'};
    AECHAR sMonth[10]={' ','\0'};
    AECHAR sDay[10]={' ','\0'};
	AECHAR sDate[30] = {' ','\0'}; 

	WWRITELONG(sYear, pme->m_year);
    STRTOWSTR("-",space,4);
    WWRITELONG(sMonth, pme->m_month);
	WWRITELONG(sDay,pme->m_day);

	WSTRCAT(date,sYear); 
	WSTRCAT(date,space); 
	WSTRCAT(date,sMonth); 
	WSTRCAT(date,space); 
	WSTRCAT(date,sDay); 
}
//--------------------------------end of file-----------------

⌨️ 快捷键说明

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