|
From: | Benja Fallenstein |
Subject: | Re: [Gzz-commits] gzz/gzz/view LinebrokenCellContentView.java |
Date: | Fri, 10 Jan 2003 20:23:18 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021226 Debian/1.2.1-9 |
Asko Soukka wrote:
Hi :) Fri, 10 Jan 2003, Benja Fallenstein wrote:Fixing LinebrokenCellContentView.getSize()Can you explain this fix to me, please? I don't understand it :)I tried to do this: lines = s.split("\n") max_width = style.getWidth(line[0], scale) for line in lines: line_width = style.getWidth(line, scale) if line_width > max_width: max_width = line_width Without this PP looked ugly, because width of a bouding box it drew around linked cell was width of the whole content of that cell. Now LinebrokenCellContentView returns the width of its longest line.
*thinking* *thinking more* *emitting smoke from ears*Wait. You're saying that it didn't do linebreaking? And you made it so that it linebreaks at newlines (and nowhere else)? Nonono, that's wrong. Not as wrong as it was before, but still wrong. ;-)
getSize() is supposed to be used by the views to decide what size the box should be they give to the Cell(Content)View. Now, think about what your algorithm would do: Make the box big enough that the longest paragraph fits into it as a single line! *Very* wide boxes... reminds me of 0.6 StretchVanishing ugliness ;)
In practice, it seems that getSize() isn't used-- getHeight() is used instead. getHeight() takes a given width, does the linebreaking and computes the height necessary to layout the text.
Now, what getSize() should do is: width = style.getWidth(widthString, scale) height = getHeight(cell, width, scale)The purpose of widthString is to determine the width of the cell, by computing what the width of that string is at the given scale.
But the above is indeed not what LCCV did. It did this: width = style.getWidth(text_in_cell, scale) height = getHeight(cell, width, scale)So, it took all the text in the cell to compute the cell's width, which should really be fixed (the *height* should grow when the text grows).
I will fix this, and it will look better-- if you want linebreaking at places other than "\n". I'm not sure whether you want this in PP; do tell. If not, we can easily find a way to make it the way you want, but your change is the wrong way because it breaks the desired view behavior :-)
- Benja
[Prev in Thread] | Current Thread | [Next in Thread] |