/****************************************************************************/
/*                   CipherLab Co., Ltd.                                    */
/*                                                                          */
/* Copyright    : Copyright (c) 2010 CipherLab Co., Ltd.                    */
/*                All Rights Reserved.                                      */
/*                                                                          */
/* Cur.Mod.Date : 06-01-2010                                                */
/* Programmer   : Justin Lin                                                */
/* Source       :                                                           */
/* Object       :                                                           */
/* Purpose      :                                                           */
/*                                                                          */
/* Contents     : this is the universal header file to map all include      */
/*                files in                                                  */
/*                                                                          */
/* Modifications:                                                           */
/*   Date     Who      Description                                          */
/* --------  ------   ----------------------------------------------------- */
/* 06-01-10  Justin    Created module                                       */
/* 06-29-12  Roy.chen  Refine code                                          */
/****************************************************************************/
#ifndef __CL8XGUI_H_
#define __CL8XGUI_H_

/****************************************************************************/
/* General                                                                  */
/****************************************************************************/
#ifndef TRUE
#define TRUE    1
#endif  /* end of TRUE */

#ifndef FALSE
#define FALSE   0
#endif  /* end of FALSE */

#define  SIGNDBF        "SIGNEDDB"

typedef struct S_FormField;
typedef struct S_MenuData;
typedef struct S_Button;

extern  char    GUIVersion[9];  /* GUI Library Version */

/****************************************************************************/
/* Structure                                                                */
/****************************************************************************/
typedef struct
{
    char Caption[27];                   /* Info Menu Caption */
    char Item[10][27];                  /* Info Menu Items */
    unsigned char   ItemReturnKey[10];  /* What key char should be returned when
                                         * we tap this menu item?
                                         */
    unsigned char   ShowCaption;        /* Should the menu caption be painted? */

} S_MenuData;                           /* Total 308 bytes */

/****************************************************************************/
/* Beeper                                                                   */
/****************************************************************************/
typedef enum
{
    BEEP_SUCCESS = 1,           /* 1: */
    BEEP_FAIL,                  /* 2: */
    BEEP_TRYAGAIN,              /* 3: */
    BEEP_KEYCLICK,              /* 4: */
    BEEP_ERROR,                 /* 5: */
    BEEP_PLUSONE                /* 6: */

} BEEP_TYPE_E;

/****************************************************************************/
/* Keypad                                                                   */
/****************************************************************************/
typedef enum
{
    TKB_MODE_LOWERCASE = 0,     /* 0: Default Keyboard layout */
    TKB_MODE_UPPERCASE,         /* 1: Shift or Caps on keyboard layout */
    TKB_MODE_RESERVED1,         /* 2: reserved */
    TKB_MODE_RESERVED2,         /* 3: reserved */
    TKB_MODE_NUMBERS,           /* 4: Numbers keyboard layout */

    TKB_MODE_NUMS

} TKB_MODE_E;

typedef enum
{
    TKB_SHIFTSTATE_OFF = 0,     /* 0: Shift off, CAPS off */
    TKB_SHIFTSTATE_SHIFT,       /* 1: Shift on, CAPS off */
    TKB_SHIFTSTATE_CAPS,        /* 2: Shift off, CAPS on */
    TKB_SHIFTSTATE_ALL,         /* 3: Shift on, CAPS on */

    TKB_SHIFTSTATE_NUMS

} TKB_SHIFTSTATE_E;

void    gui_TouchScreenActivateSWKeypad                 (int yDot);
void    gui_TouchScreenDisableSWKeypad                  (void);

char    gui_TouchScreenGetCharFromSWKeypad              (int itemNumber,
                                                         int mode_TKB);

extern  int     TKB_MODE;       /* TKB_MODE_E */
extern  int     TKBShiftState;  /* TKB_SHIFTSTATE_E */

/****************************************************************************/
/* Form                                                                     */
/****************************************************************************/
typedef enum
{
    NO_ICON = 0,                /* 0: No icon*/
    ICON_INFO,                  /* 1: Show the information icon*/
    ICON_CLOSE,                 /* 2: Show the close icon */

    ICON_NUMS

} FORM_ICON_E;

typedef struct
{
    int FieldType;          /* Helps define acceptable characters for this field
                             * (ex: numeric only, string, etc)
                             */
    int DisplayMode;        /* Video mode: Inverse/Normal */
    int Font;               /* Font Identifier: 6X8, 8X16 */
    int Origin_Column;      /* What 'X' location is this field */
    int Origin_Row;         /* What 'Y' location is this field */
    int MaxLength;          /* What is the max length for this field? */
    int CursorPosition;     /* Where is the cursor currently located in this
                             * field?
                             */
    char InputMask[27];     /* Entry mask for this field */
    char InputData[27];     /* Holds the entered data for this field */

} S_FormField;

void    gui_TouchScreenActivateForm                     (int y_dot,
                                                         int height,
                                                         char* title,
                                                         int icon,
                                                         int button_type);
void    gui_TouchScreenDisableForm                      (void);

/****************************************************************************/
/* Input Field                                                              */
/****************************************************************************/
typedef enum
{
    FORMFIELD_1 = 0,            /* 0: */
    FORMFIELD_2,                /* 1: */
    FORMFIELD_3,                /* 2: */
    FORMFIELD_4,                /* 3: */
    FORMFIELD_5,                /* 4: */
    FORMFIELD_6,                /* 5: */
    FORMFIELD_ALL,              /* 6: */

    FORMFIELD_NUMS

} FORMFIELD_E;

typedef enum
{
    FIELDTYPE_INTEGER = 1,      /* 1: integer, accept 0 ~ 9 and minus sign */
    FIELDTYPE_UINTEGER,         /* 2: unsigned integer, accept 0 ~ 9 */
    FIELDTYPE_FLOAT,            /* 3: float, accept 0 ~ 9, dot, and minus sign*/
    FIELDTYPE_UFLOAT,           /* 4: unsigned float, accept 0 ~ 9 and dot*/
    FIELDTYPE_STRING            /* 5: string, accept 0 ~ 9 and printer
                                 * character except for "?+/*\.,;:#$"
                                 */

} FIELDTYPE_E;

void    gui_TouchScreenDefineField                      (int field_index,
                                                         int field_type,
                                                         int display_mode,
                                                         int font,
                                                         int column,
                                                         int row,
                                                         int max_len,
                                                         char* initial_value,
                                                         char* input_mark);
void    gui_TouchScreenClearField                       (int field_index);
int     gui_TouchScreenFieldInput                       (int field_index,
                                                         int password,
                                                         char key);
void    gui_TouchScreenSetFieldFocus                    (int field_index);

void    gui_TouchScreenActivateField                    (int field_index,
                                                         int startColumn,
                                                         int endColumn);
void    gui_TouchScreenDisableField                     (int field_index);

char    gui_TouchScreenActivateFieldTouchPad            (int row,
                                                         char* title,
                                                         int field_index,
                                                         int password);
void    gui_TouchScreenDisableFieldTouchPad             (void);

extern  S_FormField     FormFieldCollection[6]; /* Contains array of form
                                                 * field structures...
                                                 */
extern  int             activefield; /* For keeping track of which field we
                                      * are working on...
                                      */

/****************************************************************************/
/* Button                                                                   */
/****************************************************************************/
typedef enum
{
    DIALOG_OK = 1,              /* 1: */
    DIALOG_OKCANCEL,            /* 2: */
    DIALOG_YESNO,               /* 3: */
    DIALOG_NEXT,                /* 4: */
    DIALOG_NEXTPREV,            /* 5: */
    DIALOG_PREVDONE,            /* 6: */
    DIALOG_DONE,                /* 7: */
    DIALOG_3SECONDS,            /* 8: */
    DIALOG_ICONONLY,            /* 9: */
    DIALOG_1SECOND,             /* 10: */
    DIALOG_USERDEF              /* 11: */

} DIALOG_BUTTON_E;

typedef struct
{
    int TotalButtons;                       /* Total buttons to show */
    char ButtonLabel[5][27];                /* Label of each button */
    unsigned char ButtonReturnKey[5];       /* What key char should be returned
                                             * when we tap this button?
                                             */

} S_Button;

extern  S_Button*       btnLabel;

/****************************************************************************/
/* Component                                                                */
/****************************************************************************/
int     gui_TouchScreenActivateSignatureBox             (char* title,
                                                         char* message,
                                                         int flip);
void    gui_TouchScreenDisableSignatureBox              (void);

char    gui_TouchScreenActivateSingleLineInput          (char* title,
                                                         char* message,
                                                         char* return_string,
                                                         int max_return_bytes,
                                                         int password,
                                                         int button_type,
                                                         int font);
void    gui_TouchScreenDisableSingleLineInput           (void);

char    gui_TouchScreenActivateTextBoxInput             (char* title,
                                                         char* message,
                                                         char* return_string,
                                                         int max_return_bytes);
void    gui_TouchScreenDisableTextBoxInput              (void);

char    gui_TouchScreenActivatePopUpMenu                (int column,
                                                         int row,
                                                         S_MenuData* data,
                                                         int font);
void    gui_TouchScreenDisablePopUpMenu                 (void);

char    gui_TouchScreenActivateListBox                  (char* title,
                                                         char* message,
                                                         char* items,
                                                         int* return_value,
                                                         int button_type,
                                                         int font);
void    gui_TouchScreenDisableListBox                   (void);

char    gui_TouchScreenActivateTabList                  (char* title,
                                                         char* caption_tab1,
                                                         char* caption_tab2,
                                                         int button_type,
                                                         int* return_tab1,
                                                         int* return_tab2,
                                                         char (*list_tab1)[20],
                                                         int max_items_tab1,
                                                         char (*list_tab2)[20],
                                                         int max_items_tab2,
                                                         int font_tab1,
                                                         int font_tab2);
void    gui_TouchScreenDisableTabList                   (void);

int     gui_TouchScreenActivateComboList                (char* title,
                                                         char* message,
                                                         S_MenuData* data,
                                                         int* return_value,
                                                         int button_type,
                                                         int font);
void    gui_TouchScreenDisableComboList                 (void);

char    gui_TouchScreenActivateCalendar                 (char* title,
                                                         char* return_value,
                                                         int button_type);
void    gui_TouchScreenDisableCalendar                  (void);

extern  int     iCurrentYear;   /* Current year of datebox */
extern  int     iCurrentMonth;  /* Current month of datebox */
extern  int     iCurrentDay;    /* Current day of datebox */

/****************************************************************************/
/* Dialog                                                                   */
/****************************************************************************/
char    gui_TouchScreenShowMsgBox                       (char* title,
                                                         char* message,
                                                         int beep,
                                                         int vibrate,
                                                         int button_type,
                                                         int font);
void    gui_TouchScreenShowMemoBox                      (char* title,
                                                         char* message,
                                                         int font);

void    gui_TouchScreenShowResourceInfo                 (void);

/****************************************************************************/
/* Touch area (Screen item)                                                 */
/****************************************************************************/
void    gui_ClearTouchScreenButtons                     (void); /* Clear all
                                                                 * screen item
                                                                 * from GUI*/

extern  ItemProperty        CompiledTouchButtons[70]; /* Contains array of touch
                                                       * keys
                                                       */
extern  int                 nCompiledTouchButtons; /* Total touch keys to be
                                                    * monitored
                                                    */

/****************************************************************************/
/* Text message                                                             */
/****************************************************************************/
void    gui_TouchScreenCenterStr                        (int row,
                                                         char* string,
                                                         int mode);

void    gui_TouchScreenPrintTitle                       (int nRow,
                                                         char* szTitle,
                                                         int iIcon);

/****************************************************************************/
/* Miscellaneous                                                            */
/****************************************************************************/
void    gui_TouchScreenPrintScreenLines                 (int startRow,
                                                         int endRow);

void    gui_DrawVertDotLine                             (int xDot,
                                                         int yStartDot,
                                                         int yEndDot);

#endif /* end of  __CL8XGUI_H_ */
