1 /*
2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "higv_cextfile.h"
16 #include "sample_utils.h"
17 #include "hi_gv_parser.h"
18 #include "securec.h"
19
20 #ifdef __cplusplus
21 #if __cplusplus
22 extern "C" {
23 #endif
24 #endif /* __cplusplus */
25
26 #define HIGV_CONTROL_PAGENUM 10
27 #define TIMER_SPEED (3000)
28
29 static HI_U32 g_timerId = 3;
30
31 static HI_U32 g_itemSeq = 1;
32
LISTBOX_WIN_Onhide(HIGV_HANDLE widget,HI_PARAM wParam,HI_PARAM lParam)33 HI_S32 LISTBOX_WIN_Onhide(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)
34 {
35 HIGV_UNUSED(wParam);
36 HIGV_UNUSED(lParam);
37
38 HI_U32 ret = (HI_U32)HI_GV_Timer_Stop(widget, g_timerId);
39 ret |= (HI_U32)HI_GV_Timer_Destroy(widget, g_timerId);
40
41 HIGV_CHECK("HI_GV_Timer_Destory", ret);
42
43 g_itemSeq = 0;
44
45 return HIGV_PROC_GOON;
46 }
47
LISTBOX_WIN_Onrefresh(HIGV_HANDLE widget,HI_PARAM wParam,HI_PARAM lParam)48 HI_S32 LISTBOX_WIN_Onrefresh(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)
49 {
50 HIGV_UNUSED(wParam);
51 HIGV_UNUSED(lParam);
52
53 HI_S32 ret = HI_GV_Timer_Create(widget, g_timerId, TIMER_SPEED);
54 HIGV_CHECK("HI_GV_Timer_Create", ret);
55
56 ret = HI_GV_Timer_Start(widget, g_timerId);
57 HIGV_CHECK("HI_GV_Timer_Start", ret);
58
59 return HIGV_PROC_GOON;
60 }
61
LISTBOX_WIN_Onshow(HIGV_HANDLE widget,HI_PARAM wParam,HI_PARAM lParam)62 HI_S32 LISTBOX_WIN_Onshow(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)
63 {
64 HI_S32 ret;
65 HI_U32 index;
66 HIGV_HANDLE db = 0;
67 HIGV_DBROW_S dbRow;
68 HIGV_UNUSED(widget);
69 HIGV_UNUSED(wParam);
70 HIGV_UNUSED(lParam);
71
72 HI_U32 strSet[HIGV_CONTROL_PAGENUM] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
73
74 /* Get DDB (default data base) handle */
75 ret = HI_GV_ADM_GetDDBHandle(ADM_SET_STRINGID, &db);
76 if (ret != HI_SUCCESS) {
77 printf("Failed to add data, function:<%s>, retval %#x.\n", __FUNCTION__, ret);
78 return HI_FAILURE;
79 }
80
81 /* Disable DDB change */
82 HI_GV_DDB_EnableDataChange(db, HI_FALSE);
83
84 /* Clear DDB */
85 HI_GV_DDB_Clear(db);
86
87 /* Add data */
88 for (index = 0; index < HIGV_CONTROL_PAGENUM; index++) {
89 ret = memset_s(&dbRow, sizeof(dbRow), 0x00, sizeof(dbRow));
90 if (ret != EOK) {
91 return ret;
92 }
93 dbRow.pData = &strSet[index];
94 dbRow.Size = sizeof(HI_U32);
95 HI_GV_DDB_Append(db, &dbRow);
96 }
97 /* Enable DDB change */
98 HI_GV_DDB_EnableDataChange(db, HI_TRUE);
99
100 /* Sync the ADM */
101 HI_GV_ADM_Sync(ADM_SET_STRINGID);
102
103 return HIGV_PROC_GOON;
104 }
105
LISTBOX_WIN_Ontimer(HIGV_HANDLE widget,HI_PARAM wParam,HI_PARAM lParam)106 HI_S32 LISTBOX_WIN_Ontimer(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)
107 {
108 HIGV_UNUSED(widget);
109 HIGV_UNUSED(wParam);
110 HIGV_UNUSED(lParam);
111
112 if (g_itemSeq < 3) { /* 3 is g_itemSeq MAX */
113 HI_S32 ret = HI_GV_List_SetSelItem(LISTBOX_WIN_LISTBOX1, g_itemSeq);
114 HIGV_CHECK("HI_GV_List_SetSelItem", ret);
115
116 ret = HI_GV_Widget_Paint(LISTBOX_WIN_LISTBOX1, HI_NULL);
117 HIGV_CHECK("HI_GV_Widget_Paint", ret);
118
119 g_itemSeq++;
120
121 ret = HI_GV_Timer_Reset(widget, g_timerId);
122 HIGV_CHECK("HI_GV_Timer_Reset", ret);
123 } else {
124 HI_U32 ret = (HI_U32)HI_GV_PARSER_LoadViewById(SCROLLVIEW_WIN);
125 ret |= (HI_U32)HI_GV_Widget_Show(SCROLLVIEW_WIN);
126 ret |= (HI_U32)HI_GV_Widget_Active(SCROLLVIEW_WIN);
127 ret |= (HI_U32)HI_GV_Widget_Hide(LISTBOX_WIN);
128
129 HIGV_CHECK("HI_GV_Widget_Show", ret);
130 }
131
132 return HIGV_PROC_GOON;
133 }
134
135
136 #ifdef __cplusplus
137 #if __cplusplus
138 }
139 #endif
140 #endif /* __cplusplus */
141
142