Libraries: EasyAndFastGUI library for creating graphical interfaces - page 8

 

Compiling the ExampleEAF.mq5 did the trick.

I was assuming I had to compile a library when I want to create own things with it.

However, thanks a lot!

Oh and I was stumbling across this line of code at the top of most library files:

class CWindow;

Is the creation of a "fake class" some trick to avoid an #include nightmare? How can the compiler later on actually link the correct class that is really being used?

 

First, I'd like to finalise what we have... After all, there are still a lot of deficiencies.

I have some remarks on the architecture. The specified object properties and the displayed picture live their own lives, independently of each other. And a mandatory call to Update() is required, otherwise they will remain in parallel realities. I think this is wrong, considering that we have an event-based model.Manual updating (redrawing) should not be a prerequisite, it only allows you to display changes immediately, but all changes should be displayed anyway. For this purpose, a message (event) should be sent to redraw this object, which will be processed later.

I.e. roughly like this:

class CSomeControl
{
  int  m_property;
  bool m_changed;
  bool m_event_sent;
 public:
  void Property(int value)  { m_property= value;  m_changed=true;  if (!m_event_sent) m_event_sent= EventChartCustom(m_chart_id, ON_CHANGE, m_id, 0, 0); }  

  void Update()             { /*...Redrawing...*/.  m_changed=false; }

  void OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {  
    if (id==CHARTEVENT_CUSTOM+ON_CHANGE) { m_event_sent=false;  if (m_changed) Update(); }
  }                       
};
 

Using ChangeWindowWidth, I change the window width so that it goes outside the current chart. After that, when I try to move this window, it automatically sticks to the left edge of the chart. How to disable this? I can't find a place in the code.

 
Alexey Navoykov:

Using ChangeWindowWidth, I change the window width so that it goes outside the current chart. After that, when I try to move this window, it automatically sticks to the left edge of the chart. How to disable this? I can't find a place in the code.

You need to rewrite the CWindow::UpdateWindowXY() method. It is currently implemented in such a way that the edges of the window cannot go outside the chart when the window is moved.

 

By the way, about changing the window width

   m_window1.ChangeWindowWidth(NEW_WIDTH);
   m_window1.Update(true);

In MT5 everything is fine, but in MT4 it's like this

After clicking on the header, the buttons move to their proper place. Can you tell me which way to look? Where is the movement of these buttons implemented?

 
Oleksii Chepurnyi:

By the way, about changing the width of the window

In MT5 everything is fine, but in MT4 it is like this

After clicking on the header, the buttons move to their proper place. Can you tell me which way to look? Where is the movement of these buttons implemented?

Look at the Moving() method.

Try to access the window buttons via pointers and call this method.

 
Alexey Navoykov:

Yes, you need either a proportional increase in the width of all columns or just the last column. The latter is preferable.

But in the current version it is problematic to implement this even by yourself, because I have not found a method in your class to get the current column width, and all fields are private. In general, at least this method should be added.

This is how you can try to implement what you need now:

//--- Window resizing events
   if(id==CHARTEVENT_CUSTOM+ON_WINDOW_CHANGE_YSIZE)
     {
      //--- Adjust the width of the summary table column
      if(m_table_symbols.RowsTotal()>(uint)m_table_symbols.VisibleRowsTotal())
        {
         int width[]={79};
         m_table_symbols.ColumnsWidth(width);
        }
      else
        {
         int width[]={95};
         m_table_symbols.ColumnsWidth(width);
        }
      //---
      m_table_symbols.Update(true);
      m_table_symbols.GetScrollVPointer().CurrentPos(0);
      m_table_symbols.GetScrollVPointer().Update(true);
      return;
     }
 
Anatoli Kazharski:

Look at the Moving() method.

Try to access window buttons via pointers and call this method.

Yes, that's it :) Thanks!

I thought I had already looked through everything and missed the most obvious :)

 
Anatoli Kazharski:

This is how you can try to realise what you need now:

It's just a fixed column width, but we were talking about dynamically changing the width of columns based on their previous width. However, I have already completed the class by adding the int ColumnWidth(int i) method there

 

Good afternoon.

The problem is bigger :)

We create a dynamic object, for example a label

   labels[i] = new CTextLabel;
   labels[i].MainPointer(m_window1);
   labels[i].XSize(SYMBOLS_COL_WIDTH);
   labels[i].YSize(HEAD_HIGHT);
   labels[i].Alpha(SYMBOLS_HEAD_BACK_ALPHA);
   labels[i].FontSize(SYMBOLS_HEAD_FONT_SIZE);
   labels[i].TextAlign(SYMBOLS_HEAD_TEXT_ALIGN,HORIZONTAL_SPACE,0);
   labels[i].FontStyle(SYMBOLS_HEAD_FONT_STYLE);
   labels[i].BackColor(SYMBOLS_HEAD_BACK_COLOR);
   labels[i].CreateTextLabel("0",x_gap,ProfitHeadGap);
   CWndContainer::AddToElementsArray(0,labels[i]);
   labels[i].Update(true);

But how to delete it?

I delete it this way.

      labels[i].Delete();
      delete labels[i];

But after deleting it, it crashes, it says that the access to the pointer is incorrect.

As far as I understood, CWndContainer::AddToElementsArray adds the object to the common arrays, but Delete() does not delete it from there, and the window tries to access the object. I can't find any other similar to Delete().

How to delete an object correctly?