class COutGridEx { private: int m_width; int m_height; Corner m_corner; int c_widths[]; int c_heights[]; int orig_loc_x; int orig_loc_y; int loc_x; int loc_y; int padding_hor; int padding_vert; string __id; color NegateColor(color in){ return (color) ((((int)in) & 0x00ffffff) ^0x00ffffff); } void OG_AddCell(int x,int y,int width,int height,Corner corner=CTopLeft,int fontsize=12,string fontname="Tahoma",color clr=clrWhite){ string lname=StringFormat("__rect_%s_%d_%d",__id,x,y); string lname_t=StringFormat("__lbl_%s_%d_%d",__id,x,y); if(ObjectFind(0,lname)!=-1){ ObjectDelete(0,lname); } if(ObjectFind(0,lname_t)!=-1){ ObjectDelete(0,lname_t); } int __corner=0; int __anchor=0; c_widths[x]=width; c_heights[y]=height; ObjectCreate(0,lname,OBJ_RECTANGLE_LABEL,0,0,0); ObjectSetInteger(0,lname,OBJPROP_CORNER,__corner); ObjectSetInteger(0,lname,OBJPROP_ANCHOR,__anchor); ObjectSetInteger(0,lname,OBJPROP_BACK,1); ObjectSetInteger(0,lname,OBJPROP_BORDER_TYPE,4); ObjectSetInteger(0,lname,OBJPROP_BGCOLOR,clrNONE); ObjectSetInteger(0,lname,OBJPROP_SELECTABLE,0); ObjectSetInteger(0,lname,OBJPROP_HIDDEN,1); // ObjectCreate(0,lname_t,OBJ_LABEL,0,0,0); ObjectSetInteger(0,lname_t,OBJPROP_CORNER,__corner); ObjectSetInteger(0,lname_t,OBJPROP_ANCHOR,__anchor); ObjectSetInteger(0,lname_t,OBJPROP_COLOR,clr==clrNONE?(NegateColor(((color)ChartGetInteger(0,CHART_COLOR_BACKGROUND)))):clr); ObjectSetString(0,lname_t,OBJPROP_FONT,fontname); ObjectSetInteger(0,lname_t,OBJPROP_FONTSIZE,fontsize); ObjectSetString(0,lname_t,OBJPROP_TEXT," "); ObjectSetInteger(0,lname_t,OBJPROP_TIME3,ALIGN_LEFT); ObjectSetInteger(0,lname_t,OBJPROP_SELECTABLE,0); ObjectSetInteger(0,lname_t,OBJPROP_HIDDEN,1); } void OG_UpdateCell(int x,int y){ string lname=StringFormat("__rect_%s_%d_%d",__id,x,y); string lname_t=StringFormat("__lbl_%s_%d_%d",__id,x,y); ObjectSetInteger(0,lname,OBJPROP_XDISTANCE,loc_x+x_offset_of(x,spacing_hor)); ObjectSetInteger(0,lname,OBJPROP_YDISTANCE,loc_y+y_offset_of(y,spacing_vert)); ObjectSetInteger(0,lname,OBJPROP_XSIZE,width_of(x)); ObjectSetInteger(0,lname,OBJPROP_YSIZE,height_of(y)); //ObjectSetInteger(0,lname_t,OBJPROP_XDISTANCE,loc_x+x_offset_of(x,spacing_hor)); //ObjectSetInteger(0,lname_t,OBJPROP_YDISTANCE,loc_y+y_offset_of(y,spacing_vert)); ObjectSetInteger(0,lname_t,OBJPROP_XDISTANCE,loc_x+x_offset_of(x,spacing_hor)+padding_hor); ObjectSetInteger(0,lname_t,OBJPROP_YDISTANCE,loc_y+y_offset_of(y,spacing_vert)+padding_vert); ObjectSetInteger(0,lname_t,OBJPROP_XSIZE,width_of(x)); ObjectSetInteger(0,lname_t,OBJPROP_YSIZE,height_of(y)); ENUM_ALIGN_MODE align=(ENUM_ALIGN_MODE)ObjectGetInteger(0,lname_t,OBJPROP_TIME3); P(x,y,ObjectGetString(0,lname_t,OBJPROP_TEXT),(int)ObjectGetInteger(0,lname_t,OBJPROP_COLOR),-1,align); } int x_offset_of(int x,int shift=0){ int asize=ArraySize(c_widths); if(x<0 || x>=asize)return 0; int sum=0; for(int i=0;i=asize)return 0; int sum=0; for(int i=0;i=asize)return 0; return c_widths[x]; } int height_of(int y){ int asize=ArraySize(c_heights); if(y<0 || y>=asize)return 0; return c_heights[y]; } public: void SetLocation(int x,int y){ orig_loc_x=x; orig_loc_y=y; UpdatePosition(); } int GetLocationX(){ return loc_x; } int GetLocationY(){ return loc_y; } int spacing_hor; int spacing_vert; void SetSpacing(int hor,int vert){ spacing_hor=hor; spacing_vert=vert; } void SetPadding(int hor,int vert){ padding_hor=hor; padding_vert=vert; } COutGridEx(string _id,int width,int height,Corner corner,int default_width=100, int default_height=20){ m_width=width; m_height=height; m_corner=corner; __id=_id; ArrayResize(c_widths,m_width); ArrayResize(c_heights,m_height); for(int y=0;y=asize)return; c_widths[x]=new_width; if(autoupdate)Update(); } int GetColumnWidth(int x){ int asize=ArraySize(c_widths); if(x<0 || x>=asize)return 0; return c_widths[x]; } void SetRowHeight(int y,int new_height,bool autoupdate=false){ int asize=ArraySize(c_heights); if(y<0 || y>=asize)return; c_heights[y]=new_height; if(autoupdate)Update(); } int GetRowHeight(int y){ int asize=ArraySize(c_heights); if(y<0 || y>=asize)return 0; return c_heights[y]; } void SetColumnAutoWidth(int x,int add=0){ int maxwidth=0; for(int i=0;i=PeriodSeconds(PERIOD_W1)){ dd0=TimeYear(dt_0)*12; dd1=TimeYear(dt_1)*12; } } if(PeriodSeconds(timeframe)=MathMax(PeriodSeconds(PERIOD_D1),PeriodSeconds(timeframe)))){ if(idx==shift)return i; else idx++; } } else { if(dd0!=dd1){ if(idx==shift)return i; else idx++; } } i++; } return -1; }