New article Using Layouts and Containers for GUI Controls: The CGrid Class has been published:
This article presents an alternative method of GUI creation based on
layouts and containers, using one layout manager — the CGrid class. The
CGrid class is an auxiliary control that acts as a container for other
containers and controls using a grid layout.
The CGrid class is a layout manager used
in the design of GUI controls for dialog windows in MetaTrader. It is
one of the custom container classes that can be used in GUI design
without relying on absolute positioning.
It is highly recommended to read the article about the CBox class before proceeding to the concepts discussed in this article.
The CGrid class creates a container for
one or more GUI controls and presents them in a grid arrangement. An
example layout of an instance of the CGrid class is shown in the
Figure 1. Grid Layout
this class can be convenient especially if the controls to be added to
the grid have identical dimensions, such as a set of buttons or edit
boxes within the client area.
example above is a grid of 4x4 cells (4 columns and 4 rows). However, we
aim to develop a class that would be able to accommodate any number of
rows and columns in a grid.
Author: Enrico Lambino
Great work as usual, Enrico.
I tried but couldn't make it, to place two CEdit fields one just by anoter without any spacing (fixed positioning) - but it seems the class only auto positions by the layout style.
Can it be done? For instance, I want a field name and the value like this:Total Orders: 3using two CEdit's but placing them one by the other?
The grid only accepts a single component per cell. If you are to place more than one control on any given cell, you should nest them inside CBox or CGrid.
Another option would be to extend CGrid(tk) or CBox so that you can directly specify which controls should use fixed positioning, and which ones should follow layout styles.
When compiling the "Grid Sample.mq5" I get the error:
'm_client_area' - private member access error GridSample.mqh 78 60
'm_client_area' - private member access error GridSample.mqh 78 91
I guess the language was updated. Before it was possible to call the superclass that way. But now, I see, it is now possible to call the functions ClientAreaWidth and ClientAreaHeight for instances of CDialog and its heirs. The code:
would be the equivalent statement.