Solved

Automatic control size and alignment (like matisse for netbeans)

Posted on 2007-04-10
8
2,563 Views
Last Modified: 2008-01-09
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?
(http://www.netbeans.org/products/ide/features.html#NetBeans_Swing_GUI_Builder_forme)

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.
0
Comment
Question by:alkisg
8 Comments
 
LVL 3

Accepted Solution

by:
lopem earned 250 total points
ID: 18887820
In torry.ru you can find few resizer components with source code and freeware. Also I found a paid component for that job...Try

   http://www.componentsource.com/products/newtone-resizekit-activex-vcl/summary.html

Hope this helps.
regards,
lopem (Manuel Lopez)
0
 
LVL 9

Author Comment

by:alkisg
ID: 18887904
Hi,

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.
https://filedb.experts-exchange.com/incoming/ee-stuff/3143-resizekit.png
0
 
LVL 3

Expert Comment

by:lopem
ID: 18892061
I guess then you have to start your open source project! Good luck

Manuel Lopez (lopem)
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 18921593
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.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Author Comment

by:alkisg
ID: 18922731
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! :)
0
 

Assisted Solution

by:tnhphuong
tnhphuong earned 250 total points
ID: 18936815
please refer this component: http://www.sicomponents.com
this is useful component for multi language app, of course, include what you want.
0
 
LVL 9

Author Comment

by:alkisg
ID: 18946950
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?
0
 
LVL 9

Author Comment

by:alkisg
ID: 19098736
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.

Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now