Duncan Gibson wrote:
>> my question is say i have text editor component with size of
>> h = 30
>> w = 40
>> and im wrap mode with scrolls disabled, how can i detect when i
>> typing text its reaching to the end of the size defined that is
>> h = 30 then it will stop me from typing .
> 
> 
> You will need to use fl_measure() in your callback to work out the
> width of the text in pixels and take action appropriately.

I'm afraid that it is not that easy with Fl_Text_Editor in wrap mode.

Maybe this can help:

int nlines = editor->count_lines(0,editor->buffer()->length(),1);

If editor is a pointer to your Fl_Text_Editor widget, this will return the 
number of lines needed to display the text with the current display width.

Maybe you (Meir) can estimate the line height or use the font height. I suggest 
that you look at the docs for Fl_Text_Editor, Fl_Text_Display, and 
Fl_Text_Buffer yourself. Maybe there are other methods that can help...

Measuring the text height of an arbitrary string, as Duncan wrote, can work, 
but 
the editor widget is capable of setting different text attributes, and this can 
make things even more difficult.

However, if you use only one font, ... maybe Duncan's suggestion would work if 
you set the correct width on input...

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to