#ifndef GRAPHBASE_H_
#define GRAPHBASE_H_

#include "gType.h"
#include "GraphLow.h"

#define dmClear	0
#define dmSolid	1

#define dICON16_COUNT	32
#define dICON24_COUNT	24
#define dICON32_COUNT	4

typedef enum
{
	CENTER	= 0x01,    // Center mode 
	RIGHT		= 0x02,    // Right mode  
	LEFT		= 0x03     // Left mode   
}Tdraw_string_aline_mode;

typedef struct{
	int x;
	int y;
}TPoint;

typedef struct{
	float x;
	float y;
}T2DPoint;

typedef enum{
	bvNone = 0,
	bvLowered,
	bvRaised,
	bvSpace
}TBvStyle;

class TRect{
	public:
		int Left;
		int Top;
		int Right;
		int Bottom;
		int Width;
		int Height;
		TPoint CenterPoint;
	
	public:
		void Set(int aLeft, int aTop, int aRight, int aBottom);
		void SetBySize(int aLeft, int aTop, int aWidth, int aHeight);
		void SetBy2Point(TPoint aPLT, TPoint aPRB);
		void SetLeftTop(int aL, int aT);
		void SetLeft(int aL);
		void SetTop(int aT);
		void SetRight(int aR);
		void SetBottom(int aB);
		void SetWidth(int aW);
		void SetHeight(int aH);
};

class TCircle{
	public:
		TPoint Center;
		u32 Radius;
	
		int PenWidth;
		u32 PenColor;
		int BrushStyle;	//fsSolid=1; fsClear=0;
		u32 BrushColor;
	
	private:
		void Plot4Points(int x, int y);
		void Plot4PointsFill(int x, int y);
		void Plot8Points(int x, int y);
		void Plot4PointsQuadrant(int x, int y, int quadrant);
		void Plot4PointsFillQuadrant(int x, int y, int quadrant);
		void Plot8PointsQuadrant(int x, int y, int quadrant);
	public:
		void Set(TPoint aCenter, s16 aRadius);
		void SetBySize(int aLeft, int aTop, int aWidth, int aHeight);
		
		void Render(void);
		void Render2(void);
		void RenderQuadrant (int quadrant);  

		static void sPlot4Points(int cx, int cy, int x, int y, unsigned int aClr);
		static void sPlot4PointsFill(int cx, int cy, int x, int y, unsigned int aClr);
		static void sPlot8Points(int cx, int cy, int x, int y, unsigned int aClr, int IsFill);
		static void sRender(int x, int y, int aR, unsigned int aClr, int IsFill);
		static void sRender2(int x, int y, int aR, unsigned int aClr);
	
		static void sPlot4PointsFillQuadrant(int ax, int ay, int x, int y,int quadrant, u32 aClr);
		static void sPlot8PointsFillQuadrant(int ax, int ay, int x, int y, int quadrant, u32 aClr);
		static void sPlot8PointsQuadrant(int ax, int ay, int x, int y, int quadrant,u32 aClr);
		static void sRenderQuadrant(int ax, int ay, int aR, int quadrant, u32 aClr, int IsFill);   //draw circle
};

class TImageList{	
	public:
		unsigned int AddrInFlash;
		unsigned int AllDataSize;	// N * 4K Bytes
		unsigned int DrawMode;		// 0 = Clear   1 = Solid
		unsigned int TranparrentColor;
		
	public:
		TImageList(void){
			AllDataSize = 102400;
			DrawMode = dmClear;
			TranparrentColor = 0xFFFFFFFF;
		}
		void SetData(unsigned int aSize, unsigned int aIndex);
		void LoadFromFlash(unsigned int aSize, unsigned int aIndex);
		void LoadFromFlash(void);
		void ClearAllFlash(void);
		void WriteToFlash(unsigned int Index);
		
		void Render(unsigned int aSize, unsigned int aIndex, unsigned int aLeft, unsigned int aTop);
		void Render(unsigned int aSize, unsigned int aIndex, unsigned int aLeft, unsigned int aTop, unsigned int xLimit, unsigned int yLimit);
		
		unsigned int GetSize16Count(void);
		unsigned int GetSize24Count(void);
		unsigned int GetSize32Count(void);
};

class TImage{	
	public:
		unsigned int AddrInFlash;
		unsigned int AllDataSize;	// N * 4K Bytes
		unsigned int DrawMode;		// 0 = Clear   1 = Solid
		unsigned int TranparrentColor;
		unsigned int Width;
		unsigned int Height;
		int Left;
		int Top;
	public:
		TImage(void){
			AllDataSize = 102400;
			DrawMode = dmClear;
			TranparrentColor = 0xFFFFFFFF;
		}
		void Init(int x, int y, unsigned int aA, unsigned int aW, unsigned int aH){
			Left = x;
			Top = y;
			AddrInFlash = aA;
			Width = aW;
			Height = aH;
		}
		void Render(unsigned int xLimit, unsigned int yLimit);
};


class TVScrollBar{
	public:
		static void sDrawByPoint(int x, int y, int Right, int Bottom, u32 aClr, u32 aBClr, int aItemsCount, int aLineCount, int aTopIndex);
		static void sDrawBySize(int x, int y, int aW, int aH, u32 aClr, u32 aBClr, int aItemsCount, int aLineCount, int aTopIndex);
};

class TBevel{
	public:
		static void DrawRaised(int x, int y, int Right, int Bottom, u32 aClr, u32 aBClr, int aItemsCount, int aLineCount, int aTopIndex);
		static void DrawLowered(int x, int y, int Right, int Bottom, u32 aClr, u32 aBClr, int aItemsCount, int aLineCount, int aTopIndex);
};

class TRoundBox{
	
};

class TCanvas{
	
};

class TProgressBar{
	public:
		static void sDrawByPoint(int x, int y, int Right, int Bottom, int aPercent, int aMax, u32 aClr, u32 aBClr, u32 aTClr);
		static void sDrawBySize(int x, int y, int aW, int aH, int aPercent, int aMax, u32 aClr, u32 aBClr, u32 aTClr);
};

class TRoundSquare{
	public:
		static void sDrawBySize(int x, int y, int aW, int aH, int RoundR, u32 aClr, int Active);
		static void sSelected(int ax, int ay, int aW, int aH, int aThick, u32 aColor);
};

class TRoundRect{
	public:
		static void sDrawBySize(int x, int y, int aW, int aH, int RoundR, u32 aClr, char *Text,  int LeftSpace, u32 TextClr);
};

class TTriangleLeftRight{
	public:
		static int sDrawByHight(int x, int y, int aH, unsigned int aClr);
		static int sDrawLeftByHight(int x, int y, int aH, unsigned int aClr);
		static int sDrawRightByHight(int x, int y, int aH, unsigned int aClr);
};


#endif
