Discussion of article "Graphical Interfaces X: Sorting, rebuilding the table and controls in the cells (build 11)" - page 9

 
Anatoli Kazharski:
Alignment of what?

to display the picture, you need to align the text in the table cell after calling the AddRow method, you yourself wrote me about it and before that I also guessed what I wrote above.
 
Konstantin:

to display the picture, you need to align the text in the table cell after calling the AddRow method, you wrote about it yourself and before that I also guessed what I wrote above

The text is aligned by default for the whole column. When adding rows(AddRow) the default value remains the same.

There is also such a method:

CCanvasTable::TextAlign(const ENUM_ALIGN_MODE &array[])
 
Anatoli Kazharski:
The text is aligned by default for the whole column. When adding rows(AddRow) the default value remains the same.


then it is not clear why the image is not displayed in the added row:

      if(a_table.RowsTotal() < _count) {
         a_table.AddRow(_count - 1, true);

         //--- array of pictures
         string _image[3]= { "::Images\\EasyAndFastGUI\\Icons\\bmp16\\circle_gray.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_up.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_down.bmp" };
         a_table.SetImages(1, r, _image);
      }
 
Konstantin:

By the way, if the number of rows in the table is not known in advance, then when you add them later, the information is added to the cells, but you can't change the alignment on the column with the picture:

maybe there is some other mechanism, tell me.

I made a function to add rows to the table: it reads data from the file about the symbols ticked in the table with the list of working symbols (which should be displayed in the main table) and adds them to the table:

//+------------------------------------------------------------------+
//| Adds a row to the data table |
//+------------------------------------------------------------------+
void CProgram::AddSymbolToTableMain(void){
   string img_butt0[1];    img_butt0[0]=m_img_graphic;
   string img_butt8[1];    img_butt8[0]=m_img_buy;
   string img_butt9[1];    img_butt9[0]=m_img_sell;
   string img_butt10[1];   img_butt10[0]=m_img_close;
   //---
   uint sz_used=FillingListUsedSymbols();       // Fill the file with ticked characters
   uint row=m_table_main.RowsTotal();
   string sy=m_symbol;
   for(ushort i=0; i<sz_used; i++) {
      sy=m_array_data_symbols[i].symbol_name;
      short index=IndexSymbolInTableMain(sy);   // Symbol index in the main table
      //--- if the symbol does not exist in the table yet
      if(index==WRONG_VALUE) {               
         m_table_main.AddRow(i);                // Add a row to the table
         }
      //--- Set table column parameters
      m_table_main.CellType(0,i,CELL_BUTTON);
      m_table_main.SetImages(0,i,img_butt0);
      m_table_main.CellType(8,i,CELL_BUTTON);
      m_table_main.SetImages(8,i,img_butt8);
      m_table_main.CellType(9,i,CELL_BUTTON);
      m_table_main.SetImages(9,i,img_butt9);
      m_table_main.CellType(10,i,CELL_BUTTON);
      m_table_main.SetImages(10,i,img_butt10);
      //---
      m_table_main.SetValue(0,i,sy,0);
      m_table_main.TextColor(0,i,(SymbolInfoInteger(sy,SYMBOL_TRADE_MODE)==SYMBOL_TRADE_MODE_DISABLED ? NewColor(clrRed,100,100,100) : 
                                  SymbolInfoInteger(sy,SYMBOL_TRADE_MODE)==SYMBOL_TRADE_MODE_FULL ?     NewColor(clrDimGray,0,50,0) : clrLightGray));
      for(uchar c=2; c<m_table_main.ColumnsTotal(); c++) m_table_main.TextColor(c,i,clrDimGray);
      }
   m_table_main.UpdateTable(true);
   CreateClasses();
}
//+------------------------------------------------------------------+


 
Artyom Trishkin:

I made a function to add rows to the table: it reads data from the file about the characters ticked in the table with the list of working characters (which should be output to the main table) and adds them to the table:

Good example. Because I want to help, but I don't have time. )

Based on our previous discussions, I will add simpler methods for changing table parameters. In the coming updates will be available.

 
Artyom Trishkin:

I made a function to add rows to the table: it reads data from the file about the symbols ticked in the table with the list of working symbols (which should be displayed in the main table) and adds them to the table:


I don't understand anything, I do the same thing, but the picture doesn't appear, although all the data is added and updated:

/*!
 \brief Update table values
 \param CWrapTradePair &a_pair - pointer to array with signal data
 \param CCanvasTable &a_table - table object
*/
void CTblSignal::UpdateTable(CWrapTradePair &a_pair,CCanvasTable &a_table) {
   MqlDateTime _date;
   ::TimeToStruct(::TimeTradeServer(), _date);

   //--- weekend check
   if(_date.day_of_week == 0 || _date.day_of_week == 6)
      return;

   //--- decompose the data into a table
   uint _count = 0;
   for(uint r = 0, _size = a_pair.Size(); r < _size; ++r) {
      if(!a_pair[r].coint)
         continue;

      _count++;
      //--- if there are not enough rows, add and update the table structure
      if(a_table.RowsTotal() < _count) {
         a_table.AddRow(_count - 1, true);

         a_table.CellType(1, r, CELL_BUTTON);

         //--- array of pictures
         string _image[3]= { "::Images\\EasyAndFastGUI\\Icons\\bmp16\\circle_gray.bmp",
                             "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_up.bmp",
                             "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_down.bmp" };
         a_table.SetImages(1, r, _image);
      }

      if(a_pair[r].event == COINT_BS_NOISE || a_pair[r].event == COINT_SB_NOISE) {
         //--- "Ticker"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_NOISE, true);
         //--- "Signal"
         a_table.ChangeImage(1, _count - 1, 0, true);
         //--- "DF-test"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_NOISE, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_NOISE, true);
      } else if(a_pair[r].event == COINT_BS || a_pair[r].event == COINT_SB) {
         //--- "Ticker"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_BSSB, true);
         //--- "Signal"
         a_table.ChangeImage(1, _count - 1, 1, true);
         //--- "DF-test"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_BSSB, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_BSSB, true);
      } else {
         //--- "Ticker"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_NOT, true);
         //--- "Signal"
         a_table.ChangeImage(1, _count - 1, 2, true);
         //--- "DF-test"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_NOT, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_NOT, true);
      }
   }

//--- check the table for extra rows
   for(uint r = _count, _size = a_table.RowsTotal(); r < _size; ++r)
      a_table.DeleteRow(r, true);

//--- Update table
   a_table.UpdateTable();
}


what can be the error, please tell me, because all work further stands still ))

 
Konstantin:

I don't understand anything, I'm doing the same thing, but the picture doesn't appear, although all the data is added and updated:


what can be the error, please, and then all work further stands still ))

And where do you set the alignment for columns with pictures?

There should be an array where each column has its alignment set.

 
I made tests and realised that everything depends on the number of rows set in advance by the TableSize method, I need to dig in the source code, for some reason it affects images exactly.
 
Artyom Trishkin:
Where do you set the alignment for columns with pictures?


I do it in the table creation method, but if I add it like this:

/*!
 \brief Update table values
 \param CWrapTradePair &a_pair - pointer to array with signal data
 \param CCanvasTable &a_table - table object
*/
void CTblSignal::UpdateTable(CWrapTradePair &a_pair,CCanvasTable &a_table) {
   //--- decompose the data into a table
   uint _count = 0;
   for(uint r = 0, _size = a_pair.Size(); r < _size; ++r) {
      if(!a_pair[r].coint)
         continue;

      _count++;
      //--- if there are not enough rows, add and update the table structure
      if(a_table.RowsTotal() < _count) {
         a_table.AddRow(_count - 1, true);

         //--- array of text alignment in columns
         ENUM_ALIGN_MODE _align[TBL_COLUMNS_TOTAL];
         ::ArrayInitialize(_align, ALIGN_RIGHT);
         _align[1] = ALIGN_LEFT;
         m_table.TextAlign(_align);

         a_table.CellType(1, r, CELL_BUTTON);

         //--- array of pictures
         string _image[3]= { "::Images\\EasyAndFastGUI\\Icons\\bmp16\\circle_gray.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_up.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_down.bmp" };
         a_table.SetImages(1, r, _image);
      }

      if(a_pair[r].event == COINT_BS_NOISE || a_pair[r].event == COINT_SB_NOISE) {
         //--- "Ticker"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_NOISE, true);
         //--- "Signal"
         a_table.ChangeImage(1, _count - 1, 0, true);
         //--- "DF-test"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_NOISE, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_NOISE, true);
      } else if(a_pair[r].event == COINT_BS || a_pair[r].event == COINT_SB) {
         //--- "Ticker"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_BSSB, true);
         //--- "Signal"
         a_table.ChangeImage(1, _count - 1, 1, true);
         //--- "DF-test"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_BSSB, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_BSSB, true);
      } else {
         //--- "Ticker"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_NOT, true);
         //--- "Signal"
         a_table.ChangeImage(1, _count - 1, 2, true);
         //--- "DF-test"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_NOT, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_NOT, true);
      }
   }

//--- check the table for extra rows
   for(uint r = _count, _size = a_table.RowsTotal(); r < _size; ++r)
      a_table.DeleteRow(r, true);

//--- Update table
   a_table.UpdateTable(true);
}

it still doesn't change anything ((

 

the issue's been resolved, I made a mistake in the indexing:

      if(a_table.RowsTotal() < _count) {
         a_table.AddRow(_count - 1, true);
         
         //--- делать дополнительно выравнивание не нужно, все сохраняется от первой строки

         a_table.CellType(1, _count - 1, CELL_BUTTON);

         //--- array of pictures
         string _image[3]= { "::Images\\EasyAndFastGUI\\Icons\\bmp16\\circle_gray.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_up.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_down.bmp" };
         a_table.SetImages(1, _count - 1, _image);
      }