Calendar.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:160k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * Calendar.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  * MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  * This file implements Calendar application.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * removed!
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * removed!
  162.  *
  163.  *------------------------------------------------------------------------------
  164.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  165.  *============================================================================
  166.  ****************************************************************************/
  167.  /**
  168.  * Copyright Notice
  169.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  170.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  171.  *  (It is illegal to remove this copyright notice from this software or any
  172.  *  portion of it)
  173.  */
  174. /**********************************************************************************
  175.    Filename:      Calendar.c
  176.    Author:        GAUTAM
  177.    Date Created:  July-12-2003
  178. **********************************************************************************/
  179. #ifndef _MMI_CALENDAR_C
  180. #define _MMI_CALENDAR_C
  181. #include "MMI_features.h"
  182. #include "PixtelDataTypes.h"
  183. #ifdef __MMI_CALENDAR__
  184. #include "DateTimeType.h"
  185. #include "DateTimeGprot.h"
  186. #include "AlarmGProt.h"
  187. #include "Unicodexdcl.h"
  188. #include "HistoryGprot.h"
  189. #include "ProtocolEvents.h"
  190. #include "wgui_categories.h"
  191. #include "wgui_calendar.h"
  192. #include "CustDataRes.h"
  193. #include "GlobalDefs.h"
  194. #include "OrganizerDef.h"
  195. #include "NVRAMEnum.h"
  196. #include "AudioInc.h"
  197. #include "NVRAMType.h"
  198. #include "NVRAMProt.h"
  199. #include "CalendarDef.h"
  200. #include "CalendarProt.h"
  201. #include "DebugInitDef.h"
  202. #include "CommonScreens.h"
  203. #include "ToDoListEnum.h"
  204. #include "wgui_categories_defs.h"       /* PMT MANISH   20050429 Use Common Image Id's for Calendar months */
  205. #include "wgui_calendar.h"
  206. #ifdef __MMI_TODOLIST__
  207. #include "ToDoListDef.h"
  208. #endif 
  209. #ifdef __MMI_CALENDAR_V2__
  210. #include "ScrMemMgrGprot.h"
  211. #endif 
  212. #ifdef __MMI_BIRTHDAY_REMINDER__
  213. #include "PhoneBookTypes.h"
  214. #include "PhoneBookGprot.h"
  215. #endif /* __MMI_BIRTHDAY_REMINDER__ */ 
  216. /*  Include: PS header file */
  217. /* ... Add More PS header */
  218. /* 
  219.  * Define
  220.  */
  221. /*
  222.  * Typedef 
  223.  */
  224. /* 
  225.  * Local Variable
  226.  */
  227. /* the solar term days for lunarinfo by feifan 8/1/2005 */
  228. const U8 solar_term_table[62][24] = 
  229. {
  230.     {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 */
  231.     {6, 21, 4, 19, 6, 21, 5, 21, 6, 22, 6, 22, 8, 23, 8, 24, 8, 24, 9, 24, 8, 23, 8, 22},
  232.     {6, 21, 5, 19, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  233.     {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  234.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
  235.     {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 */
  236.     {6, 21, 5, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 23},
  237.     {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  238.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 8, 24, 8, 23, 7, 22},
  239.     {6, 21, 4, 19, 6, 21, 5, 21, 6, 21, 6, 22, 8, 23, 8, 24, 8, 23, 9, 24, 8, 23, 8, 22},
  240.     {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 */
  241.     {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  242.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22},
  243.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 8, 23, 8, 24, 8, 23, 9, 24, 8, 23, 8, 22},
  244.     {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  245.     {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 */
  246.     {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22},
  247.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 24, 8, 23, 9, 24, 8, 23, 7, 22},
  248.     {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
  249.     {5, 20, 4, 19, 5, 20, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  250.     {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 */
  251.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
  252.     {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
  253.     {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  254.     {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  255.     {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 */
  256.     {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
  257.     {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  258.     {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  259.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
  260.     {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 */
  261.     {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  262.     {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  263.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
  264.     {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
  265.     {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 */
  266.     {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  267.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 9, 24, 8, 23, 7, 22},
  268.     {6, 21, 4, 19, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 22, 8, 23, 7, 22, 7, 21},
  269.     {5, 20, 4, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  270.     {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 */
  271.     {6, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 22, 7, 23, 8, 23, 8, 23, 8, 24, 8, 23, 7, 22},
  272.     {6, 21, 4, 19, 5, 20, 4, 20, 5, 20, 5, 21, 7, 22, 7, 23, 7, 22, 8, 23, 7, 22, 7, 21},
  273.     {5, 20, 4, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  274.     {5, 20, 4, 19, 6, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  275.     {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 */
  276.     {6, 20, 4, 19, 5, 20, 4, 19, 5, 20, 5, 21, 7, 22, 7, 23, 7, 22, 8, 23, 7, 22, 7, 21},
  277.     {5, 20, 3, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  278.     {5, 20, 4, 19, 5, 21, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  279.     {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22},
  280.     {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 */
  281.     {5, 20, 3, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
  282.     {5, 20, 4, 19, 5, 20, 5, 20, 5, 21, 6, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  283.     {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 24, 8, 22, 7, 22},
  284.     {6, 20, 4, 19, 5, 20, 4, 19, 5, 20, 5, 21, 6, 22, 7, 22, 7, 22, 8, 23, 7, 22, 6, 21},
  285.     {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 */
  286.     {5, 20, 4, 18, 5, 20, 5, 20, 5, 21, 5, 21, 7, 23, 7, 23, 7, 23, 8, 23, 7, 22, 7, 22},
  287.     {5, 20, 4, 19, 6, 21, 5, 20, 6, 21, 6, 21, 7, 23, 8, 23, 8, 23, 8, 23, 7, 22, 7, 22},
  288.     {6, 20, 4, 19, 5, 20, 4, 19, 5, 20, 5, 21, 6, 22, 7, 22, 7, 22, 8, 23, 7, 22, 6, 21},
  289.     {5, 20, 3, 18, 5, 20, 4, 20, 5, 21, 5, 21, 7, 22, 7, 23, 7, 23, 8, 23, 7, 22, 7, 21},
  290.     {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 */
  291. };
  292. /* number of accumulated days per solar month, non-leap year and leap year. */
  293. const S16 gClndrAccuDays[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396};
  294. /* array of lunar calendar */
  295. const clndr_lunar_table_struct gClndrLunarInfo[] = 
  296. {
  297.     {47, 2, 11, 0, 5482},
  298.     {36, 3, 16, 0, 2921},   /* 1970 */
  299.     {26, 4, 21, 5, 5970},
  300.     {45, 5, 26, 0, 6994},
  301.     {33, 0, 32, 0, 6949},
  302.     {22, 1, 37, 4, 5707},
  303.     {41, 2, 42, 0, 6731},   /* 1975 */
  304.     {30, 3, 47, 8, 5291},
  305.     {48, 5, 53, 0, 4781},
  306.     {37, 6, 58, 0, 5485},
  307.     {27, 0, 3, 6, 2921},
  308.     {46, 1, 8, 0, 3497},    /* 1980 */
  309.     {35, 3, 14, 0, 7570},
  310.     {24, 4, 19, 4, 7461},
  311.     {43, 5, 24, 0, 7461},
  312.     {32, 6, 29, 10, 6733},
  313.     {50, 1, 35, 0, 2646},   /* 1985 */
  314.     {39, 2, 40, 0, 4790},
  315.     {28, 3, 45, 6, 1461},
  316.     {47, 4, 50, 0, 5845},
  317.     {36, 6, 56, 0, 3785},
  318.     {26, 0, 1, 5, 7826},    /* 1990 */
  319.     {45, 1, 6, 0, 3730},
  320.     {34, 2, 11, 0, 3366},
  321.     {22, 4, 17, 3, 2646},
  322.     {40, 5, 22, 0, 2647},
  323.     {30, 6, 27, 8, 5334},   /* 1995 */
  324.     {49, 0, 32, 0, 4954},
  325.     {37, 2, 38, 0, 5845},
  326.     {27, 3, 43, 5, 5833},
  327.     {46, 4, 48, 0, 5961},
  328.     {35, 5, 53, 0, 5779},   /* 2000 */
  329.     {23, 0, 59, 4, 5419},
  330.     {42, 1, 4, 0, 5419},
  331.     {31, 2, 9, 0, 2651},
  332.     {21, 3, 14, 2, 5466},
  333.     {39, 5, 20, 0, 5482},   /* 2005 */
  334.     {28, 6, 25, 7, 6997},
  335.     {48, 0, 30, 0, 7076},
  336.     {37, 1, 35, 0, 6985},
  337.     {25, 3, 41, 5, 6803},
  338.     {44, 4, 46, 0, 6805},   /* 2010 */
  339.     {33, 5, 51, 0, 5421},
  340.     {22, 6, 56, 4, 2733},
  341.     {40, 1, 2, 0, 2741},
  342.     {30, 2, 7, 9, 5546},
  343.     {49, 3, 12, 0, 5586},   /* 2015 */
  344.     {38, 4, 17, 0, 3493},
  345.     {27, 6, 23, 6, 7498},
  346.     {46, 0, 28, 0, 3402},
  347.     {35, 1, 33, 0, 3222},
  348.     {24, 2, 38, 4, 5422},   /* 2020 */
  349.     {42, 4, 44, 0, 5462},
  350.     {31, 5, 49, 0, 2741},
  351.     {21, 6, 54, 2, 5546},
  352.     {40, 0, 59, 0, 5842},
  353.     {28, 2, 5, 6, 3749},    /* 2025 */
  354.     {47, 3, 10, 0, 5925},
  355.     {36, 4, 15, 0, 5707},
  356.     {25, 5, 20, 5, 3223},
  357.     {43, 0, 26, 0, 3243},
  358.     {33, 1, 31, 0, 1370},   /* 2030 */
  359.     {22, 2, 36, 3, 2774},
  360. };
  361. /* 
  362.  * Local Function
  363.  */
  364. /* 
  365.  * Global Variable
  366.  */
  367. /* the number of days for each solar month. */
  368. U8 gClndrAddToHistory;
  369. clndr_context_struct *g_clndr_cntx = NULL;
  370. extern wgui_inline_item wgui_inline_items[];
  371. extern const U8 gDaysInMonth[];
  372. /* 
  373.  * Global Function
  374.  */
  375. extern void SetCategory82Title1(U8 *);
  376. extern void SetCategory82Title2(U8 *);
  377. extern void SetCategory82Title3(U8 *);
  378. extern pBOOL IsChineseSet(void);
  379. extern MMI_BOOL mmi_frm_test_menu_item_hide(U16 menu_item_id);
  380. #define CLNDR_INITIALIZE
  381. #ifdef __MMI_CALENDAR_V2__
  382. /*****************************************************************************
  383.  * FUNCTION
  384.  *  mmi_clndr_get_week_numbers
  385.  * DESCRIPTION
  386.  *  
  387.  * PARAMETERS
  388.  *  year        [IN]        
  389.  *  month       [IN]        
  390.  *  weekStr     [IN]        
  391.  * RETURNS
  392.  *  void
  393.  *****************************************************************************/
  394. void mmi_clndr_get_week_numbers(U16 year, U8 month, U8 **weekStr)
  395. {
  396.     /*----------------------------------------------------------------*/
  397.     /* Local Variables                                                */
  398.     /*----------------------------------------------------------------*/
  399.     MYTIME dt;
  400.     U8 week, i;
  401.     S8 asciiStr[CLNDR_HORIZON_LIST_CELL_LEN], unicodeStr[CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH];
  402.     /*----------------------------------------------------------------*/
  403.     /* Code Body                                                      */
  404.     /*----------------------------------------------------------------*/
  405.     memset(&dt, 0, sizeof(MYTIME));
  406.     memset(&asciiStr, 0, CLNDR_HORIZON_LIST_CELL_LEN);
  407.     memset(&unicodeStr, 0, CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH);
  408.     dt.nYear = year;
  409.     dt.nMonth = month;
  410.     dt.nDay = 1;
  411.     /* get the week number of first day of the month */
  412. #ifdef MMI_ON_WIN32
  413. week = mmi_dt_get_week_number(& dt);
  414. #else
  415.     week = applib_dt_get_week_number((applib_time_struct*) & dt);
  416. #endif
  417.     for (i = 0; i < CLNDR_ROW; i++, week++)
  418.     {
  419.         pfnUnicodeStrncpy((S8*) weekStr[i], GetString((U16) STR_CLNDR_WEEK_SYMBOL), CLNDR_WEEK_SYMBOL_LEN);
  420.         sprintf(asciiStr, "%d", week);
  421.         /* assert if the string of week number is longer than  */
  422.         ASSERT(strlen(asciiStr) < CLNDR_HORIZON_LIST_CELL_LEN - CLNDR_WEEK_SYMBOL_LEN);
  423.         AnsiiToUnicodeString(unicodeStr, asciiStr);
  424.         pfnUnicodeStrncat((S8*) weekStr[i], unicodeStr, strlen(asciiStr));
  425.     }
  426. }
  427. /*****************************************************************************
  428.  * FUNCTION
  429.  *  mmi_clndr_get_date_str
  430.  * DESCRIPTION
  431.  *  
  432.  * PARAMETERS
  433.  *  date        [?]     [?]
  434.  *  dateStr     [?]     [?]
  435.  * RETURNS
  436.  *  void
  437.  *****************************************************************************/
  438. void mmi_clndr_get_date_str(MYTIME *date, U8 *dateStr)
  439. {
  440.     /*----------------------------------------------------------------*/
  441.     /* Local Variables                                                */
  442.     /*----------------------------------------------------------------*/
  443.     S8 asciiStr[CLNDR_TITLE_LEN], unicodeStr[CLNDR_TITLE_LEN];
  444.     /*----------------------------------------------------------------*/
  445.     /* Code Body                                                      */
  446.     /*----------------------------------------------------------------*/
  447.     memset(&asciiStr, 0, CLNDR_TITLE_LEN);
  448.     memset(&unicodeStr, 0, CLNDR_TITLE_LEN);
  449.     /* year */
  450.     sprintf(asciiStr, "%d", date->nYear);
  451.     AnsiiToUnicodeString(unicodeStr, asciiStr);
  452.     pfnUnicodeStrcpy((S8*) dateStr, unicodeStr);
  453.     pfnUnicodeStrcat((S8*) dateStr, (PS8) "/");
  454.     /* month */
  455.     if (date->nMonth < 10)
  456.     {
  457.         pfnUnicodeStrcat((S8*) dateStr, (PS8) "0");
  458.     }
  459.     sprintf(asciiStr, "%d", date->nMonth);
  460.     AnsiiToUnicodeString(unicodeStr, asciiStr);
  461.     pfnUnicodeStrcat((S8*) dateStr, unicodeStr);
  462.     pfnUnicodeStrcat((S8*) dateStr, (PS8) "/");
  463.     /* month */
  464.     if (date->nDay < 10)
  465.     {
  466.         pfnUnicodeStrcat((S8*) dateStr, (PS8) "0");
  467.     }
  468.     sprintf(asciiStr, "%d", date->nDay);
  469.     AnsiiToUnicodeString(unicodeStr, asciiStr);
  470.     pfnUnicodeStrcat((S8*) dateStr, unicodeStr);
  471. }
  472. /*****************************************************************************
  473.  * FUNCTION
  474.  *  mmi_clndr_get_weekday
  475.  * DESCRIPTION
  476.  *  
  477.  * PARAMETERS
  478.  *  weekdayStr      [IN]        
  479.  * RETURNS
  480.  *  void
  481.  *****************************************************************************/
  482. void mmi_clndr_get_weekday(U8 **weekdayStr)
  483. {
  484.     /*----------------------------------------------------------------*/
  485.     /* Local Variables                                                */
  486.     /*----------------------------------------------------------------*/
  487.     U32 i, j;
  488.     /*----------------------------------------------------------------*/
  489.     /* Code Body                                                      */
  490.     /*----------------------------------------------------------------*/
  491.     for (i = CLNDR_START_WEEKDAY; i < CLNDR_TOTAL_WEEKDAY; i++)
  492.     {
  493.         j = i + STR_CLNDR_WEEK_SUNDAY + CLNDR_START_WEEKDAY;
  494.         memcpy(weekdayStr[i], (U8*) GetString((U16) j), CLNDR_HORIZON_LIST_CELL_LEN * ENCODING_LENGTH);
  495.         /* weekdayStr[i] = GetString((U16)j); */
  496.     }
  497. }
  498. /*****************************************************************************
  499.  * FUNCTION
  500.  *  mmi_clndr_construct_monthly_cell_info
  501.  * DESCRIPTION
  502.  *  
  503.  * PARAMETERS
  504.  *  void
  505.  * RETURNS
  506.  *  void
  507.  *****************************************************************************/
  508. void mmi_clndr_construct_monthly_cell_info(void)
  509. {
  510.     /*----------------------------------------------------------------*/
  511.     /* Local Variables                                                */
  512.     /*----------------------------------------------------------------*/
  513.     S32 i, taskPos, nextMonthBoundary;
  514.     wgui_cat83_cell_struct *cell;
  515.     MYTIME preMonth, incTime, currTime;
  516.     U8 lastDayofPreMonth;
  517.     /*----------------------------------------------------------------*/
  518.     /* Code Body                                                      */
  519.     /*----------------------------------------------------------------*/
  520.     memset(&preMonth, 0, sizeof(MYTIME));
  521.     memset(&incTime, 0, sizeof(MYTIME));
  522.     memset(&currTime, 0, sizeof(MYTIME));
  523. #ifdef __MMI_BIRTHDAY_REMINDER__
  524.     mmi_clndr_set_birthday_table(g_clndr_cntx->CalTime.nYear, g_clndr_cntx->CalTime.nMonth);
  525. #endif /* __MMI_BIRTHDAY_REMINDER__ */ 
  526.     incTime.nMonth = 1;
  527. #ifdef MMI_ON_WIN32
  528. DecrementTime(g_clndr_cntx->CalTime, incTime, & preMonth);
  529. #else
  530.     applib_dt_decrease_time(
  531.         (applib_time_struct*) & (g_clndr_cntx->CalTime),
  532.         (applib_time_struct*) & incTime,
  533.         (applib_time_struct*) & preMonth);
  534.     lastDayofPreMonth = applib_dt_last_day_of_mon(preMonth.nMonth, preMonth.nYear);
  535. #endif
  536.     cell = g_clndr_cntx->CalendarCell + (g_clndr_cntx->DayOnFirst);
  537.     /* last month */
  538.     for (i = g_clndr_cntx->DayOnFirst - 1; i >= 0; i--)
  539.     {
  540.         cell--;
  541.         mmi_clndr_util_num_to_unicode(lastDayofPreMonth, (U8*) cell->text, CAT83_MAX_CELL_TEXT);
  542.         cell->valid = MMI_FALSE;
  543.         cell->bg_index = CAT83_COLOR_NONE;
  544.         lastDayofPreMonth--;
  545.     }
  546.     /* this month */
  547.     taskPos = 1;
  548. #ifdef __MMI_CLNDR_ICON_SUPPORT__
  549.     mmi_tdl_get_monthly_task_with_icon(&(g_clndr_cntx->CalTime), g_clndr_cntx->TaskDayList);
  550. #else 
  551.     TDLGetDaysToBeHilited(g_clndr_cntx->CalTime, g_clndr_cntx->TaskDayList);
  552. #endif 
  553.     cell = g_clndr_cntx->CalendarCell + g_clndr_cntx->DayOnFirst;
  554.     for (i = 1; i <= g_clndr_cntx->NumDaysInMonth; i++)
  555.     {
  556.         mmi_clndr_util_num_to_unicode(i, (U8*) cell->text, CAT83_MAX_CELL_TEXT);
  557.         cell->bg_index = cell->bg_index = CAT83_COLOR_NONE;
  558.     #ifdef __MMI_CLNDR_ICON_SUPPORT__
  559.         if (g_clndr_cntx->TaskDayList[i].date > 0)
  560.         {
  561.             cell->icon_id = g_clndr_cntx->TaskDayList[i].icon;
  562.         }
  563.     #ifdef __MMI_BIRTHDAY_REMINDER__
  564.         else if (g_clndr_cntx->BirthdayInfo[i].count > 0)
  565.         {
  566.             cell->icon_id = IMG_CLNDR_BIRTHDAY_REMINDER;
  567.         }
  568.     #endif /* __MMI_BIRTHDAY_REMINDER__ */ 
  569.     #else /* __MMI_CLNDR_ICON_SUPPORT__ */ 
  570.         if (i == g_clndr_cntx->TaskDayList[taskPos])
  571.         {
  572.             taskPos++;
  573.         }
  574.     #endif /* __MMI_CLNDR_ICON_SUPPORT__ */ 
  575.         cell->valid = MMI_TRUE;
  576.         cell++;
  577.     }
  578.     /* next month */
  579.     nextMonthBoundary = CLNDR_ROW * CLNDR_COLUMN - (g_clndr_cntx->DayOnFirst + g_clndr_cntx->NumDaysInMonth);
  580.     for (i = 1; i <= nextMonthBoundary; i++)
  581.     {
  582.         mmi_clndr_util_num_to_unicode(i, (U8*) cell->text, CAT83_MAX_CELL_TEXT);
  583.         cell->bg_index = CAT83_COLOR_NONE;
  584.         cell->valid = MMI_FALSE;
  585.         cell++;
  586.     }
  587. }
  588. /* wgui_cat83_cell_struct* mmi_clndr_construct_weekly_cell_info(); */
  589. /*****************************************************************************
  590.  * FUNCTION
  591.  *  mmi_clndr_util_num_to_unicode
  592.  * DESCRIPTION
  593.  *  
  594.  * PARAMETERS
  595.  *  num     [IN]        
  596.  *  str     [?]         [?]
  597.  *  len     [IN]        
  598.  * RETURNS
  599.  *  void
  600.  *****************************************************************************/
  601. void mmi_clndr_util_num_to_unicode(S32 num, U8 *str, U8 len)
  602. {
  603.     /*----------------------------------------------------------------*/
  604.     /* Local Variables                                                */
  605.     /*----------------------------------------------------------------*/
  606.     S8 ascii[CLNDR_TITLE_LEN];
  607.     U16 value = (U16) num;
  608.     /*----------------------------------------------------------------*/
  609.     /* Code Body                                                      */
  610.     /*----------------------------------------------------------------*/
  611.     memset(ascii, 0, CLNDR_TITLE_LEN);
  612.     sprintf(ascii, "%d", value);
  613.     /* ASSERT(strlen(ascii) < len); */
  614.     AnsiiToUnicodeString((S8*) str, ascii);
  615. }
  616. /*****************************************************************************
  617.  * FUNCTION
  618.  *  mmi_clndr_highlight_monthly_view
  619.  * DESCRIPTION
  620.  *  
  621.  * PARAMETERS
  622.  *  void
  623.  * RETURNS
  624.  *  void
  625.  *****************************************************************************/
  626. void mmi_clndr_highlight_monthly_view(void)
  627. {
  628.     /*----------------------------------------------------------------*/
  629.     /* Local Variables                                                */
  630.     /*----------------------------------------------------------------*/
  631.     /*----------------------------------------------------------------*/
  632.     /* Code Body                                                      */
  633.     /*----------------------------------------------------------------*/
  634.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  635.     SetKeyHandler(mmi_pre_entry_monthly_view_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  636.     SetLeftSoftkeyFunction(mmi_pre_entry_monthly_view_screen, KEY_EVENT_UP);
  637.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  638. }
  639. /*****************************************************************************
  640.  * FUNCTION
  641.  *  mmi_pre_entry_monthly_view_screen
  642.  * DESCRIPTION
  643.  *  
  644.  * PARAMETERS
  645.  *  void
  646.  * RETURNS
  647.  *  void
  648.  *****************************************************************************/
  649. void mmi_pre_entry_monthly_view_screen(void)
  650. {
  651.     /*----------------------------------------------------------------*/
  652.     /* Local Variables                                                */
  653.     /*----------------------------------------------------------------*/
  654.     /*----------------------------------------------------------------*/
  655.     /* Code Body                                                      */
  656.     /*----------------------------------------------------------------*/
  657.     g_clndr_cntx->DisplayType = CLNDR_MONTHLY_VIEW;
  658.     g_clndr_cntx->RowNumber = CLNDR_ROW;
  659.     GoBackHistory();
  660. }
  661. /*****************************************************************************
  662.  * FUNCTION
  663.  *  mmi_clndr_monthly_highlight
  664.  * DESCRIPTION
  665.  *  
  666.  * PARAMETERS
  667.  *  row         [IN]        
  668.  *  column      [IN]        
  669.  * RETURNS
  670.  *  
  671.  *****************************************************************************/
  672. MMI_BOOL mmi_clndr_monthly_highlight(U32 row, U32 column)
  673. {
  674.     /*----------------------------------------------------------------*/
  675.     /* Local Variables                                                */
  676.     /*----------------------------------------------------------------*/
  677.     U8 totaldays;
  678.     /*----------------------------------------------------------------*/
  679.     /* Code Body                                                      */
  680.     /*----------------------------------------------------------------*/
  681.     totaldays = (row * CLNDR_COLUMN) + column + 1;
  682.     g_clndr_cntx->CalTime.nDay = totaldays - g_clndr_cntx->DayOnFirst;
  683.     g_clndr_cntx->CalTime.DayIndex = DOW(g_clndr_cntx->CalTime.nYear, g_clndr_cntx->CalTime.nMonth, g_clndr_cntx->CalTime.nDay);
  684.     if (g_clndr_cntx->LunarState == TRUE && IsChineseSet())
  685.     {        
  686.         g_clndr_cntx->LunarInfo.SolarMonth = g_clndr_cntx->CalTime.nMonth;
  687.         g_clndr_cntx->LunarInfo.SolarYear = g_clndr_cntx->CalTime.nYear;
  688.         g_clndr_cntx->LunarInfo.SolarDay = g_clndr_cntx->CalTime.nDay;
  689.         ClndrComputeLunarInfo(&g_clndr_cntx->LunarInfo);
  690.         
  691.         wgui_cat83_set_normal_title((U8*) g_clndr_cntx->LunarInfo.TitleInfo1);        
  692.         wgui_cat83_set_popup(
  693.                     (U8*) g_clndr_cntx->LunarInfo.MessageLine1,
  694.                     (U8*) g_clndr_cntx->LunarInfo.MessageLine2,
  695.                     (U8*) g_clndr_cntx->LunarInfo.MessageLine3);
  696.     }
  697.     else
  698.     {
  699.     mmi_clndr_get_date_str(&(g_clndr_cntx->CalTime), g_clndr_cntx->Title);
  700.     wgui_cat83_set_normal_title(g_clndr_cntx->Title);
  701.     }
  702.     mmi_momthly_clndr_set_info_box();
  703.     return MMI_FALSE;
  704. }
  705. /*****************************************************************************
  706.  * FUNCTION
  707.  *  mmi_clndr_monthly_compute_next_time
  708.  * DESCRIPTION
  709.  *  
  710.  * PARAMETERS
  711.  *  arrow       [IN]        
  712.  * RETURNS
  713.  *  
  714.  *****************************************************************************/
  715. MMI_BOOL mmi_clndr_monthly_compute_next_time(U32 arrow)
  716. {
  717.     /*----------------------------------------------------------------*/
  718.     /* Local Variables                                                */
  719.     /*----------------------------------------------------------------*/
  720.     MYTIME resultDate, incTime;
  721.     /*----------------------------------------------------------------*/
  722.     /* Code Body                                                      */
  723.     /*----------------------------------------------------------------*/
  724.     memset(&resultDate, 0, sizeof(MYTIME));
  725.     memset(&incTime, 0, sizeof(MYTIME));
  726.     switch (arrow)
  727.     {
  728.         case CLNDR_KEY_UP:
  729.             incTime.nDay = CLNDR_TOTAL_WEEKDAY;
  730. #ifdef MMI_ON_WIN32
  731. DecrementTime(g_clndr_cntx->CalTime, incTime, &resultDate);
  732. #else
  733.             applib_dt_decrease_time(
  734.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  735.                 (applib_time_struct*) & incTime,
  736.                 (applib_time_struct*) & resultDate);
  737. #endif
  738.             break;
  739.         case CLNDR_KEY_DOWN:
  740.             incTime.nDay = CLNDR_TOTAL_WEEKDAY;
  741. #ifdef MMI_ON_WIN32
  742. DecrementTime(g_clndr_cntx->CalTime, incTime, &resultDate);
  743. #else
  744.             applib_dt_increase_time(
  745.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  746.                 (applib_time_struct*) & incTime,
  747.                 (applib_time_struct*) & resultDate);
  748. #endif
  749.             break;
  750.         case CLNDR_KEY_LEFT:
  751.             incTime.nDay = 1;
  752. #ifdef MMI_ON_WIN32
  753. DecrementTime(g_clndr_cntx->CalTime, incTime, &resultDate);
  754. #else
  755.             applib_dt_decrease_time(
  756.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  757.                 (applib_time_struct*) & incTime,
  758.                 (applib_time_struct*) & resultDate);
  759. #endif
  760.             break;
  761.         case CLNDR_KEY_RIGHT:
  762.             incTime.nDay = 1;
  763. #ifdef MMI_ON_WIN32
  764. DecrementTime(g_clndr_cntx->CalTime, incTime, &resultDate);
  765. #else
  766.             applib_dt_increase_time(
  767.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  768.                 (applib_time_struct*) & incTime,
  769.                 (applib_time_struct*) & resultDate);
  770. #endif
  771.             break;
  772.         default:
  773.             break;
  774.     }
  775.     return mmi_clndr_monthly_out_of_boundary(&resultDate);
  776. }
  777. /*****************************************************************************
  778.  * FUNCTION
  779.  *  mmi_clndr_monthly_out_of_boundary
  780.  * DESCRIPTION
  781.  *  
  782.  * PARAMETERS
  783.  *  resultDate      [?]     
  784.  * RETURNS
  785.  *  
  786.  *****************************************************************************/
  787. MMI_BOOL mmi_clndr_monthly_out_of_boundary(MYTIME *resultDate)
  788. {
  789.     /*----------------------------------------------------------------*/
  790.     /* Local Variables                                                */
  791.     /*----------------------------------------------------------------*/
  792.     MYTIME currTime;
  793.     U32 highlightDays, highlightX, highlightY;
  794.     S32 currCell = -1;
  795.     /*----------------------------------------------------------------*/
  796.     /* Code Body                                                      */
  797.     /*----------------------------------------------------------------*/
  798.     if (resultDate->nYear > CLNDR_END_YEAR || resultDate->nYear < CLNDR_START_YEAR)
  799.     {
  800.         DisplayPopup(
  801.         (U8*) GetString(STR_CLNDR_OUT_OF_CALENDAR),
  802.         IMG_GLOBAL_WARNING,
  803.         0,
  804.         UI_POPUP_NOTIFYDURATION_TIME,
  805.         (U8) WARNING_TONE);
  806.         
  807.         return MMI_FALSE;
  808.     }
  809.     g_clndr_cntx->DayOnFirst = DOW(resultDate->nYear, resultDate->nMonth, 1);
  810.     /* set highlight and current date */
  811.     /* subtract 1 to compute the correct highlight position */
  812.     highlightDays = g_clndr_cntx->DayOnFirst + resultDate->nDay - 1;
  813.     highlightX = highlightDays % CLNDR_TOTAL_WEEKDAY;
  814.     highlightY = highlightDays / CLNDR_TOTAL_WEEKDAY;
  815.     wgui_cat83_set_highlight(highlightY, highlightX);
  816.     /* move to next/previous month */
  817.     if (g_clndr_cntx->CalTime.nMonth != resultDate->nMonth || g_clndr_cntx->CalTime.nYear != resultDate->nYear)
  818.     {
  819.         memcpy(&g_clndr_cntx->CalTime, resultDate, sizeof(MYTIME));
  820.         /* get calendar information */
  821.         memset(g_clndr_cntx->TaskDayList, 0, CLNDR_COLUMN * CLNDR_ROW * sizeof(clndr_task_icon_struct));
  822.         g_clndr_cntx->NumDaysInMonth = LastDayOfMonth(g_clndr_cntx->CalTime.nMonth, g_clndr_cntx->CalTime.nYear);
  823.         mmi_clndr_get_date_str(&(g_clndr_cntx->CalTime), g_clndr_cntx->Title);
  824.         mmi_clndr_get_weekday(g_clndr_cntx->HorizonList);
  825.         mmi_clndr_get_week_numbers(
  826.             g_clndr_cntx->CalTime.nYear,
  827.             g_clndr_cntx->CalTime.nMonth,
  828.             g_clndr_cntx->VerticalList);
  829.         /* Set current date */
  830.         GetDateTime(&currTime);
  831.         if (currTime.nMonth == g_clndr_cntx->CalTime.nMonth && currTime.nYear == g_clndr_cntx->CalTime.nYear)
  832.         {
  833.             currCell = g_clndr_cntx->DayOnFirst + currTime.nDay - 1;
  834.         }
  835.         wgui_cat83_set_current(currCell / CLNDR_COLUMN, currCell % CLNDR_COLUMN);
  836.         /* construct cell info */
  837.         memset(g_clndr_cntx->CalendarCell, 0, g_clndr_cntx->RowNumber * CLNDR_COLUMN * CLNDR_CELL_SIZE);
  838.         mmi_clndr_construct_monthly_cell_info();
  839.         mmi_clndr_monthly_set_content();
  840.         /* ClndrGetScreenInfo(); */
  841.         return MMI_TRUE;
  842.     }
  843.     else
  844.     {
  845.         /* return MMI_FALSE; */
  846.         return MMI_TRUE;
  847.     }
  848. }
  849. /*****************************************************************************
  850.  * FUNCTION
  851.  *  mmi_clndr_left_out_of_boundary
  852.  * DESCRIPTION
  853.  *  
  854.  * PARAMETERS
  855.  *  row         [IN]        
  856.  *  column      [IN]        
  857.  * RETURNS
  858.  *  
  859.  *****************************************************************************/
  860. MMI_BOOL mmi_clndr_left_out_of_boundary(U32 row, U32 column)
  861. {
  862.     /*----------------------------------------------------------------*/
  863.     /* Local Variables                                                */
  864.     /*----------------------------------------------------------------*/
  865.     /*----------------------------------------------------------------*/
  866.     /* Code Body                                                      */
  867.     /*----------------------------------------------------------------*/
  868.     if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
  869.     {
  870.         return mmi_clndr_monthly_compute_next_time(CLNDR_KEY_LEFT);
  871.         /* return mmi_clndr_monthly_out_of_boundary(CLNDR_KEY_LEFT, row, column); */
  872.     }
  873. #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
  874.     else
  875.     {
  876.         /* return mmi_clndr_weekly_out_of_boundary(CLNDR_KEY_LEFT, row, column); */
  877.         return mmi_clndr_weekly_compute_next_time(CLNDR_KEY_LEFT);
  878.     }
  879. #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */ 
  880. }
  881. /*****************************************************************************
  882.  * FUNCTION
  883.  *  mmi_clndr_right_out_of_boundary
  884.  * DESCRIPTION
  885.  *  
  886.  * PARAMETERS
  887.  *  row         [IN]        
  888.  *  column      [IN]        
  889.  * RETURNS
  890.  *  
  891.  *****************************************************************************/
  892. MMI_BOOL mmi_clndr_right_out_of_boundary(U32 row, U32 column)
  893. {
  894.     /*----------------------------------------------------------------*/
  895.     /* Local Variables                                                */
  896.     /*----------------------------------------------------------------*/
  897.     /*----------------------------------------------------------------*/
  898.     /* Code Body                                                      */
  899.     /*----------------------------------------------------------------*/
  900.     if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
  901.     {
  902.         return mmi_clndr_monthly_compute_next_time(CLNDR_KEY_RIGHT);
  903.         /* return mmi_clndr_monthly_out_of_boundary(CLNDR_KEY_RIGHT, row, column); */
  904.     }
  905. #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
  906.     else
  907.     {
  908.         /* return mmi_clndr_weekly_out_of_boundary(CLNDR_KEY_RIGHT, row, column); */
  909.         return mmi_clndr_weekly_compute_next_time(CLNDR_KEY_RIGHT);
  910.     }
  911. #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */ 
  912. }
  913. /*****************************************************************************
  914.  * FUNCTION
  915.  *  mmi_clndr_up_out_of_boundary
  916.  * DESCRIPTION
  917.  *  
  918.  * PARAMETERS
  919.  *  row         [IN]        
  920.  *  column      [IN]        
  921.  * RETURNS
  922.  *  
  923.  *****************************************************************************/
  924. MMI_BOOL mmi_clndr_up_out_of_boundary(U32 row, U32 column)
  925. {
  926.     /*----------------------------------------------------------------*/
  927.     /* Local Variables                                                */
  928.     /*----------------------------------------------------------------*/
  929.     /*----------------------------------------------------------------*/
  930.     /* Code Body                                                      */
  931.     /*----------------------------------------------------------------*/
  932.     if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
  933.     {
  934.         return mmi_clndr_monthly_compute_next_time(CLNDR_KEY_UP);
  935.         /* return mmi_clndr_monthly_out_of_boundary(CLNDR_KEY_UP, row, column); */
  936.     }
  937. #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
  938.     else
  939.     {
  940.         /* return mmi_clndr_weekly_out_of_boundary(CLNDR_KEY_UP, row, column); */
  941.         return mmi_clndr_weekly_compute_next_time(CLNDR_KEY_UP);
  942.     }
  943. #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */ 
  944. }
  945. /*****************************************************************************
  946.  * FUNCTION
  947.  *  mmi_clndr_down_out_of_boundary
  948.  * DESCRIPTION
  949.  *  
  950.  * PARAMETERS
  951.  *  row         [IN]        
  952.  *  column      [IN]        
  953.  * RETURNS
  954.  *  
  955.  *****************************************************************************/
  956. MMI_BOOL mmi_clndr_down_out_of_boundary(U32 row, U32 column)
  957. {
  958.     /*----------------------------------------------------------------*/
  959.     /* Local Variables                                                */
  960.     /*----------------------------------------------------------------*/
  961.     /*----------------------------------------------------------------*/
  962.     /* Code Body                                                      */
  963.     /*----------------------------------------------------------------*/
  964.     if (g_clndr_cntx->DisplayType == CLNDR_MONTHLY_VIEW)
  965.     {
  966.         return mmi_clndr_monthly_compute_next_time(CLNDR_KEY_DOWN);
  967.         /* return mmi_clndr_monthly_out_of_boundary(CLNDR_KEY_DOWN, row, column); */
  968.     }
  969. #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
  970.     else
  971.     {
  972.         /* return mmi_clndr_weekly_out_of_boundary(CLNDR_KEY_DOWN, row, column); */
  973.         return mmi_clndr_weekly_compute_next_time(CLNDR_KEY_DOWN);
  974.     }
  975. #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */ 
  976. }
  977. /*****************************************************************************
  978.  * FUNCTION
  979.  *  mmi_clndr_up_side_key
  980.  * DESCRIPTION
  981.  *  
  982.  * PARAMETERS
  983.  *  row         [IN]        
  984.  *  column      [IN]        
  985.  * RETURNS
  986.  *  
  987.  *****************************************************************************/
  988. MMI_BOOL mmi_clndr_up_side_key(U32 row, U32 column)
  989. {
  990.     /*----------------------------------------------------------------*/
  991.     /* Local Variables                                                */
  992.     /*----------------------------------------------------------------*/
  993.     /*----------------------------------------------------------------*/
  994.     /* Code Body                                                      */
  995.     /*----------------------------------------------------------------*/
  996.     return mmi_clndr_monthly_movement(CLNDR_PRIVOUS_MONTH);
  997.     /* return MMI_TRUE; */
  998. }
  999. /*****************************************************************************
  1000.  * FUNCTION
  1001.  *  mmi_clndr_down_side_key
  1002.  * DESCRIPTION
  1003.  *  
  1004.  * PARAMETERS
  1005.  *  row         [IN]        
  1006.  *  column      [IN]        
  1007.  * RETURNS
  1008.  *  
  1009.  *****************************************************************************/
  1010. MMI_BOOL mmi_clndr_down_side_key(U32 row, U32 column)
  1011. {
  1012.     /*----------------------------------------------------------------*/
  1013.     /* Local Variables                                                */
  1014.     /*----------------------------------------------------------------*/
  1015.     /*----------------------------------------------------------------*/
  1016.     /* Code Body                                                      */
  1017.     /*----------------------------------------------------------------*/
  1018.     return mmi_clndr_monthly_movement(CLNDR_NEXT_MONTH);
  1019.     /* return MMI_TRUE; */
  1020. }
  1021. #ifdef __MMI_TOUCH_SCREEN__
  1022. /*****************************************************************************
  1023.  * FUNCTION
  1024.  *  mmi_clndr_touch_year_increase
  1025.  * DESCRIPTION
  1026.  *  
  1027.  * PARAMETERS
  1028.  *  row         [IN]        
  1029.  *  column      [IN]        
  1030.  * RETURNS
  1031.  *  
  1032.  *****************************************************************************/
  1033. MMI_BOOL mmi_clndr_touch_year_increase(U32 row, U32 column)
  1034. {
  1035.     /*----------------------------------------------------------------*/
  1036.     /* Local Variables                                                */
  1037.     /*----------------------------------------------------------------*/
  1038.     /*----------------------------------------------------------------*/
  1039.     /* Code Body                                                      */
  1040.     /*----------------------------------------------------------------*/
  1041.     return mmi_clndr_monthly_movement(CLNDR_NEXT_YEAR);
  1042.     /* return MMI_TRUE; */
  1043. }
  1044. /*****************************************************************************
  1045.  * FUNCTION
  1046.  *  mmi_clndr_touch_year_decrease
  1047.  * DESCRIPTION
  1048.  *  
  1049.  * PARAMETERS
  1050.  *  row         [IN]        
  1051.  *  column      [IN]        
  1052.  * RETURNS
  1053.  *  
  1054.  *****************************************************************************/
  1055. MMI_BOOL mmi_clndr_touch_year_decrease(U32 row, U32 column)
  1056. {
  1057.     /*----------------------------------------------------------------*/
  1058.     /* Local Variables                                                */
  1059.     /*----------------------------------------------------------------*/
  1060.     /*----------------------------------------------------------------*/
  1061.     /* Code Body                                                      */
  1062.     /*----------------------------------------------------------------*/
  1063.     return mmi_clndr_monthly_movement(CLNDR_PRIVOUS_YEAR);
  1064.     /* return MMI_TRUE; */
  1065. }
  1066. /*****************************************************************************
  1067.  * FUNCTION
  1068.  *  mmi_clndr_touch_month_increase
  1069.  * DESCRIPTION
  1070.  *  
  1071.  * PARAMETERS
  1072.  *  row         [IN]        
  1073.  *  column      [IN]        
  1074.  * RETURNS
  1075.  *  
  1076.  *****************************************************************************/
  1077. MMI_BOOL mmi_clndr_touch_month_increase(U32 row, U32 column)
  1078. {
  1079.     /*----------------------------------------------------------------*/
  1080.     /* Local Variables                                                */
  1081.     /*----------------------------------------------------------------*/
  1082.     /*----------------------------------------------------------------*/
  1083.     /* Code Body                                                      */
  1084.     /*----------------------------------------------------------------*/
  1085.     return mmi_clndr_monthly_movement(CLNDR_NEXT_MONTH);
  1086.     /* return MMI_TRUE; */
  1087. }
  1088. /*****************************************************************************
  1089.  * FUNCTION
  1090.  *  mmi_clndr_touch_month_decrease
  1091.  * DESCRIPTION
  1092.  *  
  1093.  * PARAMETERS
  1094.  *  row         [IN]        
  1095.  *  column      [IN]        
  1096.  * RETURNS
  1097.  *  
  1098.  *****************************************************************************/
  1099. MMI_BOOL mmi_clndr_touch_month_decrease(U32 row, U32 column)
  1100. {
  1101.     /*----------------------------------------------------------------*/
  1102.     /* Local Variables                                                */
  1103.     /*----------------------------------------------------------------*/
  1104.     /*----------------------------------------------------------------*/
  1105.     /* Code Body                                                      */
  1106.     /*----------------------------------------------------------------*/
  1107.     return mmi_clndr_monthly_movement(CLNDR_PRIVOUS_MONTH);
  1108.     /* return MMI_TRUE; */
  1109. }
  1110. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1111. /* void mmi_clndr_monthly_movement(CLNDR_CLNDAR_MOVEMENT_ENUM type) */
  1112. /*****************************************************************************
  1113.  * FUNCTION
  1114.  *  mmi_clndr_monthly_movement
  1115.  * DESCRIPTION
  1116.  *  
  1117.  * PARAMETERS
  1118.  *  type        [IN]        
  1119.  * RETURNS
  1120.  *  
  1121.  *****************************************************************************/
  1122. MMI_BOOL mmi_clndr_monthly_movement(U32 type)
  1123. {
  1124.     /*----------------------------------------------------------------*/
  1125.     /* Local Variables                                                */
  1126.     /*----------------------------------------------------------------*/
  1127.     MYTIME incTime, resultTime;
  1128.     /*----------------------------------------------------------------*/
  1129.     /* Code Body                                                      */
  1130.     /*----------------------------------------------------------------*/
  1131.     memset(&incTime, 0, sizeof(MYTIME));
  1132.     memset(&resultTime, 0, sizeof(MYTIME));
  1133.     switch (type)
  1134.     {
  1135.         case CLNDR_PRIVOUS_MONTH:
  1136.             incTime.nMonth = 1;
  1137. #ifdef MMI_ON_WIN32
  1138. DecrementTime(g_clndr_cntx->CalTime, incTime, &resultTime);
  1139. #else
  1140.             applib_dt_decrease_time(
  1141.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  1142.                 (applib_time_struct*) & incTime,
  1143.                 (applib_time_struct*) & resultTime);
  1144. #endif
  1145.             break;
  1146.         case CLNDR_NEXT_MONTH:
  1147.             incTime.nMonth = 1;
  1148. #ifdef MMI_ON_WIN32
  1149. DecrementTime(g_clndr_cntx->CalTime, incTime, &resultTime);
  1150. #else
  1151.             applib_dt_increase_time(
  1152.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  1153.                 (applib_time_struct*) & incTime,
  1154.                 (applib_time_struct*) & resultTime);
  1155. #endif
  1156.             break;
  1157.     #ifdef __MMI_TOUCH_SCREEN__
  1158.         case CLNDR_PRIVOUS_YEAR:
  1159.             incTime.nYear = 1;
  1160. #ifdef MMI_ON_WIN32
  1161. DecrementTime(g_clndr_cntx->CalTime, incTime, &resultTime);
  1162. #else
  1163.             applib_dt_decrease_time(
  1164.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  1165.                 (applib_time_struct*) & incTime,
  1166.                 (applib_time_struct*) & resultTime);
  1167. #endif
  1168.             break;
  1169.         case CLNDR_NEXT_YEAR:
  1170.             incTime.nYear = 1;
  1171. #ifdef MMI_ON_WIN32
  1172. DecrementTime(g_clndr_cntx->CalTime, incTime, &resultTime);
  1173. #else
  1174.             applib_dt_increase_time(
  1175.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  1176.                 (applib_time_struct*) & incTime,
  1177.                 (applib_time_struct*) & resultTime);
  1178. #endif
  1179.             break;
  1180.     #endif /* __MMI_TOUCH_SCREEN__ */ 
  1181.         default:
  1182.             ASSERT(0);
  1183.     }
  1184.     resultTime.nDay = 1;
  1185.     return mmi_clndr_monthly_out_of_boundary(&resultTime);
  1186. }
  1187. /*****************************************************************************
  1188.  * FUNCTION
  1189.  *  mmi_clndr_monthly_set_content
  1190.  * DESCRIPTION
  1191.  *  
  1192.  * PARAMETERS
  1193.  *  void
  1194.  * RETURNS
  1195.  *  void
  1196.  *****************************************************************************/
  1197. void mmi_clndr_monthly_set_content(void)
  1198. {
  1199.     /*----------------------------------------------------------------*/
  1200.     /* Local Variables                                                */
  1201.     /*----------------------------------------------------------------*/
  1202.     /*----------------------------------------------------------------*/
  1203.     /* Code Body                                                      */
  1204.     /*----------------------------------------------------------------*/
  1205.     memset(g_clndr_cntx->horizon_select1, 0, CLNDR_VERTICAL_SELECT_LEN);
  1206.     memset(g_clndr_cntx->horizon_select2, 0, CLNDR_VERTICAL_SELECT_LEN);
  1207.     mmi_clndr_util_num_to_unicode(
  1208.         g_clndr_cntx->CalTime.nYear,
  1209.         g_clndr_cntx->horizon_select1,
  1210.         CLNDR_VERTICAL_SELECT_LEN);
  1211.     mmi_clndr_util_num_to_unicode(
  1212.         g_clndr_cntx->CalTime.nMonth,
  1213.         g_clndr_cntx->horizon_select2,
  1214.         CLNDR_VERTICAL_SELECT_LEN);
  1215.     wgui_cat83_set_select_horizontal1(
  1216.         CAL_LEFT_ARROW_UP_IMAGE,
  1217.         CAL_LEFT_ARROW_DOWN_IMAGE,
  1218.         CAL_RIGHT_ARROW_UP_IMAGE,
  1219.         CAL_RIGHT_ARROW_DOWN_IMAGE,
  1220.         g_clndr_cntx->horizon_select1,
  1221.         CAT83_SELECT_ALIGN_CENTER);
  1222.     wgui_cat83_set_select_horizontal2(
  1223.         CAL_LEFT_ARROW_UP_IMAGE,
  1224.         CAL_LEFT_ARROW_DOWN_IMAGE,
  1225.         CAL_RIGHT_ARROW_UP_IMAGE,
  1226.         CAL_RIGHT_ARROW_DOWN_IMAGE,
  1227.         g_clndr_cntx->horizon_select2,
  1228.         CAT83_SELECT_ALIGN_CENTER);
  1229.     wgui_cat83_set_select_vertical(
  1230.         0,  /* monthly view has no vertical shift button */
  1231.         0,
  1232.         0,
  1233.         0,
  1234.         g_clndr_cntx->VerticalList,
  1235.         CAT83_SELECT_ALIGN_CELL);
  1236.     wgui_cat83_set_normal_title(g_clndr_cntx->Title);
  1237.     wgui_cat83_set_cell_array(
  1238.         g_clndr_cntx->CalendarCell,
  1239.         CAT83_CELL_BG_FILL_HORIZONTAL,
  1240.         CAT83_CELL_TEXT_DISPLAY_LEFT_BOTTOM,
  1241.         CAT83_CELL_ICON_DISPLAY_RIGHT_TOP);
  1242. }
  1243. #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
  1244. /*****************************************************************************
  1245.  * FUNCTION
  1246.  *  mmi_pre_entry_weekly_view_screen
  1247.  * DESCRIPTION
  1248.  *  
  1249.  * PARAMETERS
  1250.  *  void
  1251.  * RETURNS
  1252.  *  void
  1253.  *****************************************************************************/
  1254. void mmi_pre_entry_weekly_view_screen(void)
  1255. {
  1256.     /*----------------------------------------------------------------*/
  1257.     /* Local Variables                                                */
  1258.     /*----------------------------------------------------------------*/
  1259.     MYTIME currentTime;
  1260.     S16 error;
  1261.     /*----------------------------------------------------------------*/
  1262.     /* Code Body                                                      */
  1263.     /*----------------------------------------------------------------*/
  1264.     GetDateTime(&currentTime);
  1265.     g_clndr_cntx->DisplayType = CLNDR_WEEKLY_VIEW;
  1266.     g_clndr_cntx->RowNumber = DLNDR_MAX_DAY_HOURS / g_clndr_cntx->PeriodInterval;
  1267.     ReadValue(NVRAM_CLNDR_PERIOD_INTERVAL, &(g_clndr_cntx->PeriodInterval), DS_BYTE, &error);
  1268.     if (g_clndr_cntx->PeriodInterval == 0 || g_clndr_cntx->PeriodInterval == 0xFF)
  1269.     {
  1270.         g_clndr_cntx->PeriodInterval = CLNDR_WEEKLY_PERIOD_INTERVAL;
  1271.         WriteValue(NVRAM_CLNDR_PERIOD_INTERVAL, &(g_clndr_cntx->PeriodInterval), DS_BYTE, &error);
  1272.     }
  1273.     
  1274.     g_clndr_cntx->CurrPeriodIndex = (currentTime.nHour / g_clndr_cntx->PeriodInterval);
  1275.     /* g_clndr_cntx->PeriodStartIndex = (currentTime.nHour / g_clndr_cntx->PeriodInterval); */
  1276.     /* start index is larger than limitation */
  1277.     if (g_clndr_cntx->CurrPeriodIndex > g_clndr_cntx->RowNumber - CLNDR_ROW)
  1278.     {
  1279.         g_clndr_cntx->PeriodStartIndex = g_clndr_cntx->RowNumber - CLNDR_ROW;
  1280.     }
  1281.     else
  1282.     {
  1283.         g_clndr_cntx->PeriodStartIndex = g_clndr_cntx->CurrPeriodIndex;
  1284.     }
  1285.     GoBackHistory();
  1286. }
  1287. /*****************************************************************************
  1288.  * FUNCTION
  1289.  *  mmi_clndr_highlight_weekly_view
  1290.  * DESCRIPTION
  1291.  *  
  1292.  * PARAMETERS
  1293.  *  void
  1294.  * RETURNS
  1295.  *  void
  1296.  *****************************************************************************/
  1297. void mmi_clndr_highlight_weekly_view(void)
  1298. {
  1299.     /*----------------------------------------------------------------*/
  1300.     /* Local Variables                                                */
  1301.     /*----------------------------------------------------------------*/
  1302.     /*----------------------------------------------------------------*/
  1303.     /* Code Body                                                      */
  1304.     /*----------------------------------------------------------------*/
  1305.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1306.     SetKeyHandler(mmi_pre_entry_weekly_view_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1307.     SetLeftSoftkeyFunction(mmi_pre_entry_weekly_view_screen, KEY_EVENT_UP);
  1308.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1309. }
  1310. /*****************************************************************************
  1311.  * FUNCTION
  1312.  *  mmi_clndr_get_first_date_of_week
  1313.  * DESCRIPTION
  1314.  *  
  1315.  * PARAMETERS
  1316.  *  currDate            [?]     [?]
  1317.  *  firstDateOfWeek     [?]     [?]
  1318.  * RETURNS
  1319.  *  void
  1320.  *****************************************************************************/
  1321. void mmi_clndr_get_first_date_of_week(MYTIME *currDate, MYTIME *firstDateOfWeek)
  1322. {
  1323.     /*----------------------------------------------------------------*/
  1324.     /* Local Variables                                                */
  1325.     /*----------------------------------------------------------------*/
  1326.     U8 day;
  1327.     MYTIME incTime;
  1328.     /*----------------------------------------------------------------*/
  1329.     /* Code Body                                                      */
  1330.     /*----------------------------------------------------------------*/
  1331.     memset(&incTime, 0, sizeof(MYTIME));
  1332. #ifdef MMI_ON_WIN32
  1333. day = (U8) DOW(currDate->nYear, currDate->nMonth, currDate->nDay);
  1334. #else
  1335.     day = (U8) applib_dt_dow(currDate->nYear, currDate->nMonth, currDate->nDay);
  1336. #endif
  1337.     incTime.nDay = day;
  1338. #ifdef MMI_ON_WIN32
  1339. DecrementTime(*currDate, incTime, firstDateOfWeek);
  1340. #else
  1341.     applib_dt_decrease_time(
  1342.         (applib_time_struct*) currDate,
  1343.         (applib_time_struct*) & incTime,
  1344.         (applib_time_struct*) firstDateOfWeek);
  1345. #endif
  1346.     firstDateOfWeek->nHour = firstDateOfWeek->nMin = firstDateOfWeek->nSec = 0;
  1347. }
  1348. /*****************************************************************************
  1349.  * FUNCTION
  1350.  *  mmi_clndr_get_weekly_dates
  1351.  * DESCRIPTION
  1352.  *  
  1353.  * PARAMETERS
  1354.  *  currDate        [?]         [?]
  1355.  *  dateStr         [IN]        
  1356.  * RETURNS
  1357.  *  void
  1358.  *****************************************************************************/
  1359. void mmi_clndr_get_weekly_dates(MYTIME *currDate, U8 **dateStr)
  1360. {
  1361.     /*----------------------------------------------------------------*/
  1362.     /* Local Variables                                                */
  1363.     /*----------------------------------------------------------------*/
  1364.     S32 i, lastday, date, diffDay;
  1365.     MYTIME firstDateOfWeek;
  1366.     /*----------------------------------------------------------------*/
  1367.     /* Code Body                                                      */
  1368.     /*----------------------------------------------------------------*/
  1369.     memset(&firstDateOfWeek, 0, sizeof(MYTIME));
  1370.     mmi_clndr_get_first_date_of_week(currDate, &firstDateOfWeek);
  1371.     diffDay = (S32) (currDate->nDay - firstDateOfWeek.nDay);
  1372.     date = firstDateOfWeek.nDay;
  1373.     /* first day of week is date of previous month */
  1374.     if (diffDay < 0)
  1375.     {
  1376. #ifdef MMI_ON_WIN32
  1377. lastday = (S32) LastDayOfMonth(firstDateOfWeek.nMonth, firstDateOfWeek.nYear);
  1378. #else
  1379.         lastday = (S32) applib_dt_last_day_of_mon(firstDateOfWeek.nMonth, firstDateOfWeek.nYear);
  1380. #endif
  1381.     }
  1382.     else
  1383.     {
  1384. #ifdef MMI_ON_WIN32
  1385. lastday = (S32) LastDayOfMonth(currDate->nMonth, currDate->nYear);
  1386. #else
  1387.         lastday = (S32) applib_dt_last_day_of_mon(currDate->nMonth, currDate->nYear);
  1388. #endif
  1389.     }
  1390.     for (i = 0; i < CLNDR_TOTAL_WEEKDAY; i++, date++)
  1391.     {
  1392.         if (date > lastday)
  1393.         {
  1394.             date = 1;
  1395.         }
  1396.         mmi_clndr_util_num_to_unicode(date, dateStr[i], CLNDR_HORIZON_LIST_CELL_LEN);
  1397.     }
  1398. }
  1399. /*****************************************************************************
  1400.  * FUNCTION
  1401.  *  mmi_clndr_get_period_range
  1402.  * DESCRIPTION
  1403.  *  
  1404.  * PARAMETERS
  1405.  *  PeriodIndex     [IN]        
  1406.  *  periodStr       [IN]        
  1407.  * RETURNS
  1408.  *  void
  1409.  *****************************************************************************/
  1410. void mmi_clndr_get_period_range(U8 PeriodIndex, U8 **periodStr)
  1411. {
  1412.     /*----------------------------------------------------------------*/
  1413.     /* Local Variables                                                */
  1414.     /*----------------------------------------------------------------*/
  1415.     S32 i, time, checkPeriod;
  1416.     U8 *ptr;
  1417.     /*----------------------------------------------------------------*/
  1418.     /* Code Body                                                      */
  1419.     /*----------------------------------------------------------------*/
  1420.     /* guaranteethat the period will within the range */
  1421.     checkPeriod = (DLNDR_MAX_DAY_HOURS - CLNDR_ROW * g_clndr_cntx->PeriodInterval) / g_clndr_cntx->PeriodInterval;
  1422.     if (PeriodIndex > checkPeriod)
  1423.     {
  1424.         PeriodIndex = checkPeriod;
  1425.     }
  1426.     time = PeriodIndex * g_clndr_cntx->PeriodInterval;
  1427.     for (i = 0; i < CLNDR_ROW; i++)
  1428.     {
  1429.         ptr = periodStr[i];
  1430.         ASSERT(time < DLNDR_MAX_DAY_HOURS);
  1431.         if (time < 10)
  1432.         {
  1433.             pfnUnicodeStrcpy((S8*) ptr, (PS8) L"0");
  1434.             ptr += ENCODING_LENGTH;
  1435.             mmi_clndr_util_num_to_unicode(time, ptr, 1);
  1436.         }
  1437.         else
  1438.         {
  1439.             mmi_clndr_util_num_to_unicode(time, ptr, 2);
  1440.         }
  1441.         /* ptr += (pfnUnicodeStrlen(ptr) * ENCODING_LENGTH); */
  1442.         pfnUnicodeStrcat((S8*) ptr, (PS8) L":00");
  1443.         time += g_clndr_cntx->PeriodInterval;
  1444.     }
  1445. }
  1446. /*****************************************************************************
  1447.  * FUNCTION
  1448.  *  mmi_clndr_construct_weekly_cell_info
  1449.  * DESCRIPTION
  1450.  *  
  1451.  * PARAMETERS
  1452.  *  void
  1453.  * RETURNS
  1454.  *  void
  1455.  *****************************************************************************/
  1456. void mmi_clndr_construct_weekly_cell_info(void)
  1457. {
  1458.     /*----------------------------------------------------------------*/
  1459.     /* Local Variables                                                */
  1460.     /*----------------------------------------------------------------*/
  1461.     U32 i, dow, maxDay;
  1462.     wgui_cat83_cell_struct *cell;
  1463.     MYTIME firstDay;
  1464.     /*----------------------------------------------------------------*/
  1465.     /* Code Body                                                      */
  1466.     /*----------------------------------------------------------------*/
  1467.     mmi_tdl_get_weekly_tasks(
  1468.         &g_clndr_cntx->CalTime,
  1469.         g_clndr_cntx->TaskDayList,
  1470.         g_clndr_cntx->PeriodInterval,
  1471.         g_clndr_cntx->RowNumber);
  1472.     /* some date of weekly view is out of boundary */
  1473.     memset(&firstDay, 0, sizeof(MYTIME));
  1474.     mmi_clndr_get_first_date_of_week(&g_clndr_cntx->CalTime, &firstDay);
  1475.     maxDay = 31 - CLNDR_TOTAL_WEEKDAY;
  1476.     if (firstDay.nYear < CLNDR_START_YEAR)
  1477.     {
  1478. #ifdef MMI_ON_WIN32
  1479. dow = DOW(CLNDR_START_YEAR, 1, 1);
  1480. #else
  1481.         dow = applib_dt_dow(CLNDR_START_YEAR, 1, 1);
  1482. #endif
  1483.         mmi_clndr_weekly_set_cell_validation(dow, CLNDR_LARGER_THAN_MIN_YEAR);
  1484.     }
  1485.     /* if the first day of week is larger than 2030/12/26 */
  1486.     else if (firstDay.nYear == CLNDR_END_YEAR && firstDay.nMonth == NUM_MONTHS && firstDay.nDay >= maxDay)
  1487.     {
  1488. #ifdef MMI_ON_WIN32
  1489. dow = DOW(CLNDR_END_YEAR, 12, 31);
  1490. #else
  1491.         dow = applib_dt_dow(CLNDR_END_YEAR, 12, 31);
  1492. #endif
  1493.         mmi_clndr_weekly_set_cell_validation(dow, CLNDR_LARGER_THAN_MAX_YEAR);
  1494.     }
  1495.     else
  1496.     {
  1497.         cell = g_clndr_cntx->CalendarCell;
  1498.         for (i = 0; i < g_clndr_cntx->RowNumber * CLNDR_COLUMN; i++)
  1499.         {
  1500.             cell->valid = MMI_TRUE;
  1501.             cell++;
  1502.         }
  1503.     }
  1504.     /* set the task icon and color of calendar cell */
  1505.     g_clndr_cntx->CalendarCell->bg_index = CAT83_COLOR_NONE;
  1506.     /* for (i = 1; i <= CLNDR_COLUMN * g_clndr_cntx->RowNumber; i++) */
  1507.     for (i = 0; i < CLNDR_COLUMN * g_clndr_cntx->RowNumber; i++)
  1508.     {
  1509.         cell = g_clndr_cntx->CalendarCell + i;
  1510.         if (g_clndr_cntx->TaskDayList[i].date > 0)
  1511.         {
  1512.             if (g_clndr_cntx->TaskDayList[i].date == 1)
  1513.             {
  1514.                 cell->bg_index = CAT83_COLOR_ONE_TASK;
  1515.             }
  1516.             else
  1517.             {
  1518.                 cell->bg_index = CAT83_COLOR_MORE_TASK;
  1519.             }
  1520.             cell->icon_id = g_clndr_cntx->TaskDayList[i].icon;
  1521.         }
  1522.         else
  1523.         {
  1524.             cell->bg_index = CAT83_COLOR_NONE;
  1525.         }
  1526.     }
  1527. }
  1528. /*****************************************************************************
  1529.  * FUNCTION
  1530.  *  mmi_clndr_weekly_set_cell_validation
  1531.  * DESCRIPTION
  1532.  *  
  1533.  * PARAMETERS
  1534.  *  dow         [IN]        
  1535.  *  type        [IN]        
  1536.  * RETURNS
  1537.  *  void
  1538.  *****************************************************************************/
  1539. void mmi_clndr_weekly_set_cell_validation(U32 dow, U32 type)
  1540. {
  1541.     /*----------------------------------------------------------------*/
  1542.     /* Local Variables                                                */
  1543.     /*----------------------------------------------------------------*/
  1544.     U32 i, j;
  1545.     wgui_cat83_cell_struct* cell = g_clndr_cntx->CalendarCell;
  1546.     /*----------------------------------------------------------------*/
  1547.     /* Code Body                                                      */
  1548.     /*----------------------------------------------------------------*/
  1549.             for (i = 0; i < g_clndr_cntx->RowNumber; i++)
  1550.             {
  1551.                 for (j = 0; j< CLNDR_COLUMN; j++)
  1552.                 {                    
  1553.                     if ((type == CLNDR_LARGER_THAN_MAX_YEAR && j > dow) ||
  1554.                         (type == CLNDR_LARGER_THAN_MIN_YEAR && j < dow)) /* the date is larger than boundary */
  1555.                     {
  1556.                         cell->valid = MMI_FALSE;
  1557.                     }
  1558.                     else
  1559.                     {
  1560.                         cell->valid = MMI_TRUE;
  1561.                     }
  1562.                     cell++;
  1563.                 }
  1564.             }
  1565. }
  1566. /*****************************************************************************
  1567.  * FUNCTION
  1568.  *  mmi_clndr_weekly_highlight
  1569.  * DESCRIPTION
  1570.  *  
  1571.  * PARAMETERS
  1572.  *  row         [IN]        
  1573.  *  column      [IN]        
  1574.  * RETURNS
  1575.  *  
  1576.  *****************************************************************************/
  1577. MMI_BOOL mmi_clndr_weekly_highlight(U32 row, U32 column)
  1578. {
  1579.     /*----------------------------------------------------------------*/
  1580.     /* Local Variables                                                */
  1581.     /*----------------------------------------------------------------*/
  1582.     MYTIME firstDayofWeek, incTime;
  1583.     /*----------------------------------------------------------------*/
  1584.     /* Code Body                                                      */
  1585.     /*----------------------------------------------------------------*/
  1586.     memset(&firstDayofWeek, 0, sizeof(MYTIME));
  1587.     memset(&incTime, 0, sizeof(MYTIME));
  1588.     mmi_clndr_get_first_date_of_week(&(g_clndr_cntx->CalTime), &firstDayofWeek);
  1589.     incTime.nDay = column;
  1590.     IncrementTime(firstDayofWeek, incTime, &g_clndr_cntx->CalTime);
  1591.     g_clndr_cntx->CalTime.DayIndex = DOW(g_clndr_cntx->CalTime.nYear, g_clndr_cntx->CalTime.nMonth, g_clndr_cntx->CalTime.nDay);
  1592.     g_clndr_cntx->CurrPeriodIndex = g_clndr_cntx->PeriodStartIndex + row;
  1593.     g_clndr_cntx->CalTime.nHour = g_clndr_cntx->CurrPeriodIndex * g_clndr_cntx->PeriodInterval;
  1594.     mmi_clndr_get_date_str(&(g_clndr_cntx->CalTime), g_clndr_cntx->Title);
  1595.     wgui_cat83_set_normal_title(g_clndr_cntx->Title);
  1596.     if ((g_clndr_cntx->CalTime.nMonth == 1 && g_clndr_cntx->CalTime.nDay == 1) || 
  1597.         (g_clndr_cntx->CalTime.nMonth == 12 && g_clndr_cntx->CalTime.nDay == 31))
  1598.     {
  1599. #ifdef MMI_ON_WIN32
  1600. g_clndr_cntx->WeekNum = mmi_dt_get_week_number(& (g_clndr_cntx->CalTime));
  1601. #else
  1602.         g_clndr_cntx->WeekNum = applib_dt_get_week_number((applib_time_struct*) & g_clndr_cntx->CalTime);
  1603. #endif
  1604.         mmi_clndr_weekly_set_content();
  1605.     }
  1606.     mmi_weekly_clndr_set_info_box();
  1607.     return MMI_FALSE;
  1608. }
  1609. /*****************************************************************************
  1610.  * FUNCTION
  1611.  *  mmi_clndr_weekly_compute_next_time
  1612.  * DESCRIPTION
  1613.  *  
  1614.  * PARAMETERS
  1615.  *  arrow       [IN]        
  1616.  * RETURNS
  1617.  *  
  1618.  *****************************************************************************/
  1619. MMI_BOOL mmi_clndr_weekly_compute_next_time(U32 arrow)
  1620. {
  1621.     /*----------------------------------------------------------------*/
  1622.     /* Local Variables                                                */
  1623.     /*----------------------------------------------------------------*/
  1624.     MYTIME resultDate, incTime;
  1625.     U32 highlightY=0;
  1626.     /*----------------------------------------------------------------*/
  1627.     /* Code Body                                                      */
  1628.     /*----------------------------------------------------------------*/
  1629.     memset(&resultDate, 0, sizeof(MYTIME));
  1630.     memset(&incTime, 0, sizeof(MYTIME));
  1631.     switch (arrow)
  1632.     {
  1633.         case CLNDR_KEY_UP:
  1634.             if (g_clndr_cntx->CurrPeriodIndex > 0)
  1635.             {
  1636.                 g_clndr_cntx->CurrPeriodIndex--;
  1637.                 g_clndr_cntx->PeriodStartIndex--;
  1638.                 memcpy(&resultDate, &(g_clndr_cntx->CalTime), sizeof(MYTIME));
  1639.             }
  1640.             else
  1641.             {
  1642.                 return MMI_FALSE;
  1643.             }
  1644.             break;
  1645.         case CLNDR_KEY_DOWN:
  1646.             if (g_clndr_cntx->CurrPeriodIndex < g_clndr_cntx->RowNumber - 1)
  1647.             {
  1648.                 g_clndr_cntx->CurrPeriodIndex++;
  1649.                 g_clndr_cntx->PeriodStartIndex++;
  1650.                 memcpy(&resultDate, &(g_clndr_cntx->CalTime), sizeof(MYTIME));
  1651.             }
  1652.             else
  1653.             {
  1654.                 return MMI_FALSE;
  1655.             }
  1656.             break;
  1657.         case CLNDR_KEY_LEFT:
  1658.             incTime.nDay = 1;
  1659. #ifdef MMI_ON_WIN32
  1660. DecrementTime(g_clndr_cntx->CalTime, incTime, & resultDate);
  1661. #else
  1662.             applib_dt_decrease_time(
  1663.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  1664.                 (applib_time_struct*) & incTime,
  1665.                 (applib_time_struct*) & resultDate);
  1666. #endif
  1667.             /* highlight date become the last day of previous week */
  1668.             highlightY = g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex;
  1669.             break;
  1670.         case CLNDR_KEY_RIGHT:
  1671.             incTime.nDay = 1;
  1672. #ifdef MMI_ON_WIN32
  1673. DecrementTime(g_clndr_cntx->CalTime, incTime, & resultDate);
  1674. #else
  1675.             applib_dt_increase_time(
  1676.                 (applib_time_struct*) & (g_clndr_cntx->CalTime),
  1677.                 (applib_time_struct*) & incTime,
  1678.                 (applib_time_struct*) & resultDate);
  1679. #endif
  1680.             /* highlight date become the first day of next week */
  1681.             highlightY = g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex;
  1682.             break;
  1683.         default:
  1684.             break;
  1685.     }
  1686.     return mmi_clndr_weekly_out_of_boundary(&resultDate, highlightY);
  1687. }
  1688. /* MMI_BOOL mmi_clndr_weekly_out_of_boundary(U32 arrow, U32 row, U32 column) */
  1689. /*****************************************************************************
  1690.  * FUNCTION
  1691.  *  mmi_clndr_weekly_out_of_boundary
  1692.  * DESCRIPTION
  1693.  *  
  1694.  * PARAMETERS
  1695.  *  resultDate          [?]         
  1696.  *  highlightRow        [IN]        
  1697.  *  highlightCol        [IN]        
  1698.  * RETURNS
  1699.  *  
  1700.  *****************************************************************************/
  1701. MMI_BOOL mmi_clndr_weekly_out_of_boundary(MYTIME *resultDate, U32 highlightRow)
  1702. {
  1703.     /*----------------------------------------------------------------*/
  1704.     /* Local Variables                                                */
  1705.     /*----------------------------------------------------------------*/
  1706.     /*----------------------------------------------------------------*/
  1707.     /* Code Body                                                      */
  1708.     /*----------------------------------------------------------------*/
  1709.     /* U32 highlightY; */
  1710.     if (resultDate->nYear > CLNDR_END_YEAR || resultDate->nYear < CLNDR_START_YEAR)
  1711.     {
  1712.          DisplayPopup(
  1713.         (U8*) GetString(STR_CLNDR_OUT_OF_CALENDAR),
  1714.         IMG_GLOBAL_WARNING,
  1715.         0,
  1716.         UI_POPUP_NOTIFYDURATION_TIME,
  1717.         (U8) WARNING_TONE);
  1718.          
  1719.         return MMI_FALSE;
  1720.     }
  1721.     /* If the date changed, update the highlight period */
  1722.     /* if (arrow == CLNDR_KEY_LEFT || arrow == CLNDR_KEY_RIGHT) */
  1723.     if (g_clndr_cntx->CalTime.nYear != resultDate->nYear ||
  1724.         g_clndr_cntx->CalTime.nMonth != resultDate->nMonth || g_clndr_cntx->CalTime.nDay != resultDate->nDay)
  1725.     {
  1726.         /* highlightY = g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex; */
  1727.         memcpy(&g_clndr_cntx->CalTime, resultDate, sizeof(MYTIME));
  1728.         wgui_cat83_set_current(0xFFFFFFFF, 0xFFFFFFFF);
  1729.         wgui_cat83_set_highlight(highlightRow, g_clndr_cntx->CalTime.DayIndex);
  1730.         memset(g_clndr_cntx->TaskDayList, 0, CLNDR_COLUMN * CLNDR_ROW * sizeof(clndr_task_icon_struct));
  1731.         memset(g_clndr_cntx->CalendarCell, 0, g_clndr_cntx->RowNumber * CLNDR_COLUMN * CLNDR_CELL_SIZE);
  1732.         //mmi_clndr_get_weekly_dates(&g_clndr_cntx->CalTime, g_clndr_cntx->HorizonList);
  1733.         //mmi_clndr_get_date_str(&(g_clndr_cntx->CalTime), g_clndr_cntx->Title);        
  1734.         /* todo : compute the start period index */
  1735.         /* mmi_clndr_construct_weekly_cell_info(); */
  1736.         ClndrGetScreenInfo();
  1737.     }
  1738.     else
  1739.     {
  1740.         mmi_clndr_get_period_range(g_clndr_cntx->PeriodStartIndex, g_clndr_cntx->VerticalList);
  1741.         wgui_cat83_set_select_vertical(
  1742.             IMG_TOP_UP,
  1743.             IMG_TOP_DOWN,
  1744.             IMG_BOTTOM_UP,
  1745.             IMG_BOTTOM_DOWN,
  1746.             g_clndr_cntx->VerticalList,
  1747.             CAT83_SELECT_ALIGN_LINE);
  1748.     }
  1749.     mmi_clndr_weekly_set_content();
  1750.     return MMI_TRUE;
  1751. }
  1752. /* void mmi_clndr_weekly_movement(CLNDR_CLNDAR_MOVEMENT_ENUM type) */
  1753. /*****************************************************************************
  1754.  * FUNCTION
  1755.  *  mmi_clndr_weekly_movement
  1756.  * DESCRIPTION
  1757.  *  
  1758.  * PARAMETERS
  1759.  *  type        [IN]        
  1760.  * RETURNS
  1761.  *  
  1762.  *****************************************************************************/
  1763. MMI_BOOL mmi_clndr_weekly_movement(U32 type)
  1764. {
  1765.     /*----------------------------------------------------------------*/
  1766.     /* Local Variables                                                */
  1767.     /*----------------------------------------------------------------*/
  1768.     MYTIME incTime, firstDay;
  1769.     U32 highlightY;
  1770.     /*----------------------------------------------------------------*/
  1771.     /* Code Body                                                      */
  1772.     /*----------------------------------------------------------------*/
  1773.     memset(&incTime, 0, sizeof(MYTIME));
  1774.     memset(&firstDay, 0, sizeof(MYTIME));
  1775.     switch (type)
  1776.     {
  1777.         case CLNDR_PRIVOUS_WEEK:
  1778.             incTime.nDay = 7;
  1779. #ifdef MMI_ON_WIN32
  1780. DecrementTime(g_clndr_cntx->CalTime, incTime, & firstDay);
  1781. #else
  1782.             applib_dt_decrease_time(
  1783.                 (applib_time_struct*) & g_clndr_cntx->CalTime,
  1784.                 (applib_time_struct*) & incTime,
  1785.                 (applib_time_struct*) & firstDay);
  1786. #endif
  1787.             break;
  1788.         case CLNDR_NEXT_WEEK:
  1789.             incTime.nDay = 7;
  1790. #ifdef MMI_ON_WIN32
  1791. DecrementTime(g_clndr_cntx->CalTime, incTime, & firstDay);
  1792. #else
  1793.             applib_dt_increase_time(
  1794.                 (applib_time_struct*) & g_clndr_cntx->CalTime,
  1795.                 (applib_time_struct*) & incTime,
  1796.                 (applib_time_struct*) & firstDay);
  1797. #endif
  1798.             break;
  1799.     #ifdef __MMI_TOUCH_SCREEN__
  1800.         case CLNDR_NEXT_PERIOD:
  1801.             /* the boundary of period */
  1802.             if (g_clndr_cntx->PeriodStartIndex == g_clndr_cntx->RowNumber - CLNDR_ROW)
  1803.             {
  1804.                 return MMI_FALSE;
  1805.             }
  1806.             g_clndr_cntx->CalTime.nHour += g_clndr_cntx->PeriodInterval;
  1807.             g_clndr_cntx->PeriodStartIndex++;
  1808.             /* return; */
  1809.         case CLNDR_PRIVOUS_PERIOD:
  1810.             /* the boundary of period */
  1811.             if (g_clndr_cntx->PeriodStartIndex == 0)
  1812.             {
  1813.                 return MMI_FALSE;
  1814.             }
  1815.             g_clndr_cntx->CalTime.nHour -= g_clndr_cntx->PeriodInterval;
  1816.             g_clndr_cntx->PeriodStartIndex++;
  1817.             /* return; */
  1818.         case CLNDR_NEXT_MULTI_PERIOD:
  1819.             break;
  1820.         case CLNDR_PRIVOUS_MULTI_PERIOD:
  1821.             break;
  1822.     #endif /* __MMI_TOUCH_SCREEN__ */ 
  1823.         default:
  1824.             ASSERT(0);
  1825.     }
  1826.     highlightY = g_clndr_cntx->CurrPeriodIndex - g_clndr_cntx->PeriodStartIndex;
  1827.     return mmi_clndr_weekly_out_of_boundary(&firstDay, highlightY);
  1828. }
  1829. /*****************************************************************************
  1830.  * FUNCTION
  1831.  *  mmi_clndr_get_period_interval
  1832.  * DESCRIPTION
  1833.  *  
  1834.  * PARAMETERS
  1835.  *  void
  1836.  * RETURNS
  1837.  *  
  1838.  *****************************************************************************/
  1839. U8 mmi_clndr_get_period_interval(void)
  1840. {
  1841.     /*----------------------------------------------------------------*/
  1842.     /* Local Variables                                                */
  1843.     /*----------------------------------------------------------------*/
  1844.     U8 interval;
  1845.     S16 error;
  1846.     /*----------------------------------------------------------------*/
  1847.     /* Code Body                                                      */
  1848.     /*----------------------------------------------------------------*/
  1849.     ReadValue(NVRAM_CLNDR_PERIOD_INTERVAL, &interval, DS_BYTE, &error);
  1850.     return interval;
  1851. }
  1852. /*****************************************************************************
  1853.  * FUNCTION
  1854.  *  mmi_clndr_weekly_set_content
  1855.  * DESCRIPTION
  1856.  *  
  1857.  * PARAMETERS
  1858.  *  void
  1859.  * RETURNS
  1860.  *  void
  1861.  *****************************************************************************/
  1862. void mmi_clndr_weekly_set_content(void)
  1863. {
  1864.     /*----------------------------------------------------------------*/
  1865.     /* Local Variables                                                */
  1866.     /*----------------------------------------------------------------*/
  1867.     U32 j;
  1868.     U8* str;
  1869.     wgui_cat83_cell_struct *cell;
  1870.     /*----------------------------------------------------------------*/
  1871.     /* Code Body                                                      */
  1872.     /*----------------------------------------------------------------*/
  1873.     memset(g_clndr_cntx->horizon_select1, 0, CLNDR_VERTICAL_SELECT_LEN);
  1874.     memset(g_clndr_cntx->horizon_select2, 0, CLNDR_VERTICAL_SELECT_LEN);
  1875.     str = g_clndr_cntx->horizon_select1;
  1876.     pfnUnicodeStrcpy((S8*)str, (S8*)L"W");
  1877.     str += ENCODING_LENGTH;
  1878.     mmi_clndr_util_num_to_unicode(g_clndr_cntx->WeekNum, str, CLNDR_VERTICAL_SELECT_LEN);
  1879.     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);
  1880.     
  1881.     j = g_clndr_cntx->PeriodInterval * CLNDR_ROW;
  1882.     if (j < CLNDR_MAX_ROW)
  1883.     {
  1884.         mmi_clndr_util_num_to_unicode(j, g_clndr_cntx->horizon_select2, CLNDR_VERTICAL_SELECT_LEN);
  1885.         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);
  1886.         pfnUnicodeStrcat((S8*)g_clndr_cntx->horizon_select2,(S8*) L" H");
  1887.     }
  1888.     wgui_cat83_set_normal_title(g_clndr_cntx->Title);
  1889.     wgui_cat83_set_horizontal_string(g_clndr_cntx->HorizonList);
  1890.     /* mmi_clndr_get_period_range(g_clndr_cntx->PeriodStartIndex, g_clndr_cntx->VerticalList); */
  1891.     wgui_cat83_set_select_vertical(
  1892.         IMG_TOP_UP,
  1893.         IMG_TOP_DOWN,
  1894.         IMG_BOTTOM_UP,
  1895.         IMG_BOTTOM_DOWN,
  1896.         g_clndr_cntx->VerticalList,
  1897.         CAT83_SELECT_ALIGN_LINE);
  1898.     cell = g_clndr_cntx->CalendarCell + g_clndr_cntx->PeriodStartIndex * CLNDR_COLUMN;
  1899.     wgui_cat83_set_cell_array(
  1900.         /* g_clndr_cntx->CalendarCell, */ cell,
  1901.         CAT83_CELL_BG_FILL_VERTICAL,
  1902.         CAT83_CELL_TEXT_DISPLAY_LEFT_BOTTOM,
  1903.         CAT83_CELL_ICON_DISPLAY_CENTER);
  1904. }
  1905. /*****************************************************************************
  1906.  * FUNCTION
  1907.  *  mmi_clndr_touch_weekly_increase
  1908.  * DESCRIPTION
  1909.  *  
  1910.  * PARAMETERS
  1911.  *  row         [IN]        
  1912.  *  column      [IN]        
  1913.  * RETURNS
  1914.  *  
  1915.  *****************************************************************************/
  1916. MMI_BOOL mmi_clndr_weekly_increase(U32 row, U32 column)
  1917. {
  1918.     /*----------------------------------------------------------------*/
  1919.     /* Local Variables                                                */
  1920.     /*----------------------------------------------------------------*/
  1921.     /*----------------------------------------------------------------*/
  1922.     /* Code Body                                                      */
  1923.     /*----------------------------------------------------------------*/
  1924.     return mmi_clndr_weekly_movement(CLNDR_NEXT_WEEK);
  1925. }
  1926. /*****************************************************************************
  1927.  * FUNCTION
  1928.  *  mmi_clndr_touch_weekly_decrease
  1929.  * DESCRIPTION
  1930.  *  
  1931.  * PARAMETERS
  1932.  *  row         [IN]        
  1933.  *  column      [IN]        
  1934.  * RETURNS
  1935.  *  
  1936.  *****************************************************************************/
  1937. MMI_BOOL mmi_clndr_weekly_decrease(U32 row, U32 column)
  1938. {
  1939.     /*----------------------------------------------------------------*/
  1940.     /* Local Variables                                                */
  1941.     /*----------------------------------------------------------------*/
  1942.     /*----------------------------------------------------------------*/
  1943.     /* Code Body                                                      */
  1944.     /*----------------------------------------------------------------*/
  1945.     return mmi_clndr_weekly_movement(CLNDR_PRIVOUS_WEEK);
  1946. }
  1947. #ifdef __MMI_TOUCH_SCREEN__   
  1948. /*****************************************************************************
  1949.  * FUNCTION
  1950.  *  mmi_clndr_touch_multi_periodly_increase
  1951.  * DESCRIPTION
  1952.  *  
  1953.  * PARAMETERS
  1954.  *  row         [IN]        
  1955.  *  column      [IN]        
  1956.  * RETURNS
  1957.  *  
  1958.  *****************************************************************************/
  1959. MMI_BOOL mmi_clndr_touch_multi_periodly_increase(U32 row, U32 column)
  1960. {
  1961.     /*----------------------------------------------------------------*/
  1962.     /* Local Variables                                                */
  1963.     /*----------------------------------------------------------------*/
  1964.     /*----------------------------------------------------------------*/
  1965.     /* Code Body                                                      */
  1966.     /*----------------------------------------------------------------*/
  1967.     return mmi_clndr_periodly_movement((U32) CLNDR_NEXT_MULTI_PERIOD);
  1968. }
  1969. /*****************************************************************************
  1970.  * FUNCTION
  1971.  *  mmi_clndr_touch_multi_periodly_decrease
  1972.  * DESCRIPTION
  1973.  *  
  1974.  * PARAMETERS
  1975.  *  row         [IN]        
  1976.  *  column      [IN]        
  1977.  * RETURNS
  1978.  *  
  1979.  *****************************************************************************/
  1980. MMI_BOOL mmi_clndr_touch_multi_periodly_decrease(U32 row, U32 column)
  1981. {
  1982.     /*----------------------------------------------------------------*/
  1983.     /* Local Variables                                                */
  1984.     /*----------------------------------------------------------------*/
  1985.     /*----------------------------------------------------------------*/
  1986.     /* Code Body                                                      */
  1987.     /*----------------------------------------------------------------*/
  1988.     return mmi_clndr_periodly_movement((U32) CLNDR_PRIVOUS_MULTI_PERIOD);
  1989. }
  1990. /*****************************************************************************
  1991.  * FUNCTION
  1992.  *  mmi_clndr_touch_single_periodly_increase
  1993.  * DESCRIPTION
  1994.  *  
  1995.  * PARAMETERS
  1996.  *  row         [IN]        
  1997.  *  column      [IN]        
  1998.  * RETURNS
  1999.  *  
  2000.  *****************************************************************************/
  2001. MMI_BOOL mmi_clndr_touch_single_periodly_increase(U32 row, U32 column)
  2002. {
  2003.     /*----------------------------------------------------------------*/
  2004.     /* Local Variables                                                */
  2005.     /*----------------------------------------------------------------*/
  2006.     /*----------------------------------------------------------------*/
  2007.     /* Code Body                                                      */
  2008.     /*----------------------------------------------------------------*/
  2009.     return mmi_clndr_periodly_movement((U32) CLNDR_NEXT_PERIOD);
  2010. }
  2011. /*****************************************************************************
  2012.  * FUNCTION
  2013.  *  mmi_clndr_touch_single_periodly_decrease
  2014.  * DESCRIPTION
  2015.  *  
  2016.  * PARAMETERS
  2017.  *  row         [IN]        
  2018.  *  column      [IN]        
  2019.  * RETURNS
  2020.  *  
  2021.  *****************************************************************************/
  2022. MMI_BOOL mmi_clndr_touch_single_periodly_decrease(U32 row, U32 column)
  2023. {
  2024.     /*----------------------------------------------------------------*/
  2025.     /* Local Variables                                                */