Calendar.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:160k
源码类别:
MTK
开发平台:
C/C++
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_periodly_movement((U32) CLNDR_PRIVOUS_PERIOD);
- }
- /* void mmi_clndr_periodly_movement(CLNDR_CLNDAR_MOVEMENT type) */
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_periodly_movement
- * DESCRIPTION
- *
- * PARAMETERS
- * type [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_periodly_movement(U32 type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 highlightY;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- highlightY = g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex;
- switch (type)
- {
- case CLNDR_NEXT_PERIOD:
- /* the boundary of period */
- if (g_clndr_cntx->PeriodStartIndex == g_clndr_cntx->RowNumber - CLNDR_ROW)
- {
- return MMI_FALSE;
- }
- /* clndr_cntx->CalTime.nHour += g_clndr_cntx->PeriodInterval; */
- g_clndr_cntx->PeriodStartIndex++;
- if (highlightY > 0)
- {
- highlightY--;
- }
- break;
- /* return; */
- case CLNDR_PRIVOUS_PERIOD:
- /* the boundary of period */
- if (g_clndr_cntx->PeriodStartIndex == 0)
- {
- return MMI_FALSE;
- }
- /* clndr_cntx->CalTime.nHour -= g_clndr_cntx->PeriodInterval; */
- g_clndr_cntx->PeriodStartIndex--;
- if (highlightY < CLNDR_ROW - 1)
- {
- highlightY++;
- }
- break;
- /* return; */
- case CLNDR_NEXT_MULTI_PERIOD:
- g_clndr_cntx->PeriodStartIndex += CLNDR_ROW;
- if (g_clndr_cntx->PeriodStartIndex >= g_clndr_cntx->RowNumber - CLNDR_ROW)
- {
- g_clndr_cntx->PeriodStartIndex = g_clndr_cntx->RowNumber - CLNDR_ROW;
- }
- break;
- case CLNDR_PRIVOUS_MULTI_PERIOD:
- if (g_clndr_cntx->PeriodStartIndex <= CLNDR_ROW)
- {
- g_clndr_cntx->PeriodStartIndex = 0;
- }
- else
- {
- g_clndr_cntx->PeriodStartIndex -= CLNDR_ROW;
- }
- break;
- default:
- ASSERT(0);
- }
- mmi_clndr_get_period_range(g_clndr_cntx->PeriodStartIndex, g_clndr_cntx->VerticalList);
- wgui_cat83_set_select_vertical(
- IMG_TOP_UP,
- IMG_TOP_DOWN,
- IMG_BOTTOM_UP,
- IMG_BOTTOM_DOWN,
- g_clndr_cntx->VerticalList,
- CAT83_SELECT_ALIGN_LINE);
- mmi_clndr_weekly_set_content();
- wgui_cat83_set_highlight(highlightY, g_clndr_cntx->CalTime.DayIndex);
- return MMI_TRUE;
- }
- #endif /* __MMI_TOUCH_SCREEN__ */
- #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */
- #ifdef __MMI_TODOLIST__
- /*****************************************************************************
- * FUNCTION
- * mmi_prepare_for_add_task
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_prepare_for_add_task(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_tdl_set_clndr(&g_clndr_cntx->CalTime, g_clndr_cntx->DisplayType);
- /* TDLAddDefaultRecord(); */
- mmi_tdl_entry_select_task_type();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_highlight_add_task
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_highlight_add_task(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_tdl_cntx.CurrHiliteOption = TODO_LIST_TASK_OPTION_ADD; /* set tdl option as "ADD" */
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- SetKeyHandler(mmi_prepare_for_add_task, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetLeftSoftkeyFunction(mmi_prepare_for_add_task, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- #endif /* __MMI_TODOLIST__ */
- #ifdef __MMI_CLNDR_ICON_SUPPORT__
- /*****************************************************************************
- * FUNCTION
- * mmi_momthly_clndr_set_info_box
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_momthly_clndr_set_info_box(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- clndr_task_icon_struct task;
- /* ToDoListNode todoItem; */
- U8 taskNum[6]; /* two digits number */
- S8 timeString[CLNDR_TIME_STRING_LENGTH * 2 + 1 + 1]; /* HH:MM-HH:MM */
- #ifdef __MMI_BIRTHDAY_REMINDER__
- U8 pbNumber[MAX_PB_NUMBER_LENGTH + 1], pbName[(MAX_PB_NAME_LENGTH +1 )* ENCODING_LENGTH];
- U8 maxStrLen;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(g_clndr_cntx->info_box_text[0], 0, CLNDR_MAX_INFO_BOX_LEN + ENCODING_LENGTH);
- memset(g_clndr_cntx->info_box_text[1], 0, CLNDR_MAX_INFO_BOX_LEN + ENCODING_LENGTH);
- g_clndr_cntx->info_box_icon[0] = 0;
- g_clndr_cntx->info_box_icon[1] = 0;
- memcpy(&task, &(g_clndr_cntx->TaskDayList[g_clndr_cntx->CalTime.nDay]), sizeof(clndr_task_icon_struct));
- #ifdef __MMI_BIRTHDAY_REMINDER__
- if (g_clndr_cntx->BirthdayInfo[g_clndr_cntx->CalTime.nDay].count > 0) /* someone's birthday */
- {
- /* birthday reminder */
- g_clndr_cntx->info_box_icon[0] = IMG_CLNDR_BIRTHDAY_REMINDER;
- memset(pbNumber, 0, MAX_PB_NUMBER_LENGTH + 1);
- memset(pbName, 0, (MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH);
- mmi_phb_get_name_number(
- g_clndr_cntx->BirthdayInfo[g_clndr_cntx->CalTime.nDay].firstMatchedIndex,
- pbName,
- pbNumber);
- pfnUnicodeStrcpy((S8*) g_clndr_cntx->info_box_text[0], (PS8) L"(");
- mmi_clndr_util_num_to_unicode(g_clndr_cntx->BirthdayInfo[g_clndr_cntx->CalTime.nDay].count, taskNum, 3);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[0], (S8*) taskNum);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[0], (PS8) L") ");
- maxStrLen = (CLNDR_MAX_INFO_BOX_LEN / ENCODING_LENGTH) - pfnUnicodeStrlen((S8*)L"() ") - pfnUnicodeStrlen((S8*)taskNum);
- if(pfnUnicodeStrlen((S8*)pbName) > maxStrLen)
- {
- pfnUnicodeStrncat((S8*)g_clndr_cntx->info_box_text[0], (S8*)pbName, (U32)maxStrLen);
- }
- else
- {
- pfnUnicodeStrcat((S8*)g_clndr_cntx->info_box_text[0], (S8*)pbName);
- }
- /* todo reminder */
- if (task.date > 0)
- {
- g_clndr_cntx->info_box_icon[1] = task.icon;
- pfnUnicodeStrcpy((S8*) g_clndr_cntx->info_box_text[1], (PS8) L"(");
- mmi_clndr_util_num_to_unicode(task.date, taskNum, 3);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[1], (S8*) taskNum);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[1], (PS8) L") ");
- if(pfnUnicodeStrlen((S8*)task.maxPriorityTask->Note) > maxStrLen)
- {
- pfnUnicodeStrncat((S8*)g_clndr_cntx->info_box_text[1], (S8*)task.maxPriorityTask->Note, (U32)maxStrLen);
- }
- else
- {
- pfnUnicodeStrcat((S8*)g_clndr_cntx->info_box_text[1], (S8*)task.maxPriorityTask->Note);
- }
- }
- }
- else
- #endif /* __MMI_BIRTHDAY_REMINDER__ */
- if (task.date > 0)
- {
- g_clndr_cntx->info_box_icon[0] = IMG_CLNDR_TASK_CLOCK;
- memset(timeString, 0, CLNDR_TIME_STRING_LENGTH * 2 + 1 + 1);
- mmi_tdl_get_time_string(
- task.maxPriorityTask,
- &(g_clndr_cntx->CalTime),
- timeString);
- AnsiiToUnicodeString((S8*) g_clndr_cntx->info_box_text[0], (S8*) timeString);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[0], (PS8) L"(");
- mmi_clndr_util_num_to_unicode(task.date, taskNum, 2);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[0], (S8*) taskNum);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[0], (PS8) L"-1)");
- g_clndr_cntx->info_box_icon[1] = task.icon;
- memcpy(g_clndr_cntx->info_box_text[1], task.maxPriorityTask->Note, CLNDR_MAX_INFO_BOX_LEN);
- }
- else
- {
- g_clndr_cntx->info_box_icon[0] = 0;
- g_clndr_cntx->info_box_icon[1] = 0;
- }
- wgui_cat83_set_infobox(g_clndr_cntx->info_box_icon, g_clndr_cntx->info_box_text, CLNDR_INFO_BOX_ROW);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_weekly_clndr_set_info_box
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_weekly_clndr_set_info_box(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- clndr_task_icon_struct task;
- ToDoListNode todoItem;
- U8 taskNum[6]; /* two digits number */
- S8 timeString[CLNDR_TIME_STRING_LENGTH * 2 + 1 + 1]; /* hh:mm-hh:mm */
- U32 index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(g_clndr_cntx->info_box_text[0], 0, CLNDR_MAX_INFO_BOX_LEN + ENCODING_LENGTH);
- memset(g_clndr_cntx->info_box_text[1], 0, CLNDR_MAX_INFO_BOX_LEN + ENCODING_LENGTH);
- index = g_clndr_cntx->CurrPeriodIndex * CLNDR_COLUMN + g_clndr_cntx->CalTime.DayIndex;
- memcpy(&task, &(g_clndr_cntx->TaskDayList[index]), sizeof(clndr_task_icon_struct));
- if (task.date > 0)
- {
- memcpy(&todoItem, task.maxPriorityTask, sizeof(ToDoListNode));
- g_clndr_cntx->info_box_icon[0] = IMG_CLNDR_TASK_CLOCK;
- memset(timeString, 0, CLNDR_TIME_STRING_LENGTH * 2 + 1 + 1);
- /* start time */
- mmi_tdl_get_time_string(
- task.maxPriorityTask,
- &(g_clndr_cntx->CalTime),
- timeString);
- AnsiiToUnicodeString((S8*) g_clndr_cntx->info_box_text[0], timeString);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[0], (PS8) L"(");
- mmi_clndr_util_num_to_unicode(task.date, taskNum, 2);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[0], (S8*) taskNum);
- pfnUnicodeStrcat((S8*) g_clndr_cntx->info_box_text[0], (PS8) L"-1)");
- g_clndr_cntx->info_box_icon[1] = todoItem.Type + IMG_CLNDR_ICON_REMINDER;
- memcpy(g_clndr_cntx->info_box_text[1], task.maxPriorityTask->Note, CLNDR_MAX_INFO_BOX_LEN);
- //g_clndr_cntx->info_box_icon[1] = task.maxPriorityTask->Type + IMG_CLNDR_ICON_MEETING;
- //memcpy(g_clndr_cntx->info_box_text[1],task.maxPriorityTask->Note, CLNDR_MAX_INFO_BOX_LEN);
- }
- else
- {
- g_clndr_cntx->info_box_icon[0] = 0;
- g_clndr_cntx->info_box_icon[1] = 0;
- /* g_clndr_cntx->info_box_icon[1] = NULL; */
- }
- wgui_cat83_set_infobox(g_clndr_cntx->info_box_icon, g_clndr_cntx->info_box_text, CLNDR_INFO_BOX_ROW);
- }
- #endif /* __MMI_CLNDR_ICON_SUPPORT__ */
- #else /* __MMI_CALENDAR_V2__ */
- /*****************************************************************************
- * FUNCTION
- * HighlightClndrDate
- * DESCRIPTION
- * Highlight handler of a date on calendar
- * PARAMETERS
- * date [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void HighlightClndrDate(S32 date)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_clndr_cntx->CalTime.nDay = (U8) date;
- }
- #endif /* __MMI_CALENDAR_V2__ */
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_set_date
- * DESCRIPTION
- *
- * PARAMETERS
- * date [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_set_date(MYTIME *date)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx != NULL)
- {
- memcpy(&(g_clndr_cntx->CalTime), date, sizeof(MYTIME));
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrInit
- * DESCRIPTION
- * Register highlight handlers
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrInit(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetHiliteHandler(ORGANIZER_CALENDER_MENU, HighlightClndrMenu);
- SetHintHandler(MENU_CAL_TYPE, ClndrLunarHintHandler);
- SetHiliteHandler(MENU_GOTO_TASK_CAL, HighlightClndrViewTask);
- SetHiliteHandler(MENU_CAL_TYPE, HighlightClndrLunar);
- SetHiliteHandler(MENU_ID_CLNDR_JUMP_TO_DATE, HighlightJumpToDate);
- #ifdef __MMI_CALENDAR_V2__
- #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
- SetHiliteHandler(MENU_ID_CLNDR_MONTHLY_VIEW, mmi_clndr_highlight_monthly_view);
- SetHiliteHandler(MENU_ID_CLNDR_WEEKLY_VIEW, mmi_clndr_highlight_weekly_view);
- #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */
- SetHiliteHandler(MENU_ID_CLNDR_ADD_TASK, mmi_clndr_highlight_add_task);
- #endif /* __MMI_CALENDAR_V2__ */
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrDeInit
- * DESCRIPTION
- * Free allocated memory
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrDeInit(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx)
- {
- OslMfree(g_clndr_cntx);
- g_clndr_cntx = NULL;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * HighlightClndrMenu
- * DESCRIPTION
- * Highlight handler of Calendar menu item.
- * Register key handlers.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HighlightClndrMenu(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
- SetLeftSoftkeyFunction(ClndrPreEntryApp, KEY_EVENT_UP);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(ClndrPreEntryApp, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- #define CLNDR_APP_SCREEN
- /*****************************************************************************
- * FUNCTION
- * ClndrPreEntryApp
- * DESCRIPTION
- * Initialize variables and go to calendar screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrPreEntryApp(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME currentTime;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx == NULL)
- {
- g_clndr_cntx = OslMalloc(sizeof(clndr_context_struct));
- }
- GetDateTime(¤tTime);
- memset(&g_clndr_cntx->CalTime, 0, sizeof(MYTIME));
- g_clndr_cntx->CalTime.nDay = currentTime.nDay;
- g_clndr_cntx->CalTime.nMonth = currentTime.nMonth;
- g_clndr_cntx->CalTime.nYear = currentTime.nYear;
- #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
- g_clndr_cntx->CalTime.nHour = currentTime.nHour;
- ReadValue(NVRAM_CLNDR_PERIOD_INTERVAL, &(g_clndr_cntx->PeriodInterval), DS_BYTE, &error);
- if (g_clndr_cntx->PeriodInterval == 0 || g_clndr_cntx->PeriodInterval == 0xFF)
- {
- g_clndr_cntx->PeriodInterval = CLNDR_WEEKLY_PERIOD_INTERVAL;
- WriteValue(NVRAM_CLNDR_PERIOD_INTERVAL, &(g_clndr_cntx->PeriodInterval), DS_BYTE, &error);
- }
- g_clndr_cntx->PeriodStartIndex = (currentTime.nHour / g_clndr_cntx->PeriodInterval);
- #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */
- /* lunar state */
- ReadValue(LUNAR_CALENDAR, (void*)&g_clndr_cntx->LunarState, DS_BYTE, &error);
- if (g_clndr_cntx->LunarState != TRUE)
- {
- g_clndr_cntx->LunarState = FALSE;
- }
- #ifdef __MMI_CALENDAR_V2__
- g_clndr_cntx->DisplayType = CLNDR_MONTHLY_VIEW;
- g_clndr_cntx->RowNumber = CLNDR_ROW;
- #endif /* __MMI_CALENDAR_V2__ */
- EntryClndrScreen();
- }
- /*****************************************************************************
- * FUNCTION
- * UpdateClndrContext
- * DESCRIPTION
- * Callback from GUI layer to update calendar application
- * PARAMETERS
- * day [IN]
- * month [IN]
- * year [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void UpdateClndrContext(S32 day, S32 month, S32 year)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME myTime;
- #ifndef __MMI_CLNDR_ICON_SUPPORT__
- S32 i;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_clndr_cntx->CalTime.nDay = day;
- g_clndr_cntx->CalTime.nMonth = month;
- g_clndr_cntx->CalTime.nYear = year;
- /* get the list of days to be highlithed */
- memset(&myTime, 0, sizeof(MYTIME));
- #ifdef __MMI_TODOLIST__
- myTime.nYear = g_clndr_cntx->CalTime.nYear;
- myTime.nMonth = g_clndr_cntx->CalTime.nMonth;
- myTime.nDay = g_clndr_cntx->CalTime.nDay;
- #ifdef __MMI_CLNDR_ICON_SUPPORT__
- #else /* __MMI_CLNDR_ICON_SUPPORT__ */
- TDLGetDaysToBeHilited(myTime, g_clndr_cntx->TaskDayList);
- if (g_clndr_cntx->TaskDayList[0] != CLNDR_MAX_DAYS)
- {
- for (i = 1; i <= g_clndr_cntx->TaskDayList[0]; i++)
- {
- SetCalendarDay(g_clndr_cntx->TaskDayList[i], CALENDAR_TASK_DAY);
- }
- }
- else
- {
- for (i = 1; i <= CLNDR_MAX_DAYS; i++)
- {
- SetCalendarDay(i, CALENDAR_TASK_DAY);
- }
- }
- #endif /* __MMI_CLNDR_ICON_SUPPORT__ */
- #endif /* __MMI_TODOLIST__ */
- /* browsing to current month */
- GetDateTime(&myTime);
- if (myTime.nMonth == month && myTime.nYear == year)
- {
- SetCalendarDay(myTime.nDay, CALENDAR_CURRENT_DAY);
- }
- if (g_clndr_cntx->LunarState == TRUE && IsChineseSet())
- {
- g_clndr_cntx->LunarInfo.SolarMonth = g_clndr_cntx->CalTime.nMonth;
- g_clndr_cntx->LunarInfo.SolarYear = g_clndr_cntx->CalTime.nYear;
- g_clndr_cntx->LunarInfo.SolarDay = g_clndr_cntx->CalTime.nDay;
- ClndrComputeLunarInfo(&g_clndr_cntx->LunarInfo);
- SetCalendarPopupDay(
- g_clndr_cntx->LunarInfo.SolarDay,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine1,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine2,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine3);
- SetCategory82Title1((U8*) g_clndr_cntx->LunarInfo.TitleInfo1); /* OR calInfo.totlestring */
- SetCategory82Title3((U8*) g_clndr_cntx->LunarInfo.TitleInfo2);
- }
- }
- #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
- U16 g_image_list[3];
- U8 *g_description_list[3];
- /*****************************************************************************
- * FUNCTION
- * ClndrUpdateInfoBox
- * DESCRIPTION
- *
- * PARAMETERS
- * num_info [?] [?] [?]
- * icon_list [IN]
- * description_list [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrUpdateInfoBox(S32 *num_info, U16 **icon_list, U8 ***description_list)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *num_info = 3;
- g_description_list[0] = (U8*) g_clndr_cntx->LunarInfo.MessageLine1;
- g_description_list[1] = (U8*) g_clndr_cntx->LunarInfo.MessageLine2;
- g_description_list[2] = (U8*) g_clndr_cntx->LunarInfo.MessageLine3;
- *description_list = g_description_list;
- g_image_list[0] = g_image_list[1] = g_image_list[2] = 0;
- *icon_list = g_image_list;
- }
- #endif /* __MMI_UI_CALENDAR_WITH_INFO_BOX__ */
- /*****************************************************************************
- * FUNCTION
- * EntryClndrScreen
- * DESCRIPTION
- * Display calendar screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void EntryClndrScreen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME myTime;
- #ifdef __MMI_CALENDAR_V2__
- S32 j, highlightCell, currCell = -1;
- wgui_cat83_cell_struct *startCell;
- #else
- U8 lunarOptionInternal;
- #ifdef __MMI_TODOLIST__
- S32 i;
- #endif
- #endif /* __MMI_CALENDAR_V2__ */
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_CALENDAR_V2__
- EntryNewScreen(SCR_ID_CLNDR_SCREEN, ExitClndrScreen, EntryClndrScreen, NULL);
- g_clndr_cntx->Title = mmi_frm_scrmem_alloc(CLNDR_TITLE_LEN * CLNDR_COLUMN);
- g_clndr_cntx->HorizonList[0] =
- (U8*) mmi_frm_scrmem_alloc(CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH * CLNDR_COLUMN);
- g_clndr_cntx->VerticalList[0] =
- (U8*) mmi_frm_scrmem_alloc(CLNDR_VERTICAL_LIST_CELL_LEN * ENCODING_LENGTH * CLNDR_ROW);
- g_clndr_cntx->CalendarCell = mmi_frm_scrmem_alloc((g_clndr_cntx->RowNumber * CLNDR_COLUMN) * CLNDR_CELL_SIZE);
- /* allocate memory for reminder */
- g_clndr_cntx->info_box_text[0] = OslMalloc(CLNDR_MAX_INFO_BOX_LEN + ENCODING_LENGTH);
- g_clndr_cntx->info_box_text[1] = OslMalloc(CLNDR_MAX_INFO_BOX_LEN + ENCODING_LENGTH);
- for (j = 1; j < CLNDR_COLUMN; j++)
- {
- g_clndr_cntx->HorizonList[j] = g_clndr_cntx->HorizonList[j - 1] + CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH;
- }
- for (j = 1; j < CLNDR_ROW; j++)
- {
- g_clndr_cntx->VerticalList[j] =
- g_clndr_cntx->VerticalList[j - 1] + CLNDR_VERTICAL_LIST_CELL_LEN * ENCODING_LENGTH;
- }
- /* reset memory */
- memset(g_clndr_cntx->Title, 0, CLNDR_TITLE_LEN * CLNDR_COLUMN);
- memset(g_clndr_cntx->HorizonList[0], 0, CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH * CLNDR_COLUMN);
- memset(g_clndr_cntx->VerticalList[0], 0, CLNDR_VERTICAL_LIST_CELL_LEN * ENCODING_LENGTH * CLNDR_ROW);
- memset(g_clndr_cntx->CalendarCell, 0, g_clndr_cntx->RowNumber * CLNDR_COLUMN * CLNDR_CELL_SIZE);
- ClndrGetScreenInfo();
- wgui_cat83_set_horizontal_string(g_clndr_cntx->HorizonList);
- if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
- {
- highlightCell = g_clndr_cntx->DayOnFirst + g_clndr_cntx->CalTime.nDay - 1;
- /* set current date */
- GetDateTime(&myTime);
- if (myTime.nMonth == g_clndr_cntx->CalTime.nMonth && myTime.nYear == g_clndr_cntx->CalTime.nYear)
- {
- currCell = g_clndr_cntx->DayOnFirst + myTime.nDay - 1;
- }
- wgui_cat83_register_cell_highlight_handler(mmi_clndr_monthly_highlight);
- wgui_cat83_register_left_arrow_key_handler(mmi_clndr_left_out_of_boundary);
- wgui_cat83_register_right_arrow_key_handler(mmi_clndr_right_out_of_boundary);
- wgui_cat83_register_up_arrow_key_handler(mmi_clndr_up_out_of_boundary);
- wgui_cat83_register_down_arrow_key_handler(mmi_clndr_down_out_of_boundary);
- wgui_cat83_register_up_side_key_handler(mmi_clndr_up_side_key);
- wgui_cat83_register_down_side_key_handler(mmi_clndr_down_side_key);
- #ifdef __MMI_TOUCH_SCREEN__
- wgui_cat83_set_select_horizontal1_handler(mmi_clndr_touch_year_decrease, mmi_clndr_touch_year_increase);
- wgui_cat83_set_select_horizontal2_handler(mmi_clndr_touch_month_decrease, mmi_clndr_touch_month_increase);
- #endif
- mmi_momthly_clndr_set_info_box();
- mmi_clndr_monthly_set_content();
- ShowCategory83Screen(
- IMG_CALENDAR_JAN,
- (U8 **) g_clndr_cntx->HorizonList,
- (wgui_cat83_cell_struct*) g_clndr_cntx->CalendarCell,
- CLNDR_ROW,
- CLNDR_COLUMN,
- currCell / CLNDR_COLUMN,
- currCell % CLNDR_COLUMN,
- highlightCell / CLNDR_COLUMN,
- highlightCell % CLNDR_COLUMN,
- CAT83_CELL_BG_FILL_HORIZONTAL,
- CAT83_CELL_TEXT_DISPLAY_LEFT_BOTTOM,
- CAT83_CELL_ICON_DISPLAY_RIGHT_TOP);
- }
- #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
- else if (g_clndr_cntx->DisplayType == CLNDR_WEEKLY_VIEW)
- {
- wgui_cat83_register_cell_highlight_handler(mmi_clndr_weekly_highlight);
- wgui_cat83_register_left_arrow_key_handler(mmi_clndr_left_out_of_boundary);
- wgui_cat83_register_right_arrow_key_handler(mmi_clndr_right_out_of_boundary);
- wgui_cat83_register_up_arrow_key_handler(mmi_clndr_up_out_of_boundary);
- wgui_cat83_register_down_arrow_key_handler(mmi_clndr_down_out_of_boundary);
- wgui_cat83_register_up_side_key_handler(mmi_clndr_weekly_decrease);
- wgui_cat83_register_down_side_key_handler(mmi_clndr_weekly_increase);
- #ifdef __MMI_TOUCH_SCREEN__
- wgui_cat83_set_select_horizontal1_handler(mmi_clndr_weekly_decrease,mmi_clndr_weekly_increase);
- wgui_cat83_set_select_horizontal2_handler(
- mmi_clndr_touch_multi_periodly_decrease,
- mmi_clndr_touch_multi_periodly_increase);
- wgui_cat83_set_select_vertical_handler(
- mmi_clndr_touch_single_periodly_decrease,
- mmi_clndr_touch_single_periodly_increase);
- #endif
- ClndrGetScreenInfo();
- mmi_weekly_clndr_set_info_box();
- mmi_clndr_weekly_set_content();
- startCell = g_clndr_cntx->CalendarCell + (g_clndr_cntx->PeriodStartIndex * CLNDR_COLUMN);
- ShowCategory83Screen(
- IMG_CALENDAR_JAN,
- (U8 **) g_clndr_cntx->HorizonList,
- startCell,
- CLNDR_ROW,
- CLNDR_COLUMN,
- 0xFFFFFFFF, /* do not mark current period */
- 0xFFFFFFFF,
- g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex,
- DOW(g_clndr_cntx->CalTime.nYear, g_clndr_cntx->CalTime.nMonth, g_clndr_cntx->CalTime.nDay),
- CAT83_CELL_BG_FILL_VERTICAL,
- CAT83_CELL_TEXT_DISPLAY_LEFT_BOTTOM,
- CAT83_CELL_ICON_DISPLAY_CENTER);
- }
- #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */
- ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
- ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, 0);
- #else /* __MMI_CALENDAR_V2__ */
- gClndrAddToHistory = FALSE;
- EntryNewScreen(SCR_ID_CLNDR_SCREEN, ExitClndrScreen, NULL, NULL);
- gClndrAddToHistory = TRUE;
- ClndrGetScreenInfo();
- if (g_clndr_cntx->LunarState == TRUE && IsChineseSet())
- {
- lunarOptionInternal = TRUE;
- InitializeCategory82Screen(
- g_clndr_cntx->DayOnFirst,
- g_clndr_cntx->NumDaysInMonth,
- g_clndr_cntx->CalTime.nDay,
- g_clndr_cntx->CalTime.nMonth,
- g_clndr_cntx->CalTime.nYear);
- }
- else
- {
- lunarOptionInternal = FALSE;
- InitializeCategory80Screen(
- g_clndr_cntx->DayOnFirst,
- g_clndr_cntx->NumDaysInMonth,
- g_clndr_cntx->CalTime.nDay,
- g_clndr_cntx->CalTime.nMonth,
- g_clndr_cntx->CalTime.nYear);
- }
- #ifdef __MMI_TODOLIST__
- if (g_clndr_cntx->TaskDayList[0] != CLNDR_MAX_DAYS)
- {
- for (i = 1; i <= g_clndr_cntx->TaskDayList[0]; i++)
- {
- SetCalendarDay(g_clndr_cntx->TaskDayList[i], CALENDAR_TASK_DAY);
- }
- }
- else
- {
- for (i = 1; i <= CLNDR_MAX_DAYS; i++)
- {
- SetCalendarDay(i, CALENDAR_TASK_DAY);
- }
- }
- #endif /* __MMI_TODOLIST__ */
- /* browsing to current month */
- GetDateTime(&myTime);
- if (myTime.nMonth == g_clndr_cntx->CalTime.nMonth && myTime.nYear == g_clndr_cntx->CalTime.nYear)
- {
- SetCalendarDay(myTime.nDay, CALENDAR_CURRENT_DAY);
- }
- RegisterCalendarHighlightHandler(HighlightClndrDate);
- RegisterCalendarUpdateHandler(UpdateClndrContext);
- #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
- if (lunarOptionInternal == TRUE)
- {
- RegisterCalendarUpdateInfoBoxHandler(ClndrUpdateInfoBox);
- }
- #endif /* __MMI_UI_CALENDAR_WITH_INFO_BOX__ */
- if (IsChineseSet())
- {
- SetCalendarTitleImage(CAL_CHINESE_DAYS_IMAGE);
- }
- else
- {
- SetCalendarTitleImage(CAL_ENGLISH_DAYS_IMAGE);
- }
- if (lunarOptionInternal == FALSE)
- {
- ShowCategory80Screen(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS, STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 0);
- }
- else
- {
- g_clndr_cntx->LunarInfo.SolarMonth = g_clndr_cntx->CalTime.nMonth;
- g_clndr_cntx->LunarInfo.SolarYear = g_clndr_cntx->CalTime.nYear;
- g_clndr_cntx->LunarInfo.SolarDay = g_clndr_cntx->CalTime.nDay;
- ClndrComputeLunarInfo(&g_clndr_cntx->LunarInfo);
- SetCalendarPopupDay(
- g_clndr_cntx->LunarInfo.SolarDay,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine1,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine2,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine3);
- SetCategory82Title1((U8*) g_clndr_cntx->LunarInfo.TitleInfo1); /* OR calInfo.totlestring */
- /* SetCategory82Title2((U8*)g_clndr_cntx->TitleString); */
- SetCategory82Title3((U8*) g_clndr_cntx->LunarInfo.TitleInfo2);
- SetCalendarPopupTitleLunarFunc(ClndrGeneratePopupInfo);
- ShowCategory82Screen(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS, STR_GLOBAL_BACK, IMG_GLOBAL_OK, 0);
- }
- SetKeyHandler(wgui_calendar_previous_month, KEY_VOL_UP, KEY_EVENT_DOWN);
- SetKeyHandler(wgui_calendar_previous_month, KEY_VOL_UP, KEY_LONG_PRESS);
- SetKeyHandler(wgui_calendar_next_month, KEY_VOL_DOWN, KEY_EVENT_DOWN);
- SetKeyHandler(wgui_calendar_next_month, KEY_VOL_DOWN, KEY_LONG_PRESS);
- SetCalendarMonthFunctions(
- wgui_calendar_previous_month_day,
- wgui_calendar_next_month_day,
- wgui_calendar_previous_month_week,
- wgui_calendar_next_month_week);
- #ifdef __MMI_TOUCH_SCREEN__
- SetCalendarMonthChangeFunctions(wgui_calendar_previous_month, wgui_calendar_next_month);
- /* 053005 Calvin Start */
- #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
- SetCalendarYearChangeFunctions(wgui_calendar_previous_year, wgui_calendar_next_year);
- #endif
- /* 053005 Calvin End */
- #endif /* __MMI_TOUCH_SCREEN__ */
- #endif /* __MMI_CALENDAR_V2__ */
- SetLeftSoftkeyFunction(EntryClndrOptions, KEY_EVENT_UP);
- SetRightSoftkeyFunction(ClndrGoBackFromCalendar, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * ExitClndrScreen
- * DESCRIPTION
- * Exit function of calendar screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ExitClndrScreen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_CALENDAR_V2__
- mmi_frm_scrmem_free((void*)g_clndr_cntx->Title);
- mmi_frm_scrmem_free((void*)g_clndr_cntx->HorizonList[0]);
- mmi_frm_scrmem_free((void*)g_clndr_cntx->VerticalList[0]);
- mmi_frm_scrmem_free((void*)g_clndr_cntx->CalendarCell);
- OslMfree(g_clndr_cntx->info_box_text[0]);
- OslMfree(g_clndr_cntx->info_box_text[1]);
- #else /* __MMI_CALENDAR_V2__ */
- if (gClndrAddToHistory)
- {
- history Scr;
- S16 nHistory = 0;
- Scr.scrnID = SCR_ID_CLNDR_SCREEN;
- Scr.entryFuncPtr = EntryClndrScreen;
- GetCategoryHistory(Scr.guiBuffer);
- pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
- AddHistory(Scr);
- }
- #endif /* __MMI_CALENDAR_V2__ */
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrGetScreenInfo
- * DESCRIPTION
- * Get screen display information of.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrGetScreenInfo(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_TODOLIST__
- MYTIME myTime;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* get the DOW 1st of todays month */
- g_clndr_cntx->DayOnFirst = DOW(g_clndr_cntx->CalTime.nYear, g_clndr_cntx->CalTime.nMonth, 1);
- /* get the num of days in todays month */
- g_clndr_cntx->NumDaysInMonth = LastDayOfMonth(g_clndr_cntx->CalTime.nMonth, g_clndr_cntx->CalTime.nYear);
- /* get the list of days to be highlithed */
- #ifdef __MMI_TODOLIST__
- memset(&myTime, 0, sizeof(MYTIME));
- myTime.nYear = g_clndr_cntx->CalTime.nYear;
- myTime.nMonth = g_clndr_cntx->CalTime.nMonth;
- myTime.nDay = g_clndr_cntx->CalTime.nDay;
- #ifdef __MMI_CALENDAR_V2__
- /* reset task list */
- memset(g_clndr_cntx->TaskDayList, 0, CLNDR_COLUMN * CLNDR_ROW * sizeof(clndr_task_icon_struct));
- mmi_clndr_get_date_str(&(g_clndr_cntx->CalTime), g_clndr_cntx->Title);
- if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
- {
- mmi_clndr_get_weekday(g_clndr_cntx->HorizonList);
- mmi_clndr_get_week_numbers(
- g_clndr_cntx->CalTime.nYear,
- g_clndr_cntx->CalTime.nMonth,
- g_clndr_cntx->VerticalList);
- mmi_clndr_construct_monthly_cell_info();
- }
- #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
- else
- {
- mmi_clndr_get_weekly_dates(&g_clndr_cntx->CalTime, g_clndr_cntx->HorizonList);
- /* todo : compute the start period index */
- mmi_clndr_get_period_range(g_clndr_cntx->PeriodStartIndex, g_clndr_cntx->VerticalList);
- mmi_clndr_construct_weekly_cell_info();
- #ifdef MMI_ON_WIN32
- g_clndr_cntx->WeekNum = mmi_dt_get_week_number(& g_clndr_cntx->CalTime);
- #else
- g_clndr_cntx->WeekNum = applib_dt_get_week_number((applib_time_struct*) & g_clndr_cntx->CalTime);
- #endif
- }
- #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */
- #else /* __MMI_CALENDAR_V2__ */
- TDLGetDaysToBeHilited(myTime, g_clndr_cntx->TaskDayList);
- #endif /* __MMI_CALENDAR_V2__ */
- #endif /* __MMI_TODOLIST__ */
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrGoBackFromCalendar
- * DESCRIPTION
- * Free memory and go back to previous screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrGoBackFromCalendar(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- GoBackHistory();
- ClndrDeInit();
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrGeneratePopupInfo
- * DESCRIPTION
- * Adjust solar day accoding and get lunar info.
- * PARAMETERS
- * type [IN]
- * num_cols [IN]
- * new_day [IN]
- * old_day [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrGeneratePopupInfo(U8 type, U8 num_cols, U8 new_day, U8 old_day)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (type)
- {
- case NEXT_DAY:
- g_clndr_cntx->LunarInfo.SolarDay += 1;
- break;
- case PREV_DAY:
- g_clndr_cntx->LunarInfo.SolarDay -= 1;
- break;
- case NEXT_ROW:
- g_clndr_cntx->LunarInfo.SolarDay += (S16) num_cols;
- break;
- case PREV_ROW:
- g_clndr_cntx->LunarInfo.SolarDay -= (S16) num_cols;
- break;
- case SELECTED_DAY:
- g_clndr_cntx->LunarInfo.SolarDay += new_day - old_day;
- break;
- default:
- break;
- }
- ClndrComputeLunarInfo(&g_clndr_cntx->LunarInfo);
- SetCalendarPopupDay(
- g_clndr_cntx->LunarInfo.SolarDay,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine1,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine2,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine3);
- ChangeCategory82Title1((U8*) g_clndr_cntx->LunarInfo.TitleInfo1); /* OR calInfo.totlestring */
- ChangeCategory82Title3((U8*) g_clndr_cntx->LunarInfo.TitleInfo2);
- }
- #define CLNDR_OPTION
- /*****************************************************************************
- * FUNCTION
- * EntryClndrOptions
- * DESCRIPTION
- * Side down key handler, go to 1st day of next month.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void EntryClndrOptions(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- U8 *pop_up_desc[5];
- U16 nStrItemList[5]; /* Stores the strings id of submenus returned */
- U16 nNumofItem; /* Stores no of children in the submenu */
- U16 menuId;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gClndrAddToHistory = TRUE;
- EntryNewScreen(SCR_ID_CLNDR_OPTION, ExitClndrOptions, EntryClndrOptions, NULL);
- gClndrAddToHistory = FALSE;
- #ifdef __MMI_CALENDAR_V2__
- if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
- {
- menuId = ORGANIZER_CALENDER_MONTHLY_OPTIONS_MENU;
- }
- else
- {
- menuId = ORGANIZER_CALENDER_WEEKLY_OPTIONS_MENU;
- }
- #else /* __MMI_CALENDAR_V2__ */
- menuId = ORGANIZER_CALENDER_MENU;
- #endif /* __MMI_CALENDAR_V2__ */
- #if defined(__MMI_CALENDAR_V2__) && defined(__MMI_TODOLIST__)
- /* Hide options of adding task if the amount of todolist equals to max value */
- if (TDLGetTotalItem() >= NUM_OF_TDL)
- {
- mmi_frm_hide_menu_item(MENU_ID_CLNDR_ADD_TASK);
- }
- else if (mmi_frm_test_menu_item_hide(MENU_ID_CLNDR_ADD_TASK))
- {
- mmi_frm_unhide_menu_item(MENU_ID_CLNDR_ADD_TASK);
- }
- #endif
- guiBuffer = GetCurrGuiBuffer(SCR_ID_CLNDR_OPTION);
- /* Retrieve no of child of menu item to be displayed */
- nNumofItem = GetNumOfChild_Ext(menuId);
- /* Retrieve string ids in sequence of given menu item to be displayed */
- GetSequenceStringIds_Ext(menuId, nStrItemList);
- ConstructHintsList(menuId, pop_up_desc);
- /* Set current parent id */
- SetParentHandler(menuId);
- /* Register highlight handler to be called in menu screen */
- RegisterHighlightHandler(ExecuteCurrHiliteHandler);
- if (IsChineseSet())
- {
- ShowCategory52Screen(
- STR_GLOBAL_OPTIONS,
- GetRootTitleIcon(ORGANIZER_CALENDER_MENU),
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_OK,
- nNumofItem,
- nStrItemList,
- (PU16) gIndexIconsImageList,
- pop_up_desc,
- 0,
- 0,
- guiBuffer);
- }
- else
- {
- ShowCategory52Screen(
- STR_GLOBAL_OPTIONS,
- ORGANIZER_TITLE_IMAGEID,
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_OK,
- (nNumofItem - 1),
- nStrItemList,
- (PU16) gIndexIconsImageList,
- pop_up_desc,
- 0,
- 0,
- guiBuffer);
- }
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * ExitClndrOptions
- * DESCRIPTION
- * Exit function of calendar option screen. write lunar state to nvram.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ExitClndrOptions(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- WriteValue(LUNAR_CALENDAR, &g_clndr_cntx->LunarState, DS_BYTE, &error);
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrSetLunarState
- * DESCRIPTION
- * Toggle state of lunar calendar.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrSetLunarState(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 indexPopup;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- indexPopup = GetCurrHiliteID();
- if (g_clndr_cntx->LunarState == TRUE)
- {
- g_clndr_cntx->LunarState = FALSE;
- pfnUnicodeStrcpy((S8*) hintData[indexPopup], (S8*) GetString(STR_GLOBAL_OFF));
- ChangeLeftSoftkey(STR_GLOBAL_ON, IMG_CAL_ON);
- }
- else
- {
- g_clndr_cntx->LunarState = TRUE;
- pfnUnicodeStrcpy((S8*) hintData[indexPopup], (S8*) GetString(STR_GLOBAL_ON));
- ChangeLeftSoftkey(STR_GLOBAL_OFF, IMG_CAL_OFF);
- }
- Category52ChangeItemDescription(indexPopup, hintData[indexPopup]);
- SetLeftSoftkeyFunction(ClndrSetLunarState, KEY_EVENT_UP);
- RedrawCategoryFunction();
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrDisplayTask
- * DESCRIPTION
- * Display to do list task of selected date.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrDisplayTask(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_TODOLIST__
- #ifdef __MMI_CALENDAR_V2__
- mmi_tdl_set_clndr(&g_clndr_cntx->CalTime, g_clndr_cntx->DisplayType);
- #else
- mmi_tdl_set_clndr(&g_clndr_cntx->CalTime, MMI_TRUE);
- #endif
- TDLShowSpecificDateList();
- #endif /* __MMI_TODOLIST__ */
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrLunarHintHandler
- * DESCRIPTION
- * Hint handler of lunar calendar option.
- * PARAMETERS
- * index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrLunarHintHandler(U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx->LunarState == FALSE)
- {
- pfnUnicodeStrcpy((S8*) hintData[index], (S8*) GetString(STR_GLOBAL_OFF));
- }
- else
- {
- pfnUnicodeStrcpy((S8*) hintData[index], (S8*) GetString(STR_GLOBAL_ON));
- }
- }
- /*****************************************************************************
- * FUNCTION
- * HighlightClndrViewTask
- * DESCRIPTION
- * Highlight handler of View Task option.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HighlightClndrViewTask(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- SetLeftSoftkeyFunction(ClndrDisplayTask, KEY_EVENT_UP);
- SetKeyHandler(ClndrDisplayTask, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * HighlightClndrLunar
- * DESCRIPTION
- * Highlight handler on lunar calendar option.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HighlightClndrLunar(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 indexPopup = GetCurrHiliteID();
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx->LunarState == FALSE)
- {
- pfnUnicodeStrcpy((S8*) hintData[indexPopup], (S8*) GetString(STR_GLOBAL_OFF));
- ChangeLeftSoftkey(STR_GLOBAL_ON, IMG_CAL_ON);
- }
- else
- {
- pfnUnicodeStrcpy((S8*) hintData[indexPopup], (S8*) GetString(STR_GLOBAL_ON));
- ChangeLeftSoftkey(STR_GLOBAL_OFF, IMG_CAL_OFF);
- }
- SetLeftSoftkeyFunction(ClndrSetLunarState, KEY_EVENT_UP);
- ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- #define CLNDR_JUMP_TO_DATE
- /*****************************************************************************
- * FUNCTION
- * ClndrValidateInput
- * DESCRIPTION
- * Validate correctness of date and jump to the date in calendar.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrValidateInput(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 tmpMon[CLNDR_DAY_LEN];
- S8 tmpDay[CLNDR_MON_LEN];
- S8 tmpYear[CLNDR_YEAR_LEN];
- U8 DayOfMon;
- U8 nDay, nMonth;
- U16 nYear;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- CloseCategory57Screen();
- /* validate day */
- UnicodeToAnsii(tmpDay, g_clndr_cntx->DayBuf);
- UnicodeToAnsii(tmpMon, g_clndr_cntx->MonBuf);
- UnicodeToAnsii(tmpYear, g_clndr_cntx->YearBuf);
- nDay = atoi(tmpDay);
- nMonth = atoi(tmpMon);
- nYear = atoi(tmpYear);
- /* daty out of boundary */
- DayOfMon = LastDayOfMonth(nMonth, nYear);
- if (nDay > DayOfMon)
- {
- DisplayPopup(
- (U8*) GetString(STR_CLNDR_WRONG_DATE),
- IMG_GLOBAL_WARNING,
- 0,
- UI_POPUP_NOTIFYDURATION_TIME,
- (U8) WARNING_TONE);
- }
- else
- {
- g_clndr_cntx->CalTime.nDay = nDay;
- g_clndr_cntx->CalTime.nMonth = nMonth;
- g_clndr_cntx->CalTime.nYear = nYear;
- GoBackToHistory(SCR_ID_CLNDR_SCREEN);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrFillInilineStruct
- * DESCRIPTION
- * Fill inline structure of date input screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrFillInilineStruct(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 tmpMon[CLNDR_DAY_LEN];
- S8 tmpDay[CLNDR_MON_LEN];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gui_itoa((S32) g_clndr_cntx->CalTime.nYear, (U16*) g_clndr_cntx->YearBuf, 10);
- sprintf(tmpMon, "%02d", g_clndr_cntx->CalTime.nMonth);
- AnsiiToUnicodeString(g_clndr_cntx->MonBuf, tmpMon);
- sprintf(tmpDay, "%02d", g_clndr_cntx->CalTime.nDay);
- AnsiiToUnicodeString(g_clndr_cntx->DayBuf, tmpDay);
- SetInlineItemActivation(&wgui_inline_items[0], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
- SetInlineItemCaption(&wgui_inline_items[0], (U8*) GetString(STR_CLNDR_DATE));
- SetInlineItemActivation(&wgui_inline_items[1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
- SetInlineItemDate(
- &wgui_inline_items[1],
- (U8*) g_clndr_cntx->DayBuf,
- (U8*) g_clndr_cntx->MonBuf,
- (U8*) g_clndr_cntx->YearBuf,
- ClndrDateEditorCallBack);
- RightJustifyInlineItem(&wgui_inline_items[1]);
- EnableInlineItemBoundary(&wgui_inline_items[1]);
- set_inline_date_boundary(2030, 1970, 12, 1);
- }
- /*****************************************************************************
- * FUNCTION
- * HighlightClndrInputItem
- * DESCRIPTION
- * Highlight handler of inline editor items.
- * PARAMETERS
- * nIndex [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void HighlightClndrInputItem(S32 nIndex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- SetLeftSoftkeyFunction(ClndrValidateInput, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * ExitClndrJumpToDate
- * DESCRIPTION
- * Exit function of Jump To screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ExitClndrJumpToDate(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- history Scr;
- U16 inputBufferSize; /* added for inline edit history */
- S16 nHistory = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- Scr.scrnID = SCR_ID_CLNDR_JUMP;
- CloseCategory57Screen();
- Scr.entryFuncPtr = EntryClndrJumpToDate;
- pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
- GetCategoryHistory(Scr.guiBuffer);
- GetCategory57Data((U8*) Scr.inputBuffer); /* added for inline edit history */
- inputBufferSize = (U16) GetCategory57DataSize(); /* added for inline edit history */
- AddNHistory(Scr, inputBufferSize); /* added for inline edit history */
- }
- /*****************************************************************************
- * FUNCTION
- * EntryClndrJumpToDate
- * DESCRIPTION
- * Entry function of Jump To screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void EntryClndrJumpToDate(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer; /* Buffer holding history data */
- U8 *inputBuffer;
- U16 inputBufferSize; /* added for inline edit history */
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_CLNDR_JUMP, ExitClndrJumpToDate, NULL, NULL);
- InitializeCategory57Screen();
- ClndrFillInilineStruct();
- RegisterHighlightHandler(HighlightClndrInputItem);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_CLNDR_JUMP);
- inputBuffer = GetCurrNInputBuffer(SCR_ID_CLNDR_JUMP, &inputBufferSize);
- if (inputBuffer != NULL) /* added for inline edit history */
- {
- SetCategory57Data(wgui_inline_items, 2, inputBuffer); /* sets the data */
- }
- DisableCategory57ScreenDone();
- ShowCategory57Screen(
- STR_CLNDR_JUMP_TO,
- GetRootTitleIcon(ORGANIZER_CALENDER_MENU),
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- 2,
- NULL,
- wgui_inline_items,
- 1,
- guiBuffer);
- SetKeyHandler(ClndrValidateInput, KEY_LSK, KEY_EVENT_UP);
- SetCategory57RightSoftkeyFunctions(ClndrValidateInput, GoBackHistory);
- }
- /*****************************************************************************
- * FUNCTION
- * HighlightJumpToDate
- * DESCRIPTION
- * Highlight handler on lunar calendar option.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HighlightJumpToDate(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- SetKeyHandler(EntryClndrJumpToDate, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetLeftSoftkeyFunction(EntryClndrJumpToDate, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- #define CLNDR_LUNAR_CALENDAR
- /*****************************************************************************
- * FUNCTION
- * ClndrComputeSolarTerm
- * DESCRIPTION
- * This function is to calculate the date of solar item in given year.
- * PARAMETERS
- * year [IN] Year in solar calendar, e.g. 2003
- * month [IN]
- * solar_index [IN] Index of solar term, 0 = SC (Slight Cold), 1 = GC,...
- * RETURNS
- * the solar day of given solar item
- *****************************************************************************/
- S16 ClndrComputeSolarTerm(S16 year, S16 month, S16 solar_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* adjust the solar term days for lunarinfo by feifan 8/1/2005 */
- return solar_term_table[year - CLNDR_FIRST_NAVI_YEAR][solar_index];
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- }
- /*****************************************************************************
- * FUNCTION
- * ClndrComputeLunarInfo
- * DESCRIPTION
- * This function is to convert solar date infomation to lunar date.
- * CALLS
- * PARAMETERS
- * DI [IN/OUT] A struct contains solar date information and lunar information will also be stored here
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrComputeLunarInfo(clndr_lnuar_date_info_struct *DI)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 LeapDay;
- S16 StartMonth;
- S16 YearIndex;
- S16 AccumulateDay;
- S16 KanChiDay;
- S16 DateDiff;
- S16 IntercalaryMonth;
- S16 LunarDays;
- S16 SolarDate1, SolarDate2, SolarDate3;
- S16 MonthIndex;
- S8 dummyString[CLNDR_TITLE_LEN];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* to check if the month out of boundary */
- StartMonth = DI->SolarMonth - 1;
- /* to calculate the number of days in Feb. this year */
- if (StartMonth > 1)
- {
- LeapDay = (U8) IsLeapYear(DI->SolarYear);
- }
- else
- {
- LeapDay = 0;
- }
- YearIndex = DI->SolarYear - CLNDR_TABLE_START_YEAR;
- /* to calculate weekday */
- AccumulateDay = (gClndrAccuDays[StartMonth] + LeapDay + DI->SolarDay);
- /* to calculate the Kan and Chin of today */
- KanChiDay = AccumulateDay + gClndrLunarInfo[YearIndex].BaseKanChi;
- /* to check if today is earlier than the Chinese New Year day of this year */
- if (AccumulateDay <= gClndrLunarInfo[YearIndex].BaseDays)
- {
- YearIndex--;
- DI->LunarYear = DI->SolarYear - 1;
- LeapDay = (U8) IsLeapYear(DI->LunarYear);
- StartMonth += 12;
- AccumulateDay = (gClndrAccuDays[StartMonth] + LeapDay + DI->SolarDay);
- }
- else
- {
- DI->LunarYear = DI->SolarYear;
- }
- /* to calculate the lunar month and day */
- IntercalaryMonth = gClndrLunarInfo[YearIndex].Intercalary;
- DateDiff = gClndrLunarInfo[YearIndex].BaseDays;
- for (MonthIndex = 0; MonthIndex < 13; MonthIndex++)
- {
- LunarDays = DateDiff + 29;
- if (gClndrLunarInfo[YearIndex].MonthDays & (0x01 << MonthIndex))
- {
- LunarDays++;
- }
- if (AccumulateDay <= LunarDays)
- {
- break;
- }
- DateDiff = LunarDays;
- }
- DI->LunarMonth = (MonthIndex + 1);
- DI->LunarDay = AccumulateDay - DateDiff;
- /* to adjust Lunar month if there is a intercalary month in this year */
- if (IntercalaryMonth != 0 && DI->LunarMonth > IntercalaryMonth)
- {
- DI->LunarMonth--;
- }
- if (DI->LunarMonth > 12)
- {
- DI->LunarMonth -= 12;
- }
- /* the unfortunate direction, age, and animal today */
- DI->Direction = KanChiDay % 4;
- DI->Age = (82 - (KanChiDay % 60) + (DI->LunarYear - CLNDR_BASE)) % 60;
- if (DI->Age <= 10)
- {
- DI->Age += 60;
- }
- DI->Animal = (KanChiDay + 6) % 12;
- /* to calculate the Kan and Chin of this year */
- if (DI->LunarYear == DI->SolarYear)
- {
- DI->KanYear = (DI->SolarYear - 1900 + 36) % 10;
- DI->ChiYear = (DI->SolarYear - 1900 + 36) % 12;
- /* to calculate the animal of this year */
- DI->YearAnimal = (DI->SolarYear + 8) % 12;
- }
- else
- {
- DI->KanYear = (DI->SolarYear - 1900 + 36 - 1) % 10;
- DI->ChiYear = (DI->SolarYear - 1900 + 36 - 1) % 12;
- /* to calculate the animal of this year */
- DI->YearAnimal = (DI->SolarYear + 8 - 1) % 12;
- }
- /* to calculate the lunar day of solar term in this month */
- SolarDate1 = ClndrComputeSolarTerm(DI->SolarYear, DI->SolarMonth, (S16) ((DI->SolarMonth - 1) * 2));
- SolarDate2 = ClndrComputeSolarTerm(DI->SolarYear, DI->SolarMonth, (S16) ((DI->SolarMonth - 1) * 2 + 1));
- if (DI->SolarMonth < 12)
- {
- SolarDate3 = ClndrComputeSolarTerm(DI->SolarYear, (S16) (DI->SolarMonth + 1), (S16) ((DI->SolarMonth - 1) * 2 + 2));
- }
- else
- {
- SolarDate3 = ClndrComputeSolarTerm((S16) (DI->SolarYear + 1), (S16) 1, (S16) (0));
- }
- if (DI->SolarDay < SolarDate1)
- {
- DI->SolarTerm = 0;
- DI->SolarDate = SolarDate1 - DI->SolarDay + DI->LunarDay;
- }
- else if (DI->SolarDay == SolarDate1)
- {
- DI->SolarTerm = 0;
- DI->SolarDate = 0;
- }
- else if (DI->SolarDay < SolarDate2)
- {
- DI->SolarTerm = 1;
- DI->SolarDate = SolarDate2 - DI->SolarDay + DI->LunarDay;
- }
- else if (DI->SolarDay == SolarDate2)
- {
- DI->SolarTerm = 1;
- DI->SolarDate = 0;
- }
- else
- {
- DI->SolarTerm = 2;
- if (DI->SolarMonth == 2)
- {
- DI->SolarDate = gDaysInMonth[DI->SolarMonth - 1] - DI->SolarDay + SolarDate3 + DI->LunarDay + LeapDay;
- }
- else
- {
- DI->SolarDate = gDaysInMonth[DI->SolarMonth - 1] - DI->SolarDay + SolarDate3 + DI->LunarDay;
- }
- }
- if (gClndrLunarInfo[YearIndex].MonthDays & (0x01 << MonthIndex))
- {
- LunarDays = 30;
- }
- else
- {
- LunarDays = 29;
- }
- if (DI->SolarDate > LunarDays)
- {
- DI->SolarDate -= LunarDays;
- }
- /* to recode the information to present */
- /* Chinese year/month/day information */
- pfnUnicodeStrcpy(DI->TitleInfo1, GetString((U16) (STR_CAL_KAN1 + DI->KanYear)));
- pfnUnicodeStrcat(DI->TitleInfo1, GetString((U16) (STR_CAL_CHI1 + DI->ChiYear)));
- pfnUnicodeStrcat(DI->TitleInfo1, GetString(STR_CAL_YEAR));
- if (DI->LunarMonth < 10)
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString((U16) (STR_CAL_CHINESE_NO1 + DI->LunarMonth - 1)));
- }
- else
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString(STR_CAL_CHINESE_NO10));
- if (DI->LunarMonth > 10)
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString((U16) (STR_CAL_CHINESE_NO1 + (DI->LunarMonth % 10 - 1))));
- }
- }
- pfnUnicodeStrcat(DI->TitleInfo1, GetString(STR_CAL_MONTH));
- if (DI->LunarDay < 10)
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString((U16) (STR_CAL_CHINESE_NO1 + DI->LunarDay - 1)));
- }
- else if (DI->LunarDay < 20)
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString(STR_CAL_CHINESE_NO10));
- if (DI->LunarDay > 10)
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString((U16) (STR_CAL_CHINESE_NO1 + DI->LunarDay % 10 - 1)));
- }
- }
- else if (DI->LunarDay < 30)
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString(STR_CAL_CHINESE_NO20));
- if (DI->LunarDay > 20)
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString((U16) (STR_CAL_CHINESE_NO1 + DI->LunarDay % 10 - 1)));
- }
- }
- else
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString(STR_CAL_CHINESE_NO30));
- if (DI->LunarDay > 30)
- {
- pfnUnicodeStrcat(DI->TitleInfo1, GetString((U16) (STR_CAL_CHINESE_NO1 + DI->LunarDay % 10 - 1)));
- }
- }
- pfnUnicodeStrcat(DI->TitleInfo1, GetString(STR_CAL_DAY));
- /* Animal index */
- pfnUnicodeStrcpy(DI->TitleInfo2, GetString((U16) (STR_CAL_ANIMAL1 + DI->YearAnimal)));
- /* Solar Term */
- if (DI->SolarDate == 0)
- {
- pfnUnicodeStrcpy(
- DI->MessageLine1,
- GetString((U16) (STR_CAL_SOLARTERM1 + (DI->SolarMonth - 1) * 2 + DI->SolarTerm)));
- }
- else
- {
- sprintf(dummyString, "%d", DI->SolarDate);
- AnsiiToUnicodeString(DI->MessageLine1, dummyString);
- if (DI->SolarTerm == 2 && DI->SolarMonth == 12)
- {
- pfnUnicodeStrcat(DI->MessageLine1, GetString(STR_CAL_SOLARTERM1));
- }
- else
- {
- pfnUnicodeStrcat(
- DI->MessageLine1,
- GetString((U16) (STR_CAL_SOLARTERM1 + (DI->SolarMonth - 1) * 2 + DI->SolarTerm)));
- }
- }
- /* Unfortunate */
- pfnUnicodeStrcpy(DI->MessageLine2, GetString(STR_CAL_UNLUCKY));
- pfnUnicodeStrcat(DI->MessageLine2, GetString((U16) (STR_CAL_DIRECTION1 + DI->Direction)));
- /* Unlucky */
- sprintf(DI->MessageLine3, "%d", DI->Age);
- AnsiiToUnicodeString(dummyString, DI->MessageLine3);
- pfnUnicodeStrcpy(DI->MessageLine3, GetString(STR_CAL_UNFORTUNATE));
- pfnUnicodeStrcat(DI->MessageLine3, GetString((U16) (STR_CAL_ANIMAL1 + DI->Animal)));
- pfnUnicodeStrcat(DI->MessageLine3, dummyString);
- }
- #endif /* __MMI_CALENDAR__ */
- /*****************************************************************************
- * FUNCTION
- * ClndrDateEditorCallBack
- * DESCRIPTION
- * Call back funtion for inline date input.
- * PARAMETERS
- * DateStr [?]
- * day [?]
- * month [?]
- * year [?]
- * RETURNS
- * void
- *****************************************************************************/
- void ClndrDateEditorCallBack(U8 *DateStr, U8 *day, U8 *month, U8 *year)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) DateStr, (S8*) year);
- pfnUnicodeStrcat((S8*) DateStr, (S8*) "/");
- pfnUnicodeStrcat((S8*) DateStr, (S8*) month);
- pfnUnicodeStrcat((S8*) DateStr, (S8*) "/");
- pfnUnicodeStrcat((S8*) DateStr, (S8*) day);
- }
- #ifdef __MMI_BIRTHDAY_REMINDER__
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_monthly_birthday_info
- * DESCRIPTION
- *
- * PARAMETERS
- * month [IN]
- * BirthdayInfo [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_get_monthly_birthday_info(U16 year, U8 month, birthday_info_struct *BirthdayInfo)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 i, date;
- MMI_PHB_BDAY_STRUCT *bday;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- bday = (MMI_PHB_BDAY_STRUCT*) mmi_frm_scrmem_alloc(NVRAM_EF_PHB_BIRTHDAY_SIZE * NVRAM_EF_PHB_BIRTHDAY_TOTAL);
- mmi_clndr_read_birthday_info(bday);
- for (i = 0; i < MAX_PB_PHONE_ENTRIES; i++)
- {
- date = bday[i].bDay;
- if (bday[i].bMonth == month && year >= bday[i].bYear)
- {
- if (BirthdayInfo[date].count == 0)
- {
- BirthdayInfo[date].firstMatchedIndex = i;
- BirthdayInfo[date].count++;
- }
- else
- {
- BirthdayInfo[date].count++;
- }
- }
- }
- mmi_frm_scrmem_free((void*)bday);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_daily_birthday_info
- * DESCRIPTION
- *
- * PARAMETERS
- * month [IN]
- * day [IN]
- * amount [IN]
- * PBIndexList [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_get_daily_birthday_info(U16 year, U8 month, U8 day, U16 amount, U16 *PBIndexList)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 i, count = 0;
- MMI_PHB_BDAY_STRUCT *bday;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- bday = (MMI_PHB_BDAY_STRUCT*) mmi_frm_scrmem_alloc(NVRAM_EF_PHB_BIRTHDAY_SIZE * NVRAM_EF_PHB_BIRTHDAY_TOTAL);
- mmi_clndr_read_birthday_info(bday);
- for (i = 0; i < MAX_PB_PHONE_ENTRIES; i++)
- {
- if (bday[i].bMonth == month && bday[i].bDay == day && year >= bday[i].bYear)
- {
- PBIndexList[count] = i;
- count++;
- }
- if (count >= amount)
- {
- break;
- }
- }
- mmi_frm_scrmem_free((void*)bday);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_read_birthday_info
- * DESCRIPTION
- *
- * PARAMETERS
- * bday_data [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_read_birthday_info(MMI_PHB_BDAY_STRUCT *bday_data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- U32 bday_record;
- MMI_PHB_BDAY_STRUCT *data_pos = bday_data;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (bday_record = 1; bday_record <= NVRAM_EF_PHB_BIRTHDAY_TOTAL; bday_record++)
- {
- data_pos = bday_data + ((bday_record - 1) * NVRAM_EF_PHB_BIRTHDAY_COUNT);
- ReadRecord(NVRAM_EF_PHB_BIRTHDAY_LID, bday_record, (void*)data_pos, NVRAM_EF_PHB_BIRTHDAY_SIZE, &error);
- }
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #if 1
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #else /* MMI_ON_WIN32 */
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* MMI_ON_WIN32 */
- #endif /* 0 */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_daily_birthday_amount
- * DESCRIPTION
- *
- * PARAMETERS
- * date [IN]
- * RETURNS
- *
- *****************************************************************************/
- U16 mmi_clndr_get_daily_birthday_amount(U8 date)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx != NULL)
- {
- return g_clndr_cntx->BirthdayInfo[date].count;
- }
- else
- {
- return 0;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_set_birthday_table
- * DESCRIPTION
- * Set birthday information when month is changed.
- * PARAMETERS
- * date [IN]
- * RETURNS
- *
- *****************************************************************************/
- void mmi_clndr_set_birthday_table(U16 year, U8 month)
- {
- #ifdef __MMI_BIRTHDAY_REMINDER__
- memset(g_clndr_cntx->BirthdayInfo, 0, sizeof(birthday_info_struct) * (CLNDR_MONTH_DAYS + 1));
- /* get birthday information */
- mmi_clndr_get_monthly_birthday_info(year, month, g_clndr_cntx->BirthdayInfo);
- #endif /* __MMI_BIRTHDAY_REMINDER__ */
- }
- #endif /* __MMI_BIRTHDAY_REMINDER__ */
- #endif /* _MMI_CALENDAR_C */ // #ifndef _MMI_CALENDAR_C