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 16 #ifndef HI_GV_LIST_H 17 #define HI_GV_LIST_H 18 #include "hi_gv_conf.h" 19 #ifdef HIGV_USE_WIDGET_LISTBOX 20 /* add include here */ 21 #include "hi_gv_resm.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Max col number */ 28 #define HIGV_LISTBOX_COL_MAX 20 29 30 typedef enum { 31 LIST_COLTYPE_TXT = 0, 32 /* Text */ 33 LIST_COLTYPE_IMG, 34 /* Picture */ 35 LIST_COLTYPE_TXTICONLEFT, 36 /* Text and icon,icon on left */ 37 LIST_COLTYPE_TXTICONRIGHT, 38 /* Text and icon,icon on right */ 39 LIST_COLTYPE_BUTT 40 } HIGV_LIST_COLTYPE_E; 41 42 typedef HI_S32 (*HIGV_LIST_CONV_CB)(HIGV_HANDLE listHandle, HI_U32 col, HI_U32 item, const HI_CHAR *srcStr, 43 HI_CHAR *dstStr, HI_U32 length); 44 45 /* At cell focus mode, the callback function is used to get the cell width */ 46 47 typedef HI_S32 (*HIGV_GET_WIDTH_CB)(HIGV_HANDLE listHandle, HI_U32 item, HI_U32 col); 48 49 typedef struct { 50 HIGV_LIST_COLTYPE_E Type; /* Column type */ 51 HI_U32 Width; /* Column width */ 52 HI_U32 Align; /* Alignment text */ 53 HI_COLOR Fgidx; /* Font color of column text */ 54 HIGV_HANDLE hImage; /* Picture surface handle (only support type is LIST_COLTYPE_IMG) 55 */ 56 HI_U32 FieldColIdxInDb; /* Column index in db */ 57 HIGV_LIST_CONV_CB ConvString; /* function which convert string (only support type is LIST_COLTYPE_TXT) 58 */ 59 } HIGV_LIST_COLATTR_S; 60 61 typedef struct { 62 HI_U32 RowNum; /* Row number */ 63 HI_U32 ColNum; /* Column number */ 64 HI_BOOL NoFrame; /* Is no frame Draw */ 65 HI_BOOL Cyc; /* Is cycle */ 66 HI_BOOL IsCellActive; /* Is cell active */ 67 HI_BOOL AutoSwitchCell; /* If cell active auto suwich active cell */ 68 HI_BOOL Scroll; /* Is scroll */ 69 HI_BOOL Fromleft; /* Is Scroll from left */ 70 HI_U32 Timeinterval; /* Time interval */ 71 HI_U32 Step; /* Scroll step */ 72 HI_U32 ScrollCol; /* If item active,scroll col of item */ 73 HIGV_GET_WIDTH_CB GetWidthCb; /* Function get cell width from call back */ 74 HIGV_LIST_COLATTR_S *pColAttr; /* List column attributes array */ 75 } HIGV_LIST_ATTRIBUTE_S; 76 77 /* 78 * brief Init the listbox. 79 * param[in] listHandle 80 * param[in] rowNum Row number of display. 81 * param[in] colNum Column number. 82 * param[in] colAttr Column attribute array. 83 * retval ::HI_SUCCESS 84 * retval ::HI_ERR_COMM_LOST 85 * retval ::HI_ERR_COMM_INVAL 86 * retval ::HI_ERR_COMM_NORES 87 */ 88 HI_S32 HI_GV_List_Init(HIGV_HANDLE listHandle, HI_U32 rowNum, HI_U32 colNum, const HIGV_LIST_COLATTR_S *colAttr); 89 90 /* 91 * brief Init the listbox. 92 * param[in] listHandle 93 * param[in] listAttr Init listbox attributes. 94 * retval ::HI_SUCCESS 95 * retval ::HI_ERR_COMM_LOST 96 * retval ::HI_ERR_COMM_INVAL 97 * retval ::HI_ERR_COMM_NORES 98 */ 99 HI_S32 HI_GV_List_InitEx(HIGV_HANDLE listHandle, const HIGV_LIST_ATTRIBUTE_S *listAttr); 100 101 /* 102 * brief Get the content of listbox. 103 * param[in] listHandle Listbox handle. 104 * param[in] item Item index. 105 * param[in] col Column index. 106 * param[out] value Cell's content. 107 * param[in] length Length of pValue. 108 * retval ::HI_SUCCESS 109 * retval ::HI_ERR_COMM_LOST 110 * retval ::HI_ERR_COMM_INVAL 111 */ 112 HI_S32 HI_GV_List_GetCell(HIGV_HANDLE listHandle, HI_U32 item, HI_U32 col, HI_CHAR *value, HI_U32 length); 113 114 /* 115 * brief Set skin of focus item. 116 * param[in] listHandle Listbox handle. 117 * param[in] selSkin The skin of Selected status. 118 * param[in] normSkin The skin of normal status. 119 * retval ::HI_SUCCESS 120 * retval ::HI_ERR_COMM_LOST 121 * retval ::HI_ERR_COMM_INVAL 122 */ 123 HI_S32 HI_GV_List_SetRowSkin(HIGV_HANDLE listHandle, HIGV_HANDLE selSkin, HIGV_HANDLE normSkin); 124 125 /* 126 * brief Set selected item of listbox. 127 * attention ::The api is only support the selected item and apply this api at the init stage. 128 * 129 * param[in] listHandle Listbox handle. 130 * param[in] item Item index. 131 * retval ::HI_SUCCESS 132 * retval ::HI_ERR_COMM_LOST 133 * retval ::HI_ERR_COMM_INVAL 134 * retval ::HI_ERR_COMM_PAERM Focus moe error. 135 * see :: HI_GV_List_GetSelItem 136 */ 137 HI_S32 HI_GV_List_SetSelItem(HIGV_HANDLE listHandle, HI_U32 item); 138 139 /* 140 * brief Get the item of listbox. 141 * param[in] listHandle Listbox handle. 142 * param[out] item Item index. 143 * retval ::HI_SUCCESS 144 * retval ::HI_ERR_COMM_LOST 145 * retval ::HI_ERR_COMM_INVAL 146 * see :: HI_GV_List_SetSelItem 147 */ 148 HI_S32 HI_GV_List_GetSelItem(HIGV_HANDLE listHandle, HI_U32 *item); 149 150 /* 151 * brief Get the total item number of listbox. 152 * param[in] listHandle Listbox handle. 153 * param[out] itemNum Toal item number. 154 * retval ::HI_SUCCESS 155 * retval ::HI_ERR_COMM_LOST 156 * retval ::HI_ERR_COMM_INVAL 157 */ 158 HI_S32 HI_GV_List_GetItemNum(HIGV_HANDLE listHandle, HI_U32 *itemNum); 159 160 /* 161 * brief 162 * param[in] listHandle 163 * retval ::HI_TRUE 164 * retval ::HI_FALSE 165 */ 166 HI_BOOL HI_GV_List_IsListBoxType(HIGV_HANDLE listHandle); 167 168 /* 169 * brief Set the attribute of listbox. 170 * param[in] listHandle Listbox handle. 171 * param[in] horizontalLineHeight The height of horizontal line. 172 * param[in] horizontalLineColor The color of horizontal line. 173 * param[in] verticalLineWidth The width of vertical line. 174 * param[in] verticalLineColor The color of vertical line. 175 * retval ::HI_SUCCESS 176 * retval ::HI_ERR_COMM_LOST 177 * retval ::HI_ERR_COMM_INVAL 178 * see ::HI_GV_List_GetGridding 179 */ 180 HI_S32 HI_GV_List_SetGridding(HIGV_HANDLE listHandle, HI_U32 horizontalLineHeight, 181 HI_COLOR horizontalLineColor, HI_U32 verticalLineWidth, HI_COLOR verticalLineColor); 182 183 /* 184 * brief Get the attribute of listbox. 185 * param[in] listHandle Listbox handle.ؼ 186 * param[out] horizontalLineHeight The height of horizontal line. 187 * param[out] horizontalLineColor The color of horizontal line. 188 * param[out] verticalLineWidth The width of vertical line. 189 * param[out] verticalLineColor The color of vertical line. 190 * retval ::HI_SUCCESS 191 * retval ::HI_ERR_COMM_LOST 192 * retval ::HI_ERR_COMM_INVAL 193 * see ::HI_GV_List_SetGridding 194 */ 195 HI_S32 HI_GV_List_GetGridding(HIGV_HANDLE listHandle, HI_U32 *horizontalLineHeight, 196 HI_COLOR *horizontalLineColor, HI_U32 *verticalLineWidth, HI_COLOR *verticalLineColor); 197 198 /* 199 * brief Change the image of column. 200 * param[in] listHandle Listbox handle. 201 * param[in] col Column index. 202 * param[in] imageHandle Picture handle. 203 * retval N/A. 204 */ 205 HI_S32 HI_GV_List_ChangeImage(HIGV_HANDLE listHandle, HI_U32 col, HIGV_HANDLE imageHandle); 206 207 /* 208 * brief Get the start index of current page. 209 * param[in] listHandle Listbox handle. 210 * param[out] item Item. 211 * retval N/A. 212 * retval ::HI_SUCCESS 213 * retval ::HI_ERR_COMM_LOST 214 * retval ::HI_ERR_COMM_INVAL 215 */ 216 HI_S32 HI_GV_List_GetStartItem(HIGV_HANDLE listHandle, HI_U32 *item); 217 218 /* 219 * brief Set the start index of current page. 220 * param[in] listHandle Listbox handle. 221 * param[in] item Item. 222 * retval N/A. 223 * retval ::HI_SUCCESS 224 * retval ::HI_ERR_COMM_LOST 225 * retval ::HI_ERR_COMM_INVAL 226 */ 227 HI_S32 HI_GV_List_SetStartItem(HIGV_HANDLE listHandle, HI_U32 item); 228 229 /* 230 * brief Get the index of the end item. 231 * param[in] listHandle Listbox handle. 232 * param[out] item Item. 233 * retval N/A. 234 * retval ::HI_SUCCESS 235 * retval ::HI_ERR_COMM_LOST 236 * retval ::HI_ERR_COMM_INVAL 237 */ 238 HI_S32 HI_GV_List_GetEndItem(HIGV_HANDLE listHandle, HI_U32 *item); 239 240 /* 241 * brief Set the foucus of listbox. 242 * attention : The api is only support the selected cell. 243 * 244 * param[in] listHandle Listbox handle. 245 * param[in] item Row index. 246 * param[in] col Column index. 247 * retval ::HI_SUCCESS 248 * retval ::HI_ERR_COMM_LOST 249 * retval ::HI_ERR_COMM_INVAL 250 * retval ::HI_ERR_COMM_PAERM Error at focus mode. 251 * see ::HI_GV_List_GetSelCell 252 */ 253 HI_S32 HI_GV_List_SetSelCell(HIGV_HANDLE listHandle, HI_U32 item, HI_U32 col); 254 255 /* 256 * brief Get the position of cell which selected. 257 * param[in] listHandle Listbox handle. 258 * param[out] item row index. 259 * param[out] col Column index. 260 * retval ::HI_SUCCESS 261 * retval ::HI_ERR_COMM_LOST 262 * retval ::HI_ERR_COMM_INVAL 263 * see ::HI_GV_List_SetSelCell 264 */ 265 HI_S32 HI_GV_List_GetSelCell(HIGV_HANDLE listHandle, HI_U32 *item, HI_U32 *col); 266 267 /* 268 * brief Get the width of cell at focus mode. 269 * attention : if the cell not display, it will return 0. 270 * 271 * param[in] listHandle Listbox handle. 272 * param[in] item item index. 273 * param[in] col Column index. 274 * param[out] pWidth The pointer of width. 275 * retval ::HI_SUCCESS 276 * retval ::HI_ERR_COMM_LOST 277 * retval ::HI_ERR_COMM_INVAL 278 */ 279 HI_S32 HI_GV_List_GetCellWidth(HIGV_HANDLE listHandle, HI_U32 item, HI_U32 col, HI_U32 *width); 280 281 /* 282 * brief Set scroll step of text. 283 * attention : it is only valid at focus mode. 284 * 285 * param[in] listHandle Listbox handle. 286 * param[in] step Scroll step(unit:pixel, default:10piexl). 287 * retval ::HI_SUCCESS 288 * retval ::HI_ERR_COMM_LOST 289 * retval ::HI_ERR_COMM_INVAL 290 * retval ::HI_ERR_COMM_PAERM Error at focus mode. 291 */ 292 HI_S32 HI_GV_List_SetStep(HIGV_HANDLE listHandle, HI_U32 step); 293 294 /* 295 * brief Set the scroll direction of listbox. 296 * attention : it is only valid at focus mode. 297 * 298 * param[in] listHandle Listbox handle. 299 * param[in] fromLeft Scroll direction. 300 * retval ::HI_SUCCESS 301 * retval ::HI_ERR_COMM_LOST 302 * retval ::HI_ERR_COMM_INVAL 303 * retval ::HI_ERR_COMM_PAERM Error at focus mode. 304 */ 305 HI_S32 HI_GV_List_SetDirection(HIGV_HANDLE listHandle, HI_BOOL fromLeft); 306 307 /* 308 * brief Set the status of widget. 309 * attention : it is only valid at focus mode. 310 * 311 * param[in] listHandle Listbox handle. 312 * param[in] scroll Scroll status. 313 * retval ::HI_SUCCESS 314 * retval ::HI_ERR_COMM_LOST 315 * retval ::HI_ERR_COMM_INVAL 316 * retval ::HI_ERR_COMM_PAERM Error at focus mode. 317 */ 318 HI_S32 HI_GV_List_SetScroll(HIGV_HANDLE listHandle, HI_BOOL scroll); 319 320 /* 321 * brief Set the foreground color of column. 322 * attention :it is only support the column type is LIST_COLTYPE_TXT, 323 * if col is -1, it will effect the color of text to all column . 324 * 325 * param[in] listHandle Listbox handle. 326 * param[in] col Column index. 327 * param[in] index Foreground color index. 328 * retval ::HI_SUCCESS 329 * retval ::HI_ERR_COMM_LOST 330 * retval ::HI_ERR_COMM_INVAL 331 * retval ::HI_ERR_COMM_PAERM Unsupported the column to set picture. 332 */ 333 HI_S32 HI_GV_List_SetColFgIdx(HIGV_HANDLE listHandle, HI_U32 col, HI_COLOR index); 334 335 /* 336 * brief Set the exterior line of listbox. 337 * param[in] listHandle Listbox handle. 338 * param[in] noFrame Is not draw. 339 * retval ::HI_SUCCESS 340 * retval ::HI_ERR_COMM_LOST 341 */ 342 HI_S32 HI_GV_List_SetNoFrame(HIGV_HANDLE listHandle, HI_BOOL noFrame); 343 344 /* 345 * brief Set the focus whether cycle. 346 * attention :It is only valid at focus mode. 347 * 348 * param[in] listHandle Listbox handle. 349 * param[in] cycle Focus cycle. 350 * retval ::HI_SUCCESS 351 * retval ::HI_ERR_COMM_LOST 352 */ 353 HI_S32 HI_GV_List_SetCyc(HIGV_HANDLE listHandle, HI_BOOL cycle); 354 355 /* 356 * brief Set scroll param. 357 \attention \n 358 N/A. 359 * param[in] listHandle Listbox handle. 360 * param[in] scrollParam scroll index. 361 * retval ::HI_SUCCESS 362 * retval ::HI_ERR_COMM_LOST 363 * retval ::HI_ERR_COMM_INVAL 364 */ 365 HI_S32 HI_GV_List_SetScrollParam(HIGV_HANDLE listHandle, HI_FLOAT scrollParam); 366 367 /* 368 * brief Set fling param. 369 * param[in] listHandle Listbox handle. 370 * param[in] flingParam fling index. 371 * retval ::HI_SUCCESS 372 * retval ::HI_ERR_COMM_LOST 373 * retval ::HI_ERR_COMM_INVAL 374 */ 375 HI_S32 HI_GV_List_SetFlingParam(HIGV_HANDLE listHandle, HI_S32 flingParam); 376 377 #ifdef __cplusplus 378 } 379 #endif 380 #endif 381 #endif /* HI_GV_LIST_H */ 382