📄 healthmenstural.c
字号:
Scr.entryFuncPtr = EntryMensResult;
UCS2Strcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
if (g_mens_cntx->CurrDay > 0)
{
g_mens_cntx->CurrDay = g_mens_cntx->CurrDay;
}
AddHistory(Scr);
}
#ifdef __MMI_CALENDAR_V2__
/* Deinit has not been executed */
if (g_mens_cntx != NULL)
{
mmi_frm_scrmem_free((void*)g_mens_cntx->HorizonList[0]);
mmi_frm_scrmem_free((void*)g_mens_cntx->VerticalList[0]);
mmi_frm_scrmem_free((void*)g_mens_cntx->MenstrulCell);
g_mens_cntx->HorizonList[0] = NULL;
g_mens_cntx->VerticalList[0] = NULL;
g_mens_cntx->MenstrulCell = NULL;
}
#endif /* __MMI_CALENDAR_V2__ */
}
/*****************************************************************************
* FUNCTION
* EntryMensResult
* DESCRIPTION
* Display result calendar of computation.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void EntryMensResult(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *guiBuffer; /* Buffer holding history data */
S32 j;
#ifdef __MMI_CALENDAR_V2__
S32 highlightCell;
U8 *rsk, *lsk;
#else /* __MMI_CALENDAR_V2__ */
S16 Color[31];
S16 DiffDays;
#endif /* __MMI_CALENDAR_V2__ */
S8 tmpString[MENS_TITLE_LEN];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
EntryNewScreen(SCR_ID_MENS_RESULT, ExitMensResult, NULL, NULL);
g_mens_cntx->IsAddToHistory = TRUE;
guiBuffer = GetCurrGuiBuffer(SCR_ID_MENS_RESULT);
/* back ground initialize */
g_mens_cntx->DayOnFirst = DOW((U16) g_mens_cntx->CurrYear, (U8) g_mens_cntx->CurrMonth, 1);
g_mens_cntx->DayOfMon = LastDayOfMonth((U8) g_mens_cntx->CurrMonth, (U16) g_mens_cntx->CurrYear);
#ifdef __MMI_CALENDAR_V2__
g_mens_cntx->HorizonList[0] =
(U8*) mmi_frm_scrmem_alloc(CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH * CLNDR_COLUMN);
g_mens_cntx->VerticalList[0] =
(U8*) mmi_frm_scrmem_alloc(CLNDR_VERTICAL_LIST_CELL_LEN * ENCODING_LENGTH * CLNDR_ROW);
g_mens_cntx->MenstrulCell =
(gui_calendar_cell_struct*) mmi_frm_scrmem_alloc((CLNDR_ROW * CLNDR_COLUMN) * CLNDR_CELL_SIZE);
for (j = 1; j < CLNDR_COLUMN; j++)
{
g_mens_cntx->HorizonList[j] = g_mens_cntx->HorizonList[j - 1] + CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH;
}
for (j = 1; j < CLNDR_ROW; j++)
{
g_mens_cntx->VerticalList[j] =
g_mens_cntx->VerticalList[j - 1] + CLNDR_VERTICAL_LIST_CELL_LEN * ENCODING_LENGTH;
}
/* reset memory */
memset(g_mens_cntx->HorizonList[0], 0, CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH * CLNDR_COLUMN);
memset(g_mens_cntx->VerticalList[0], 0, CLNDR_VERTICAL_LIST_CELL_LEN * ENCODING_LENGTH * CLNDR_ROW);
memset(g_mens_cntx->MenstrulCell, 0, CLNDR_ROW * CLNDR_COLUMN * CLNDR_CELL_SIZE);
/* Set Calendar info */
g_mens_cntx->MensTime.nYear = g_mens_cntx->CurrYear;
g_mens_cntx->MensTime.nMonth = g_mens_cntx->CurrMonth;
g_mens_cntx->MensTime.nDay = g_mens_cntx->CurrDay;
/* GetDateTime(&currTime); */
sprintf(tmpString, "%d %02d", (U16) g_mens_cntx->CurrYear, g_mens_cntx->CurrMonth);
AnsiiToUnicodeString(g_mens_cntx->TitleString, tmpString);
mmi_clndr_get_weekday(g_mens_cntx->HorizonList);
mmi_clndr_get_week_numbers(
g_mens_cntx->CurrYear,
g_mens_cntx->CurrMonth,
g_mens_cntx->VerticalList);
mmi_mens_construct_cell_info();
wgui_calendar_set_horizontal_string(g_mens_cntx->HorizonList);
wgui_calendar_set_select_vertical(
NULL,
NULL,
NULL,
NULL,
g_mens_cntx->VerticalList,
GUI_CALENDAR_SELECT_ALIGN_CELL);
highlightCell = g_mens_cntx->DayOnFirst + g_mens_cntx->CurrDay - 1;
wgui_calendar_register_cell_highlight_handler(mmi_mens_highlight);
wgui_calendar_register_left_arrow_key_handler(mmi_mens_left_out_of_boundary);
wgui_calendar_register_right_arrow_key_handler(mmi_mens_right_out_of_boundary);
wgui_calendar_register_up_arrow_key_handler(mmi_mens_up_out_of_boundary);
wgui_calendar_register_down_arrow_key_handler(mmi_mens_down_out_of_boundary);
wgui_calendar_register_up_side_key_handler(mmi_mens_up_side_key);
wgui_calendar_register_down_side_key_handler(mmi_mens_down_side_key);
mmi_mens_set_content();
rsk = (U8*)GetString(STR_GLOBAL_BACK);
lsk = (U8*)GetString(STR_GLOBAL_OPTIONS);
ShowCategory83Screen(
IMG_CALENDAR_JAN,
(U8 **) g_mens_cntx->HorizonList,
(gui_calendar_cell_struct*) g_mens_cntx->MenstrulCell,
CLNDR_ROW,
CLNDR_COLUMN,
-1,
-1,
highlightCell / CLNDR_COLUMN,
highlightCell % CLNDR_COLUMN,
GUI_CALENDAR_CELL_BG_FILL_HORIZONTAL,
GUI_CALENDAR_CELL_TEXT_DISPLAY_LEFT_BOTTOM,
GUI_CALENDAR_CELL_ICON_DISPLAY_RIGHT_TOP,
MMI_TRUE,
lsk,
rsk);
#else /* __MMI_CALENDAR_V2__ */
memset(&currTime, 0, sizeof(MYTIME));
currTime.nMonth = (U8) g_mens_cntx->CurrMonth;
currTime.nYear = (U16) g_mens_cntx->CurrYear;
currTime.nDay = 1;
InitializeCategory81Screen(
g_mens_cntx->DayOnFirst,
g_mens_cntx->DayOfMon,
g_mens_cntx->CurrDay,
g_mens_cntx->CurrMonth,
g_mens_cntx->CurrYear);
#ifdef __MMI_SLIM_CALENDAR__
SetCalendarBackground((U16) IMG_CALENDAR_JAN);
#else
SetCalendarBackground((U16) (IMG_CALENDAR_JAN + g_mens_cntx->CurrMonth - 1));
#endif
/* title string */
sprintf(tmpString, "%d %02d", (U16) g_mens_cntx->CurrYear, g_mens_cntx->CurrMonth);
AnsiiToUnicodeString(g_mens_cntx->TitleString, tmpString);
/* get/set color of days */
DiffDays = MensGetDaysDifference(&currTime, &g_mens_cntx->InputDate);
for (i = 1; i <= g_mens_cntx->DayOfMon; i++, DiffDays++)
{
Color[i] = (MensGetDisplayColor(DiffDays, g_mens_cntx->AvgPeriod));
if (Color[i] != COLOR_NONE)
{
SetCalendarDay(i, (U8) (CALENDAR_SPECIAL_DAY1 + Color[i] - 1));
}
}
ShowCategory81Screen(
(U8*) g_mens_cntx->TitleString,
STR_GLOBAL_OK,
IMG_GLOBAL_OK,
STR_GLOBAL_BACK,
IMG_GLOBAL_BACK,
(U8*) GetString(STR_CALENDER_MESSAAGE1_PP),
(U8*) GetString(STR_CALENDER_MESSAAGE2_MENS),
guiBuffer);
SetCalendarMonthFunctions(MensGoToPreviousDay, MensGoToNextDay, MensGoToPreviousWeek, MensGoToNextWeek);
#ifdef __MMI_TOUCH_SCREEN__
SetCalendarMonthChangeFunctions(MensGoToPreviousMonth, MensGoToNextMonth);
#endif
SetKeyHandler(MensGoToNextMonth, KEY_VOL_DOWN, KEY_EVENT_DOWN);
SetKeyHandler(MensGoToPreviousMonth, KEY_VOL_UP, KEY_EVENT_DOWN);
#endif /* __MMI_CALENDAR_V2__ */
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
SetLeftSoftkeyFunction(EntryMensProbability, KEY_EVENT_UP);
}
/*****************************************************************************
* FUNCTION
* MensPreEntryResult
* DESCRIPTION
* Initialize variables and go to result screen.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void MensPreEntryResult(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
MYTIME currTime;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
GetDateTime(&currTime);
g_mens_cntx->NumOfMon = 0;
g_mens_cntx->CurrMonth = currTime.nMonth;
g_mens_cntx->CurrYear = currTime.nYear;
g_mens_cntx->CurrDay = currTime.nDay;
EntryMensResult();
}
/*****************************************************************************
* FUNCTION
* HighlightMensNevigeteDate
* DESCRIPTION
* Highlight handler of calendar screen.
* PARAMETERS
* index [IN]
* RETURNS
* void
*****************************************************************************/
void HighlightMensNevigeteDate(S32 index)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_mens_cntx->CurrDay = (U8) index;
}
/*****************************************************************************
* FUNCTION
* MensGoToPreviousDay
* DESCRIPTION
* Handle left arrow key when highlighting on 1st day of month.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void MensGoToPreviousDay(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_mens_cntx->NumOfMon > 0)
{
MYTIME myTime, incTime, finaltime;
/* do not have to prevent 1970/01/01 because can not nevigate previous month */
memset(&myTime, 0, sizeof(MYTIME));
myTime.nDay = 1;
myTime.nMonth = (U8) g_mens_cntx->CurrMonth;
myTime.nYear = (U16) g_mens_cntx->CurrYear;
memset(&incTime, 0, sizeof(MYTIME));
incTime.nDay = 1;
DecrementTime(myTime, incTime, &finaltime);
g_mens_cntx->NumOfMon--;
g_mens_cntx->CurrYear = finaltime.nYear;
g_mens_cntx->CurrMonth = finaltime.nMonth;
g_mens_cntx->CurrDay = finaltime.nDay;
g_mens_cntx->IsAddToHistory = FALSE;
EntryMensResult();
}
else
{
g_mens_cntx->IsAddToHistory = TRUE;
MensDisplayBoundaryPopup();
}
}
/*****************************************************************************
* FUNCTION
* MensGoToNextDay
* DESCRIPTION
* Handle right arrow key when highlighting on last day of month.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void MensGoToNextDay(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_mens_cntx->NumOfMon < MENS_MAX_NAVI_MON)
{
if (g_mens_cntx->CurrYear != 2030 || g_mens_cntx->CurrMonth != 12)
{
MYTIME myTime, incTime, finaltime;
memset(&myTime, 0, sizeof(MYTIME));
myTime.nDay = 1;
myTime.nMonth = (U8) g_mens_cntx->CurrMonth;
myTime.nYear = (U16) g_mens_cntx->CurrYear;
memset(&incTime, 0, sizeof(MYTIME));
incTime.nMonth = 1;
IncrementTime(myTime, incTime, &finaltime);
g_mens_cntx->NumOfMon++;
g_mens_cntx->CurrYear = finaltime.nYear;
g_mens_cntx->CurrMonth = finaltime.nMonth;
g_mens_cntx->CurrDay = finaltime.nDay;
g_mens_cntx->IsAddToHistory = FALSE;
EntryMensResult();
return;
}
}
g_mens_cntx->IsAddToHistory = TRUE;
MensDisplayBoundaryPopup();
}
/*****************************************************************************
* FUNCTION
* MensGoToPreviousWeek
* DESCRIPTION
* Handle up arrow key when highlighting on first week of the month.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void MensGoToPreviousWeek(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_mens_cntx->NumOfMon > 0)
{
MYTIME myTime, incTime, finaltime;
memset(&myTime, 0, sizeof(MYTIME));
myTime.nDay = (U8) g_mens_cntx->CurrDay;
myTime.nMonth = (U8) g_mens_cntx->CurrMonth;
myTime.nYear = (U16) g_mens_cntx->CurrYear;
memset(&incTime, 0, sizeof(MYTIME));
incTime.nDay = 7;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -