Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Automatic control size and alignment (like matisse for netbeans)

Posted on 2007-04-10
8
Medium Priority
?
2,593 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Accepted Solution

by:
lopem earned 1000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
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 1000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

671 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