#ifndef DEVICE_DYM_PRM_H_
#define DEVICE_DYM_PRM_H_

#include "gType.h" 
#include "GraphLow.h"
#include "GraphBase.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "my_string.h"

#include "MainCtl.h"
#include "Device.h"
#include "EpDevice.h"

#include "StaticText.h"

//have two list to View Root device and Endpoing device's Dynamics Analog Value Parameter

class TBasePercentBar{
	public:
		int x0,y0,x1,y1;
		int Len, Width,Height;
		unsigned int BgColor;
		unsigned int Color;

	public:
		void SetSize(short aX0, short aY0, short aX1, short aY1){
			x0 = aX0; y0 = aY0; x1 = aX1; y1 = aY1;
			Width = x1 - x0;
			Height = y1 - y0;
		}
		void SetColor(u32 aColor, u32 aBgColor){
			Color = aColor;
			BgColor = aBgColor;
		}
		void PercentRender(float da, float tt, unsigned char aGotUpdata){
			int i, ax;
			float f1 = da / tt * static_cast<float>(Width);
			Len =  static_cast<short>(f1);
			if(Len < 1)Len = 1;
			if(aGotUpdata == 0) Len = 0;
			ax = x0;
			for(i=0; i<Len; i++){
				VertLineRender(ax, y0, Height, Color);
				ax++;
			}
			for(i=Len; i<Width; i++){
				VertLineRender(ax, y0, Height, BgColor);
			}
		}			
};

class TDevDymPrm{
	private:
		int Active;
		int FontSize;
		int FontHeight;
		struct{
			u32 Color;
			u32 RibbonColor;
		}VScrollBar;

		struct{
			unsigned char UpdataSecond[256];
			unsigned char GotUpdata[256];
			unsigned short Value[256][8];
		}DymPrm;
		unsigned char CmdBuf[24];
		
		TBasePercentBar PercentBar;
	public:
		float ScrollVertical;
		TStaticText Caption;
		TMyString Str[12];
		u32 FixColColor;
		u32 FixColTextColor;
		u32 Color;
		u32 TextColor;
		u32 SelectedColor;
		u32 SelectedTextColor;
	
		unsigned int PathX;
		int TabOrder;
	
		TPoint OwnerLeftTop; //ParrentLeftTop;
		TRect Bound;	
		TRect VScrollBarBox;
		TRect Content;
		struct{
			struct{
				int SelectedIndex;
				int TopIndex;
			}Path0;
			struct{
				int SelectedIndex;
				int TopIndex;
			}Path1;
		}Bk;
		struct{
			int TopIndex;

			unsigned short ColTop[16];
			unsigned short ColBottom[16];
			unsigned short ColWidth[16];
			unsigned short ColLeft[16];
			unsigned short ColRight[16];
			unsigned short FixColTop;
			unsigned short FixColBottom;
			unsigned short RowCount;
			unsigned short ColHeight;
			unsigned int  TransparrentColor;
			int SelectedCol;
		}Lv;
		
		struct{
			unsigned int Selected_dType;
			int Count;
			int SelectedIndex;
			TRootDevice *Dev[256];
			TRootDevice *SelectedDev;
			int TopIndex;
			int ActiveLineNum;
		}RootItems;
		struct{
			unsigned int Selected_dType;
			int Count;
			int SelectedIndex;
			TEpDevice *Dev[256];
			TEpDevice *SelectedDev;
			int TopIndex;
			int ActiveLineNum;
		}EpItems;
		
	private:
		void SetListColWidth(int w0, int w1, int w2, int w3, int w4,int w5, int w6, int w7, int w8, int w9, int w10, int w11, int w12, int w13);
		void LoadPath0Item(TRootDevice *pItem);
		void LoadPath1Item(TEpDevice *pItem);
		
	public:
		TDevDymPrm(){};

		TDevDymPrm(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 SetFontSize(int size);		
		unsigned int ItemGetIcon(unsigned int aIndex);
		
		void RenderBackGround(void);
		void RenderBackGround(unsigned int aClr);
		void RenderContent(void);
		void DrawSelf(void);
		void DrawVertScrollBar(void);
		void DrawShortList(void);
		void DrawList(void);
		void Show(void);
		
		void ClearPath(void);
		void ClearPath1(void);
		void LoadPath0(void);
		void LoadPath1(void);
		void SetEditMode(unsigned int aMode);
		
		void DrawPowerSpply(void);
		void DrawBattery(void);
		void DrawGraphCtl(void);
		void DrawCommCan(void);
		void DrawCommMulti(void);
		void DrawLcdBoard(void);
		void DrawKeyBoard(void);
		void DrawMotherBoard(void);
		void DrawHandPad(void);
		void DrawDirectCtl(void);
		void DrawPort(void);
		
		void DrawSmokeDet(void);	//Req  1, IR Raw Data;  2, Blue Raw Data;
		void DrawTempeDet(void);	//Req  1, Tempe in Celsius degree;  2, Raw Data;
		void DrawSmokeTempeDet(void);	//Req  1, IR Raw Data;  2, Blue Raw Data;  3, Tempe in Celsius degree;  4, Raw Data;
		
		void DrawCaption(void);
		void DrawRootDevList(void);
		void DrawEpDevList(void);
		void FullRePaint(void);
		void RePaint(void);
		
		void UpChange_dType(void);
		void DownChange_dType(void);
		
		void SendReqCmd(void);
		
		void SetActive(void);
		void SetDeActive(void);
		
		void TimeTickTask(void);
		
		TGuiMsgReturn KeyIn(unsigned char aKey);
};











#endif


