Discussion of article "Graphical Interfaces XI: Rendered controls (build 14.2)" - page 2

 
Artyom Trishkin:

And another question at the same time: when drawing a text label (CTextLabel) on the background of a window that has some transparency, the labels are drawn on their opaque background, which does not react to the Alpha() method, and it does not look good ... Is it possible to make the background of labels with transparency as well?

From the article:

"Transparency in this version applies only to the background fill and frame. Text and images will remain completely opaque and sharp at any set alpha channel value."

 
Artyom Trishkin:

Hi. Tol, I didn't find something in the examples how I can draw a dividing line in the window now.

What does index mean?

What index parameter, index of what, should be passed there?

And another question at the same time: when drawing a text label (CTextLabel) on the background of a window that has some transparency, the labels are drawn on their opaque background, which does not respond to the Alpha() method, and it does not look good .... Is it possible to make the background of labels with transparency as well?


The parameter with the index should not be there. I forgot to remove it. Now you can pass any value there. I will remove this parameter in one of the next updates.

Example:

//+------------------------------------------------------------------+
//| Creates a dividing line|
//+------------------------------------------------------------------+
bool CProgram::CreateSepLine1(const int x_gap,const int y_gap)
  {
//--- Save the window pointer
   m_sep_line1.MainPointer(m_window);
//--- Dimensions
   int x_size=2;
   int y_size=72;
//--- Properties
   m_sep_line1.DarkColor(C'150,150,150');
   m_sep_line1.LightColor(clrWhite);
   m_sep_line1.TypeSepLine(V_SEP_LINE);
//--- Creating an element
   if(!m_sep_line1.CreateSeparateLine(0,x_gap,y_gap,x_size,y_size))
      return(false);
//--- Add a pointer to the element in the base
   CWndContainer::AddToElementsArray(0,m_sep_line1);
   return(true);
  }

//---

Artyom Trishkin:

...

And another question at the same time: when drawing a text label (CTextLabel) on the background of a window that has some transparency, the labels are drawn on their own opaque background, which does not react to the Alpha() method, and it looks bad ... Is it possible to make the background of labels with transparency as well?

Now the transparency of each element can be set manually. In the example below, the window background is set to alpha channel 200. The background of the text label is set to 0.

//---

Example:

//+------------------------------------------------------------------+
//|| Creates text label 1|
//+------------------------------------------------------------------+
#resource "\\Images\\EasyAndFastGUI\\Icons\\bmp16\\line_chart.bmp"
//---
bool CProgram::CreateTextLabel(const int x_gap,const int y_gap,string text)
  {
//--- Save the pointer to the main element
   m_text_label.MainPointer(m_window);
//--- Properties
   m_text_label.Alpha(0);
   m_text_label.XSize(190);
   m_text_label.YSize(20);
   m_text_label.LabelXGap(21);
   m_text_label.LabelYGap(3);
   m_text_label.IconFile("Images\\EasyAndFastGUI\\Icons\\bmp16\\line_chart.bmp");
//--- Creating an element
   if(!m_text_label.CreateTextLabel(text,x_gap,y_gap))
      return(false);
//--- Add a pointer to the element in the base
   CWndContainer::AddToElementsArray(0,m_text_label);
   return(true);
  }
 
Oleksii Chepurnyi:

From the article:

"Transparency in this version applies only to the background fill and border. Text and images will remain completely opaque and crisp at any alpha channel setting."

This is the rule for all items in the library. That is, the alpha channel can be set for each item separately.
 
Anatoli Kazharski:
This is the rule for all items in the library. That is, the alpha channel can be set for each item separately.

Thanks for the clarification. One more question:

In what coordinate system are the coordinates of the objects returned?

For example, if I take the coordinate of the right edge of the button m_button_text.X2(), then the coordinate of the button is returned in what coordinate system? The form window, or the chart window?

Here's my point: I'm building objects in a form window. If the buttons are consecutive one after another, I take the X() coordinate of the second button as the X2()+2 coordinate of the first button. The X() coordinate of the third button is the X2()+2 coordinate of the second button, and so on ... .

Everything is fine as long as the panel is at coordinate 0 of the symbol chart. If you move it to the right and switch the TF, the buttons move to the right. And the further the window-form is from the left edge of the chart, the more the buttons move away from each other.

How do I set the coordinates of each button so that they don't move around the screen when moving the form window to a new place and then switching the TF?

 
Artyom Trishkin:

Thanks for the clarification. One more question:

...

Absolute coordinates are returned. I need to convert them to relative coordinates. Relative to the element to which the element to be created is attached.

If the main element is a form, then:

...
   int x=(m_button1.X2()+5)-m_window.X();
   if(!CreateButton2(x,50,"Button 2"))
      return(false);
...

//---


 
Anatoli Kazharski:

Absolute coordinates are returned. They must be converted into relative coordinates. Relative to the element to which the element to be created is attached.

If the main element is a form, then:

//---


Thanks. Strange, I tried to do it this way - the buttons went to the left edge of the chart window when changing the tf. I'll try again more carefully.
 
Anatoli Kazharski:

Absolute coordinates are returned. They must be converted into relative coordinates. Relative to the element to which the element to be created is attached.

If the main element is a form, then:

//---


Strange. When I pass the coordinate calculated by this method into the object construction method, everything is fine....

int x=(m_button1.X2()+5)-m_window.X();

But if I pass only the calculated coordinate to the method:

int x=m_button1.X2()+5;

... and then in the method immediately subtract the value of m_window.X() from the passed coordinate, everything floats.... Although what difference does it make where to subtract it? Immediately, or already in the build method....

Maybe I've eaten something, but I can't understand why it's like this?

 

If you write one line in Program.mqh in TestLibrary14 - change of window title colour:

//+------------------------------------------------------------------+
//|| Creates the GUI of the programme |
//+------------------------------------------------------------------+
bool CProgram::CreateGUI(void)
  {
//--- Creating a panel
   if(!CreateWindow("EXPERT PANEL"))
      return(false);
   m_window.CaptionColor(clrDimGray);
   

Then minimising the window returns the colour to the default value. And the tooltips, minimise/unmodify and close buttons are repainted in the window title colour that was programmatically set. And then the colour of these buttons changes to the default colour only when the cursor is hovered over.

By the way - is it possible to make the background of these buttons transparent? For example, the window header is grey, but the buttons are blue....

 

Tol, in which of the articles in this series can you read about CKeys ?

Sometimes when entering NUMBERS in the input field, the characters of these numeric keys, which are on the key+Shift, are entered. I.e., I enter 2, but @ is entered ....

In some situations - I don't understand which ones (probably depends on the number and type of controls on the form window), pressing the Backspace key causes the controls to be deleted from the form window in the reverse order of their addition. I don't understand why it sees pressing Backspace not as a control character for the input field when the cursor is in it, but as a command to delete the controls on the form window. I.e.: I start the programme and start pressing Backspace - all the controls are deleted with each Backspace press, starting from the last one added. Eventually, the already empty window-form is deleted as well.

Is it possible to disable the reaction to Backspace while the cursor is not in the input field?

 
Artyom Trishkin:

...

By the way - is it possible to make the background of these buttons transparent? For example, the window title is grey, but the buttons are blue....

Use methods to get pointers of compound elements. The same rule applies to all elements.