On 18.08.2012, at 09:24, David FLEURY <dfleu...@free.fr> wrote:

> Hi,
> 
> (I starting to use Fl_Text_Display/Editor to do something like NEdit, so 
> I have a lot of questions)
> 
> I was wondering why xy_to_rowcol is protected ?
> or is there a way to have the current line displayed ?
> 
> For column, there is position_to_xy and x_to_col, but found nothing for 
> y_to_line ?


Congratulations on scraping the paint on the most complex and convoluted widget 
in FLTK (besides HelpView, maybe) ;-)

TextDisplay and TextEdit are based on an old version of NEdit with permission 
of the authors. Originally it was a source code editor wfor ASCII characters 
and monospaced fonts. Proportional font support was added later and has 
generated a lot of special cases and places where we need to measure and count 
instead of just ,ultiplying the number of bytes by a character width to get 
pixel positions.

A couple of years ago, I made it worse by adding UTF8 support to this widget, 
generating a lot of byte counting on top of pixel counting. You are welcome ;-)

What I want to say is, that a lot of interfaces or non obvious, and a lot of 
methods may take more time than it is obvious. However, I think that there is a 
pretty complete set of methods for this class. You are probably looking for 
this function:

/**
\brief Translate pixel coordinates into row and column.

Translate window coordinates to the nearest row and column number for
positioning the cursor.  This, of course, makes no sense when the font is
proportional, since there are no absolute columns.  The parameter posType
specifies how to interpret the position: CURSOR_POS means translate the
coordinates to the nearest position between characters, and CHARACTER_POS
means translate the position to the nearest character cell.

\param X, Y pixel coordinates
\param[out] row, column nearest row and column
\param posType CURSOR_POS or CHARACTER_POS
*/
void fltk3::TextDisplay::xy_to_rowcol( int X, int Y, int *row,
                              int *column, int posType ) const {

_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to