Recent

Author Topic: Alternative to Delphi's TGridPanel?  (Read 1752 times)

feds

  • New Member
  • *
  • Posts: 32
Alternative to Delphi's TGridPanel?
« on: April 07, 2019, 05:15:32 pm »
Hi all

There is no TGridPanel component in Lazarus afaik.

Ok, Lazarus has some differnt mechanism for handling the layout, compared to Delphi & C#.
However, i did not get a smooth way to layout larger groups of GUI elements by hand with lazarus.

What i want to do (to make my problem more clear):
Sometimes i need to  hack tools for the configuration of electronic devices. These devices are configured by tons of registers.
Each register consists of single bits for setting a particular device property, interspeared with groups of consecutive bits that represents a numerical value (i.e. 5bit to present the values 0..31). Obviously each need to carry a label to indicate what itis usefull.

My tools should show a kind of "register map" where i can click flags (on/off) and choose numerical values from comboboxes. (the latter is favored to edit field for various reasions).
Thing of up to 50 registers, up to 16 bits each. 

Obviously this should look nicely ordered. While this fits smoothly in vertical direction it becomes a nightmare in horizontal direction.

This is a snap with Delphi/MSVC due to the TGridPanel because the panel handles the horizontal alignment gracefully. Diffent number of controls in different rows are also not a problem for the alignment, even over multiple rows.

How can i handle this with Lazarus?
I know that i can align controls one-by-one. But it is so much more time consuming compared with only drop an element into a TGridpanel.
It becomes even more terrible when i need to change the order of elements later (wich usually hapens with design changes).


So my question is how to handle this amount of controls without a TGridPanel?

Thanks for any hint

Regards
feds


jamie

  • Hero Member
  • *****
  • Posts: 2261
Re: Alternative to Delphi's TGridPanel?
« Reply #1 on: April 07, 2019, 05:37:16 pm »
Give us a couple of screen shots ..

I am sure I understand what it is you are looking for and can be done with a DrawGrid
which allows custom drawing of each cell.

 You can drop Tpanels on other controls and build what you need.
Number 1 at blue screen app creations!

lucamar

  • Hero Member
  • *****
  • Posts: 2267
Re: Alternative to Delphi's TGridPanel?
« Reply #2 on: April 07, 2019, 05:50:23 pm »
There is some info in the wiki; read the pages in the Layout category.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

wp

  • Hero Member
  • *****
  • Posts: 6650
Re: Alternative to Delphi's TGridPanel?
« Reply #3 on: April 07, 2019, 06:43:43 pm »
I don't fully understand what you want to achieve, but you could play with a normal panel and set its ChildSizing properties accordingly:
- ControlsPerLine: number of "columns" in the grid, rows unlimited
- Layout: cclLeftToRightThenTopToBottom to fill fill by rows, or cclTopToBottomThenLeftToRight to fill by columns. Determines the order in which new controls are added in the columns and rows

That's all. Now drop your controls and they will be automatically arranged. In order to keep "cells" empty at the end just drop standard bevels with Shape=bsSpacer. Rearrange controls with the Z order context menu (or the keyboard shortcuts Ctrl-PgUp or Ctrl-PgDown).

If a "cell" should contain a combination of controls, like a label and a combobox, put then onto a frame and insert the frame instances into the panel.
« Last Edit: April 07, 2019, 06:47:02 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

jamie

  • Hero Member
  • *****
  • Posts: 2261
Re: Alternative to Delphi's TGridPanel?
« Reply #4 on: April 07, 2019, 06:58:20 pm »
He wants something like the TflowControl and maybe even the TButtonPanel

Where all the controls automatically align ..

basically with the combination of using Tpanels and TFlowControl will basically give him
what he wants.
Number 1 at blue screen app creations!

feds

  • New Member
  • *
  • Posts: 32
Re: Alternative to Delphi's TGridPanel?
« Reply #5 on: April 08, 2019, 12:56:53 pm »
Give us a couple of screen shots ..

I am sure I understand what it is you are looking for and can be done with a DrawGrid
which allows custom drawing of each cell.

 You can drop Tpanels on other controls and build what you need.

Hi all

Thanks for your comments. Unfortunally i didn't get it to work at all.


I prepared a small demo to show what i mean using VS2013 and table-layouts. It shows two registers, nine bit each.
Please note the DEEMP combobox in the first register. It is two bit wide (bit2, bit1).
Also note the border around the bits. It comes from the tablelayout, too.

Obviously this can be done with an endless stack of nested panes. But this looks very unconvinient to me.
The attached demo takes around 15 minutes to build up.Please refer to VS2013_sample_dev_view.PNG to get an impression how clean it looks during design.


wp

  • Hero Member
  • *****
  • Posts: 6650
Re: Alternative to Delphi's TGridPanel?
« Reply #6 on: April 08, 2019, 01:11:29 pm »
The merged cells for bit 1 and 2 indicate that my ChildSizing solution above is not applicable; varying row heights may be an issue, too. But I wonder if this can be achieved with Delphi's TGridPanel either.
« Last Edit: April 08, 2019, 01:17:29 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Thausand

  • Full Member
  • ***
  • Posts: 234
Re: Alternative to Delphi's TGridPanel?
« Reply #7 on: April 08, 2019, 01:18:42 pm »
But I wonder if this can be achieved with Delphi's TGridPanel.
article https://edn.embarcadero.com/article/33421

Quote
There are two other magical properties - ColumnSpan and RowSpan. These work similarly to HTML tables. In the screen shot below button 2 and 5's ColumnSpan, and button 4 and 11's RowSpan property have all been set to two. Button 2, 5 and 11 work exactly as you would expect. Button 4, however, causes some problems. It is positioned correctly, but it causes Buttons 8 and 12 to be positioned incorrectly.
If is then yes  :)

I look multipanel ondrej but have split and maybe can not do span ?

Thausand

  • Full Member
  • ***
  • Posts: 234
Re: Alternative to Delphi's TGridPanel?
« Reply #8 on: April 08, 2019, 04:04:43 pm »
Ok hello.

I try Multipanel. It work but maybe not easy ? Maybe you try ?

I not know multipanel then i not sure i write all good. Is small experience my when try.

OMultipanel can download and install Lazarus 2.0.0 ok (work other i not know. Help say can) http://www.kluug.net/omultipanel.php

1) OMultipanel not have grid but work line (horizontal or vertical).
2) if copy you example then horizontal OMultipanel
3) Make Panel on Form
4) Make OMultipanel on Panel
4a) Make splitsize property 0 (no show splitter mouse and can not split)
4b) Make align property top
4c) Add (many) Opanelcollection item (picture attach make 8 )
4d) Any collection item have add panel (if want)
4e) Any panel add have control you want (TEdit, TComboBox etc)

Then if want multi line can repeat number 4 any many line you want.

Not easy but work. I try resize and see if out of sync vertical border but is not see out of sync.

If want can make 8 (or nine ?) every line with panel and then property hide Opanelcollection to not show attach panel. So can use example empty panel and when change mind and want bit show can show Opanelcollection. But is not nice when Design time and run-time not see same.

I have question: why is 9 bit ? normal is 8 or 4 or 12 or 16. Maybe i not good know. I look and see 9 bits  :)
« Last Edit: April 08, 2019, 04:06:52 pm by Thausand »

feds

  • New Member
  • *
  • Posts: 32
Re: Alternative to Delphi's TGridPanel?
« Reply #9 on: April 08, 2019, 11:27:54 pm »
The merged cells for bit 1 and 2 indicate that my ChildSizing solution above is not applicable; varying row heights may be an issue, too. But I wonder if this can be achieved with Delphi's TGridPanel either.

You can do this in a (more or less) similar fashion like in VS C# but i didn't tested it yet (i have some issues with Delphi due to the lack of Linux support - Another story ;) )

That's why i ask about a GridPanel in Lazarus. From some projects with c# i know how extrem practical this is.
To be honest i'm astonished that there is nothing comparable in Lazarus. Even the lack of Columnspan/rowspan et al let me assume that Lazarus has a different, but not less powerfull mechanism for handling complex GUIs.

Is there a special reason for not implementing  the gridpanel or is this simple lack of development resources?
 
I try Multipanel. It work but maybe not easy ? Maybe you try ?

Not yet. But i will give it a try in the next few days. Thanks for this hint :)

I have question: why is 9 bit ? normal is 8 or 4 or 12 or 16. Maybe i not good know. I look and see 9 bits  :)
I just  choose two registers, one with a bitfield, to show my problem. Hence i take an arbitrary datasheet flying around here. No secret, no magic ;)

But if you're interested:The registers are from an simple low-power audio codec (WM8731, cirrus logic).
Cirrus use 16 bit registers with 7bit address + 9bit data to configure the device via I2C or SPI. These are serial protocols and one need to provide the register(address) to operate on. 

The address is (obviously) not shown in the configuration tool because it is only relevant when transfering data to the device, not for the setup configuration itself.
This left the 9bit you asked for :)

Regards
feds
 

dsiders

  • Sr. Member
  • ****
  • Posts: 253
Re: Alternative to Delphi's TGridPanel?
« Reply #10 on: April 08, 2019, 11:37:32 pm »
That's why i ask about a GridPanel in Lazarus. From some projects with c# i know how extrem practical this is.
To be honest i'm astonished that there is nothing comparable in Lazarus. Even the lack of Columnspan/rowspan et al let me assume that Lazarus has a different, but not less powerfull mechanism for handling complex GUIs.

Is there a special reason for not implementing  the gridpanel or is this simple lack of development resources?

I'm not sure if it's what you are looking for, but there is a TFlowPanel control in extctrls.pp.
Lazarus 2.0.6 / Lazarus 2.1 (SVN) / FPC 3.0.4 / Windows 8.1 64-bit

feds

  • New Member
  • *
  • Posts: 32
Re: Alternative to Delphi's TGridPanel?
« Reply #11 on: April 08, 2019, 11:59:54 pm »
I'm not sure if it's what you are looking for, but there is a TFlowPanel control in extctrls.pp.
Right. But unfortunally, as you say, it's a flow panel.
If you look at the DEEMP field the picure that i posted above (VS2013_sample_dev_view.PNG), you will find the problem with ease.
The combobox is smaller than the two fields above/below it.
While this is not a problem with the gridpanel, a flowpanel would shift the ADCHPD bit (right from DEEMP) to the right border of DEEMP.
Hence it was not anymore aligned with the LINEINPD field of the next line.

I can adjust the width of every field by hand, of course. But, to be honest, then i can place/adjust all the fields by hand, wasting hours of development time.
And that is not the idea of rapid prototyping, isn't it?

Regards
feds 

P.S:
The example that i posted is just an example. Typical register maps are much bigger. Hence my resitance to manual adjustments.
f.
« Last Edit: April 09, 2019, 12:06:04 am by feds »

Thausand

  • Full Member
  • ***
  • Posts: 234
Re: Alternative to Delphi's TGridPanel?
« Reply #12 on: April 10, 2019, 12:09:23 pm »
This left the 9bit you asked for :)
Thanks you for explain. Look that is nice project.

I not work TGridPanel Delphi and not know if more easy Lazarus OMultipanel. Use OMultipanel not many need change. Resize work automatic. Can set relative position vertical divide. For many line have make same divide number. Only maybe set minimal size panel so that not shrink too many and not see TLabel/TEdit/TCombo.

I think complicate when change all lines not 8 then make 9 bit. Is not work nice when use design-time. Is complicate insert new panel (then use object Inspector make more easy). Is difficult explain then that is i say maybe you try. Then can see self if can work for you. Sorry i not know other component and i no think Lazarus have TGridPanel or some thing work same.

TFlowpanel not work because then all component in order. I try and not work. Flowpanel not can combine bits and have vertical divide same place any (bits) line. Maybe can work if set panel minimal and maximum size so that not resize panel ? (that i not try TFlowpanel)

Is not make easy and need many TPanel and have vertical line right for any horizontal bits. OMutlipanel make more easy make right horizontal/vertical TPanel.

If not care design-time then maybe better can use TDrawGrid or some thing like.