/**
 *******************************************************************************
 * @file  menu_list.h
 * @brief This file contains all the functions prototypes of the menu list.
 @verbatim
   Change Logs:
   Date             Author          Notes
   2022-06-30       CDT             First version
 @endverbatim
 *******************************************************************************
 * Copyright (C) 2022-2023, Xiaohua Semiconductor Co., Ltd. All rights reserved.
 *
 * This software component is licensed by XHSC under BSD 3-Clause license
 * (the "License"); You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at:
 *                    opensource.org/licenses/BSD-3-Clause
 *
 *******************************************************************************
 */

#ifndef __MENU_lIST_H__
#define __MENU_lIST_H__

/* C binding of definitions if building with C++ compiler */
#ifdef __cplusplus
extern "C"
{
#endif

/*******************************************************************************
 * Include files
 ******************************************************************************/
#include "console_common.h"
#include "console_slist.h"
#include "menu_item.h"

/**
 * @addtogroup Menu_Test_Console
 * @{
 */

/**
 * @addtogroup Menu_List
 * @{
 */

/*******************************************************************************
 * Global type definitions ('typedef')
 ******************************************************************************/
/**
 * @defgroup Menu_List_Global_Types Menu List Global Types
 * @{
 */

/**
 * @brief Menu list information structure definition
 */
typedef struct {
    const char  *pcName;
    const char  *pcListTop;
    const char  *pcListBottom;
    const char  *pcItemLeft;
    const char  *pcItemRight;

    const char  *pcDisplayFormatName;
    const char  *pcDisplayFormatListTop;
    const char  *pcDisplayFormatListBottom;
    const char  *pcDisplayFormatItemLeft;
    const char  *pcDisplayFormatItemRight;
    const char  *pcDisplayFormatItem;
} stc_menu_list_attr_t;

/**
 * @brief Menu list structure definition
 */
typedef struct stc_menu_list {
    stc_slist_t                  stcListNode;
    const stc_menu_list_attr_t  *pstcListAttr;
    stc_menu_item_t             *pstcItemTable;
} stc_menu_list_t;

/**
 * @}
 */

/*******************************************************************************
 * Global pre-processor symbols/macros ('#define')
 ******************************************************************************/

/*******************************************************************************
 * Global variable definitions ('extern')
 ******************************************************************************/

/*******************************************************************************
  Global function prototypes (definition in C source)
 ******************************************************************************/

/**
 * @addtogroup Menu_List_Global_Functions
 * @{
 */

stc_menu_list_t *Menu_List_Create(const stc_menu_list_attr_t *pstcListAttr, stc_menu_item_t astcItemTable[]);
void Menu_List_Destroy(stc_menu_list_t *pstcList);
stc_menu_item_t *Menu_List_FindItemByName(stc_menu_list_t *pstcList, const char *pcItemName);
stc_menu_item_t *Menu_List_FindItemById(stc_menu_list_t *pstcList, uint16_t u16ItemId);
int32_t Menu_List_ExecItemByName(stc_menu_list_t *pstcList, const char *pcItemName);
int32_t Menu_List_ExecItemById(stc_menu_list_t *pstcList, uint16_t u16ItemId);
void Menu_List_ShowAttr(stc_menu_list_t *pstcList, int32_t (*pfnShow)(stc_menu_item_t *));

/**
 * @}
 */

/**
 * @}
 */

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* __MENU_LIST_H__ */

/*******************************************************************************
 * EOF (not truncated)
 ******************************************************************************/
