Automatic control size and alignment (like matisse for netbeans)

Hi all,

Does anybody know of a way (e.g. a paid component suite) to automatically size the controls of a form, like the matisse project in netbeans for java?

The purpose of this question is to see if something like this exists for Delphi, and if not, I'd like to make an open source project for this.

Desired behaviour:
1) At design time, suppose I have a TEdit (actually any TControl). I should be able to define that
a) I want its Left property to be the same as, say, aTLabel.Left (some TLabel that is above the TEdit).
b) I want its Top property to be the same as aTLabel.Bottom. This way the TEdit would be positioned exactly under the TLabel. The TControl.Margins public property should be used to declare the desired spacing.
c) I want its Right property to be the same as ParentForm.Right.
d) I want its Height property calculated automatically based on the TEdit.Font.Size.

2) At run time, I should be able to
a) Resize the form and the controls should be automatically aligned and sized.
b) Change ANY font, either the form font or the control fonts, and again everything should be automatically sized and aligned.
c) Change ANY control text (e.g. a TLabel.Caption), and again everything should be automatically sized and aligned.

I think that this way works much better and COULD REPLACE ALL of Delphi similar constructs, such as anchors, alignment, autosize, gridpanels etc. E.g. align=bottom would be translated to Left=Form.Left, Right=Form.Right, Bottom=Form.Bottom.
I guess you know the usual problems that come with the Delphi control alignment strategy, I won't go into details in this. Just an example, if someone wants to localize a form OR increase at runtime the form font size, he'll get into trouble! :-)
Anchors and alignment are just not good enough.
Who is Participating?
lopemConnect With a Mentor Commented:
In you can find few resizer components with source code and freeware. Also I found a paid component for that job...Try

Hope this helps.
lopem (Manuel Lopez)
alkisgAuthor Commented:

I haven't tried all of these components, but the ones I've tried rely on percentages and font scaling to handle the form resizing. This, well, to put it simply, sucks! If a form is translated, a TLabel should be (e.g.) wider, not resized based on percentage. If the user increases the windows font size, all controls are clipped.

I downloaded and tested the resizekit you've linked to. Here's a screenshot that demonstrates that it doesn't work (many controls are clipped). I just changed the font size.
I guess then you have to start your open source project! Good luck

Manuel Lopez (lopem)
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

TheRealLokiSenior DeveloperCommented:
Good idea. I made a set of routines to automatically squeeze the components into the client area if the area was resized, but it did not allow you to ensure edit1 was under label1 unless you had them in their own group (panel/groupbox, etc), so i would also be interested if you find something that can achieve this in Delphi.
alkisgAuthor Commented:
Automatic alignment is easy enough, and (from what I've searched so far) I think it can easily be implemented for all TControl descendants on D2006+ using ISelectionPropertyFilter and maybe class helpers. See my Q_22504055 for details.

I think it'll take me about a week of coding to replace Anchors and Align properties with the more generic approach of "control - edge - anchors".
Anchoring based on the middle of a control can also be supported, so it'll be possible to align the right side of a TButton 10px left of the form's center.

I did some tests, everything works OK and resizing is smother than when panels are used.

What troubles me is auto-sizing, based on the form or control Font property. E.g. if you enable TLabel.AutoSize, it scales according to the font size. Also TEdit works OK.
But TCheckBox, TButton etc don't behave well for different fonts, so specific code is required for each control class...

If I don't find anything similar, I'll give it a go on the summer and I'll let you know of the results! :)
tnhphuongConnect With a Mentor Commented:
please refer this component:
this is useful component for multi language app, of course, include what you want.
alkisgAuthor Commented:
It's a nice suite of components for multi language applications, but I saw NOTHING about control positioning and autosizing there!

I tried the TsiLang Components Suite Trial version, did I miss something?
alkisgAuthor Commented:
I guess it's time to close this one.
I've made most of the controls I use autosizing / autopositioning, but with no designer support yet. Works great. If/when I finish it, I'll upload it to e.g. sourceforge and post the link here.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.