Einzelnen Beitrag anzeigen
  #11 (permalink)  
Alt 19.11.13
pako pako ist offline
Mitglied
 
Registriert seit: Sep 2012
Beiträge: 224
pako befindet sich auf einem aufstrebenden Ast
Standard

Zitat:
Zitat von Ca$hDigger Beitrag anzeigen
Aber dann ist nur die Schrift größer oder? Ich möchte ja ein Hintergrund für die Schriften
Code:
//+------------------------------------------------------------------+
//| script program                                                              |
//+------------------------------------------------------------------+
int start()
{
   string Header[]={"Spalte 1","Spalte 2"};
   int ColWidth[]={9,9};
   string Content[20][2];       
      for(int i=0;i<20;i++)
      {
         for(int j=0;j<2;j++)
         {
            Content[i][j]="Spalte "+(j+1)+", Zeile "+(i+1);
         }
      }
   fObjLableTable("Table_a",Header,ColWidth,Content,5,10,10,12,Silver,Navy,true,Gainsboro,Black);
   fObjLableTable("Table_b",Header,ColWidth,Content,45,110,10,10,Red,Yellow,true,Lime,Blue);   
   fObjLableTable("Table_c",Header,ColWidth,Content,125,180,10,8,Black,White,true,White,Black);     
   fObjLableTable("Table_d",Header,ColWidth,Content,250,230,10,6,Aqua,Navy,true,DodgerBlue,Yellow);   
   fObjLableTable("Table_e",Header,ColWidth,Content,80,270,10,4,Yellow,Red,true,Khaki,Black);  
   fObjLableTable("Table_f",Header,ColWidth,Content,30,295,10,2,Blue,Aqua,true,Red,Yellow);    
}
void fObjLableTable(
                        string aName,
                        string aHeader[],                            
                        int aColWidth[],                            
                        string aContent[][],                         
                        int aX                     =  5,            
                        int aY                     =  10,            
                        int aRows                  =  30,           
                        int tTableSize             =  4,            
                        color aHeaderBackColor     =  Silver,        
                        color aHeaderTextColor     =  Navy,          
                        bool aHeaderBold           =  true,          
                        color aContentBackColor    =  Gainsboro,     
                        color aContentTextColor    =  Black         
                        )
                        {
   int tFontSize;
   int tBoxFontSize;
   int tBoxWidth;
   int tTextXMargin;
   int tTextYMargin;
   int tHeaderCorrector;
      switch(tTableSize){
         case 1:  tFontSize=5;   tBoxFontSize=10;  tBoxWidth=8;   tTextXMargin=5;   tTextYMargin=4;   tHeaderCorrector=-1; break;
         case 2:  tFontSize=6;   tBoxFontSize=14;  tBoxWidth=10;  tTextXMargin=6;   tTextYMargin=5;   tHeaderCorrector=-1; break;
         case 3:  tFontSize=7;   tBoxFontSize=16;  tBoxWidth=12;  tTextXMargin=6;   tTextYMargin=6;   tHeaderCorrector=-1; break;
         case 4:  tFontSize=8;   tBoxFontSize=18;  tBoxWidth=14;  tTextXMargin=6;   tTextYMargin=6;   tHeaderCorrector=-1; break;      
         case 5:  tFontSize=10;  tBoxFontSize=22;  tBoxWidth=17;  tTextXMargin=8;   tTextYMargin=8;   tHeaderCorrector=-1; break;
         case 6:  tFontSize=12;  tBoxFontSize=26;  tBoxWidth=20;  tTextXMargin=9;   tTextYMargin=9;   tHeaderCorrector=-2; break;      
         case 7:  tFontSize=14;  tBoxFontSize=32;  tBoxWidth=24;  tTextXMargin=12;  tTextYMargin=12;  tHeaderCorrector=-2; break;        
         case 8:  tFontSize=16;  tBoxFontSize=36;  tBoxWidth=28;  tTextXMargin=15;  tTextYMargin=15;  tHeaderCorrector=-3; break;   
         case 9:  tFontSize=18;  tBoxFontSize=42;  tBoxWidth=32;  tTextXMargin=18;  tTextYMargin=18;  tHeaderCorrector=-4; break;              
         case 10: tFontSize=20;  tBoxFontSize=46;  tBoxWidth=35;  tTextXMargin=18;  tTextYMargin=18;  tHeaderCorrector=-4; break;   
         case 11: tFontSize=22;  tBoxFontSize=48;  tBoxWidth=37;  tTextXMargin=18;  tTextYMargin=18;  tHeaderCorrector=-4; break;     
         case 12: tFontSize=24;  tBoxFontSize=52;  tBoxWidth=40;  tTextXMargin=21;  tTextYMargin=21;  tHeaderCorrector=-6; break;                 
      }
   int tCollXPOsAdd_1=0;
   int tCollXPOsAdd_2=0;   
   int tCollXPOsAdd_3=0;      
   string tHeaderFont="Arial";
   int tHeaderYAdd=0;
      if(aHeaderBold){
         tHeaderFont=tHeaderFont+" Black";
         tHeaderYAdd=tHeaderCorrector;
      }
   int tBoxHeight=tBoxWidth+1;         
   int tHeaderCounter=0; 
   int tRowCounter=0;
   int tWindowNumber=0;
      for(int tk=0;tk<ArraySize(aContent)/ArraySize(aHeader);tk++)
{
            if(tRowCounter==0)
{
               tCollXPOsAdd_1=0;
                  for(int ti=0;ti<ArraySize(aHeader);ti++)
                  {
                        for(int tj=0;tj<aColWidth[ti];tj++)
                        {
                           string tName=aName+"_hb_"+tHeaderCounter+"_"+ti+"_"+tj;
                           fObjLabel(tName,aX+tCollXPOsAdd_2+tCollXPOsAdd_1+tj*tBoxWidth,aY,"n",0,aHeaderBackColor,tBoxFontSize,0,"WingDings",false);
                        }      
                     fObjLabel(aName+"_ht_"+tHeaderCounter+"_"+ti,aX+tCollXPOsAdd_2+tCollXPOsAdd_1+tTextXMargin,aY+tTextYMargin+tHeaderYAdd,aHeader[ti],0,aHeaderTextColor,tFontSize,0,tHeaderFont,false);
                     tCollXPOsAdd_1+=aColWidth[ti]*tBoxWidth+1;
                  } 
               tCollXPOsAdd_3=tCollXPOsAdd_2;    
               tCollXPOsAdd_2+=tCollXPOsAdd_1+3; 
               tHeaderCounter++; 
            }
         tCollXPOsAdd_1=0;
            for(ti=0;ti<ArraySize(aHeader);ti++)
            {
                  for(tj=0;tj<aColWidth[ti];tj++)
                  {
                     fObjLabel(aName+"_cb_"+tHeaderCounter+"_"+tRowCounter+"_"+ti+"_"+tj,aX+tCollXPOsAdd_3+tCollXPOsAdd_1+tj*tBoxWidth,aY+tRowCounter*tBoxHeight+tBoxHeight,"n",0,aContentBackColor,tBoxFontSize,0,"WingDings",false);
                  }      
               fObjLabel(aName+"_ct_"+tHeaderCounter+"_"+tRowCounter+"_"+ti,aX+tCollXPOsAdd_3+tCollXPOsAdd_1+tTextXMargin,aY+tTextYMargin+tRowCounter*tBoxHeight+tBoxHeight,aContent[tk][ti],0,aContentTextColor,tFontSize,0,"Arial",false);
               tCollXPOsAdd_1+=aColWidth[ti]*tBoxWidth+1;
            }  
         tRowCounter++;
            if(tRowCounter>=aRows)
            {
               tRowCounter=0;
            }
      }
   WindowRedraw();      
}

void fObjLabel(
   string aObjectName,              
   int aX,                          
   int aY,                          
   string aText,                    
   int aCorner       =  0,         
                                   
   color aColor      =  Red,      
   int aFontSize     =  8,          
   int aWindowNumber =  0,         
   string aFont      =  "Arial",    
   bool aBack        =  false       
   )
   {   
      if(ObjectFind(aObjectName)!=aWindowNumber)
      {
         ObjectCreate(aObjectName,OBJ_LABEL,aWindowNumber,0,0);
      }      
   ObjectSet(aObjectName,OBJPROP_XDISTANCE,aX);
   ObjectSet(aObjectName,OBJPROP_YDISTANCE,aY);   
   ObjectSetText(aObjectName,aText,aFontSize,aFont,aColor);
   ObjectSet(aObjectName,OBJPROP_BACK,aBack);
   ObjectSet(aObjectName,OBJPROP_CORNER,aCorner);   
}
Angehängte Dateien
Dateityp: mq4 background.mq4 (6,8 KB, 6x aufgerufen)