Hello Jean-Marc, > > Le 26/06/2013 08:45, Hashini Senaratne a écrit : > > Hello Jean-Marc, > > > >> * A Cursor is a descendant of CursorData that contains interesting > >> display-related information, in particular targetX(), the horizontal > >> position of the cursor in pixels. > > > > I checked targetX() and it only gets changed when the cursor is moving along > > a Math equation. > > To mention more precisely, when I am typing normal text, targertX() value > > changes, when I typing in a Math inset targetX() do not change. But when I > > go along a already typed text targetX() do not change and when I go along a > > already inserted Math targetX() changes accordingly. > > Why is that? > > Is not targetX() valid for any Row? > > Is there any other attribute that can be used to absolute pixel value where > > the cursor lies in. > > You can use setTargetX() to force a recomputation. Does this work? >
Sorry that did not work. I am using this within drawparagraph() of TextMetrics. As setTargetX() is not a const method, I cannot call it as cur.setTargetX(). So I defined another non- cnstant cursor called 'cr'.and setTargetX(). Before I call the setTagetX I tried printing x_target() (which will return targetX or -1 if unset). Here I got -1 when I am in the Math and the value same as targetX() when I am within the text. (Actually what I hoped to get is a result which is totally upside down) But as I mentioned, that value did not change when I go right or left in that same text row. Then I called cr.setTargetX() and againg tried printing x_target() values. There I did not get any -1 for any case. The value I got was exactly like the value from targetX(). But here also nothing changed when moving to and fro in a text row. So the problem did not solve. Am I doing anything wrong? And as I figured out, the comment for int targetX() const; in Cursor.h file is wrong. It says "in pixels from left of screen, set to current position if unset", but it really does not set to current position if unset. void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) const { //... Cursor const & cur = bv_->cursor(); Cursor & cr = bv_->cursor(); //... for (size_t i = 0; i != nrows; ++i) { Row const & row = pm.rows()[i]; if (i) y += row.ascent(); bool const inside = (y + row.descent() >= 0 && y - row.ascent() < ww); // It is not needed to draw on screen if we are not inside. pi.pain.setDrawingEnabled(inside && original_drawing_state); // horizontal sliding for too long insects int inc_x=x; //current x position of the cursor in pixels int cur_x=cur.targetX(); BufferView & bv = cur.bv(); int const maxwidth = bv.workWidth(); if (cur_x >= maxwidth) inc_x-=(cur_x-maxwidth)+10; //test cr.setTargetX(); cout << "targetX(): " << cur.targetX() << " " << cur.x_target() << endl; RowPainter rp(pi, *text_, pit, row, bidi, inc_x, y);