⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 engine.h

📁 VIA VT6524 8口网管交换机源码
💻 H
字号:
/*
 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
 * All rights reserved.
 *
 * This software is copyrighted by and is the sole property of
 * VIA Networking Technologies, Inc. This software may only be used
 * in accordance with the corresponding license agreement. Any unauthorized
 * use, duplication, transmission, distribution, or disclosure of this
 * software is expressly forbidden.
 *
 * This software is provided by VIA Networking Technologies, Inc. "as is"
 * and any express or implied warranties, including, but not limited to, the
 * implied warranties of merchantability and fitness for a particular purpose
 * are disclaimed. In no event shall VIA Networking Technologies, Inc.
 * be liable for any direct, indirect, incidental, special, exemplary, or
 * consequential damages.
 *
 *
 * File:    engine.h
 *
 * Purpose: UI engine main body
 *
 * Author:  Jenda Jao
 *
 * Date:    Jan 08, 2002
 *
 */

#ifndef __ENGINE_H__
#define __ENGINE_H__

#include "ttype.h"


/*---------------------  Export Classes -----------------------------*/
//// define position
typedef struct tagPosition
{
    BYTE        byRow;
    BYTE        byCol;
} SPosition;

// define fix label
typedef struct tagFixLabel
{
    SPosition   SPos;
    char*       strLabel;
    BYTE        byDrawLineLen;
} SFixLabel;


//// define all items
#define NULL_ITEM_ID        0xFF
#define NULL_LINE_ID        0xFF
#define MAX_ITEM_STR_LEN    7       // USERNAME_STR_LEN+1
#define MAX_ITEM_DEC_LEN    4

enum EItemDataType {
    ITEM_DECNUM,
    ITEM_HEXNUM,
    //ITEM_BYTEARRAY,     // for sram, use SItemNum, only hex, byMaxLen = byte array size, not support input yet
    ITEM_STRING,
    ITEM_PASSWORD,
    ITEM_LISTBOX,
    ITEM_VAR_LISTBOX,   // the list number is assigned by a variable and a byte array is specified for mapping value to string index
    ITEM_MENU_PAGESEL,  // the item in a menu page
    ITEM_ACTION
};

enum EItemHyperLinkType {
    LINK_TYPE_NONE,
    LINK_TYPE_EDITPAGE,     // list in edit page and link to other page when selected. Attention: this item can be any data type but will not be edit (change value).
    LINK_TYPE_LISTBOX       // jump to different page when selected different value in listbox item
};

enum EItemRepeatType {
    REPEAT_TYPE_NONE,
    REPEAT_TYPE_RECT_SINGLE,      // repeat item in rectangle, and rank items in column
    REPEAT_TYPE_RECT_MULTI        // repeat item in rectangle, and intersect repeat items
};

typedef struct tagItem
{
    SPosition   SPos;
    void*       pvItem;

    char*       strDescription;

    // item info
    BYTE        f4DataType:     4;      // definition list in EItemDataType
    BYTE        f2RepeatType:   2;      // definition list in EItemRepeatType
    BYTE        f2LinkType:     2;      // definition list in EItemHyperLinkType

    BYTE        byLineNumPerColumn;
    BYTE        byPosColOffset;         // position offset of X coord. for REPEAT_TYPE_RECT_SINGLE only
} SItem, SVarLabel;


typedef struct tagItemPageSel
{
    char*       strPageSel;
    BYTE        byPageID;
} SItemPageSel;

typedef struct tagItemNum
{
    BYTE*       pbyNum;

    BYTE        f3ByteNum;
    BYTE        f5MaxLen;

    BYTE        byVarByteOffset;    // for repeat item. if not roll-page, don't care this value
} SItemNum;

typedef struct tagItemString
{
    char*       strString;
    BYTE        byMaxLen;
} SItemString;

typedef struct tagItemPasswd
{
    char*       strPassword;
    BYTE        byMaxLen;
} SItemPasswd;

typedef struct tagItemListbox
{
    BYTE*       pbyIndex;           // the max size of value is 1 byte(8 bits),

    BYTE        byStartBit;         // (byEndBit - byStartBit +1) must <= 8
    BYTE        byEndBit;
    BYTE        byVarBitOffset;     // for repeat item

    char**      astrListbox;        // string array of listbox
    BYTE        byListNum;          // number of items in this listbox for var_item only
} SItemListbox;

// for variable list number of listbox
typedef struct tagSStringTableMap    // this should allocate in RAM
{
    BYTE       byListNum;           // number of string in this listbox
    BYTE*      abyListIndex;        // mapping value to string index
} SStringTableMap;

typedef struct tagSItemVarListbox
{
    BYTE*       pbyIndex;           // the max size of value is 1 byte(8 bits),

    BYTE        byStartBit;         // (byEndBit - byStartBit +1) must <= 8
    BYTE        byEndBit;
    BYTE        byVarBitOffset;     // for repeat item (not support in engine now, for reducing code size)

    char**      astrListbox;        // string array of listbox
    SStringTableMap* pSStrTblMap;
} SItemVarListbox;


// action item
typedef struct tagActionItem
{
    SPosition   SPos;
    char*       strLabel;                               // the display string
    //char        cHotKey;                                // hot key support

    BOOL        (*bActFunc)(void) DIRECT_FUNTYPE_REENT; // action function pointer, return TRUE if change page
} SActItem;


//// define whole page, if any object not needed, assign NULL value
typedef struct tagPage
{
    SFixLabel*  aSFixLabel;     // constant label
    BYTE        byFixLabelNum;

    SVarLabel*  aSVarLabel;     // variable label, i.e., the value can be changed, but can not be edited(highlight)
    BYTE        byVarLabelNum;

    SItem*      aSVarItem;      // the item can be edited and highlight
    BYTE        byVarItemNum;

    SActItem*   aSActItem;      // action items
    BYTE        byActItemNum;

    BOOL        (*bLoadPage)(void) DIRECT_FUNTYPE_REENT;
} SPage;


/*---------------------  Export Variables  --------------------------*/
// Default is 0, and the action may specify them ...
// repeated times for repeat-item; pass to
extern BYTE g_byTotalLineNum;   // load_config function may specify
extern BOOL g_bDataDirty;       // save_config function may specify
extern BYTE g_byRootPageID;     // the root page after login, it should be modified in write_default action function
extern BYTE g_byCurPageID;      // It may change in action function to change page
extern BYTE g_byCurKey;         // used to distinguish between ENTER and ESC key and pass to eng_io

// pass to action functions of add/edit page
// DON'T change except UI engine
extern BYTE g_byCurLineID;
extern BYTE g_byCurItemID;

#define g_pSCurPage         g_apSPage[g_byCurPageID]
#define g_aSCurItemList     g_apSPage[g_byCurPageID]->aSVarItem
#define g_SCurItem          g_apSPage[g_byCurPageID]->aSVarItem[g_byCurItemID]
#define g_aSCurActionList   g_apSPage[g_byCurPageID]->aSActItem

/*---------------------  Export Functions  --------------------------*/
// starting entry of menuline engine
void ENGvEnterPage(void) DIRECT_FUNTYPE_REENT;
// select a var item, return the array index of aSVarItem
void ENGvItemSelect(void) DIRECT_FUNTYPE_REENT;


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -