How to shrinkwrap a shell with a table

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to shrinkwrap a shell with a table

Jochen Riekhof-8
Hi...

my Shells contain a table. I would like to set the inital size of my
shell such that all column values and rows in the contained table are
fully visible. This resembles doubleclicking all the seams between
columns in the table header bar) and then resizing the window such that
all rows and columns are visible (I do not have that many rows and columns).

Is this possible in some way?

Ciao

...Jochen


Reply | Threaded
Open this post in threaded view
|

Re: How to shrinkwrap a shell with a table

Schwab,Wilhelm K
Jochen,

> my Shells contain a table. I would like to set the inital size of my
> shell such that all column values and rows in the contained table are
> fully visible. This resembles doubleclicking all the seams between
> columns in the table header bar) and then resizing the window such that
> all rows and columns are visible (I do not have that many rows and
> columns).
>
> Is this possible in some way?

If I'm following you, there is an auto size option (for the columns of
an enhanced list view) that might do what you want.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How to shrinkwrap a shell with a table

Jochen Riekhof-8
Hi Bill...

yep, I use autosize to scale the table columns according to window size,
but what I want is kind of the opposite. A filled table has some ideal
column width that would just show all the contents untruncated but not
moer. You can easily achieve this by doubleclicking on the thin seam
between adjacent columns in the column header (seems to be windows
functionality). Given I have done this for all my columns I will end up
with some size I have to resize my window to that shows all the table
contents untruncated but does not waste any more screen space - this is
what I meant with shrinkwrapped. I am just wondering if one could do
this programmatically. Currently I open the shells all with a given size
and have to manually doubleclick all the column seams, then resize the
window manually - quite annoying.

If the width is not working the height would be a big help. E.g. some of
my tables have merely two rows, others 20. If I could resize the shell
to just show all rows but not more, this would be a good start. I
thought I could just nil out preferredExtent and let the layout do the
job but it does not seem to work.

Ciao

...Jochen


Reply | Threaded
Open this post in threaded view
|

Re: How to shrinkwrap a shell with a table

Ian Bartholomew-21
Jochen,

I've had a play and came up with the following workspace code.  It isn't
pretty but it sort of works.  There are a couple of "fiddle factors"
(see inline comments) that could probably be eliminated with a bit more
work.

You can test the rearrangement by removing the $m from the list of
characters in the "populate it" section.  It generates the widest field.

"SETUP
add a couple of missing methods"
ListView compile: 'lvmGetTopIndex ^self sendMessage: 4135
"LVM_GETTOPINDEX"'.
ListView compile: 'lvmGetCountPerPage ^self sendMessage: 4136
"LVM_GETCOUNTPERPAGE"'.

"create a ListView with 4 columns"
lv := ListView show.
lv primaryColumn text: 'Col1'.
lv addColumn: (ListViewColumn text: 'Col2').
lv addColumn: (ListViewColumn text: 'Col3').
lv addColumn: (ListViewColumn text: 'Col4').
lv getImageBlock: nil.
(lv columnAtIndex: 1) getTextBlock: [:item | item at: 1]; isAutoResize:
false; width: 10.
(lv columnAtIndex: 2) getTextBlock: [:item | item at: 2]; isAutoResize:
false; width: 10.
(lv columnAtIndex: 3) getTextBlock: [:item | item at: 3]; isAutoResize:
false; width: 10.
(lv columnAtIndex: 4) getTextBlock: [:item | item at: 4]; isAutoResize:
false; width: 10.

"populate it"
lv list: ('abcdefghijklmnopqrstuvwxyz' asArray collect: [:each |
        Array
                with: ((String new: 2) atAllPut: each)
                with: ((String new: 4) atAllPut: each)
                with: ((String new: 6) atAllPut: each)
                with: ((String new: 9) atAllPut: each)]).

"REARRANGE
for each column find out the maximum width of each string and set the
column's width to the widest.

it needs two fiddle factors
1) allow for excta whitespace in each cell
2) allow some extra room for the vertical scroll bar "
top := lv lvmGetTopIndex. "first visible item (0 based)"
count := lv lvmGetCountPerPage. "visible rows"
fiddle := 8.
total := 0.
1 to: 4 do: [:index | | max |
        "width of title"
        max := lv lvmGetStringWidth: (lv columnAtIndex: index) text.
        top to: top + count do: [:row |
                "width of cells in column"
                max := max max: (lv lvmGetStringWidth: ((lv list at: row + 1) at:
index) printString)].
        (lv columnAtIndex: index) width: max + fiddle.
        total := total + max + fiddle].

"now set the width of the top shell + scroll bar"
lv topShell width: total + 32


--
Ian

Use the Reply-To address to contact me (limited validity).
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: How to shrinkwrap a shell with a table

Jochen Riekhof-6
Hi Ian...

wow, this is much more I expected! Thanks a lot! Actually I do not even
need the two added methods to list view as I enlarge the shell in height
anyway to hold the whole table. The height-adjusting was easy with your
example at hand. Nevertheless the two methods are great to know! The
fiddle factors are weird, looks to me like the 8 pixels fiddle per
column are somewhat hardcoded inside the table. Anyway it workd great
for me, thanks again!

Ciao

...Jochen