DUIM question 
Author Message
 DUIM question

What would be the simplest way to make a dialog with a series of text fields
in a column, each with a text label to its left.  I would like all of the
text fields to align with each other.  I've experimented with many of the
keyword options to <row-layout>, but they don't seem to help (e.g.,
equalize-widths: , x-ratios:, ratios:).   The only thing I can come up with
so far is to experiment with x-spacing: until the columns line up correctly
as in the code below:

define frame <thread-frame> (<dialog-frame>)
   pane latitude-pane  (frame)
    make(<text-field>, label: "Latitude:",
                              width: 30, fixed-width?: #t,
                             activate-callback: not-yet-implemented);

  pane longitude-pane  (frame)
    make(<text-field>, label: "Longitude:",
                              width: 30, fixed-width?: #t,
                             activate-callback: not-yet-implemented);

  pane data-layout (frame)
        vertically(  )
          horizontally(  )
             make( <label>, label: "Longitude");
             frame.longitude-pane;
          end;
          horizontally(x-spacing: 10)
             make( <label>, label: "Latitude");
             frame.latitude-pane;
          end;
        end;  // vertically ()

  layout (frame) frame.data-layout;
  keyword title: = "KLN 94 RS 232 Info";
end frame <thread-frame>;

Thanks in advance for any help.



Mon, 09 Dec 2002 03:00:00 GMT  
 DUIM question
The class <table-layout> is the way to do this. Try the following in
the Dylan Playground:

  contain(make(<table-layout>,
               children: vector(make(<label>, label: "Short"),
                                make(<text-field>),
                                make(<label>, label: "Much longer"),
                                make(<text-field>)),
               columns: 2,
               x-spacing: 2, y-spacing: 5,
               x-alignment: #[#"right", #"left"]));

The DUIM GUI test suite has a number of examples of this, try
the 'Borders' example for starters, in:

  [FD]\examples\duim\duim-gui-test-suite\borders.dylan

Hope this helps,

Andy

---
Andy Armstrong

On Thu, 22 Jun 2000 01:15:05  

Quote:

>What would be the simplest way to make a dialog with a series of text fields
>in a column, each with a text label to its left.  I would like all of the
>text fields to align with each other.  I've experimented with many of the
>keyword options to <row-layout>, but they don't seem to help (e.g.,
>equalize-widths: , x-ratios:, ratios:).   The only thing I can come up with
>so far is to experiment with x-spacing: until the columns line up correctly
>as in the code below:

>define frame <thread-frame> (<dialog-frame>)
>   pane latitude-pane  (frame)
>    make(<text-field>, label: "Latitude:",
>                              width: 30, fixed-width?: #t,
>                             activate-callback: not-yet-implemented);

>  pane longitude-pane  (frame)
>    make(<text-field>, label: "Longitude:",
>                              width: 30, fixed-width?: #t,
>                             activate-callback: not-yet-implemented);

>  pane data-layout (frame)
>        vertically(  )
>          horizontally(  )
>             make( <label>, label: "Longitude");
>             frame.longitude-pane;
>          end;
>          horizontally(x-spacing: 10)
>             make( <label>, label: "Latitude");
>             frame.latitude-pane;
>          end;
>        end;  // vertically ()

>  layout (frame) frame.data-layout;
>  keyword title: = "KLN 94 RS 232 Info";
>end frame <thread-frame>;

>Thanks in advance for any help.

Send FREE Greetings for Father's Day--or any day!
Click here: http://www.whowhere.lycos.com/redirects/fathers_day.rdct


Mon, 09 Dec 2002 03:00:00 GMT  
 DUIM question
Cool.  Thanks.  That should do the trick.  I didn't know about
<table-layout>.

Another ignorant question about DUIM:
I tried calling contain( make( <my-pane>)) in the playground with the
pane defined below, but it
didn't do what I expected--make a label and show it.  I'm guessing it
has something to do with display functions and setting up ports, etc.  I
get lost trying to follow it all.  Would I need to define a frame for
it?  I was trying to get to the point where I could experiment with
changing the font/size/style in the label.  Is that possible?

define pane <my-pane> ( )
   pane the-text (pane)
    make( <label> , label: "hello" );
   pane the-layout (pane)
    make( <fixed-layout> , children: pane.the-text );
end pane;


Quote:

> The class <table-layout> is the way to do this. Try the following in
> the Dylan Playground:

>   contain(make(<table-layout>,
>                children: vector(make(<label>, label: "Short"),
>                                 make(<text-field>),
>                                 make(<label>, label: "Much longer"),
>                                 make(<text-field>)),
>                columns: 2,
>                x-spacing: 2, y-spacing: 5,
>                x-alignment: #[#"right", #"left"]));

Sent via Deja.com http://www.deja.com/
Before you buy.


Mon, 09 Dec 2002 03:00:00 GMT  
 DUIM question

Quote:

> The class <table-layout> is the way to do this. Try the following in
> the Dylan Playground:

>   contain(make(<table-layout>,
>                children: vector(make(<label>, label: "Short"),
>                                 make(<text-field>),
>                                 make(<label>, label: "Much longer"),
>                                 make(<text-field>)),
>                columns: 2,
>                x-spacing: 2, y-spacing: 5,
>                x-alignment: #[#"right", #"left"]));

There is a "tabling" macro that you can use like this:

tabling(columns: 2, x-spacing: 2, y-spacing: 5,
             x-alignment: #[#"right", #"left"])
  make(<label>, label: "Short"),
  make(<text-field>),
  make(<label>, label: "Much longer"),
  make(<text-field>)
end;

Also note that there are "labelling" and a "grouping" convenience
macros too that you can use to ease the implementation of your layouts.

Sent via Deja.com http://www.deja.com/
Before you buy.



Mon, 09 Dec 2002 03:00:00 GMT  
 DUIM question
On Thu, 22 Jun 2000 11:15:02  

Quote:

>Cool.  Thanks.  That should do the trick.  I didn't know about
><table-layout>.

>Another ignorant question about DUIM:
>I tried calling contain( make( <my-pane>)) in the playground with the
>pane defined below, but it
>didn't do what I expected--make a label and show it.  I'm guessing it
>has something to do with display functions and setting up ports, etc.  I
>get lost trying to follow it all.  Would I need to define a frame for
>it?  I was trying to get to the point where I could experiment with
>changing the font/size/style in the label.  Is that possible?

>define pane <my-pane> ( )
>   pane the-text (pane)
>    make( <label> , label: "hello" );
>   pane the-layout (pane)
>    make( <fixed-layout> , children: pane.the-text );
>end pane;

You need to provide a layout clause, something like the
following should do:

define pane <my-pane> ()
  pane the-text (pane)
    make(<label>, label: "hello");
  layout (pane)
    vertically () pane.the-text end;
end pane <my-pane>;

But, you can just contain the label directly too:

  contain(make(<label>, label: "hello"));

All that 'contain' does is to create a frame to wrap up whatever
DUIM object you pass, and then calls start-frame on that frame. It
is a great tool for experimentation. Note that it even works with
menus, toolbars etc.:

  contain(make(<menu-box>, items: #["Red", "Green", "Blue"]));

  contain(make(<progress-bar>,
               value-range: range(from: 0, to: 100),
               value: 33));

Hope this helps,

Andy

---
Andy Armstrong

Send FREE Greetings for Father's Day--or any day!
Click here: http://www.whowhere.lycos.com/redirects/fathers_day.rdct



Mon, 09 Dec 2002 03:00:00 GMT  
 DUIM question
Maybe Carl Gay can regale us with the stories of his recent battles
with the Java GridBug class.  He has some Java code to do this,
and it's literally three screenfuls long.

Oh, I meant GridBag.

Quote:

>The class <table-layout> is the way to do this. Try the following in
>the Dylan Playground:

>  contain(make(<table-layout>,
>               children: vector(make(<label>, label: "Short"),
>                                make(<text-field>),
>                                make(<label>, label: "Much longer"),
>                                make(<text-field>)),
>               columns: 2,
>               x-spacing: 2, y-spacing: 5,
>               x-alignment: #[#"right", #"left"]));

>The DUIM GUI test suite has a number of examples of this, try
>the 'Borders' example for starters, in:

>  [FD]\examples\duim\duim-gui-test-suite\borders.dylan



Tue, 10 Dec 2002 03:00:00 GMT  
 DUIM question

Quote:

> Maybe Carl Gay can regale us with the stories of his recent battles
> with the Java GridBug class.  He has some Java code to do this,
> and it's literally three screenfuls long.

> Oh, I meant GridBag.

Actually after much time wasted with GridBug I found that there
_is_ a way to do this in Java that isn't too bad _once you know
how to do it_.  Basically you use two columns, each with a
GridLayout.  The fact that GridLayout ensures its cells are
all the same size makes the rows line up correctly:

    /**
     * Make a JPanel that has its components layed-out in two columns
     * each with an equal number of rows.  This is useful for preferences
     * panes and dialogs.



     *        numbered elements will appear in the left column and the odd
     *        in the right column.
     */
    public static JPanel make_2column_panel (String title, int spacing, Component[] components) {
        JPanel panel = new JPanel(new BorderLayout());
        JPanel columns = new JPanel(new BorderLayout());
        JPanel east = new JPanel(new GridLayout(0, 1, 5, 5));
        JPanel west = new JPanel(new GridLayout(0, 1, 5, 5));
        for (int i = 0; i < components.length; i++) {
            ((i % 2 == 0) ? west : east).add(components[i]);
        }
        columns.add(east, BorderLayout.EAST);
        columns.add(west, BorderLayout.WEST);
        if (title != null)
            panel.setBorder(Util.make_border(title, spacing));
        panel.add(columns, BorderLayout.WEST);
        panel.add(Box.createHorizontalGlue(), BorderLayout.CENTER);
        return panel;
    }

Unfortunately, as soon as you want to put anything of a different
height in one of the cells the above completely breaks down, and
that's exactly what I needed to do.  So it's back to GridBugLayout.

GridBugLayout is great for showing off deficiencies in the Java
language.  Because there are no keyword arguments it's hard to
create new GridBagConstraint objects with just the constraints
you want (so people end up reusing the same one, with the obvious
result).  Because of the dichotomy between Object and primitive
types it's hard to roll your own keyword args.  i.e., this doesn't
work:

  make_gbconstraint(new Object[] { "gridx", 1, "gridy", 2 });

Because there are no macros you can't do something like DUIM's
tabling macro.  It's just an all-around Bad Scene.

I'm hoping I'll find the time to convert this app to Dylan for
a full comparison, but you know how that goes.

Quote:

> >The class <table-layout> is the way to do this. Try the following in
> >the Dylan Playground:

> >  contain(make(<table-layout>,
> >               children: vector(make(<label>, label: "Short"),
> >                                make(<text-field>),
> >                                make(<label>, label: "Much longer"),
> >                                make(<text-field>)),
> >               columns: 2,
> >               x-spacing: 2, y-spacing: 5,
> >               x-alignment: #[#"right", #"left"]));

> >The DUIM GUI test suite has a number of examples of this, try
> >the 'Borders' example for starters, in:

> >  [FD]\examples\duim\duim-gui-test-suite\borders.dylan



Tue, 10 Dec 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. DUIM question

2. DUIM focus question

3. A duim menu question

4. DUIM font question

5. Stupid question about DUIM/widgets

6. problem with DUIM at higher resolutions

7. updating an icon label in DUIM

8. updating an icon label in DUIM

9. help with DUIM application

10. DUIM clipboard

11. <tree-node> in DUIM

12. Browser gadget sugguestions for a DUIM app

 

 
Powered by phpBB® Forum Software