Sign in Join

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

Mailing lists / lazarus / 2009-01

Does Lazarus have "sizer" or "layout" objects?

28 messages · 10 people · –

Reply by email Subscribe to this list Your subscription

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

David W Noon

Hi,

Some C++ class libraries have object classes that automatically resize widgets when a form is resized by the user. For example, wxWidgets calls them sizers, and Qt calls them layouts. I have perused the LCL documentation and have found nothing that quite meets the bill. I tried a TPanel object, but it did not have anywhere near that functionality; in fact, it seemed to do very little.

So, as the subject line says, does Lazarus have such classes?

Regards, Dave [RLU #314465] ======================================================================= (David W Noon) =======================================================================

Reply by email

Vincent Snijders
to David W Noon

2009/1/7 David W Noon :

Show quoted text 10 lines
Hi, Some C++ class libraries have object classes that automatically resize widgets when a form is resized by the user. For example, wxWidgets calls them sizers, and Qt calls them layouts. I have perused the LCL documentation and have found nothing that quite meets the bill. I tried a TPanel object, but it did not have anywhere near that functionality; in fact, it seemed to do very little. So, as the subject line says, does Lazarus have such classes?

No, there are no such classes. A control has anchors, and a number of a controls can autosize (i.e. adjust size accoding to their contents).

For anchoring, see wiki:
http://wiki.lazarus.freepascal.org/IDE_Window:_Anchor_Editor and
http://wiki.lazarus.freepascal.org/Anchor_Sides

Vincent

Reply by email

Martin Friebe
to Vincent Snijders
Vincent Snijders wrote 23 lines
2009/1/7 David W Noon : > Hi, > > Some C++ class libraries have object classes that automatically resize > widgets when a form is resized by the user. For example, wxWidgets calls > them sizers, and Qt calls them layouts. I have perused the LCL > documentation and have found nothing that quite meets the bill. I tried > a TPanel object, but it did not have anywhere near that functionality; > in fact, it seemed to do very little. > > So, as the subject line says, does Lazarus have such classes? > No, there are no such classes. A control has anchors, and a number of a controls can autosize (i.e. adjust size accoding to their contents). For anchoring, see wiki: http://wiki.lazarus.freepascal.org/IDE_Window:_Anchor_Editor and http://wiki.lazarus.freepascal.org/Anchor_Sides

Forms/Panels... also have "ChildSizing", which comes close to a grid-layout

Martin

Reply by email

David W Noon
to Vincent Snijders: 2009/1/7 David W Noon : No, there are no such classes. A control has anchors, and a…
Vincent Snijders wrote
2009/1/7 David W Noon : > Some C++ class libraries have object classes that automatically resize > widgets when a form is resized by the user. For example, wxWidgets calls > them sizers, and Qt calls them layouts.

[snip]

No, there are no such classes. A control has anchors, and a number of a controls can autosize (i.e. adjust size accoding to their contents).

This gives me exactly the functionality I need. Many thanks!

Regards, Dave [RLU #314465] ======================================================================= (David W Noon) =======================================================================

Reply by email

Hans-Peter Diettrich
to Vincent Snijders: 2009/1/7 David W Noon : No, there are no such classes. A control has anchors, and a…
Show quoted text 6 lines
> Some C++ class libraries have object classes that automatically resize > widgets when a form is resized by the user. For example, wxWidgets calls > them sizers, and Qt calls them layouts. I have perused the LCL > documentation and have found nothing that quite meets the bill. I tried > a TPanel object, but it did not have anywhere near that functionality; > in fact, it seemed to do very little.

Delphi at least has Toolbars, with more features than simple TPanels.

Show quoted text 9 lines
> So, as the subject line says, does Lazarus have such classes? No, there are no such classes. A control has anchors, and a number of a controls can autosize (i.e. adjust size accoding to their contents). For anchoring, see wiki: http://wiki.lazarus.freepascal.org/IDE_Window:_Anchor_Editor and http://wiki.lazarus.freepascal.org/Anchor_Sides

Anchoring is not a useful replacement for other (more systematic) layouts. E.g. I found docking impossible with anchors.

IMO we should add more "regular" (rectangular) layout managers to the basic controls, not restricted to containers derived from TWinControl. A TDockTree with TDockZones were a useful base class for such layout managers, provided that it can be implemented as a self contained alternative for anchoring. The implementation should not be complicated, from the management viewpoint: every layout level covers a rectangular zone, which can be subdivided horizontally or vertically into further zones, with "leaf" zones containing one control each. It must be possible to anchor sliders (beformentioned sizers) to zones, not only to controls. Then we can try to integrate the current anchoring into such a commonly used, stable and useful layout management.

DoDi

Reply by email

Graeme Geldenhuys
to David W Noon: Some C++ class libraries have object classes that automatically resize widgets when a…
David W Noon wrote
So, as the subject line says, does Lazarus have such classes?

No, but it has anchoring, alignment etc...

I am working on such a layout manager class though. I am porting the MiG Layout from Java to Free Pascal. It's mainly for use with fpGUI, but most of the core code is GUI toolkit independent, so it should be easy to support LCL as well. I will definitely post a notice here once I have completed the port - somewhere in the first half of this year. MiG Layout is simply fantastic!! Google for it's website and try the demo.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

David W Noon
to Graeme Geldenhuys
Graeme Geldenhuys wrote 5 lines
On Wed, Jan 7, 2009 at 5:09 PM, David W Noon wrote: > > So, as the subject line says, does Lazarus have such classes? No, but it has anchoring, alignment etc...

This has proven to be completely adequate for the modest requirements of the application I am writing.

Show quoted text 7 lines
I am working on such a layout manager class though. I am porting the MiG Layout from Java to Free Pascal. It's mainly for use with fpGUI, but most of the core code is GUI toolkit independent, so it should be easy to support LCL as well. I will definitely post a notice here once I have completed the port - somewhere in the first half of this year. MiG Layout is simply fantastic!! Google for it's website and try the demo.

If it's only half as good a Qt's layout classes it will be very good indeed.

Regards, Dave [RLU #314465] ======================================================================= (David W Noon) =======================================================================

Reply by email

Lord Satan
to David W Noon
If it's only half as good a Qt's layout classes it will be very good indeed.

Did you ever do a 'more complex' GUI with Qt? I am working with Qt in my job and I would gladly trade Qt's layouts for Lazarus' anchoring and friends? It takes ages to align Qt's layouts and spacers in a way that they work at least a little bit like you wish. The Qt-Designer is more hindering than helping and very often I have more space between my GUI elements than I want to have. Perhaps me and my colleagues are just too stupid to use Qt, but our GUI design is most of the time 'just good enough' and not like we imagined to do it. Sorry for ranting, but I can't let a chance to bash Qt's layouts just pass.

Greetings,
The Lord

A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

David W Noon
to Lord Satan
Lord Satan wrote 9 lines
On Sat, 10 Jan 2009 19:49:43 +0000 David W Noon wrote: > If it's only half as good a Qt's layout classes it will be very good > indeed. Did you ever do a 'more complex' GUI with Qt? I am working with Qt in my job and I would gladly trade Qt's layouts for Lazarus' anchoring and friends? It takes ages to align Qt's layouts and spacers in a way that they work at least a little bit like you wish. The Qt-Designer is more hindering than helping and very often I have more space between my GUI elements than I want to have. Perhaps me and my colleagues are just too stupid to use Qt, but our GUI design is most of the time 'just good enough' and not like we imagined to do it. Sorry for ranting, but I can't let a chance to bash Qt's layouts just pass.

I do the coding by hand for Qt layouts and wxWidgets sizers. It's far easier that way.

What you are ultimately saying is that Lazarus's form designer is easier to use than Qt designer. I won't dispute that.

Regards, Dave [RLU #314465] ======================================================================= (David W Noon) =======================================================================

Reply by email

Lord Satan
to David W Noon: I do the coding by hand for Qt layouts and wxWidgets sizers. It's far easier that way.…
What you are ultimately saying is that Lazarus's form designer is easier to use than Qt designer.

No, I am not. I am saying that with the Qt layouts we don't achieve the look we want and that the Qt-Designer (as a bonus) is a major PITA, too. Doing it by hand does not fix the shortcomings of layouts and spacers and just adds ugly code. I am not talking about one form with some memos, buttons, etc here and there. We have a highly dynamical GUI in our application, with lots of plugins adding/removing their own GUI-elements at runtime or extending existing GUI-elements. We switched from hand coded GUI to ui-files as the old system just became unmanageable. Once again, this is not about Qt-Designer vs Lazarus' form designer. Layouts are a nice and easy way for simple GUIs, but too restricted for more complex tasks. I would post screen shots of the problems, but I am unfortunately not allowed to do this.

But you did not answer my question. Do you have experience with developing complex layouts in Qt or are you just talking about simple stuff?

Greeting,
Beelzebub

A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Felipe Monteiro de Carvalho
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
What's the base class for an layout manager?

There is none specific. I would suggest trying TCustomControl if you also want to draw borders or TControl if you just want to position childs.

Felipe Monteiro de Carvalho

Reply by email

Graeme Geldenhuys
to Lord Satan: On Sat, 10 Jan 2009 19:49:43 +0000 Did you ever do a 'more complex' GUI with Qt? I am…
Lord Satan wrote 5 lines
Did you ever do a 'more complex' GUI with Qt? I am working with Qt in my job and I would gladly trade Qt's layouts for Lazarus' anchoring and friends? It takes ages to align Qt's layouts and spacers in a way that they work at least a little bit like you wish. The Qt-Designer is more hindering than helping and very often I have more space between my GUI elements than I want to have. Perhaps me and my colleagues are just too stupid to use Qt, but our GUI design is most of the time 'just good enough' and not like we imagined to do it. Sorry for ranting, but I can't let a chance to bash Qt's layouts just pass.

;-) MiG Layout is simply fantastic. Try the demo on there website and see for yourself! You only need one layout manager to build any GUI. They once had a test like that - duplicate any application's GUI using MiG Layout. There wasn't a single GUI they couldn't reproduce with little effort.

You can even specify spacing between components in mm, inches, cm, pixels etc... It's resolution independent and dpi independent. The other neat feature is the Debug mode, where it highlights containing components etc.. to help you design your GUI layout. The layout interface is relatively simple, so no GUI designer is required - it's all possible from a few lines of code.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

David W Noon
to Lord Satan: On Sat, 10 Jan 2009 21:37:28 +0000 No, I am not. I am saying that with the Qt layouts we…
Lord Satan wrote 12 lines
On Sat, 10 Jan 2009 21:37:28 +0000 David W Noon wrote: > What you are ultimately saying is that Lazarus's form designer is easier > to use than Qt designer. No, I am not. I am saying that with the Qt layouts we don't achieve the look we want and that the Qt-Designer (as a bonus) is a major PITA, too. Doing it by hand does not fix the shortcomings of layouts and spacers and just adds ugly code. I am not talking about one form with some memos, buttons, etc here and there. We have a highly dynamical GUI in our application, with lots of plugins adding/removing their own GUI-elements at runtime or extending existing GUI-elements. We switched from hand coded GUI to ui-files as the old system just became unmanageable. Once again, this is not about Qt-Designer vs Lazarus' form designer. Layouts are a nice and easy way for simple GUIs, but too restricted for more complex tasks. I would post screen shots of the problems, but I am unfortunately not allowed to do this. But you did not answer my question. Do you have experience with developing complex layouts in Qt or are you just talking about simple stuff?

By my standards they were reasonably complex. However, all the dialogues are statically populated with controls, so the layouts are for resizing and/or repositioning controls whose initial positions are known at compile time -- i.e. no dynamic plugins.

Regards, Dave [RLU #314465] ======================================================================= (David W Noon) =======================================================================

Reply by email

Hans-Peter Diettrich
to Felipe Monteiro de Carvalho: On Sun, Jan 11, 2009 at 9:57 AM, Hans-Peter Diettrich There is none specific. I would…
Show quoted text 5 lines
> What's the base class for an layout manager? There is none specific. I would suggest trying TCustomControl if you also want to draw borders or TControl if you just want to position childs.

That doesn't answer the question, how to marry controls and layout manager. How will the form designer interact with the layout manager...

DoDi

Reply by email

Mattias Gaertner
to Hans-Peter Diettrich: That doesn't answer the question, how to marry controls and layout manager. How will the…
Show quoted text 11 lines
Felipe Monteiro de Carvalho schrieb: >> What's the base class for an layout manager? > > There is none specific. I would suggest trying TCustomControl if you > also want to draw borders or TControl if you just want to position > childs. That doesn't answer the question, how to marry controls and layout manager. How will the form designer interact with the layout manager...

At the moment this is completely in the LCL. Controls can override various methods to alter that behavior and applications can set events. For example you can create a component that sets all OnResize/OnChangeBounds events.
There is no global or form based possibility to override. You are welcome to make a proposal.

Mattias

Reply by email

Hans-Peter Diettrich
to Mattias Gaertner
Show quoted text 10 lines
> That doesn't answer the question, how to marry controls and layout > manager. How will the form designer interact with the layout > manager... At the moment this is completely in the LCL. Controls can override various methods to alter that behavior and applications can set events. For example you can create a component that sets all OnResize/OnChangeBounds events. There is no global or form based possibility to override. You are welcome to make a proposal.

Bite ;-)

Since docking managers are kind of layout managers, I'd suggest an extension of the IDockManager interface.

Unfortunately I'm still recovering from catching a cold (Grippe), but I hope to contribute soon :-)

DoDi

Reply by email

Graeme Geldenhuys
to Hans-Peter Diettrich: What kind of graphics are supported? Pixel-based bitmaps do not fit well together with…
Hans-Peter Diettrich wrote
What kind of graphics are supported? Pixel-based bitmaps do not fit well together with otherwise measured fonts and other GUI elements.

It has nothing to do with "what kind of graphics are supported". Layout manager are used to design or layout components on a form. MiG Layout does just that. It positions, resizes etc components (edits, comboboxes, treeviews, labels etc) on a form without using nested layout managers or resize event handlers. Position or size of components can be specified in any measuring unit and will keep the form looking correct irrespective of when it is resized, dpi is changed etc..

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Reenen Laurie
to Graeme Geldenhuys

Yes, that demo of MiG looks truely awesome...
The fact that you can write:

  hPanel.add(createTextField(""), "width 25%!");

is awesome... I've always wanted to be able to express the size in terms of a % of the parent!

Greame wrote:
I am working on such a layout manager class though. I am porting the MiG Layout from Java to Free Pascal.

Yes please! Let us know about your progress!

On Mon, Jan 12, 2009 at 10:08 AM, Graeme Geldenhuys <

Show quoted text 30 lines
wrote: On Sun, Jan 11, 2009 at 5:52 PM, Hans-Peter Diettrich wrote: > > What kind of graphics are supported? Pixel-based bitmaps do not fit well > together with otherwise measured fonts and other GUI elements. It has nothing to do with "what kind of graphics are supported". Layout manager are used to design or layout components on a form. MiG Layout does just that. It positions, resizes etc components (edits, comboboxes, treeviews, labels etc) on a form without using nested layout managers or resize event handlers. Position or size of components can be specified in any measuring unit and will keep the form looking correct irrespective of when it is resized, dpi is changed etc.. Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090112/79eb8d81/attachment.html

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: On Sun, Jan 11, 2009 at 5:52 PM, Hans-Peter Diettrich It has nothing to do with "what…
Position or size of components can be specified in any measuring unit and will keep the form looking correct irrespective of when it is resized, dpi is changed etc..

Looking "correct" and looking "good" are different things. Most designs, built with "powerful" layout managers, do no more look nice when the dpi change, or when elements start wrapping after the form is shrinked.

My experience: Really scalable designs do not deserve sophisticated layout managers with almost unpredictable runtime behaviour. All other designs only deserve a sophisticated design tool, and no runtime management should garble the tweaked design.

DoDi

Reply by email

Graeme Geldenhuys
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
Looking "correct" and looking "good" are different things. Most designs,

What I meant by "correct", is that after a resize or dpi or resolution change, the form is still as you designed it. If you designed a bad looking form (that's your problem) it will look bad in all dpi settings. ;-)

How the form looks, is up to the person that designed the form. They layout manager's only job is to make sure that it looks just like you designed it, so matter what!

If you haven't at least looked at the MiG Layout example, then there is nothing further I can say. All I know is that it is a lot better than anything else I have seen!

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Reenen Laurie
to Graeme Geldenhuys

I can imagine you can mess up a form with MiG. But I think you'll have to try.

http://www.migcalendar.com/miglayout/swingdemoapp.jnlp

Graeme Geldenhuys wrote 31 lines
On Mon, Jan 12, 2009 at 1:48 PM, Hans-Peter Diettrich wrote: > > Looking "correct" and looking "good" are different things. Most designs, What I meant by "correct", is that after a resize or dpi or resolution change, the form is still as you designed it. If you designed a bad looking form (that's your problem) it will look bad in all dpi settings. ;-) How the form looks, is up to the person that designed the form. They layout manager's only job is to make sure that it looks just like you designed it, so matter what! If you haven't at least looked at the MiG Layout example, then there is nothing further I can say. All I know is that it is a lot better than anything else I have seen! Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090112/84e800af/attachment.html

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: On Mon, Jan 12, 2009 at 1:48 PM, Hans-Peter Diettrich What I meant by "correct", is that…
Show quoted text 6 lines
> Looking "correct" and looking "good" are different things. Most designs, What I meant by "correct", is that after a resize or dpi or resolution change, the form is still as you designed it. If you designed a bad looking form (that's your problem) it will look bad in all dpi settings. ;-)

The form stays as designed, of course, but often the designer's expectations differ from the layout manager's instructions ;-)

If you haven't at least looked at the MiG Layout example, then there is nothing further I can say. All I know is that it is a lot better than anything else I have seen!

On the first attempt I got an invalid jar - can java 1.5 not handle a version 1.4 jar?

A general problem with demos: they show what has been made work, not the limits of the tool or library. I don't say that MiG has problems, I'm only very cautious with too powerful layout and docking managers...

DoDi

Reply by email

Pavel Řezníček
to David W Noon: Some C++ class libraries have object classes that automatically resize widgets when a…

Hi all,

I code also in wxPython and I use its sizers quite often. I think they are a great idea and they are what I almost always miss in the Pascal world.

One advantage of the sizers is the cross-platformity of your layout. There are predefined sizes of every control for each platform, depending on the default font size, icon size etc. so when you don't force the sizes you can expect a reasonably good look on every computer you application can run on. You have the chance to express yourself in the terms of percentage or ratio but you can still specify fixed measurements if you insist. And you can add margins around the laid out controls (widgets, components).

I must agree: I also never became familiar with the more complex sizers, e. g. the grid sizer or flow sizer. I always build my layout out of simple horizontal or vertical box sizers. Don't ask me why but maybe I don't like things that pretend to be more clever than me ;-) On the other hand, I'm a bit lazy to cope with that more advanced sizers. I tend to build up structures of primitive sizers so I can hold control above them.

Still, though untouched by the more complicated sizers, I find them all an advantage because of the flexible and instant layout features they provide.

There is always a way how to prevent ugliness when you use sizers: you can set the minimal possible size of the entire form as a size constraint and also the maximal size.

Pavel

Reply by email

Graeme Geldenhuys
to Hans-Peter Diettrich: The form stays as designed, of course, but often the designer's expectations differ from…
Hans-Peter Diettrich wrote
On the first attempt I got an invalid jar - can java 1.5 not handle a version 1.4 jar?

I don't know. I have Java 1.6.0_03 runtime environment installed and the demo runs fine.

A general problem with demos: they show what has been made work, not the limits of the tool or library. I don't say that MiG has problems, I'm

That demo is very well designed. It has a lot of different examples. You can view the source code for each example. You can even change the layout manager settings at runtime to customise each example - so you can play around with the different settings and options and instantly see the affect. You can also enable the debug mode in each example which is very handy to understand the layout structure.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email