ctrl Scatter {
	group "Extra";

	GetMinSize() {sz.cx=150; sz.cy = 100; return sz; }
	GetStdSize() {sz.cx=300; sz.cy = 200; return sz; }
	
	Frame  SetFrame @20;
	Color  SetColor =:White @1;
	Text SetTitle @5;
	Font SetTitleFont @6;
	Color SetTitleColor =:Black @7;
	int H_Border =30 @2;
	int V_Border =30 @3;
	Color SetPlotAreaColor =:WhiteGray @4;
	Text SetLabelX @8;
	Text SetLabelY @9;
	Font SetLabelsFont @10;
	Color SetLabelsColor=:Black @11;
	Color SetAxisColor =:Black @12;
	int SetAxisWidth =6 @13;
	Color SetGridColor=:Color(102,102,102);
	int SetGridWidth=-4;
	bool ShowHGrid=true;
	bool ShowVGrid=true;
	bool ShowLegend=true;
	int SetLegendWeight=80;	
	bool SetFastViewX=false;
	bool SetSequentialXAll=false;

	Paint(w) {          
		r = GetRect();
		w.DrawRect(r, .SetColor);
		DrawCtrlFrame(w, r, .SetFrame);
		sz = GetSize();
		textsize = GetTextSize(.SetTitle, .SetTitleFont); 
		if(.SetTitle=="") textsize.cy=0;
		HB=0;
		if(.H_Border>0) HB=.H_Border;		
		VB=0;
		if(.V_Border>0) VB=.V_Border;
		w.DrawRect(HB-1,VB-1+textsize.cy,-2*HB+2+sz.cx,-2*VB+2-textsize.cy+sz.cy,:Gray);
		aw=6;
		if(.SetAxisWidth >= 6) aw=.SetAxisWidth;
		
		w.DrawRect(HB-int(aw/6),
					VB+textsize.cy,
					-2*HB+int(aw/6)+sz.cx,
					-2*VB+int(aw/6)-textsize.cy+sz.cy,
					.SetAxisColor);
		w.DrawRect(HB,VB+textsize.cy,-2*HB+sz.cx,-2*VB-textsize.cy+sz.cy,.SetPlotAreaColor);
		
		w.DrawText((sz.cx - textsize.cx) / 2, 4, .SetTitle, .SetTitleFont, .SetTitleColor);
		lx=GetTextSize(.SetLabelX,.SetLabelsFont);
		ly=GetTextSize(.SetLabelY,.SetLabelsFont);
		
		w.DrawText(int((sz.cx-lx.cx)/2),sz.cy -(ly.cy+2),.SetLabelX,.SetLabelsFont,.SetLabelsColor);
		w.DrawText(2,int((sz.cy+textsize.cy+ly.cx)/2),900,.SetLabelY,.SetLabelsFont,.SetLabelsColor);	
       
	}
};
enum_property titlePosition {
	"0" : "BOTTOM",
	"1" : "TOP"
};
ctrl PieChart {
	group "Extra";
	
	GetMinSize() {sz.cx=50; sz.cy = 50; return sz; }
	GetStdSize() {sz.cx=200; sz.cy = 200; return sz; }
	
	Frame  SetFrame @20;
	Color  SetColor =:White @1;
	Text SetTitle @5;
	Font SetTitleFont =StdFont(16)@6;
	Color SetTitleColor =:Black @7;
	titlePosition TitlePos = 1;
	int SetTitleGap=2;
	int SetRadius=60;
	bool ShowPercent=true;
	Color SetPercentBack=Null;
	Font SetLegendFont;
	Color SetLegendTextColor=:Black;
	Color SetLegendBackColor=Null;
	int SetLegend_cx=60;
	int SetLegend_cy=120;
	bool SetShowLegend=true;
	
	Paint(w) {          
		r = GetRect();
		w.DrawRect(r, .SetColor);
		DrawCtrlFrame(w, r, .SetFrame);
		sz = GetSize();
		textsize = GetTextSize(.SetTitle, .SetTitleFont);
		Gap=0;
		if(.SetTitleGap>0) Gap=.SetTitleGap;
		if(.TitlePos=="1") w.DrawText((sz.cx - textsize.cx) / 2, Gap, .SetTitle, .SetTitleFont, .SetTitleColor);
		else w.DrawText((sz.cx - textsize.cx) / 2, sz.cy-textsize.cy-Gap, .SetTitle, .SetTitleFont, .SetTitleColor);
		
		if(.SetTitle=="") textsize.cy=0;
		radius=0;
		if(.SetRadius>0) radius=.SetRadius;
		lcx=0;
		lcy=0;
		numitor=2;
		legendBk=.SetColor;
		if(.SetLegendBackColor!=Null) legendBk=.SetLegendBackColor;
		if(.SetLegend_cx>0 && .SetShowLegend) {lcx=.SetLegend_cx; numitor=3;}
		if(.SetLegend_cy>0 && .SetShowLegend) lcy=.SetLegend_cy;
		if(.TitlePos=="1") 
		{
			w.DrawRect((sz.cx-2*radius-lcx)/numitor, (sz.cy+Gap+textsize.cy-2*radius)/2, 2*radius,2*radius,:Gray);
			w.DrawRect((sz.cx-2*radius-lcx)/numitor+2, (sz.cy+Gap+textsize.cy-2*radius)/2+2, 2*radius-4,2*radius-4,:White);
			w.DrawRect(2*(sz.cx+radius-lcx)/3, (sz.cy+Gap+textsize.cy-lcy)/2, lcx,lcy,:Gray);
			w.DrawRect(2*(sz.cx+radius-lcx)/3+2, (sz.cy+Gap+textsize.cy-lcy)/2+2, lcx-4,lcy-4,legendBk);
			if(.SetShowLegend)
				w.DrawText(2*(sz.cx+radius-lcx)/3+2, (sz.cy+Gap+textsize.cy-lcy)/2+2,"LEGEND",.SetLegendFont, .SetLegendTextColor);
		}
		else
		{
 			w.DrawRect((sz.cx-2*radius-lcx)/numitor, (sz.cy-Gap-textsize.cy-2*radius)/2, 2*radius,2*radius,:Gray);
 			w.DrawRect((sz.cx-2*radius-lcx)/numitor+2, (sz.cy-Gap-textsize.cy-2*radius)/2+2, 2*radius-4,2*radius-4,:White);
 			w.DrawRect(2*(sz.cx+radius-lcx)/3, (sz.cy-Gap-textsize.cy-lcy)/2, lcx,lcy,:Gray);
 			w.DrawRect(2*(sz.cx+radius-lcx)/3+2, (sz.cy-Gap-textsize.cy-lcy)/2+2, lcx-4,lcy-4,legendBk);
 			if(.SetShowLegend)
 				w.DrawText(2*(sz.cx+radius-lcx)/3+2, (sz.cy-Gap-textsize.cy-lcy)/2+2,"LEGEND",.SetLegendFont, .SetLegendTextColor);
		}
		
	}
};
