On Sun, Dec 4, 2011 at 11:23 PM, Jesse Vander Does <[email protected]> wrote: > I am having some trouble getting the layout I would like, I suspect I am > missing something fundamental about how to use pyjs widgets. I am using a > vertical layout with a label set to a fixed height on the top and a scroll > panel containing a table bellow. The scroll panel and table should resize > to fill what the header does not. > > The problem is that even though the header is set to a fixed number of > pixels and the scroll table is set to a width/height of 100%, the vertical > panel seems to give each widget 50% of the screen. What am I missing?
that's just how tables behave in general. cells don't really care about their contents until the contents grow larger than their allocated space -- keep in mind, as it will help to understand *any* provided "solution" -- and cells can never, ever -- EVER -- be smaller than their contents. ever. this is just how tables behave since the beginning of time (but it can be used to our benefit). solution A: 1) set <html> *and* <body> are 100% x 100% 2) set verticalpanel to 100% x 100% 3) set verticalpanel.setCellHeight(label, '1px') 4) do NOT define a height for scrollpanel cell 5) add a wrapper, a simplepanel, to scrollpanel cell 6) set wrapper to relative positioning, and 100% x 100% 7) add scrollpanel to wrapper 8) set scrollpanel to absolute positioning, and set top/bottom/left/right to '0' 9) add stuff to scrollpanel 10) ... 11) PROFIT! solution B: 1-4) [see above] 5) add scrollpanel to scrollpanel cell 6) add an obscenely large negative bottom margin to scrollpanel 6a) ... this margin must be larger than the scrollpanel will ever be 6b) ... and no, negative 100% doesn't work due to W3C oversight :-( 7) add stuff to scrollpanel 8) ... 9) PROFIT! [ B is detailed here: http://pyjs.org/wiki/csshellandhowtodealwithit/ ] ... probably are other ways too. ultimately, because table cells cannot overflow, a child, normal flow <div> WILL NEVER overflow because it's container (the cell) will keep obnoxiously expanding to accommodate (a div MUST be first constrained by it's containing block [or absolute dimensions] before overflowing). solution B works around this by convincing the cell it's OK to collapse on the div, and hence trigger overflow ... solution A sidesteps the issue completely by removing the scrollpanel from normal flow immediately. both rely on the outer table dimensions preventing complete collapse (eg. without step #2 the scrollpanel cell will collapse to nothing, in both A and B). there might be some ways using floats by virtue of their normal "anti-clearfix" behavior, not tested. B is hacky and has unknown consequences. A is more verbose but ultimately correct. both appear to work in my experiences, but i prefer A. note the `1px` height -- some people will use other methods but i find this to be rock solid. since a cell will always expand, setting to `1px` effectively means "minimize this cell". minimization works for N cells, so long as at least ONE is undefined (to accommodate any remaining space). there is one other cool trick related to this ... proportional cell spacing. when all cells are defined in a given dimension, but the table's calculated dimension is LARGER than the cells, the remaining space is distributed proportionally amongst the cells ... ... an example is better ... for a 4x1 table (w x h) 1px, 1px, 1px, 1px = 1/4, 1/4, 1/4, 1/4 1px, 1px, 2px, 1px = 1/5, 1/5, 2/5, 1/5 1px, 1px, 2px, 2px = 1/6, 1/6, 1/3, 1/3 1px, 2px, 3px, 4px = 1/10, 1/5, 3/10, 2/5 unfortunately if you want to be a pyjamasta, you'll have to learn to wield the mighty CSS stick-of-power ... despite being worth massive hit points, it's crazy heavy, worthless in boss matches, changes properties by world, and tends to wet-noodle-slap-you-in-the-face at the worst of times ... other than that it's pretty sweet ;-) hth -- C Anthony

