Calendar.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:160k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * Calendar.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file implements Calendar application.
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- /**
- * Copyright Notice
- * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
- * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
- * (It is illegal to remove this copyright notice from this software or any
- * portion of it)
- */
- /**********************************************************************************
- Filename: Calendar.c
- Author: GAUTAM
- Date Created: July-12-2003
- **********************************************************************************/
- #ifndef _MMI_CALENDAR_C
- #define _MMI_CALENDAR_C
- #include "MMI_features.h"
- #include "PixtelDataTypes.h"
- #ifdef __MMI_CALENDAR__
- #include "DateTimeType.h"
- #include "DateTimeGprot.h"
- #include "AlarmGProt.h"
- #include "Unicodexdcl.h"
- #include "HistoryGprot.h"
- #include "ProtocolEvents.h"
- #include "wgui_categories.h"
- #include "wgui_calendar.h"
- #include "CustDataRes.h"
- #include "GlobalDefs.h"
- #include "OrganizerDef.h"
- #include "NVRAMEnum.h"
- #include "AudioInc.h"
- #include "NVRAMType.h"
- #include "NVRAMProt.h"
- #include "CalendarDef.h"
- #include "CalendarProt.h"
- #include "DebugInitDef.h"
- #include "CommonScreens.h"
- #include "ToDoListEnum.h"
- #include "wgui_categories_defs.h" /* PMT MANISH 20050429 Use Common Image Id's for Calendar months */
- #include "wgui_calendar.h"
- #ifdef __MMI_TODOLIST__
- #include "ToDoListDef.h"
- #endif
- #ifdef __MMI_CALENDAR_V2__
- #include "ScrMemMgrGprot.h"
- #endif
- #ifdef __MMI_BIRTHDAY_REMINDER__
- #include "PhoneBookTypes.h"
- #include "PhoneBookGprot.h"
- #endif /* __MMI_BIRTHDAY_REMINDER__ */
- /* Include: PS header file */
- /* ... Add More PS header */
- /*
- * Define
- */
- /*
- * Typedef
- */
- /*
- * Local Variable
- */
- /* the solar term days for lunarinfo by feifan 8/1/2005 */
- const U8 solar_term_table[62][24] =
- {
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22}, /* 1970 */
- {6, 21, 4, 19, 6, 21, 5, 21, 6, 22, 6, 22, 8, 23, 8, 24, 8, 24, 9, 24, 8, 23, 8, 22},
- {6, 21, 5, 19, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
- {6, 21, 4, 19, 6, 21, 5, 21, 6, 22, 6, 22, 8, 23, 8, 24, 8, 23, 9, 24, 8, 23, 8, 22}, /* 1975 */
- {6, 21, 5, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 23},
- {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 8, 24, 8, 23, 7, 22},
- {6, 21, 4, 19, 6, 21, 5, 21, 6, 21, 6, 22, 8, 23, 8, 24, 8, 23, 9, 24, 8, 23, 8, 22},
- {6, 21, 5, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22}, /* 1980 */
- {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 8, 23, 8, 24, 8, 23, 9, 24, 8, 23, 8, 22},
- {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 5, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22}, /* 1985 */
- {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 24, 8, 23, 9, 24, 8, 23, 7, 22},
- {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
- {5, 20, 4, 19, 5, 20, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22}, /* 1990 */
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
- {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
- {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22}, /* 1995 */
- {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
- {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
- {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21}, /* 2000 */
- {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
- {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
- {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22}, /* 2005 */
- {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
- {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 22, 8, 23, 7, 22, 7, 21},
- {5, 20, 4, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22}, /* 2010 */
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 8, 24, 8, 23, 7, 22},
- {6, 21, 4, 19, 5, 20, 4, 20, 5, 20, 5, 21, 7, 22, 7, 23, 7, 22, 8, 23, 7, 22, 7, 21},
- {5, 20, 4, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22}, /* 2015 */
- {6, 20, 4, 19, 5, 20, 4, 19, 5, 20, 5, 21, 7, 22, 7, 23, 7, 22, 8, 23, 7, 22, 7, 21},
- {5, 20, 3, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 5, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22},
- {6, 20, 4, 19, 5, 20, 4, 19, 5, 20, 5, 21, 6, 22, 7, 22, 7, 22, 8, 23, 7, 22, 7, 21}, /* 2020 */
- {5, 20, 3, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
- {5, 20, 4, 19, 5, 20, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22},
- {6, 20, 4, 19, 5, 20, 4, 19, 5, 20, 5, 21, 6, 22, 7, 22, 7, 22, 8, 23, 7, 22, 6, 21},
- {5, 20, 3, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21}, /* 2025 */
- {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
- {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
- {6, 20, 4, 19, 5, 20, 4, 19, 5, 20, 5, 21, 6, 22, 7, 22, 7, 22, 8, 23, 7, 22, 6, 21},
- {5, 20, 3, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
- {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22}, /* 2030 */
- };
- /* number of accumulated days per solar month, non-leap year and leap year. */
- const S16 gClndrAccuDays[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396};
- /* array of lunar calendar */
- const clndr_lunar_table_struct gClndrLunarInfo[] =
- {
- {47, 2, 11, 0, 5482},
- {36, 3, 16, 0, 2921}, /* 1970 */
- {26, 4, 21, 5, 5970},
- {45, 5, 26, 0, 6994},
- {33, 0, 32, 0, 6949},
- {22, 1, 37, 4, 5707},
- {41, 2, 42, 0, 6731}, /* 1975 */
- {30, 3, 47, 8, 5291},
- {48, 5, 53, 0, 4781},
- {37, 6, 58, 0, 5485},
- {27, 0, 3, 6, 2921},
- {46, 1, 8, 0, 3497}, /* 1980 */
- {35, 3, 14, 0, 7570},
- {24, 4, 19, 4, 7461},
- {43, 5, 24, 0, 7461},
- {32, 6, 29, 10, 6733},
- {50, 1, 35, 0, 2646}, /* 1985 */
- {39, 2, 40, 0, 4790},
- {28, 3, 45, 6, 1461},
- {47, 4, 50, 0, 5845},
- {36, 6, 56, 0, 3785},
- {26, 0, 1, 5, 7826}, /* 1990 */
- {45, 1, 6, 0, 3730},
- {34, 2, 11, 0, 3366},
- {22, 4, 17, 3, 2646},
- {40, 5, 22, 0, 2647},
- {30, 6, 27, 8, 5334}, /* 1995 */
- {49, 0, 32, 0, 4954},
- {37, 2, 38, 0, 5845},
- {27, 3, 43, 5, 5833},
- {46, 4, 48, 0, 5961},
- {35, 5, 53, 0, 5779}, /* 2000 */
- {23, 0, 59, 4, 5419},
- {42, 1, 4, 0, 5419},
- {31, 2, 9, 0, 2651},
- {21, 3, 14, 2, 5466},
- {39, 5, 20, 0, 5482}, /* 2005 */
- {28, 6, 25, 7, 6997},
- {48, 0, 30, 0, 7076},
- {37, 1, 35, 0, 6985},
- {25, 3, 41, 5, 6803},
- {44, 4, 46, 0, 6805}, /* 2010 */
- {33, 5, 51, 0, 5421},
- {22, 6, 56, 4, 2733},
- {40, 1, 2, 0, 2741},
- {30, 2, 7, 9, 5546},
- {49, 3, 12, 0, 5586}, /* 2015 */
- {38, 4, 17, 0, 3493},
- {27, 6, 23, 6, 7498},
- {46, 0, 28, 0, 3402},
- {35, 1, 33, 0, 3222},
- {24, 2, 38, 4, 5422}, /* 2020 */
- {42, 4, 44, 0, 5462},
- {31, 5, 49, 0, 2741},
- {21, 6, 54, 2, 5546},
- {40, 0, 59, 0, 5842},
- {28, 2, 5, 6, 3749}, /* 2025 */
- {47, 3, 10, 0, 5925},
- {36, 4, 15, 0, 5707},
- {25, 5, 20, 5, 3223},
- {43, 0, 26, 0, 3243},
- {33, 1, 31, 0, 1370}, /* 2030 */
- {22, 2, 36, 3, 2774},
- };
- /*
- * Local Function
- */
- /*
- * Global Variable
- */
- /* the number of days for each solar month. */
- U8 gClndrAddToHistory;
- clndr_context_struct *g_clndr_cntx = NULL;
- extern wgui_inline_item wgui_inline_items[];
- extern const U8 gDaysInMonth[];
- /*
- * Global Function
- */
- extern void SetCategory82Title1(U8 *);
- extern void SetCategory82Title2(U8 *);
- extern void SetCategory82Title3(U8 *);
- extern pBOOL IsChineseSet(void);
- extern MMI_BOOL mmi_frm_test_menu_item_hide(U16 menu_item_id);
- #define CLNDR_INITIALIZE
- #ifdef __MMI_CALENDAR_V2__
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_week_numbers
- * DESCRIPTION
- *
- * PARAMETERS
- * year [IN]
- * month [IN]
- * weekStr [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_get_week_numbers(U16 year, U8 month, U8 **weekStr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME dt;
- U8 week, i;
- S8 asciiStr[CLNDR_HORIZON_LIST_CELL_LEN], unicodeStr[CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&dt, 0, sizeof(MYTIME));
- memset(&asciiStr, 0, CLNDR_HORIZON_LIST_CELL_LEN);
- memset(&unicodeStr, 0, CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH);
- dt.nYear = year;
- dt.nMonth = month;
- dt.nDay = 1;
- /* get the week number of first day of the month */
- #ifdef MMI_ON_WIN32
- week = mmi_dt_get_week_number(& dt);
- #else
- week = applib_dt_get_week_number((applib_time_struct*) & dt);
- #endif
- for (i = 0; i < CLNDR_ROW; i++, week++)
- {
- pfnUnicodeStrncpy((S8*) weekStr[i], GetString((U16) STR_CLNDR_WEEK_SYMBOL), CLNDR_WEEK_SYMBOL_LEN);
- sprintf(asciiStr, "%d", week);
- /* assert if the string of week number is longer than */
- ASSERT(strlen(asciiStr) < CLNDR_HORIZON_LIST_CELL_LEN - CLNDR_WEEK_SYMBOL_LEN);
- AnsiiToUnicodeString(unicodeStr, asciiStr);
- pfnUnicodeStrncat((S8*) weekStr[i], unicodeStr, strlen(asciiStr));
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_date_str
- * DESCRIPTION
- *
- * PARAMETERS
- * date [?] [?]
- * dateStr [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_get_date_str(MYTIME *date, U8 *dateStr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 asciiStr[CLNDR_TITLE_LEN], unicodeStr[CLNDR_TITLE_LEN];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&asciiStr, 0, CLNDR_TITLE_LEN);
- memset(&unicodeStr, 0, CLNDR_TITLE_LEN);
- /* year */
- sprintf(asciiStr, "%d", date->nYear);
- AnsiiToUnicodeString(unicodeStr, asciiStr);
- pfnUnicodeStrcpy((S8*) dateStr, unicodeStr);
- pfnUnicodeStrcat((S8*) dateStr, (PS8) "/");
- /* month */
- if (date->nMonth < 10)
- {
- pfnUnicodeStrcat((S8*) dateStr, (PS8) "0");
- }
- sprintf(asciiStr, "%d", date->nMonth);
- AnsiiToUnicodeString(unicodeStr, asciiStr);
- pfnUnicodeStrcat((S8*) dateStr, unicodeStr);
- pfnUnicodeStrcat((S8*) dateStr, (PS8) "/");
- /* month */
- if (date->nDay < 10)
- {
- pfnUnicodeStrcat((S8*) dateStr, (PS8) "0");
- }
- sprintf(asciiStr, "%d", date->nDay);
- AnsiiToUnicodeString(unicodeStr, asciiStr);
- pfnUnicodeStrcat((S8*) dateStr, unicodeStr);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_weekday
- * DESCRIPTION
- *
- * PARAMETERS
- * weekdayStr [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_get_weekday(U8 **weekdayStr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 i, j;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = CLNDR_START_WEEKDAY; i < CLNDR_TOTAL_WEEKDAY; i++)
- {
- j = i + STR_CLNDR_WEEK_SUNDAY + CLNDR_START_WEEKDAY;
- memcpy(weekdayStr[i], (U8*) GetString((U16) j), CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH);
- /* weekdayStr[i] = GetString((U16)j); */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_construct_monthly_cell_info
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_construct_monthly_cell_info(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, taskPos, nextMonthBoundary;
- wgui_cat83_cell_struct *cell;
- MYTIME preMonth, incTime, currTime;
- U8 lastDayofPreMonth;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&preMonth, 0, sizeof(MYTIME));
- memset(&incTime, 0, sizeof(MYTIME));
- memset(&currTime, 0, sizeof(MYTIME));
- #ifdef __MMI_BIRTHDAY_REMINDER__
- mmi_clndr_set_birthday_table(g_clndr_cntx->CalTime.nYear, g_clndr_cntx->CalTime.nMonth);
- #endif /* __MMI_BIRTHDAY_REMINDER__ */
- incTime.nMonth = 1;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, & preMonth);
- #else
- applib_dt_decrease_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & preMonth);
- lastDayofPreMonth = applib_dt_last_day_of_mon(preMonth.nMonth, preMonth.nYear);
- #endif
- cell = g_clndr_cntx->CalendarCell + (g_clndr_cntx->DayOnFirst);
- /* last month */
- for (i = g_clndr_cntx->DayOnFirst - 1; i >= 0; i--)
- {
- cell--;
- mmi_clndr_util_num_to_unicode(lastDayofPreMonth, (U8*) cell->text, CAT83_MAX_CELL_TEXT);
- cell->valid = MMI_FALSE;
- cell->bg_index = CAT83_COLOR_NONE;
- lastDayofPreMonth--;
- }
- /* this month */
- taskPos = 1;
- #ifdef __MMI_CLNDR_ICON_SUPPORT__
- mmi_tdl_get_monthly_task_with_icon(&(g_clndr_cntx->CalTime), g_clndr_cntx->TaskDayList);
- #else
- TDLGetDaysToBeHilited(g_clndr_cntx->CalTime, g_clndr_cntx->TaskDayList);
- #endif
- cell = g_clndr_cntx->CalendarCell + g_clndr_cntx->DayOnFirst;
- for (i = 1; i <= g_clndr_cntx->NumDaysInMonth; i++)
- {
- mmi_clndr_util_num_to_unicode(i, (U8*) cell->text, CAT83_MAX_CELL_TEXT);
- cell->bg_index = cell->bg_index = CAT83_COLOR_NONE;
- #ifdef __MMI_CLNDR_ICON_SUPPORT__
- if (g_clndr_cntx->TaskDayList[i].date > 0)
- {
- cell->icon_id = g_clndr_cntx->TaskDayList[i].icon;
- }
- #ifdef __MMI_BIRTHDAY_REMINDER__
- else if (g_clndr_cntx->BirthdayInfo[i].count > 0)
- {
- cell->icon_id = IMG_CLNDR_BIRTHDAY_REMINDER;
- }
- #endif /* __MMI_BIRTHDAY_REMINDER__ */
- #else /* __MMI_CLNDR_ICON_SUPPORT__ */
- if (i == g_clndr_cntx->TaskDayList[taskPos])
- {
- taskPos++;
- }
- #endif /* __MMI_CLNDR_ICON_SUPPORT__ */
- cell->valid = MMI_TRUE;
- cell++;
- }
- /* next month */
- nextMonthBoundary = CLNDR_ROW * CLNDR_COLUMN - (g_clndr_cntx->DayOnFirst + g_clndr_cntx->NumDaysInMonth);
- for (i = 1; i <= nextMonthBoundary; i++)
- {
- mmi_clndr_util_num_to_unicode(i, (U8*) cell->text, CAT83_MAX_CELL_TEXT);
- cell->bg_index = CAT83_COLOR_NONE;
- cell->valid = MMI_FALSE;
- cell++;
- }
- }
- /* wgui_cat83_cell_struct* mmi_clndr_construct_weekly_cell_info(); */
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_util_num_to_unicode
- * DESCRIPTION
- *
- * PARAMETERS
- * num [IN]
- * str [?] [?]
- * len [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_util_num_to_unicode(S32 num, U8 *str, U8 len)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 ascii[CLNDR_TITLE_LEN];
- U16 value = (U16) num;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(ascii, 0, CLNDR_TITLE_LEN);
- sprintf(ascii, "%d", value);
- /* ASSERT(strlen(ascii) < len); */
- AnsiiToUnicodeString((S8*) str, ascii);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_highlight_monthly_view
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_highlight_monthly_view(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- SetKeyHandler(mmi_pre_entry_monthly_view_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetLeftSoftkeyFunction(mmi_pre_entry_monthly_view_screen, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_pre_entry_monthly_view_screen
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_pre_entry_monthly_view_screen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_clndr_cntx->DisplayType = CLNDR_MONTHLY_VIEW;
- g_clndr_cntx->RowNumber = CLNDR_ROW;
- GoBackHistory();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_monthly_highlight
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_monthly_highlight(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 totaldays;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- totaldays = (row * CLNDR_COLUMN) + column + 1;
- g_clndr_cntx->CalTime.nDay = totaldays - g_clndr_cntx->DayOnFirst;
- g_clndr_cntx->CalTime.DayIndex = DOW(g_clndr_cntx->CalTime.nYear, g_clndr_cntx->CalTime.nMonth, g_clndr_cntx->CalTime.nDay);
- 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);
- wgui_cat83_set_normal_title((U8*) g_clndr_cntx->LunarInfo.TitleInfo1);
- wgui_cat83_set_popup(
- (U8*) g_clndr_cntx->LunarInfo.MessageLine1,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine2,
- (U8*) g_clndr_cntx->LunarInfo.MessageLine3);
- }
- else
- {
- mmi_clndr_get_date_str(&(g_clndr_cntx->CalTime), g_clndr_cntx->Title);
- wgui_cat83_set_normal_title(g_clndr_cntx->Title);
- }
- mmi_momthly_clndr_set_info_box();
- return MMI_FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_monthly_compute_next_time
- * DESCRIPTION
- *
- * PARAMETERS
- * arrow [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_monthly_compute_next_time(U32 arrow)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME resultDate, incTime;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&resultDate, 0, sizeof(MYTIME));
- memset(&incTime, 0, sizeof(MYTIME));
- switch (arrow)
- {
- case CLNDR_KEY_UP:
- incTime.nDay = CLNDR_TOTAL_WEEKDAY;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, &resultDate);
- #else
- applib_dt_decrease_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultDate);
- #endif
- break;
- case CLNDR_KEY_DOWN:
- incTime.nDay = CLNDR_TOTAL_WEEKDAY;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, &resultDate);
- #else
- applib_dt_increase_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultDate);
- #endif
- break;
- case CLNDR_KEY_LEFT:
- incTime.nDay = 1;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, &resultDate);
- #else
- applib_dt_decrease_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultDate);
- #endif
- break;
- case CLNDR_KEY_RIGHT:
- incTime.nDay = 1;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, &resultDate);
- #else
- applib_dt_increase_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultDate);
- #endif
- break;
- default:
- break;
- }
- return mmi_clndr_monthly_out_of_boundary(&resultDate);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_monthly_out_of_boundary
- * DESCRIPTION
- *
- * PARAMETERS
- * resultDate [?]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_monthly_out_of_boundary(MYTIME *resultDate)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME currTime;
- U32 highlightDays, highlightX, highlightY;
- S32 currCell = -1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (resultDate->nYear > CLNDR_END_YEAR || resultDate->nYear < CLNDR_START_YEAR)
- {
- DisplayPopup(
- (U8*) GetString(STR_CLNDR_OUT_OF_CALENDAR),
- IMG_GLOBAL_WARNING,
- 0,
- UI_POPUP_NOTIFYDURATION_TIME,
- (U8) WARNING_TONE);
- return MMI_FALSE;
- }
- g_clndr_cntx->DayOnFirst = DOW(resultDate->nYear, resultDate->nMonth, 1);
- /* set highlight and current date */
- /* subtract 1 to compute the correct highlight position */
- highlightDays = g_clndr_cntx->DayOnFirst + resultDate->nDay - 1;
- highlightX = highlightDays % CLNDR_TOTAL_WEEKDAY;
- highlightY = highlightDays / CLNDR_TOTAL_WEEKDAY;
- wgui_cat83_set_highlight(highlightY, highlightX);
- /* move to next/previous month */
- if (g_clndr_cntx->CalTime.nMonth != resultDate->nMonth || g_clndr_cntx->CalTime.nYear != resultDate->nYear)
- {
- memcpy(&g_clndr_cntx->CalTime, resultDate, sizeof(MYTIME));
- /* get calendar information */
- memset(g_clndr_cntx->TaskDayList, 0, CLNDR_COLUMN * CLNDR_ROW * sizeof(clndr_task_icon_struct));
- g_clndr_cntx->NumDaysInMonth = LastDayOfMonth(g_clndr_cntx->CalTime.nMonth, g_clndr_cntx->CalTime.nYear);
- mmi_clndr_get_date_str(&(g_clndr_cntx->CalTime), g_clndr_cntx->Title);
- 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);
- /* Set current date */
- GetDateTime(&currTime);
- if (currTime.nMonth == g_clndr_cntx->CalTime.nMonth && currTime.nYear == g_clndr_cntx->CalTime.nYear)
- {
- currCell = g_clndr_cntx->DayOnFirst + currTime.nDay - 1;
- }
- wgui_cat83_set_current(currCell / CLNDR_COLUMN, currCell % CLNDR_COLUMN);
- /* construct cell info */
- memset(g_clndr_cntx->CalendarCell, 0, g_clndr_cntx->RowNumber * CLNDR_COLUMN * CLNDR_CELL_SIZE);
- mmi_clndr_construct_monthly_cell_info();
- mmi_clndr_monthly_set_content();
- /* ClndrGetScreenInfo(); */
- return MMI_TRUE;
- }
- else
- {
- /* return MMI_FALSE; */
- return MMI_TRUE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_left_out_of_boundary
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_left_out_of_boundary(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
- {
- return mmi_clndr_monthly_compute_next_time(CLNDR_KEY_LEFT);
- /* return mmi_clndr_monthly_out_of_boundary(CLNDR_KEY_LEFT, row, column); */
- }
- #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
- else
- {
- /* return mmi_clndr_weekly_out_of_boundary(CLNDR_KEY_LEFT, row, column); */
- return mmi_clndr_weekly_compute_next_time(CLNDR_KEY_LEFT);
- }
- #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_right_out_of_boundary
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_right_out_of_boundary(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
- {
- return mmi_clndr_monthly_compute_next_time(CLNDR_KEY_RIGHT);
- /* return mmi_clndr_monthly_out_of_boundary(CLNDR_KEY_RIGHT, row, column); */
- }
- #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
- else
- {
- /* return mmi_clndr_weekly_out_of_boundary(CLNDR_KEY_RIGHT, row, column); */
- return mmi_clndr_weekly_compute_next_time(CLNDR_KEY_RIGHT);
- }
- #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_up_out_of_boundary
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_up_out_of_boundary(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
- {
- return mmi_clndr_monthly_compute_next_time(CLNDR_KEY_UP);
- /* return mmi_clndr_monthly_out_of_boundary(CLNDR_KEY_UP, row, column); */
- }
- #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
- else
- {
- /* return mmi_clndr_weekly_out_of_boundary(CLNDR_KEY_UP, row, column); */
- return mmi_clndr_weekly_compute_next_time(CLNDR_KEY_UP);
- }
- #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_down_out_of_boundary
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_down_out_of_boundary(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
- {
- return mmi_clndr_monthly_compute_next_time(CLNDR_KEY_DOWN);
- /* return mmi_clndr_monthly_out_of_boundary(CLNDR_KEY_DOWN, row, column); */
- }
- #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
- else
- {
- /* return mmi_clndr_weekly_out_of_boundary(CLNDR_KEY_DOWN, row, column); */
- return mmi_clndr_weekly_compute_next_time(CLNDR_KEY_DOWN);
- }
- #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_up_side_key
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_up_side_key(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_monthly_movement(CLNDR_PRIVOUS_MONTH);
- /* return MMI_TRUE; */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_down_side_key
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_down_side_key(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_monthly_movement(CLNDR_NEXT_MONTH);
- /* return MMI_TRUE; */
- }
- #ifdef __MMI_TOUCH_SCREEN__
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_year_increase
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_touch_year_increase(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_monthly_movement(CLNDR_NEXT_YEAR);
- /* return MMI_TRUE; */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_year_decrease
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_touch_year_decrease(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_monthly_movement(CLNDR_PRIVOUS_YEAR);
- /* return MMI_TRUE; */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_month_increase
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_touch_month_increase(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_monthly_movement(CLNDR_NEXT_MONTH);
- /* return MMI_TRUE; */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_month_decrease
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_touch_month_decrease(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_monthly_movement(CLNDR_PRIVOUS_MONTH);
- /* return MMI_TRUE; */
- }
- #endif /* __MMI_TOUCH_SCREEN__ */
- /* void mmi_clndr_monthly_movement(CLNDR_CLNDAR_MOVEMENT_ENUM type) */
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_monthly_movement
- * DESCRIPTION
- *
- * PARAMETERS
- * type [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_monthly_movement(U32 type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME incTime, resultTime;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&incTime, 0, sizeof(MYTIME));
- memset(&resultTime, 0, sizeof(MYTIME));
- switch (type)
- {
- case CLNDR_PRIVOUS_MONTH:
- incTime.nMonth = 1;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, &resultTime);
- #else
- applib_dt_decrease_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultTime);
- #endif
- break;
- case CLNDR_NEXT_MONTH:
- incTime.nMonth = 1;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, &resultTime);
- #else
- applib_dt_increase_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultTime);
- #endif
- break;
- #ifdef __MMI_TOUCH_SCREEN__
- case CLNDR_PRIVOUS_YEAR:
- incTime.nYear = 1;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, &resultTime);
- #else
- applib_dt_decrease_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultTime);
- #endif
- break;
- case CLNDR_NEXT_YEAR:
- incTime.nYear = 1;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, &resultTime);
- #else
- applib_dt_increase_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultTime);
- #endif
- break;
- #endif /* __MMI_TOUCH_SCREEN__ */
- default:
- ASSERT(0);
- }
- resultTime.nDay = 1;
- return mmi_clndr_monthly_out_of_boundary(&resultTime);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_monthly_set_content
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_monthly_set_content(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(g_clndr_cntx->horizon_select1, 0, CLNDR_VERTICAL_SELECT_LEN);
- memset(g_clndr_cntx->horizon_select2, 0, CLNDR_VERTICAL_SELECT_LEN);
- mmi_clndr_util_num_to_unicode(
- g_clndr_cntx->CalTime.nYear,
- g_clndr_cntx->horizon_select1,
- CLNDR_VERTICAL_SELECT_LEN);
- mmi_clndr_util_num_to_unicode(
- g_clndr_cntx->CalTime.nMonth,
- g_clndr_cntx->horizon_select2,
- CLNDR_VERTICAL_SELECT_LEN);
- wgui_cat83_set_select_horizontal1(
- CAL_LEFT_ARROW_UP_IMAGE,
- CAL_LEFT_ARROW_DOWN_IMAGE,
- CAL_RIGHT_ARROW_UP_IMAGE,
- CAL_RIGHT_ARROW_DOWN_IMAGE,
- g_clndr_cntx->horizon_select1,
- CAT83_SELECT_ALIGN_CENTER);
- wgui_cat83_set_select_horizontal2(
- CAL_LEFT_ARROW_UP_IMAGE,
- CAL_LEFT_ARROW_DOWN_IMAGE,
- CAL_RIGHT_ARROW_UP_IMAGE,
- CAL_RIGHT_ARROW_DOWN_IMAGE,
- g_clndr_cntx->horizon_select2,
- CAT83_SELECT_ALIGN_CENTER);
- wgui_cat83_set_select_vertical(
- 0, /* monthly view has no vertical shift button */
- 0,
- 0,
- 0,
- g_clndr_cntx->VerticalList,
- CAT83_SELECT_ALIGN_CELL);
- wgui_cat83_set_normal_title(g_clndr_cntx->Title);
- wgui_cat83_set_cell_array(
- g_clndr_cntx->CalendarCell,
- CAT83_CELL_BG_FILL_HORIZONTAL,
- CAT83_CELL_TEXT_DISPLAY_LEFT_BOTTOM,
- CAT83_CELL_ICON_DISPLAY_RIGHT_TOP);
- }
- #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
- /*****************************************************************************
- * FUNCTION
- * mmi_pre_entry_weekly_view_screen
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_pre_entry_weekly_view_screen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME currentTime;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- GetDateTime(¤tTime);
- g_clndr_cntx->DisplayType = CLNDR_WEEKLY_VIEW;
- g_clndr_cntx->RowNumber = DLNDR_MAX_DAY_HOURS / g_clndr_cntx->PeriodInterval;
- 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->CurrPeriodIndex = (currentTime.nHour / g_clndr_cntx->PeriodInterval);
- /* g_clndr_cntx->PeriodStartIndex = (currentTime.nHour / g_clndr_cntx->PeriodInterval); */
- /* start index is larger than limitation */
- if (g_clndr_cntx->CurrPeriodIndex > g_clndr_cntx->RowNumber - CLNDR_ROW)
- {
- g_clndr_cntx->PeriodStartIndex = g_clndr_cntx->RowNumber - CLNDR_ROW;
- }
- else
- {
- g_clndr_cntx->PeriodStartIndex = g_clndr_cntx->CurrPeriodIndex;
- }
- GoBackHistory();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_highlight_weekly_view
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_highlight_weekly_view(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- SetKeyHandler(mmi_pre_entry_weekly_view_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetLeftSoftkeyFunction(mmi_pre_entry_weekly_view_screen, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_first_date_of_week
- * DESCRIPTION
- *
- * PARAMETERS
- * currDate [?] [?]
- * firstDateOfWeek [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_get_first_date_of_week(MYTIME *currDate, MYTIME *firstDateOfWeek)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 day;
- MYTIME incTime;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&incTime, 0, sizeof(MYTIME));
- #ifdef MMI_ON_WIN32
- day = (U8) DOW(currDate->nYear, currDate->nMonth, currDate->nDay);
- #else
- day = (U8) applib_dt_dow(currDate->nYear, currDate->nMonth, currDate->nDay);
- #endif
- incTime.nDay = day;
- #ifdef MMI_ON_WIN32
- DecrementTime(*currDate, incTime, firstDateOfWeek);
- #else
- applib_dt_decrease_time(
- (applib_time_struct*) currDate,
- (applib_time_struct*) & incTime,
- (applib_time_struct*) firstDateOfWeek);
- #endif
- firstDateOfWeek->nHour = firstDateOfWeek->nMin = firstDateOfWeek->nSec = 0;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_weekly_dates
- * DESCRIPTION
- *
- * PARAMETERS
- * currDate [?] [?]
- * dateStr [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_get_weekly_dates(MYTIME *currDate, U8 **dateStr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, lastday, date, diffDay;
- MYTIME firstDateOfWeek;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&firstDateOfWeek, 0, sizeof(MYTIME));
- mmi_clndr_get_first_date_of_week(currDate, &firstDateOfWeek);
- diffDay = (S32) (currDate->nDay - firstDateOfWeek.nDay);
- date = firstDateOfWeek.nDay;
- /* first day of week is date of previous month */
- if (diffDay < 0)
- {
- #ifdef MMI_ON_WIN32
- lastday = (S32) LastDayOfMonth(firstDateOfWeek.nMonth, firstDateOfWeek.nYear);
- #else
- lastday = (S32) applib_dt_last_day_of_mon(firstDateOfWeek.nMonth, firstDateOfWeek.nYear);
- #endif
- }
- else
- {
- #ifdef MMI_ON_WIN32
- lastday = (S32) LastDayOfMonth(currDate->nMonth, currDate->nYear);
- #else
- lastday = (S32) applib_dt_last_day_of_mon(currDate->nMonth, currDate->nYear);
- #endif
- }
- for (i = 0; i < CLNDR_TOTAL_WEEKDAY; i++, date++)
- {
- if (date > lastday)
- {
- date = 1;
- }
- mmi_clndr_util_num_to_unicode(date, dateStr[i], CLNDR_HORIZON_LIST_CELL_LEN);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_period_range
- * DESCRIPTION
- *
- * PARAMETERS
- * PeriodIndex [IN]
- * periodStr [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_get_period_range(U8 PeriodIndex, U8 **periodStr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, time, checkPeriod;
- U8 *ptr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* guaranteethat the period will within the range */
- checkPeriod = (DLNDR_MAX_DAY_HOURS - CLNDR_ROW * g_clndr_cntx->PeriodInterval) / g_clndr_cntx->PeriodInterval;
- if (PeriodIndex > checkPeriod)
- {
- PeriodIndex = checkPeriod;
- }
- time = PeriodIndex * g_clndr_cntx->PeriodInterval;
- for (i = 0; i < CLNDR_ROW; i++)
- {
- ptr = periodStr[i];
- ASSERT(time < DLNDR_MAX_DAY_HOURS);
- if (time < 10)
- {
- pfnUnicodeStrcpy((S8*) ptr, (PS8) L"0");
- ptr += ENCODING_LENGTH;
- mmi_clndr_util_num_to_unicode(time, ptr, 1);
- }
- else
- {
- mmi_clndr_util_num_to_unicode(time, ptr, 2);
- }
- /* ptr += (pfnUnicodeStrlen(ptr) * ENCODING_LENGTH); */
- pfnUnicodeStrcat((S8*) ptr, (PS8) L":00");
- time += g_clndr_cntx->PeriodInterval;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_construct_weekly_cell_info
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_construct_weekly_cell_info(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 i, dow, maxDay;
- wgui_cat83_cell_struct *cell;
- MYTIME firstDay;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_tdl_get_weekly_tasks(
- &g_clndr_cntx->CalTime,
- g_clndr_cntx->TaskDayList,
- g_clndr_cntx->PeriodInterval,
- g_clndr_cntx->RowNumber);
- /* some date of weekly view is out of boundary */
- memset(&firstDay, 0, sizeof(MYTIME));
- mmi_clndr_get_first_date_of_week(&g_clndr_cntx->CalTime, &firstDay);
- maxDay = 31 - CLNDR_TOTAL_WEEKDAY;
- if (firstDay.nYear < CLNDR_START_YEAR)
- {
- #ifdef MMI_ON_WIN32
- dow = DOW(CLNDR_START_YEAR, 1, 1);
- #else
- dow = applib_dt_dow(CLNDR_START_YEAR, 1, 1);
- #endif
- mmi_clndr_weekly_set_cell_validation(dow, CLNDR_LARGER_THAN_MIN_YEAR);
- }
- /* if the first day of week is larger than 2030/12/26 */
- else if (firstDay.nYear == CLNDR_END_YEAR && firstDay.nMonth == NUM_MONTHS && firstDay.nDay >= maxDay)
- {
- #ifdef MMI_ON_WIN32
- dow = DOW(CLNDR_END_YEAR, 12, 31);
- #else
- dow = applib_dt_dow(CLNDR_END_YEAR, 12, 31);
- #endif
- mmi_clndr_weekly_set_cell_validation(dow, CLNDR_LARGER_THAN_MAX_YEAR);
- }
- else
- {
- cell = g_clndr_cntx->CalendarCell;
- for (i = 0; i < g_clndr_cntx->RowNumber * CLNDR_COLUMN; i++)
- {
- cell->valid = MMI_TRUE;
- cell++;
- }
- }
- /* set the task icon and color of calendar cell */
- g_clndr_cntx->CalendarCell->bg_index = CAT83_COLOR_NONE;
- /* for (i = 1; i <= CLNDR_COLUMN * g_clndr_cntx->RowNumber; i++) */
- for (i = 0; i < CLNDR_COLUMN * g_clndr_cntx->RowNumber; i++)
- {
- cell = g_clndr_cntx->CalendarCell + i;
- if (g_clndr_cntx->TaskDayList[i].date > 0)
- {
- if (g_clndr_cntx->TaskDayList[i].date == 1)
- {
- cell->bg_index = CAT83_COLOR_ONE_TASK;
- }
- else
- {
- cell->bg_index = CAT83_COLOR_MORE_TASK;
- }
- cell->icon_id = g_clndr_cntx->TaskDayList[i].icon;
- }
- else
- {
- cell->bg_index = CAT83_COLOR_NONE;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_weekly_set_cell_validation
- * DESCRIPTION
- *
- * PARAMETERS
- * dow [IN]
- * type [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_weekly_set_cell_validation(U32 dow, U32 type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 i, j;
- wgui_cat83_cell_struct* cell = g_clndr_cntx->CalendarCell;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < g_clndr_cntx->RowNumber; i++)
- {
- for (j = 0; j< CLNDR_COLUMN; j++)
- {
- if ((type == CLNDR_LARGER_THAN_MAX_YEAR && j > dow) ||
- (type == CLNDR_LARGER_THAN_MIN_YEAR && j < dow)) /* the date is larger than boundary */
- {
- cell->valid = MMI_FALSE;
- }
- else
- {
- cell->valid = MMI_TRUE;
- }
- cell++;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_weekly_highlight
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_weekly_highlight(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME firstDayofWeek, incTime;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&firstDayofWeek, 0, sizeof(MYTIME));
- memset(&incTime, 0, sizeof(MYTIME));
- mmi_clndr_get_first_date_of_week(&(g_clndr_cntx->CalTime), &firstDayofWeek);
- incTime.nDay = column;
- IncrementTime(firstDayofWeek, incTime, &g_clndr_cntx->CalTime);
- g_clndr_cntx->CalTime.DayIndex = DOW(g_clndr_cntx->CalTime.nYear, g_clndr_cntx->CalTime.nMonth, g_clndr_cntx->CalTime.nDay);
- g_clndr_cntx->CurrPeriodIndex = g_clndr_cntx->PeriodStartIndex + row;
- g_clndr_cntx->CalTime.nHour = g_clndr_cntx->CurrPeriodIndex * g_clndr_cntx->PeriodInterval;
- mmi_clndr_get_date_str(&(g_clndr_cntx->CalTime), g_clndr_cntx->Title);
- wgui_cat83_set_normal_title(g_clndr_cntx->Title);
- if ((g_clndr_cntx->CalTime.nMonth == 1 && g_clndr_cntx->CalTime.nDay == 1) ||
- (g_clndr_cntx->CalTime.nMonth == 12 && g_clndr_cntx->CalTime.nDay == 31))
- {
- #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
- mmi_clndr_weekly_set_content();
- }
- mmi_weekly_clndr_set_info_box();
- return MMI_FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_weekly_compute_next_time
- * DESCRIPTION
- *
- * PARAMETERS
- * arrow [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_weekly_compute_next_time(U32 arrow)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME resultDate, incTime;
- U32 highlightY=0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&resultDate, 0, sizeof(MYTIME));
- memset(&incTime, 0, sizeof(MYTIME));
- switch (arrow)
- {
- case CLNDR_KEY_UP:
- if (g_clndr_cntx->CurrPeriodIndex > 0)
- {
- g_clndr_cntx->CurrPeriodIndex--;
- g_clndr_cntx->PeriodStartIndex--;
- memcpy(&resultDate, &(g_clndr_cntx->CalTime), sizeof(MYTIME));
- }
- else
- {
- return MMI_FALSE;
- }
- break;
- case CLNDR_KEY_DOWN:
- if (g_clndr_cntx->CurrPeriodIndex < g_clndr_cntx->RowNumber - 1)
- {
- g_clndr_cntx->CurrPeriodIndex++;
- g_clndr_cntx->PeriodStartIndex++;
- memcpy(&resultDate, &(g_clndr_cntx->CalTime), sizeof(MYTIME));
- }
- else
- {
- return MMI_FALSE;
- }
- break;
- case CLNDR_KEY_LEFT:
- incTime.nDay = 1;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, & resultDate);
- #else
- applib_dt_decrease_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultDate);
- #endif
- /* highlight date become the last day of previous week */
- highlightY = g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex;
- break;
- case CLNDR_KEY_RIGHT:
- incTime.nDay = 1;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, & resultDate);
- #else
- applib_dt_increase_time(
- (applib_time_struct*) & (g_clndr_cntx->CalTime),
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & resultDate);
- #endif
- /* highlight date become the first day of next week */
- highlightY = g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex;
- break;
- default:
- break;
- }
- return mmi_clndr_weekly_out_of_boundary(&resultDate, highlightY);
- }
- /* MMI_BOOL mmi_clndr_weekly_out_of_boundary(U32 arrow, U32 row, U32 column) */
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_weekly_out_of_boundary
- * DESCRIPTION
- *
- * PARAMETERS
- * resultDate [?]
- * highlightRow [IN]
- * highlightCol [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_weekly_out_of_boundary(MYTIME *resultDate, U32 highlightRow)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* U32 highlightY; */
- if (resultDate->nYear > CLNDR_END_YEAR || resultDate->nYear < CLNDR_START_YEAR)
- {
- DisplayPopup(
- (U8*) GetString(STR_CLNDR_OUT_OF_CALENDAR),
- IMG_GLOBAL_WARNING,
- 0,
- UI_POPUP_NOTIFYDURATION_TIME,
- (U8) WARNING_TONE);
- return MMI_FALSE;
- }
- /* If the date changed, update the highlight period */
- /* if (arrow == CLNDR_KEY_LEFT || arrow == CLNDR_KEY_RIGHT) */
- if (g_clndr_cntx->CalTime.nYear != resultDate->nYear ||
- g_clndr_cntx->CalTime.nMonth != resultDate->nMonth || g_clndr_cntx->CalTime.nDay != resultDate->nDay)
- {
- /* highlightY = g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex; */
- memcpy(&g_clndr_cntx->CalTime, resultDate, sizeof(MYTIME));
- wgui_cat83_set_current(0xFFFFFFFF, 0xFFFFFFFF);
- wgui_cat83_set_highlight(highlightRow, g_clndr_cntx->CalTime.DayIndex);
- memset(g_clndr_cntx->TaskDayList, 0, CLNDR_COLUMN * CLNDR_ROW * sizeof(clndr_task_icon_struct));
- memset(g_clndr_cntx->CalendarCell, 0, g_clndr_cntx->RowNumber * CLNDR_COLUMN * CLNDR_CELL_SIZE);
- //mmi_clndr_get_weekly_dates(&g_clndr_cntx->CalTime, g_clndr_cntx->HorizonList);
- //mmi_clndr_get_date_str(&(g_clndr_cntx->CalTime), g_clndr_cntx->Title);
- /* todo : compute the start period index */
- /* mmi_clndr_construct_weekly_cell_info(); */
- ClndrGetScreenInfo();
- }
- else
- {
- 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();
- return MMI_TRUE;
- }
- /* void mmi_clndr_weekly_movement(CLNDR_CLNDAR_MOVEMENT_ENUM type) */
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_weekly_movement
- * DESCRIPTION
- *
- * PARAMETERS
- * type [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_weekly_movement(U32 type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME incTime, firstDay;
- U32 highlightY;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(&incTime, 0, sizeof(MYTIME));
- memset(&firstDay, 0, sizeof(MYTIME));
- switch (type)
- {
- case CLNDR_PRIVOUS_WEEK:
- incTime.nDay = 7;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, & firstDay);
- #else
- applib_dt_decrease_time(
- (applib_time_struct*) & g_clndr_cntx->CalTime,
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & firstDay);
- #endif
- break;
- case CLNDR_NEXT_WEEK:
- incTime.nDay = 7;
- #ifdef MMI_ON_WIN32
- DecrementTime(g_clndr_cntx->CalTime, incTime, & firstDay);
- #else
- applib_dt_increase_time(
- (applib_time_struct*) & g_clndr_cntx->CalTime,
- (applib_time_struct*) & incTime,
- (applib_time_struct*) & firstDay);
- #endif
- break;
- #ifdef __MMI_TOUCH_SCREEN__
- case CLNDR_NEXT_PERIOD:
- /* the boundary of period */
- if (g_clndr_cntx->PeriodStartIndex == g_clndr_cntx->RowNumber - CLNDR_ROW)
- {
- return MMI_FALSE;
- }
- g_clndr_cntx->CalTime.nHour += g_clndr_cntx->PeriodInterval;
- g_clndr_cntx->PeriodStartIndex++;
- /* return; */
- case CLNDR_PRIVOUS_PERIOD:
- /* the boundary of period */
- if (g_clndr_cntx->PeriodStartIndex == 0)
- {
- return MMI_FALSE;
- }
- g_clndr_cntx->CalTime.nHour -= g_clndr_cntx->PeriodInterval;
- g_clndr_cntx->PeriodStartIndex++;
- /* return; */
- case CLNDR_NEXT_MULTI_PERIOD:
- break;
- case CLNDR_PRIVOUS_MULTI_PERIOD:
- break;
- #endif /* __MMI_TOUCH_SCREEN__ */
- default:
- ASSERT(0);
- }
- highlightY = g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex;
- return mmi_clndr_weekly_out_of_boundary(&firstDay, highlightY);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_get_period_interval
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- U8 mmi_clndr_get_period_interval(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 interval;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadValue(NVRAM_CLNDR_PERIOD_INTERVAL, &interval, DS_BYTE, &error);
- return interval;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_weekly_set_content
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_clndr_weekly_set_content(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 j;
- U8* str;
- wgui_cat83_cell_struct *cell;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(g_clndr_cntx->horizon_select1, 0, CLNDR_VERTICAL_SELECT_LEN);
- memset(g_clndr_cntx->horizon_select2, 0, CLNDR_VERTICAL_SELECT_LEN);
- str = g_clndr_cntx->horizon_select1;
- pfnUnicodeStrcpy((S8*)str, (S8*)L"W");
- str += ENCODING_LENGTH;
- mmi_clndr_util_num_to_unicode(g_clndr_cntx->WeekNum, str, CLNDR_VERTICAL_SELECT_LEN);
- wgui_cat83_set_select_horizontal1(CAL_LEFT_ARROW_UP_IMAGE, CAL_LEFT_ARROW_DOWN_IMAGE, CAL_RIGHT_ARROW_UP_IMAGE, CAL_RIGHT_ARROW_DOWN_IMAGE, g_clndr_cntx->horizon_select1, CAT83_SELECT_ALIGN_CENTER);
- j = g_clndr_cntx->PeriodInterval * CLNDR_ROW;
- if (j < CLNDR_MAX_ROW)
- {
- mmi_clndr_util_num_to_unicode(j, g_clndr_cntx->horizon_select2, CLNDR_VERTICAL_SELECT_LEN);
- wgui_cat83_set_select_horizontal2(IMG_HOUR_SUBTRACT_UP, IMG_HOUR_SUBTRACT_DOWN, IMG_HOUR_PLUS_UP, IMG_HOUR_PLUS_DOWN, g_clndr_cntx->horizon_select2, CAT83_SELECT_ALIGN_CENTER);
- pfnUnicodeStrcat((S8*)g_clndr_cntx->horizon_select2,(S8*) L" H");
- }
- wgui_cat83_set_normal_title(g_clndr_cntx->Title);
- wgui_cat83_set_horizontal_string(g_clndr_cntx->HorizonList);
- /* 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);
- cell = g_clndr_cntx->CalendarCell + g_clndr_cntx->PeriodStartIndex * CLNDR_COLUMN;
- wgui_cat83_set_cell_array(
- /* g_clndr_cntx->CalendarCell, */ cell,
- CAT83_CELL_BG_FILL_VERTICAL,
- CAT83_CELL_TEXT_DISPLAY_LEFT_BOTTOM,
- CAT83_CELL_ICON_DISPLAY_CENTER);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_weekly_increase
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_weekly_increase(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_weekly_movement(CLNDR_NEXT_WEEK);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_weekly_decrease
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_weekly_decrease(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_weekly_movement(CLNDR_PRIVOUS_WEEK);
- }
- #ifdef __MMI_TOUCH_SCREEN__
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_multi_periodly_increase
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_touch_multi_periodly_increase(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_periodly_movement((U32) CLNDR_NEXT_MULTI_PERIOD);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_multi_periodly_decrease
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_touch_multi_periodly_decrease(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_periodly_movement((U32) CLNDR_PRIVOUS_MULTI_PERIOD);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_single_periodly_increase
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_touch_single_periodly_increase(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return mmi_clndr_periodly_movement((U32) CLNDR_NEXT_PERIOD);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_clndr_touch_single_periodly_decrease
- * DESCRIPTION
- *
- * PARAMETERS
- * row [IN]
- * column [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_clndr_touch_single_periodly_decrease(U32 row, U32 column)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */