#ifndef USERSET_H_
#define USERSET_H_ 

#include "gType.h" 
#include "GraphBase.h"
//#include "stdio.h"
//#include "stdlib.h"
//#include "string.h"
#include "my_string.h"
#include "TEdit.h"
#include "Device.h"
#include "EpDevice.h"
#include "StaticText.h"
#include "MainCtl.h"
#include "Runtime.h"

#define dLISTVIEW_VSCOLLBAR_WIDTH	20

//For Device View or Edit
class TUserSet{
	public:
		struct{
			u32 Color;
			u32 RibbonColor;
		}VScrollBar;
		class TEdit vEdit;
		struct{
			int TopIndex;
			unsigned short RowCount;
			unsigned short ColTop[12];
			unsigned short ColBottom[12];
			unsigned short ColHeight;
			unsigned short ColWidth[12];
			unsigned short ColLeft[12];
			unsigned short ColRight[12];
			unsigned short FixColTop;
			unsigned short FixColBottom;
			unsigned int  TransparrentColor;
			int SelectedCol;
		}Lv;
		int BkP0TopIndex;
		struct{
			int Count;
			int SelectedIndex;
			unsigned char addr[64];
		}Load0;
		struct{
			int Count;
			int SelectedIndex;
			unsigned char P0;
			unsigned char addr[256];
		}Load1;
		
		unsigned char IsProgram;
		
	public:
		TStaticText Caption;
		TStaticText SText;
		unsigned int ViewPath;
		int ActiveLineNum;
		int LineHeight;
		float ScrollVertical;
	
		u32 FixColColor;
		u32 FixColTextColor;
		u32 Color;
		u32 TextColor;
		u32 SelectedColor;
		u32 SelectedTextColor;
	
		int TabOrder;
	
		TPoint OwnerLeftTop; //ParrentLeftTop;
		TRect Bound;	
		TRect VScrollBarBox;
		TRect Content;
	
		unsigned char GridX;
		unsigned char OnEditing;
		unsigned char IsEditUsercode;
		unsigned char IsEditDescp;
		unsigned char EditUsercodeIndex;
		unsigned char EditDescpIndex;
		unsigned char AskingSave;
	private:
		void SetListColWidth(int w0, int w1, int w2, int w3, int w4,int w5,int w6, int w7, int w8);
		void LoadPath0Item(unsigned char aP);
		void LoadPath1Item(unsigned char aP);
	
		void DrawVScrollBar_ListView(void);
		void DrawVScrollBar_IconView(void);
		TGuiMsgReturn QueryKeyIn(unsigned char aKey);
		TGuiMsgReturn EditKeyIn(unsigned char aKey);
		
	public:
		TUserSet(){};
		TUserSet(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);	
		unsigned int ItemGetIcon(unsigned int aIndex);
		
		void RenderBackGround(void);
		void RenderBackGround(unsigned int aClr);
		void DrawSelf(void);
		void DrawShortList(void);
		void DrawList(void);
		void Show(void);
		void ReDraw(void);
		void FullRedraw(int Prm);
		void DrawCaption(void);
		void DrawCaption1(void);
		void DrawCaption2(void);
		void RenderContent(void);
		
		void DrawValueP0(void);
		void DrawValueP1(void);
		
		TGuiMsgReturn KeyIn(unsigned char aKey);
		
		void ClearPath0(void);
		void ClearPath1(void);
		void LoadPath0(void);
		void LoadPath1(void);
		void SetEditMode(unsigned int aMode);
		
		void DataInit();
		void DataLoad();
		void LoadTextToTemp(unsigned int aAddr);
		
		void FullRePaint(void);
		void RePaint(void);
		void ShowIfSave();
		
		void DevPropertyInit(void);
		
		void SetEditStart(void);
		void RestoreFromEdit(void);
		
		int ExtRequst(unsigned char Prm){return 0;}
};





































#endif

