Discussion of article "Graphical interfaces X: Advanced management of lists and tables. Code optimization (build 7)" - page 7

 
Anatoli Kazharski:
Not enough data to reproduce. Give me a complete example so that I can replicate it myself.

In a private message then - you need additional classes there.

Yes, it happens after rebuilding the table.

 
Anatoli Kazharski:
Not enough data to reproduce. Please attach a complete example so that I can repeat it myself.

Tol, on the previous question and on the private message with a code example without tambourines: Take your example from Experts\Article10\TestLibrary06.

In Program.mqh in the timer you just write a few lines, compile and watch.

//+------------------------------------------------------------------+
//| Timer|
//+------------------------------------------------------------------+
void CProgram::OnTimerEvent(void)
  {
   CWndEvents::OnTimerEvent();
//--- Pause between element updates
   if(m_counter1.CheckTimeCounter())
     {
      //--- Updating the second item of the status bar
      m_status_bar.ValueToItem(1,::TimeToString(::TimeLocal(),TIME_DATE|TIME_SECONDS));
      //--- Redraw the graph
      m_chart.Redraw();
     }
//--- Pause between element updates
   if(m_counter2.CheckTimeCounter())
     {
      //--- Enter the price value of the current symbol into the Price of the first row
      MqlTick tick;

      if(SymbolInfoTick(Symbol(),tick))
        {
         int dg=(int)SymbolInfoInteger(Symbol(),SYMBOL_DIGITS);
         m_table.SetValue(1,1,DoubleToString(tick.bid,dg),dg);
         m_table.UpdateTable();
        }

      //--- Add a row to the table if the total number is less than the specified one
      if(m_table.RowsTotal()<m_spin_edit1.GetValue())
         m_table.AddRow();
      //--- Add a column to the table if the total number of columns is less than the specified number.
      if(m_table.ColumnsTotal()<m_spin_edit2.GetValue())
         m_table.AddColumn();
      //--- Add an item to the list if the total number is less than the specified number.
      if(m_listview.ItemsTotal()<m_spin_edit5.GetValue())
        {
         m_listview.AddItem("SYMBOL "+string(m_listview.ItemsTotal()));
         //--- Move the scroll bar slider to the end of the list
         m_listview.Scrolling();
        }
      //--- Add an item to the list from the checkboxes if the total number is less than the specified one
      if(m_checkbox_list.ItemsTotal()<m_spin_edit5.GetValue())
        {
         m_checkbox_list.AddItem("Checkbox "+string(m_checkbox_list.ItemsTotal()));
         //--- Move the scroll bar slider to the end of the list
         m_checkbox_list.Scrolling();
        }
      //--- Redraw the graph
      m_chart.Redraw();
     }
  }
//+------------------------------------------------------------------+

Without a row with table update, there is no price in the first column of the first row. If there is, the price is entered and changed, but the table is constantly redrawn, and it is no longer possible to work with it.

What should I do if I need real-time updating of many rows of the table? (many symbols, and for each you need to display the current price)

 
Artyom Trishkin:

Tol, regarding the previous question and the personal message with a code example without tambourines: Take your example from Experts\Article10\TestLibrary06.

In Program.mqh in the timer just write a few lines, compile and watch.

...

Without a row with table update, there is no price in the first column of the first row. If there is, the price is entered and changed, but the table is constantly redrawn, and it is no longer possible to work with it.

What should I do if I need real-time updating of many rows of the table? (many symbols, and for each you need to display the current price).

Perhaps (at first glance), it will be necessary to slightly modify the CTable::SetValue() method, so that it would be possible to change the value of the specified cell with updating only this cell (if it is in the visible area), and not the whole table.

I'll take a look when I'm done working on the current article.

P.S. I will fix blinking of the highlighted row too.

 
Anatoli Kazharski:

Perhaps (at first glance), you'll need to modify the CTable::SetValue() method a bit to allow you to change the value of a specified cell with only that cell updated (if it's in the visible area), not the entire table.

I'll take a look when I'm done working on the current article.

P.S. I'll fix the blinking of the highlighted row too.

Is there a "quick" solution that can be done "right now"?
 
Artyom Trishkin:
There is no "quick" solution, which is "right now"?

To prevent the selected table row from blinking, add these lines to the CTable::UpdateTable() method in the last loop:

//--- Columns
   for(uint c=l; c<m_visible_columns_total; c++)
     {
      //--- Get the current position of the vertical scroll bar slider
      v=m_scrollv.CurrentPos()+t;
      //--- Rows
      for(uint r=t; r<m_visible_rows_total; r++)
        {
         //--- Offset table data
         if(v>=t && v<m_rows_total && h>=l && h<m_columns_total)
           {
            //--- Adjustment for the highlighted line
            color back_color=(m_selected_item==v) ? m_selected_row_color : m_vcolumns[h].m_cell_color[v];
            color text_color=(m_selected_item==v) ? m_selected_row_text_color : m_vcolumns[h].m_text_color[v];

            //--- Adjust (1) values, (2) background colour, (3) text colour and (4) text alignment in cells
            SetCellParameters(c,r,m_vcolumns[h].m_vrows[v],back_color,text_color,m_vcolumns[h].m_text_align[v]);
            v++;
           }
        }
      //---
      h++;
     }

//---

And with the rest you need more details.

Artyom Trishkin:

If you update the table every time a new tick is received, it becomes impossible to work with the table - it blinks, the selected row blinks , etc,etc,etc....

What is this? :

  1. pr.
  2. pr.
  3. pr...
 
Anatoli Kazharski:

To prevent the highlighted row from blinking, add these lines to the CTable::UpdateTable() method in the last loop:

//--- Columns
   for(uint c=l; c<m_visible_columns_total; c++)
     {
      //--- Get the current position of the vertical scroll bar slider
      v=m_scrollv.CurrentPos()+t;
      //--- Rows
      for(uint r=t; r<m_visible_rows_total; r++)
        {
         //--- Offset table data
         if(v>=t && v<m_rows_total && h>=l && h<m_columns_total)
           {
            //--- Adjustment for the highlighted line
            color back_color=(m_selected_item==v) ? m_selected_row_color : m_vcolumns[h].m_cell_color[v];
            color text_color=(m_selected_item==v) ? m_selected_row_text_color : m_vcolumns[h].m_text_color[v];

            //--- Adjust (1) values, (2) background colour, (3) text colour and (4) text alignment in cells
            SetCellParameters(c,r,m_vcolumns[h].m_vrows[v],back_color,text_color,m_vcolumns[h].m_text_align[v]);
            v++;
           }
        }
      //---
      h++;
     }

//---

And with the rest you need more details.

What is this? :

  1. Ave.
  2. pr.
  3. pr--
Thanks for correcting the code, and about "pr, pr, pr, pr". - maybe I was in a hurry to write it that way ;) I'll see how and what will be with corrections, then I'll report back. But one thing that I can already say is that the whole table is updated, not just one row, I think. This leads to sometimes noticeable blinking when updating the whole table - this is one of the "pr."
 
Anatoli Kazharski:

To prevent the highlighted row from blinking, add these lines to the CTable::UpdateTable() method in the last loop:

//--- Columns
   for(uint c=l; c<m_visible_columns_total; c++)
     {
      //--- Get the current position of the vertical scroll bar slider
      v=m_scrollv.CurrentPos()+t;
      //--- Rows
      for(uint r=t; r<m_visible_rows_total; r++)
        {
         //--- Offset table data
         if(v>=t && v<m_rows_total && h>=l && h<m_columns_total)
           {
            //--- Adjustment for the highlighted line
            color back_color=(m_selected_item==v) ? m_selected_row_color : m_vcolumns[h].m_cell_color[v];
            color text_color=(m_selected_item==v) ? m_selected_row_text_color : m_vcolumns[h].m_text_color[v];

            //--- Adjust (1) values, (2) background colour, (3) text colour and (4) text alignment in cells
            SetCellParameters(c,r,m_vcolumns[h].m_vrows[v],back_color,text_color,m_vcolumns[h].m_text_align[v]);
            v++;
           }
        }
      //---
      h++;
     }

No, nothing has changed in behaviour - it still blinks. If the mouse cursor is above the table, it blinks, if the mouse cursor is outside the window, there is no visible row selection at all.
 
Artyom Trishkin:
No, nothing has changed in behaviour - it still blinks. If the mouse cursor is above the table, it blinks, if the mouse cursor is outside the window, there is no visible row selection at all.
This is not the case with my changes. The highlighted row no longer blinks on the example you suggested to test.
 
Anatoli Kazharski:
I don't see this with the changes I've made. The highlighted line no longer blinks on the example you suggested to test.
Tol, I'll take a look at that example - I've looked through it in my programme, but now I have to run away. When I come back, I'll write you back.
 
Artyom Trishkin:
Tol, I'll have a look at that example - I've looked through it in my programme, but now I have to run away. When I come back, I'll write you back.
Good. Let's continue later on the example we started with here. Complete it to the level when the problem starts to appear.