directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre-Arnaud Marcelot" ...@marcelot.net>
Subject Re: [Studio] Customizable size for ConnectionWidget
Date Mon, 22 Oct 2007 10:01:40 GMT
Hi Stefan,

you are totally right. Hardcoding the width and height in that way is
> not a good idea, my fault. On Linux/GTK the height of the widget is
> good. But on other platforms it may be too high.


Well, the problem is actually on Linux/GTK (and on the other platforms too).

Instead the width and heigt of widgets should be calculated depending on
> the platform dependent font metrics. Here is a code snippet:
>
> ------------------------------------------------
> GC gc = new GC( control );
> gc.setFont( JFaceResources.getDialogFont() );
> FontMetrics fontMetrics = gc.getFontMetrics();
> gc.dispose();
>
> int width = Dialog.convertHorizontalDLUsToPixels( fontMetrics,
> IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
> int height = Dialog.convertVerticalDLUsToPixels( fontMetrics,
> IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
> ------------------------------------------------


I tried this code but it does not solves the problem. We only win 6 pixels
on the height.

I tried with the following code (without height and width hints):
    tree = new Tree( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.BORDER );
    GridData data = new GridData( GridData.FILL_BOTH );
    tree.setLayoutData( data );
And here, I win 101 pixels on the height. And the size of the dialog is no
longer changed (it's the default minimum size I think).

Here are a few screenshots:
the dialog, as it is right now ->
http://people.apache.org/~pamarcelot/ConnectionWidget/Window_ATM.png
the dialog with your fix ->
http://people.apache.org/~pamarcelot/ConnectionWidget/Window_Stefan_fix.png
the dialog with no height and width hints ->
http://people.apache.org/~pamarcelot/ConnectionWidget/Window_good.png

I don't think we need to pass a GridData to the createContent() method
> when we use that calculation.


I had a second (closer) look at the ConnectionWidget and I saw I could get
the TreeViewer with the method "public TreeViewer getViewer()".

Maybe what we could do, is set the default GridData with no height and width
hints and when we use the ConnectionWidget and need to change its size, use
the following code (which overrides the default definition):
    GridData myGridData = new GridData( GridData.FILL_BOTH );
    myGridData.widthHint = 450;
    myGridData.heightHint = 250;
    connectionWidget.getViewer.getTree.setLayoutData( myGridData );

It should be working...
WDYT ?

Regards,
P-A

Mime
View raw message