A question was asked some time ago regarding the layout of the Matrix object.
While we all use the object in its usual form (Layout = 0), which is a regular tabular “grid”, like the following example:
But, by changing the Layout (1 or 2), the exact same Matrix will be displayed as the following:
Since getting the correct layout, is not so easy, it should be explained a bit.
The Matrix is used to display data as a matrice defined as columns which contains rows:
- When the property Layout = 0, then columns are on the x axis of the display and rows on the y, which is the regular way.
- When the property Layout = 1 or 2, the display is inverted: columns go to the y axis and rows to the x axis.
Three other properties are involved in the process:
- titleHeight and cellHeight in the Specific tag of the Matrix,
- width in the definition of any column.
The way these properties are used to render the object is different depending on the Layout property.
If Layout = 0, then:
- titleHeight is the height in pixel of the title part of the UI object,
- cellHeight is the height of any row (so except the title),
- width is the width of the specific column.
If Layout = 1 or 2, then:
- titleHeight is the width of the first column (the static part, containing the labels in the sample),
- cellHeight is the width of any of the other columns,
- width is the height of the specific row;
For the shown sample, the configured values are respectively:
- Layout = 0: titleHeight = 16, cellHeight = 20 and width = 16 for the first column and 80 for the others,
- Layout = 1 or 2: titleHeight = 80, cellHeight = 100 and width = 16 for all columns.
There is also another difference in the way the UI object is rendered:
When Layout = 0, then the title bar is displayed and the global width and height of the object are set by using the corresponding properties of the Item; and the engine really uses this space.
When Layout = 1 or 2, then the title bar is also displayed, but:
- The displayed width of the rendered object is the value of the corresponding property of the Item object,
- The displayed height of the rendered object is calculated by the engine by summing the width value of each column except the first one.
So, to get the correct display like the provided sample then the first column (which usually is the Line number of the row) has to be made invisible.
The two corresponding srf files are provided as sample.