Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-06

Fitting a form around a grid

9 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

It's obviously easy enough to fit a grid into the client space of a form or panel, but how does one do the reverse?

The exact size of a grid (i.e. such that the outermost grid lines are either displayed or not displayed predictably) depends on the widget set, and possibly on other details such as fount metrics, screen DPI and so on. At present I find myself applying "fudge factors" when shrinking a form to be an exact fit around a grid of a predetermined number of rows and columns, and that's still not entirely reliable when moving between systems.

Is there a "correct" way of doing this?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

David W Noon
to Mark Morgan Lloyd

On Thu, 16 Jun 2011 10:28:40 +0000, Mark Morgan Lloyd wrote about [Lazarus] Fitting a form around a grid:

It's obviously easy enough to fit a grid into the client space of a form or panel, but how does one do the reverse?

Can you not use the "anchor" property of the grid to tie its boundaries to the edges of the form? This has worked for me in the past.

Regards, Dave [RLU #314465] *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* (David W Noon) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110616/f8601905/attachment.bin>

Reply by email

Martin
to David W Noon

http://wiki.lazarus.freepascal.org/Autosize_/_Layout#AutoSize_and_Forms

David W Noon wrote 14 lines
On Thu, 16 Jun 2011 10:28:40 +0000, Mark Morgan Lloyd wrote about [Lazarus] Fitting a form around a grid: > It's obviously easy enough to fit a grid into the client space of a > form or panel, but how does one do the reverse? Can you not use the "anchor" property of the grid to tie its boundaries to the edges of the form? This has worked for me in the past. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110616/c696ac05/attachment-0001.html>

Reply by email

Mattias Gaertner
to Mark Morgan Lloyd: It's obviously easy enough to fit a grid into the client space of a form or panel, but…

?
?

Mark Morgan Lloyd hat am 16. Juni 2011 um
12:28 geschrieben:

Show quoted text 12 lines
It's obviously easy enough to fit a grid into the client space of a form or panel, but how does one do the reverse? The exact size of a grid (i.e. such that the outermost grid lines are either displayed or not displayed predictably) depends on the widget set, and possibly on other details such as fount metrics, screen DPI and so on. At present I find myself applying "fudge factors" when shrinking a form to be an exact fit around a grid of a predetermined number of rows and columns, and that's still not entirely reliable when moving between systems. Is there a "correct" way of doing this??

When you set the Forms.AutoSize to true, the form will automatically adjust its size. See the wiki for details. For example you can set the Grid.Align to alClient. Then the form will use the preferred size of the grid. The problem is, that TStringGrid does not override the method CalculatePreferredSize, so the LCL does not know the preferred size of the grid and therefore can not auto size the form.?
You can define your own TStringGrid descendant that overrides the method.? Or you can set the grids constraints.?
?
Mattias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110616/b7afeb6f/attachment.html>

Reply by email

Hans-Peter Diettrich
to Mark Morgan Lloyd: It's obviously easy enough to fit a grid into the client space of a form or panel, but…
Show quoted text 12 lines
It's obviously easy enough to fit a grid into the client space of a form or panel, but how does one do the reverse? The exact size of a grid (i.e. such that the outermost grid lines are either displayed or not displayed predictably) depends on the widget set, and possibly on other details such as fount metrics, screen DPI and so on. At present I find myself applying "fudge factors" when shrinking a form to be an exact fit around a grid of a predetermined number of rows and columns, and that's still not entirely reliable when moving between systems. Is there a "correct" way of doing this?

If you don't want to calculate the exact amount, you can dimension the form sufficiently big, and adjust the columns to fill the form.

DoDi

Reply by email

Mark Morgan Lloyd
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 16 lines
Mark Morgan Lloyd schrieb: > It's obviously easy enough to fit a grid into the client space of a > form or panel, but how does one do the reverse? > > The exact size of a grid (i.e. such that the outermost grid lines are > either displayed or not displayed predictably) depends on the widget > set, and possibly on other details such as fount metrics, screen DPI > and so on. At present I find myself applying "fudge factors" when > shrinking a form to be an exact fit around a grid of a predetermined > number of rows and columns, and that's still not entirely reliable > when moving between systems. > > Is there a "correct" way of doing this? If you don't want to calculate the exact amount, you can dimension the form sufficiently big, and adjust the columns to fill the form.

That's doable for the width, but what about rows where I believe there's less scope for per-row tweaking?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Hans-Peter Diettrich
to Mark Morgan Lloyd
Show quoted text 5 lines
> If you don't want to calculate the exact amount, you can dimension the > form sufficiently big, and adjust the columns to fill the form. That's doable for the width, but what about rows where I believe there's less scope for per-row tweaking?

Depends on whether the number of rows is fixed, or only known at runtime. I'd adjust for a minimal number of rows, so that the form will not "jump" too much in height, with every occurence.

As long as there exist only rows of a single line, it should not be so hard to calculate the minimum height of each row, depending on the choosen font. Then bitmaps, of a constant height, will be another factor to consider. Finally there is a choice of adjusting the row height, so that the rows fill the grid, or to shrink the grid to the total rows height.

DoDi

Reply by email

Mark Morgan Lloyd
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 18 lines
Mark Morgan Lloyd schrieb: >> If you don't want to calculate the exact amount, you can dimension >> the form sufficiently big, and adjust the columns to fill the form. > > That's doable for the width, but what about rows where I believe > there's less scope for per-row tweaking? Depends on whether the number of rows is fixed, or only known at runtime. I'd adjust for a minimal number of rows, so that the form will not "jump" too much in height, with every occurence. As long as there exist only rows of a single line, it should not be so hard to calculate the minimum height of each row, depending on the choosen font. Then bitmaps, of a constant height, will be another factor to consider. Finally there is a choice of adjusting the row height, so that the rows fill the grid, or to shrink the grid to the total rows height.

Assuming the number of rows is known, I'm already doing that and finding that I have to adjust by different amounts depending on the widget set: I think that the issue is the amount of overhead between a form's size and the size of its client space. It would be nice to have a facility to specify a precise client size and have the container (i.e. form etc.) adjust to that, in other words the exact opposite of the standard situation.

However, I thought yesterday that I was seeing different behavior on different machines (possibly based on the gtk2 library version, or on DPI) but that was a red herring- lazbuild wasn't rebuilding a unit when the target changed. So fortunately I've got nothing intractable here.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Hans-Peter Diettrich
to Mark Morgan Lloyd
Show quoted text 7 lines
Assuming the number of rows is known, I'm already doing that and finding that I have to adjust by different amounts depending on the widget set: I think that the issue is the amount of overhead between a form's size and the size of its client space. It would be nice to have a facility to specify a precise client size and have the container (i.e. form etc.) adjust to that, in other words the exact opposite of the standard situation.

Right, the current mix of form, control and client sizes is annoying. When the form borders are hard to determine, because they are not handled by the widgetset, but instead are handled by the window manager, then *every* widgetset should allow to specify the client size, and the window manager would add whatever window borders are configured.

DoDi

Reply by email