Solved

Automatic control size and alignment (like matisse for netbeans)

Posted on 2007-04-10
8
2,556 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
Comment Utility
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
Comment Utility
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
Comment Utility
I guess then you have to start your open source project! Good luck

Manuel Lopez (lopem)
0
 
LVL 17

Expert Comment

by:TheRealLoki
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 9

Author Comment

by:alkisg
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

10 Experts available now in Live!

Get 1:1 Help Now