On 09/15/2010 03:02 AM, Richard Heck wrote:
On 09/14/2010 07:31 PM, Uwe Stöhr wrote:
Am 14.09.2010 20:13, schrieb Andre Poenitz:
This is my problem:
In line 433 of TextMetrics.cpp the text width is calculated:
int const w = max_width_ - leftMargin(max_width_, pit, ii->pos)
- right_margin;
I need this result "w" in InsetLine::draw to be able to draw the line.
The store it in the inset?
How can I do this without changing the code for all of our 98!
insets? This information is only needed in InsetLine and I thus
cannot pollute all other insets with info.
If there is no other solution than to make it accessible for all
insets, how can I do it?
Right, we don't want to have a member in all the insets. But you get a
chance to store it in InsetLine::metrics(), where it's available as
mi.base.textwidth. In fact, it may already be cached for you by the
setDimCache() call at the end of that routine,
Yes, it's cached there (unless Uwe removed that part too).
but I don't know that stuff well enough to know how to access that.
My fix did that. There was a FIXME here about InsetCommand::dimension()
which gives the dimension of the button. Problem is that the InsetLine
does not use any button. So using InsetCommand for InsetLine is not a
good fit. This part of InsetCommand must be reworked I think.
That said, Abdel's previous comment applies here: The value you want
is dependent upon the BufferView, so you cannot just calculate it and
store it once and for all. You'll need something like a map<BufferView
const *, int> to store it for each BufferView. You can get the
BufferView back from the PainterInfo in the draw() routine and then
recover the value.
Correct.
Actually, looking at this again: Isn't pi.base.textwidth what you need
there?
No, rather mi.base.textwidth in the metric() routine. The draw() routine
should not do any calculation, it should just draw.
Abdel.