#ifndef TEDIT_H_
#define TEDIT_H_

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


class TEdit{
	private:
		struct{
			unsigned int Width;
			unsigned int Color;
		}Border;		
	public:
		TMyString Str;
		bool Enable;
		int FontSize;
		int DrawMode;	//dmRaised=1 dmLowered=-1 dmNone=0
		unsigned int Color;
		unsigned int TextColor;
		unsigned int Index;
		unsigned int Edit;
		int TabOrder;
	
		int Selected;
		unsigned int SelectedColor;
		unsigned int SelectedTextColor;
	
		TPoint OwnerLeftTop;	//Parrent Left Top;
		TRect Bound;
		TRect Content;
	
		int Pst;
		int MaxLen;
		bool 	FlickDominance;
		unsigned int FlickTick;
		TInputMethod InputMethod;
		unsigned int Visible;
		unsigned char IsShowCursor;
		
		unsigned char CursorMode;
		unsigned char MaskMode;
	public:
		TEdit(void){};
		TEdit(u16 aX, u16 aY, u16 aW, u16 aH, u16 OwnerX, u16 OwnerY, u32 aBorderWidth, u32 aBorderColor){
			Init(aX, aY, aW, aH, OwnerX, OwnerY, aBorderWidth, aBorderColor);
		}
		void Init(u16 aX, u16 aY, u16 aW, u16 aH, u16 OwnerX, u16 OwnerY, u32 aBorderWidth, u32 aBorderColor);
		void SetText(char *p, int aFontSize);
		void SetText(const char *p, int aFontSize);
		void SelfDraw(void);
		void TextClear(void);
		
		void SetSelect(void);
		void SetDeSelect(void);
		void ShowCursor(void);
		void ShowCursor(unsigned int aClr);
		void ReDraw(void);
		void Show(void);
		
		void KeyIn(unsigned char aKey);
		
		void OnTime100mS(void);
		void SetMaxLen(unsigned int aLen);
		
		void SetInputMaskEn(void);
		void SetInputCN(void);
		void CorrectPst();
		
		void SetPstTail(void);
		
		void SetTextShowMaskNone(){MaskMode = 0;}
		void SetTextShowMaskByAsterisk(){MaskMode = '*';}
		
		static void sDrawSelf(int x, int y, int x2, int y2, unsigned int aClr);
};

#endif

