
#ifndef __TLPINPAD_LAYOUT_H__
#define __TLPINPAD_LAYOUT_H__

#include <stdint.h>

/** Layout of pinpad, define size and position of buttons and input area. */

/** Values for control buttons */
#define PAD_CORRECT_VAL  (10)
#define PAD_VALIDATE_VAL (11)
#define PAD_CANCEL_VAL   (12)
//#define PAD_CONFIRM_VAL  (13)
#define PAD_CONFIRM_VAL  (13)
#define PAD_SOFTKEY_BACK_VAL	(14)
//#define PAD_CHECKBOX_VAL	(15)
//#define PAD_ECO_TEXT_VAL	(16)
#define PIN_SOFTKEY_BACK_VAL	(17)

#define PAD_NOKEY_VAL    (0xFF)
#define PAD_KEY_OUT_VAL  (0xFE)

/** Button types */
typedef enum {
	NOKEY = 0,
	PAD_NUM, /**< Number */
	PAD_CORRECT,
	PAD_VALIDATE,
	PAD_CANCEL,
	//PAD_CONFIRM,
	PAD_CONFIRM,
	//PAD_MERCHANT,
	PAD_SOFTKEY_BACK,
	//PAD_CHECKBOX,
	//PAD_ECO_TEXT,
} pinPadKeyType_t;


/** Button definition: location, type, value */
typedef struct {
	uint32_t xLeft;
	uint32_t xRight;
	uint32_t yTop;
	uint32_t yBottom;
	uint8_t val;
	pinPadKeyType_t type;
} sPinPadKey_t;

#define SOFTKEY_SIZE	(1)
#define SOFTKEY_SIZE_INDEX	(-1)

#define ECO_TEXT_INDEX	0xfff

/** buttons_array - Array of buttons used to find out pressed key
 *
 * Layout:
 * 0: Empty button in the beginning
 * 1-9: Position of buttons for 1-9
 * 10: Position of buttons for 0
 * 11: Position of buttons for PAD_CORRECT_VAL
 * 12: Position of buttons for PAD_CANCEL_VAL
 * 13: Position of buttons for PAD_VALIDATE_VAL
 * 14: Position of buttons for PAD_CONFIRM_VAL
 */
#define PINPAD_SIZE       (14)
#define PIN_MAX_SIZE      (12)

/** Text area definition: location, layout
 * The text area displays the stars (and blanks).
 */
typedef struct {
	uint32_t taLeft;
	uint32_t taRight;
	uint32_t taTop;
	uint32_t taBottom;
	uint32_t taMargin;
	/**< space between stars */
	uint32_t taCharsize;
	/**< width of stars */
} sTextAreaLayout_t;


/* The area where we will show the secret
*/
typedef struct {
	uint32_t secretLeft;
	uint32_t secretRight;
	uint32_t secretTop;
	uint32_t secretBottom;
} sSecretAreaLayout_t;


typedef struct {
	uint32_t pinTextLeft;
	uint32_t pinTextTop;
	uint32_t clearPinLeft;
	uint32_t clearPinTop;
} sPinAreaLayout_t;


typedef struct {
	uint32_t okLeft;
	uint32_t okTop;
} sOkEnable_t;

typedef struct {
    uint32_t xLeft;
    uint32_t yTop;
} sPinBoxLayout_t;

typedef struct {
    uint32_t xLeft;
    uint32_t yTop;
} sPinDotLayout_t;

/** Layout definition including buttons and textarea */
typedef struct {
	sPinPadKey_t buttons_array[PINPAD_SIZE + 1];
	sTextAreaLayout_t textarea;
	sSecretAreaLayout_t secret_area;
	sPinAreaLayout_t pin_area;
	sOkEnable_t ok_enable;
	sPinBoxLayout_t pinbox_array[PIN_MAX_SIZE];
	sPinDotLayout_t pindot_array[PIN_MAX_SIZE];
} sLayout_t;

#endif	/* #ifndef __TLPINPAD_LAYOUT_H__ */
