#ifndef DEVICESETUP_H_
#define DEVICESETUP_H_

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

class TDeviceSetup{
	public:
		TCtlPanel1 *aPanel;
	public:
		TStaticText Caption;
		TStaticText SText;
		u32 Color;
	
		int TabOrder;
	
		TPoint OwnerLeftTop; //ParrentLeftTop;
		TRect Bound;	
		TRect Content;
		TMyString Str;
	
		int IsShowing;
		int IsFound;
		int SetupMode;
		unsigned char CtlIndex;
	
		unsigned char RecData[12];
		
		unsigned char Path0;
		unsigned char Addr;
		unsigned char AddrStart;
		unsigned char AddrEnd;
		unsigned char AssignType;
		unsigned short Pitch;
		
		unsigned char DirectPadNum;
		unsigned char NodeNum;
		unsigned char DirectPadAva;
		unsigned char IsPump;
		
		TUserCode UserCode;
		
		char Text[68];
		
		union{
			unsigned char D8[256];
			unsigned int  D32[64];
		}ReadWriteData;
		
	public:
		TDeviceSetup(){};
		TDeviceSetup(int x1, int y1, int aW, int aH, int OwnerX, int OwnerY, u32 aColor){
			Init(x1, y1, aW, aH, OwnerX, OwnerY, aColor);
		}
		void Init(int x1, int y1, int aW, int aH, int OwnerX, int OwnerY, u32 aColor);
	
		void SetAndShowCaption(unsigned char aType);
		void RenderBackGround(void);
		void RenderBackGround(unsigned int aClr);
		void DrawSelf(void);
		void ClearOutText();
		void DelayMs(unsigned int aMs);
		static void sDelayMs(unsigned int aMs);

		void Show(void);
		void ShowCaption();
		void ReDraw(void);
		void FullRedraw(int Prm);
		void DrawList();
		void DrawListStatic();
		void SetPanelCaptionColor();
		
		void DrawTip();
		void ShowSaveOk();
		void ShowSaveNotOk();
		void ShowCheckDataFail();
		
		void SendAskType(unsigned char aNum);
		void SendAskDescp(unsigned char aNum);
		void SendNwList();
		TGuiMsgReturn KeyIn(unsigned char aKey);
		
		void InitPanel(void);
		void InitPanel4Setup(void);
		void InitPanel4Fast(void);
		void InitPanel4DirectPad(void);
		void Check4Selected(void);
		void Check4SelectedInSetup();
		void Check4SelectedInFast();
		void Check4SelectedInDirectPad();
		void LoadStart();
		void LoadNext();
		void FindType(int Dir);
		void LoadData(int Inc);
		void DrawFast();
		int PrepData2Write();
		void Write2Flash();
		void WriteDirectPad2Flash();
		void ClearAll();
		
		void GetNewPathAddr();
		
		void CheckDirectPadAva();
		void DirectPadDataShow();
		
		void GetMinMax(unsigned int aP0);
		
		void Task1000Ms();
		void Task10Ms();
		
		int ExtRequst(unsigned char Prm);

};



#endif

