Andrew Lister <[EMAIL PROTECTED]> wrote:
> >to the beginning of the DrawCB() function in examples/draw.c and see what
> >happens when changing the cell focus, either by Tab traversing or clicking
> with
> >the mouse. For such an event, Xbae makes _4_ redraws: (old cell) (old cell)
> (new
> >cell) (old cell), while I'd expect only two are needed: (old cell) (new
> cell).
>
> While it sounds good in theory, there are actually more calls needed in
> practice due to the refresh of the text widget and Xbae not really knowing
> where it is. I believe it is caused by the draw cell cb asking what i should
> draw in the text field *twice* - once for the leaveCell, once for the
> enterCell, and then asking what it needs for the non-text cell.
Well, I disabled leave, enter, and write callbacks with the same result. Also, I
do use it for text, not pixmaps.
> If you think about it, when you leave a cell, it (the matrix) has to
> request wha's in the current cell (one call), leave it (another), find
> out what's in the next cell (another) and redraw that (anoher).
That means the old-old-new-new order. In practice, it's old-old-new-old; which
proves that a single call is enough for the (new) cell, hence I don't understand
why it needs to query the old one three times.
> The reason
> for that is so it knows what should be passed to the appropriate callback.
> It's possible that it could be streamlined but I doubt the overhead is
> significant.
Just times two :-). The "2" factor is quite important when the draw callback is
a complex thing (not just sprintf).
> BTW Does the same happen when not using the drawCellCallback? I would
> expect not as all the information is "at hand".
May be; however, without the callback the issue is not really important.
Actually, I'd rather discuss whether the current implementation of
drawCellCallback is meaningful. Namely, the fact that it does NOT copy the
supplied value. Why? What's the reasoning behind that? In the man page, one
finds that
By defining an XmNdrawCellCallback the need for the
storage of the XbaeMatrix data within the matrix is
eliminated and can prove to be advantageous for mem-
ory usage.
But since the values are not copied, the application must worry about allocating
them as needed; and since there is no way to know when the strings are not
needed anymore (because of the asynchronous nature of X), one ends up with
allocating the whole 2d array anyway. It would be better if Xbae did copy the
strings and freed them as necessary. Alternatively, (probably the best way,
since it won't break the backward compatibility) the cbs->value as passed _to_
the callback should contain the previously supplied by the application value
(now it's always ""). Then the app would reallocate it.
Regards,
Evgeny
--
____________________________________________________________
/ Evgeny Stambulchik <[EMAIL PROTECTED]> \
/ Plasma Laboratory, Weizmann Institute of Science, Israel \ \
| Phone : (972)8-934-3610 == | == FAX : (972)8-934-3491 | |
| URL : http://plasma-gate.weizmann.ac.il/~fnevgeny/ | |
| Finger for PGP key >=====================================+ |
|______________________________________________________________|