#property indicator_chart_window

extern int nWindow = 0;
extern string nCellName = "test"; 
extern double nX = 200; 
extern double nY = 200; 
extern double nWidth= 20; 
extern double nHeight= 100; 
extern color nColor=White ;
 

int start()
{
   ObjectsDeleteAll(0);
   DrawCell(nWindow,nCellName,nX,nY,nHeight,nHeight,nColor);
   return(0);
}

//=========================================================
// DrawCell.
//
// Author:        Alexandre A. B. Borela
// Description:   Draws a cell using the minimum character
//                as it can, so it's going to take less time
//                to draw the cell.
void DrawCell(int nWindow, string nCellName, double nX, double nY, double nWidth, double nHeight, color nColor)
{
   double   iHeight, iWidth, iXSpace;
   int      iSquares, i;
   
   if(nWidth > nHeight)
   {
     iSquares = MathCeil(nWidth/nHeight);      // Number of squares used.
     iHeight  = MathRound((nHeight*100)/77);   // Real height size.
     iWidth   = MathRound((nWidth*100)/77);    // Real width size.
     iXSpace  = iWidth/iSquares - ((iHeight/(9-(nHeight/100)))*2);
     
      for(i=0;i<iSquares;i++)
      {
         ObjectCreate   (nCellName+i, OBJ_LABEL,nWindow,0,0);
         ObjectSetText  (nCellName+i, CharToStr(110),iHeight, "Wingdings", nColor);
         ObjectSet      (nCellName+i, OBJPROP_XDISTANCE,nX + iXSpace*i);
         ObjectSet      (nCellName+i, OBJPROP_YDISTANCE,nY);    
         ObjectSet      (nCellName+i, OBJPROP_BACK, true);
      }        
   }else{
      iSquares = MathCeil(nHeight/nWidth);      // Number of squares used.
      iHeight  = MathRound((nHeight*100)/77);   // Real height size.
      iWidth   = MathRound((nWidth*100)/77);    // Real width size.
      iXSpace  = iHeight/iSquares - ((iWidth/(9-(nWidth/100)))*2);   
 
      for(i=0;i<iSquares;i++)
      {
         ObjectCreate   (nCellName+i, OBJ_LABEL,nWindow,0,0);
         ObjectSetText  (nCellName+i, CharToStr(110),iWidth, "Wingdings", nColor);
         ObjectSet      (nCellName+i, OBJPROP_XDISTANCE,nX);
         ObjectSet      (nCellName+i, OBJPROP_YDISTANCE,nY + iXSpace*i);    
         ObjectSet      (nCellName+i, OBJPROP_BACK, true);
      }       
   }
}


