Gallery of UIs written in MQL - page 61

 
Let's move on to the next topic:

4. navigating through lists of individual item properties.

//-----------------------------------------------------------------------------------------

Let me remind you of the list of topics to consider:

1. Orienting in the list of intellisense and selecting the function of the right window.

2. Programmatically opening and closing windows.

3. Orienting in the list of intellisense and selecting the right item in the right window.

4. navigating through lists of individual element properties.

5. Parsing the name of an element and window wrapper function.

6.returning the parameter value of a selected element to a variable of its type. Consider three types of several different elements.

7. Setting values in the parameters of different types of elements. Let's see how the values will appear in the interface windows of these elements.

8. Returning the parameter values of one element, modifying and forwarding that value to another element. Consider different types of elements and values, and test forwarding between different types of elements in different windows.

9. Return previous value (_V_LAST). When and for what cases the last value is required (not to be confused with the current value).

10. Test the setting of ON/OFF/LOCK_ON/LOCK_OFF/LOCK/UNLOCK states for different types of elements.

11. Let's try to link and synchronise changes of values of elements of different types: for example, input field with buttons and slider. Let's assume that when the value of one element (manual or software) changes, the value in the second element changes accordingly.

12. Let's try to programmatically reset the range boundaries of the slider and the input field with buttons via wrapper functions. I haven't had time to test it, but something suggests that it will work. However, let's see.

13. Let's try to return element states through wrapper functions. It is included in the functionality, but I haven't had time to test it. So we'll see... The result is unknown.

14. Let's get and set colours for text and element bases. We can try to associate these colours with some simple events or value boundaries.

15. I'll tell you more about how to navigate and read the new API file printout.

//------------------------------------------

Yellow colour indicates topics that have already been covered.

 
Let's break down the topic point by point:

  • The concept of separating properties into lists, based on the "relatedness" of the elements, has been successfully implemented.
  • As a result of the implementation, 7 unique property lists were created for all types of elements.
  • Each list is assigned a special identifier. This is the prefix p (abbreviation of property) and a serial number.
  • As a result, each list can be found in intellisense by seven prefixes: p1, p2, p3, p4, p5, p6, and p7.
  • For convenience and to avoid confusion, the prefixes of property lists are imprinted in the names of wrapper functions:

  • When the prefix is entered, a list of individual properties appears. I emphasised the word "individual" on purpose, as this point is of key importance.
  • To return and set property values, the wrapper functions accept property names ONLY with the prefix written in their own name:


//--------------------------------------------------------------------------------------------------------------


  • ONLY these properties from the list are available for the checkbox. However, the list itself belongs not only to the checkbox, but also to some other elements.

//--------------------------------------------------------------------------------------------------------------


  • The C_LIST element has no special properties in its list yet. Only actions that can be performed by the wrapper (except returning V_LAST - the last value).

//--------------------------------------------------------------------------------------------------------------


  • Unlike C_LIST, the slider has a large list of available properties and actions.

//--------------------------------------------------------------------------------------------------------------


  • A wide range of available properties and actions belongs to the S_EDIT element:


Emphasis added:

Each wrapper function accepts properties only with the prefix spelled out in its name.


This is how working with lists looks like in practice(put brackets at the end, because intellisense does not work inside the brackets of wrapper functions):

The gif is slightly sped up.


As a result of the calls shown in the gif, the wrapper functions return the values of the specified properties.

Before the call, you must declare a variable to store the value of the property or the result of the function execution. More information about this in the following topics.

 

5. Parsing the name of the element and window wrapper function:


1. Element wrapper function name:

Let's look at the EDIT text input field element function example: w7_s_p4_EDIT_Comment_1();

//-------------------------------------------------------------

  • w7 - window number 7
//-------------------------------------------------------------
  • s - Return value type of this wrapper function string.
//-------------------------------------------------------------
  • p4 - Prefix of the property list of this element type.
//-------------------------------------------------------------
  • EDIT - Type of element.

//-------------------------------------------------------------

  • Comment_1 - Name of the specific element.

//-------------------------------------------------------------


2. The name of the window wrapper function:

Let's look at another function as an example: w_15_Processing_the_data();

//-------------------------------------------------------------

  • w_15 - window number 15
Note that the number does not come immediately after w, but through the dash _. This is important. )
//-------------------------------------------------------------
  • Processing_the_data - The name of this window ( for warning windows the name may not coincide with Caption - the text in the window header).

//-------------------------------------------------------------

It should be noted that the window function does not yet have a prefix for opening the list of properties. This feature will definitely appear. A special list of window properties to return/set will be generated, and a prefix will be assigned. Also the window function does not yet contain a return type letter.

For now, the function can only open or close a window.


These defects will be fixed in the next release.


 
It is recommended that this tutorial information be summarised once privately and separately, otherwise it will flood the comments in the future
 
hini #:
It is recommended to summarise this training information once privately and separately, otherwise it will flood the comments in the future
Of course, this information will be summarised and ordered as it should be.
 
In the current period of time, the order of instructions, explanations and comments is just being formed. The content of future documentation is harmoniously accumulated in the process of development and communication with users. As a consequence, the background information is presented in parts. Receiving feedback is necessary and it is an important stage that increases the quality of technical solutions. The software goes through a formative stage and will be able to achieve full functionality thanks to the active participation of the public. The result will be a complete programme with detailed documentation.
 

6.return the value ofthe parameter or property to a variable of the required type:


The type of the element parameter(int, double or string) determines the type of the element function.

It is known that element functions return the value of the parameter with one of three types: int, double or string.

However, functions also return property values...

A situation arises when the type of the parameter value may not coincide with the type of properties, which are always int.It turns out that functions return property values of the wrong type, for example double or string instead of int. This forced inconvenience is the price for the universality of functions.

The user's task is to to convert the received value to the required type by himself..


Let me emphasise: the main type of all element properties is int.


Let's take a closer look at the question-answer examples:

  • - Q: How will the function return the value of a property of type int if the function type is string?
  • - Answer: The function will return the value of int with the type string.
  • - Question: How will the function return the value ofint if the function type is double?
  • - Answer: The function will return the value of int with double type.
  • - Question: How will the function return the value double if the function type is int?
  • - Answer: Properties of elements of double type do not exist. Properties of the element's parameter can be of type double. In this case, the function itself will be of type double.


The type of the parameter value determines the type of the element's function.

There are no properties of an element of double type . Only int. But there are parameter properties that accept double, string or int types. For example, V_CURRENT, V_LAST, V_MAX, V_MIN, V_STEP can be either int or double. In both cases, the element function will also become int or double. But the function cannot become int if the properties of the parameter, or the parameter itself, are not int. And if the slider function returns int type, it means that at the stage of element creation the user himself assigned integers to its parameter or its properties - for example, placed the slider range or input fields with buttons inside integer values.

.


Conclusion: The user's task is to convert the received values to the required type.

Let's consider some practical examples:

1.

   //------------------------------------------------
   //Текстовое поле ввода EDIT. Тип функции - string.
   //Получение и установка цвета текста и основания:
   //------------------------------------------------
   
   //1. Устанавливаем любой текст в пустое поле ввода:
   w7_s_p4_EDIT_Comment_1("Some random text");
   //------------------------------------------------

//------------------------------------------------------------------------------------------------------------

2.

   //------------------------------------------------
   //2. Получаем цвет основания поля ввода:
   uint Comment_1_base_color =  (uint)w7_s_p4_EDIT_Comment_1(get_s,p4_COLOR_base); 
   //------------------------------------------------
   //Выводим результат в журнал:
   Print("Comment_1_base_color  ",Comment_1_base_color);
   //------------------------------------------------

//------------------------------------------------------------------------------------------------------------

3.

   //------------------------------------------------
   //3. Назначаем основанию новый цвет:
   w7_s_p4_EDIT_Comment_1((uint)clrWheat,p4_COLOR_base); 
   //------------------------------------------------

See the result:


//------------------------------------------------------------------------------------------------------------

4.

   //------------------------------------------------
   //4. Получаем цвет текста поля ввода: 
   uint Comment_1_text_color =  (uint)w7_s_p4_EDIT_Comment_1(get_s,p4_COLOR_text); 
   //------------------------------------------------
   //Выводим результат в журнал:
   Print("Comment_1_text_color  ",Comment_1_text_color); 
   //------------------------------------------------


//------------------------------------------------------------------------------------------------------------

5.

   //------------------------------------------------
   //5. Устанавливаем другой цвет тексту:
   w7_s_p4_EDIT_Comment_1((uint)clrRed,p4_COLOR_text); 
   //------------------------------------------------

See the result:




Next, let's test getting and setting other element and parameter properties. Let's also try to work with the double type.

Документация по MQL5: Основы языка / Операторы / Оператор возврата return
Документация по MQL5: Основы языка / Операторы / Оператор возврата return
  • www.mql5.com
Оператор return прекращает выполнение текущей функции и возвращает управление вызвавшей программе. Результат вычисления выражения возвращается...
 

I've followed the code and tested it, and found an unexpected thing that doesn't auto-hide when the length of the random string is too long

w7_s_p4_EDIT_Comment_1("Some random text AAAAAAAA");


 
These are minor issues, please leave them for later and see what happens, if you have time check them out, if not don't fix them for now!
 

I have found a fatal problem for me, which is that typing the text I am using is displayed on the GUI in a horizontal orientation ...... rotated 90 degrees, as normal is:

你好