#ifndef PADINF_H_
#define PADINF_H_

#include "gType.h" 
#include "GraphBase.h"
#include "my_string.h"
#include "Device.h"
#include "BusPadLnk.h"
#include "DirectPadCfg.h"

#define dLISTVIEW_TYPE_DUMP		0
#define dLISTVIEW_TYPE_SYS		1
#define dLISTVIEW_TYPE_EP		2
#define dLISTVIEW_TYPE_PORT		3
#define dLISTVIEW_TYPE_HANDCTL	4
#define dLISTVIEW_TYPE_DIRECTCTL	5

#define dLISTVIEW_STYLE_LIST		0
#define dLISTVIEW_STYLE_ICON		1
#define dLISTVIEW_VSCOLLBAR_WIDTH	20

//For Device View or Edit
class TPadInf{
	public:
		static constexpr unsigned short hList[12] = {60,32,32,32,	32,32,32,32,	32,32,32,34};
		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) + (2 + hList[0]) +2,
			.Grid.Top[2] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]),
			.Grid.Top[3] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]),
			.Grid.Top[4] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]),
			.Grid.Top[5] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]),
			.Grid.Top[6] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]),
			.Grid.Top[7] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]),
			.Grid.Top[8] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]),
			.Grid.Top[9] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]),
			.Grid.Top[10] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + (2 + hList[9]),
			.Grid.Top[11] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + (2 + hList[9]) + (2 + hList[10]),
				
			.Grid.Bottom[0] = (36 + 32 +2) + hList[0],
			.Grid.Bottom[1] = (36 + 32 +2) + (2 + hList[0]) + hList[1] +2,
			.Grid.Bottom[2] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + hList[2],
			.Grid.Bottom[3] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + hList[3],
			.Grid.Bottom[4] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + hList[4],
			.Grid.Bottom[5] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + hList[5],
			.Grid.Bottom[6] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + hList[6],
			.Grid.Bottom[7] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + hList[7],
			.Grid.Bottom[8] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + hList[8],
			.Grid.Bottom[9] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + hList[9],
			.Grid.Bottom[10] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + (2 + hList[9]) + hList[10],
			.Grid.Bottom[11] = (36 + 32 +2) + (2 + hList[0]) + (6 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + (2 + hList[9]) + (2 + hList[10]) + hList[11],
			
			.Grid.UsingCount = 10,
			
			.Panel.Active = 0,
			.Panel.ItemType = piMemo,
			.PanelSmall.Active = 0,
		};
	public:
		class TBusPadLnk 		*BusPad;
		class TDirectPadCfg 	*DirectPad;
		unsigned char ViewingLevel;
		struct{
			int Count;
			int Inx;
			int TopInx;
			unsigned char Type[40];
			unsigned char Num[40];
			void Reset(){
				Inx = 0;
				TopInx = 0;
			}
		}Items;
		struct{
			unsigned char Type;
			unsigned char Num;
			unsigned char Node;
		}LoadedPad;
		struct{
			unsigned short Path0;
			unsigned short Path1;
			TRootDevice *RootDev;
			TEpDevice *EpDev;
		}ItemEnter;
		unsigned char TypeAndCount[256];
		unsigned char TypeCount;
		unsigned char TypeCountIndex;
		unsigned char TypeCountPageIndex;
		unsigned char TypeCountPageCount;
		unsigned char TypeCharHasShow;
		
		char Text[80];
		unsigned char TextInputIndex;
		
		int DrawX,DrawY;
		int LastDrawX,LastDrawY;
		
		int CircuitShowFig;
		struct{
			unsigned int Smoke;
			unsigned int Tempe;
			unsigned int HandReport;
			unsigned int HydKp;
			unsigned int ModuleInput;
			unsigned int ModuleInOut;
			unsigned int ModuleOutput;
			unsigned int Va;
			unsigned int FDisplay;
			unsigned int Sv;
			unsigned int cOther;
			
			unsigned int Tt;
		}Count;
		struct{
			int Inx;
			void Reset(){
				Inx = 0;
			}
		}Tag;
	public:
		TStaticText SText;
		
		int IsShow;
	private:
		void CalcIconDrawPrm(void);
		void SetListColWidth(int w0, int w1, int w2, int w3, int w4,int w5,int w6, int w7, int w8);
		void LoadPath1Item(TEpDevice *pItem);
	
		void DrawVScrollBar_ListView(void);
		void DrawVScrollBar_IconView(void);
		TGuiMsgReturn QueryKeyIn(unsigned char aKey);
		TGuiMsgReturn EditKeyIn(unsigned char aKey);
		
	public:
		TPadInf(){};
		void Init();
		void LoadItem();
		void ReLoadItem(void); 
		void ClearItem();	
		unsigned int ItemGetIcon(unsigned int aIndex);
		
		void RenderBackGround(void);
		void RenderBackGround(unsigned int aClr);
		void Show(void);
		void ReDraw(void);
		void FullRedraw(int Prm);
			
		void DrawSelf();
		void DrawBusPadInf();
		void DrawDirectPadInf();
		void DrawTitle();
		void DrawList(int aIsNotFull =0);
		
		TGuiMsgReturn KeyIn(unsigned char aKey);
		
		void GetTypeAndCount();
		int  FindStartPoint();
		void SetEditMode(unsigned int aMode);
		
		void CheckNewLine(int aLen);
		void ShowCount(unsigned char aP0);
		
		void FullRePaint(void);
		void RePaint(void);
		
		void ClearSelected(void);
		void Check4Selected(void);
		
		int ExtRequst(unsigned char Prm){
			if(this->BusPad != nullptr)
				this->BusPad->ExtRequst(Prm);
			if(this->DirectPad != nullptr)
				this->DirectPad->ExtRequst(Prm);
			IsShow = 0;
			return 0;
		}
};











#endif


