#ifndef DESIGNPRMSET_H_
#define DESIGNPRMSET_H_

#include "gType.h" 
#include "GraphBase.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "my_string.h"
#include "Device.h"
#include "EpDevice.h"
#include "StaticText.h"
#include "EditML.h"
#include "CtlPanel1.h"

class TDesignPrmSet{
	public:
		static constexpr unsigned short hList[12] = {36,70,70,70,	70,70,32,32,	32,32,32,32};
		static constexpr unsigned short wList[12] = {800,800,800,800,	800,800,800,800,	800,800,800,800};
		static constexpr TLv Lv = {
			.Caption.Left = 0,
			.Caption.Top = 36,
			.Caption.Width = 800,
			.Caption.Heigh = 32,
			.Caption.Right = 800 -0 -1,
			.Caption.Bottom = 36 + 32,
			
			.Grid.Left = {0,0,0,0,	0,0,0,0,	0,0,0,0},
			.Grid.Right = {wList[0]-1,wList[1]-1,wList[2]-1,wList[3]-1,	wList[4]-1,wList[5]-1,wList[6]-1,wList[7]-1,	wList[8]-1,wList[9]-1,wList[10]-1,wList[11]-1},
			.Grid.Top[0] = (36 + 32 +2),
			.Grid.Top[1] = (36 + 32 +2) + (24 + hList[0]),
			.Grid.Top[2] = (36 + 32 +2) + (24 + hList[0]) + (2 + hList[1]),
			.Grid.Top[3] = (36 + 32 +2) + (24 + hList[0]) + (2 + hList[1]) + (2 + hList[2]),
			.Grid.Top[4] = (36 + 32 +2) + (24 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]),
			.Grid.Top[5] = (36 + 32 +2) + (24 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]),
				
			.Grid.Bottom[0] = (36 + 32 +2) + hList[0],
			.Grid.Bottom[1] = (36 + 32 +2) + (24 + hList[0]) + hList[1],
			.Grid.Bottom[2] = (36 + 32 +2) + (24 + hList[0]) + (2 + hList[1]) + hList[2],
			.Grid.Bottom[3] = (36 + 32 +2) + (24 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + hList[3],
			.Grid.Bottom[4] = (36 + 32 +2) + (24 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + hList[4],
			.Grid.Bottom[5] = (36 + 32 +2) + (24 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + hList[5],
			
			.Grid.UsingCount = 5,
			
			.Panel.Active = 0,
			.Panel.ItemType = piMemo,
			.PanelSmall.Active = 0,
		};
		static constexpr TPoint ArrowUpPoint = {
			.x = Lv.Grid.Left[0] + 700,
			.y = Lv.Grid.Bottom[0] + 6,
		};
		static constexpr TPoint ArrowDownPoint = {
			.x = Lv.Grid.Left[0] + 700,
			.y = Lv.Grid.Bottom[4] + 6,
		};
		static constexpr TPoint ResultTipPoint = {
			.x = Lv.Grid.Left[2] + 340,
			.y = Lv.Grid.Top[2] + 132,
		};
		static constexpr TPoint ResultSavePoint = {
			.x = Lv.Grid.Left[0] + 700,
			.y = Lv.Grid.Top[0] + 8,
		};
		
		
	public:
		TStaticText Caption;
		int SaveSta;
	
		u32 Color;
		TRect Bound;	
		TRect Content;
		TRect RectPanel;
	
		class TImageList *IconList;
		class TCtlPanel1 *aPanel;
	
		struct{
			unsigned int Inx;
			void Reset(){
				Inx = 0;
			}
		}Tag;
		struct{
			int Count;
			unsigned char IsDescpByUserSet[256];
			unsigned char dType[256];
		}TypeList;
		struct{
			int Entry;
			int TopEntry;
			unsigned char Using[256];
			unsigned int Count[256];
			void Reset(){
				Entry = 0;
				TopEntry = 0;
				for(int i=0; i<256; i++){
					Using[i] = 0;
					Count[i] = 0;
				}
			}
			int UsingTypeCount;
			int EpCount;
		}Setting;
		struct{
			int UsingTypeCount;
			int EpCount;
		}ExtInf;
		char TextType[48];
		union{
			unsigned char D8[128];
			unsigned int Count[32];
			struct{
				unsigned char Dump0;
				unsigned char Dump1;
				unsigned char Dump2;
				unsigned char sType;
			}Pnt[32];
		}ReadWriteData;
		unsigned char TmpUsing[256];
		unsigned char IsPermission;
		unsigned char CntError;
	public:
		TDesignPrmSet(){};
		void Init();
		void InitBackEnd();
		void DelayMs(unsigned int aMs);
		void RenderBackGround(void);

		void RenderBackGround(unsigned int aClr);
		void RenderContent(void);
		void DrawSelf(void);
		void DrawCaption(void);
		void DrawGrid();
		void Show();
		void FullRedraw(int Prm);
		void DrawEntryActive(int aInx, int IsENtryActive);
		void DrawEntryTypeString(int aInx);
			
		void ShowState();
		void ShowState(unsigned int aSta);
		void ShowSetting();
		void ReStorage();
		void ReAligne();
			
		void LoadBaseTypeList();
		void LoadData();
		void SaveData();
		void LoadData2RuntimeData();
		void BackEnd_LoadData2RuntimeData();
			
		void ClearSelected(void);
		void Check4Selected();
		void Analy();

		void InitPanel();
			
		TGuiMsgReturn KeyIn(unsigned char aKey);
		
		void ExtLoadData();
		void ReadData();
		void Write2Eep();
		void RecoverSetDefault();
		
		void PermissionCmdReturnDraw();
		void PermissionCmdGO();

		int ExtRequst(unsigned char Prm){return 0;}
};



































#endif
