#ifndef _DOG_MENU_H_
#define _DOG_MENU_H_

#include "zf_common_headfile.h"
#include "zf_common_debug.h"
#include "DOG_data.h"

#define MAX_PAGE_WIDGET_NUM 	(50)	// ҳɿؼ
#define SCREEN_KIND 			(1)		// Ļѡ 0:tft180 1:ips200 
#define FONT_WIDTH				(6)		// ʾȣ6/8
#define FONT_HEIGHT				(8)		// ʾ߶ȣ8/16

/* ʾַָ */ 
typedef void (*SCREEN_STRING)(uint16, uint16, const char dat[]);
/* ʾͺָ */
typedef void (*SCREEN_INT)(uint16, uint16, const int32, uint8);
/* ʾ޷ͺָ */
typedef void (*SCREEN_UINT)(uint16, uint16, const uint32, uint8);
/* ʾͺָ */
typedef void (*SCREEN_FLOAT)(uint16, uint16, const double, uint8, uint8);
/* ʾҶͼ */
typedef void (*SCREEN_IMAGE)(uint16 x, uint16 y, const uint8 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height, uint8 threshold);
/* ָ */
typedef void (*SCREEN_CLEAR)(void);
/* ʾֱߺָ */
typedef void (*SCREEN_DRAW_LINE)(uint16 x_start, uint16 y_start, uint16 x_end, uint16 y_end, const uint16 color);
/* ʾ㺯ָ */
typedef void (*SCREEN_DRAW_POINT)(uint16 x, uint16 y, const uint16 color);

struct DOG_MENU_WIDGET;
struct DOG_MENU_PAGE;

// ˵ؼ
typedef struct DOG_MENU_WIDGET{
	/* ؼ */
	char* name;				// ؼַ
	_data_kind_ data_kind;	// 
	int8* data_int8; 		// int8
	uint8* data_uint8;		// uint8
	int16* data_int16; 		// int16
	uint16* data_uint16;	// uint16
	int32* data_int32; 		// int32
	uint32* data_uint32;	// uint32
	float* data_float;		// float
	double* data_double;	// double
	void (*MENU_PAGE)(void);	// ҳ溯
	
	_bool_ change_enable_flag;	// ݸʹܱ־λ
	_bool_ title_enable_flag;	// ҳʹܱ־λ
	
	uint32 x;	// ؼX
	uint32 y;	// ؼY 
	
	/* Ա */
	void (*data_add)(struct DOG_MENU_WIDGET* this, uint8 idx, double step);		// 
	void (*data_reduce)(struct DOG_MENU_WIDGET* this, uint8 idx, double step);	// ݼ
	void (*data_bind)(struct DOG_MENU_WIDGET* this, _bool_ change_enable_flag, _data_kind_ data_kind, ...);	// ݰ
	void (*page_bind)(struct DOG_MENU_WIDGET* this, _bool_ title_enable_flag, void (*MENU_PAGE)(void));		// ҳ
}DOG_MENU_WIDGET;

// 
void data_add(struct DOG_MENU_WIDGET* this, uint8 idx, double step);
// ݼ
void data_reduce(struct DOG_MENU_WIDGET* this, uint8 idx, double step);
// ݰ
void data_bind(struct DOG_MENU_WIDGET* this, _bool_ change_enable_flag, _data_kind_ data_kind, ...);	
// ҳ
void page_bind(struct DOG_MENU_WIDGET* this, _bool_ title_enable_flag, void (*MENU_PAGE)(void));		
// 캯	
void widget(struct DOG_MENU_WIDGET* this, char* name, uint32 x, uint32 y);
// 	
void _widget(struct DOG_MENU_WIDGET* this);

// ˵ҳ
typedef struct DOG_MENU_PAGE{
	/* ҳ */
	struct DOG_MENU_WIDGET* menu_page_widget_bind;		// 󶨸ҳĿؼ
	struct DOG_MENU_WIDGET* menu_widgets[MAX_PAGE_WIDGET_NUM];			// ҳʾĿؼ
	
	/*  */
	int16 idx;			// ؼ
	uint16 widget_num;	// ؼ
	uint16 screen_width;	// Ļؿ
	uint16 screen_height;	// Ļظ߶
	uint32 sliding_window_x;	// ϽX
	uint32 sliding_window_y;	// ϽY
	uint16 options_window_x;	// ѡϽX
	uint16 options_window_y;	// ѡϽY
	
	/* Ա */
	void (*page_sliding_window)(struct DOG_MENU_PAGE* this);	// 
	void (*page_service)(void);			// 
}DOG_MENU_PAGE;

// 
void page_sliding_window(struct DOG_MENU_PAGE* this);
// 
void page_service(void);	
// 캯
void menu_page(struct DOG_MENU_PAGE* this, struct DOG_MENU_WIDGET* menu_page_widget_bind, void (*page_service)(void), uint16 widget_num, ...);
// 
void _menu_page(struct DOG_MENU_PAGE* this);

#endif