@ -40,11 +40,12 @@
@@ -40,11 +40,12 @@
# include "Fl_Text_Buffer.H"
/**
This is the FLTK text display widget . It allows the user to
view multiple lines of text and supports highlighting and
scrolling . The buffer that is displayed in the widget is managed
by the Fl_Text_Buffer
class .
\ brief Rich text display widget .
This is the FLTK text display widget . It allows the user to view multiple lines
of text and supports highlighting and scrolling . The buffer that is displayed
in the widget is managed by the Fl_Text_Buffer class . A single Text Buffer
can be displayed by multiple Text Displays .
*/
class FL_EXPORT Fl_Text_Display : public Fl_Group
{
@ -54,8 +55,11 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -54,8 +55,11 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
text display cursor shapes enumeration
*/
enum {
NORMAL_CURSOR , CARET_CURSOR , DIM_CURSOR ,
BLOCK_CURSOR , HEAVY_CURSOR
NORMAL_CURSOR , /**< I-beam */
CARET_CURSOR , /**< caret under the text */
DIM_CURSOR , /**< dim I-beam */
BLOCK_CURSOR , /**< unfille box under the current character */
HEAVY_CURSOR /**< thick I-beam */
} ;
/**
@ -64,7 +68,8 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -64,7 +68,8 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
characters .
*/
enum {
CURSOR_POS , CHARACTER_POS
CURSOR_POS ,
CHARACTER_POS
} ;
/**
@ -73,22 +78,15 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -73,22 +78,15 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
word and triple clicking selects by line .
*/
enum {
DRAG_CHAR = 0 , DRAG_WORD = 1 , DRAG_LINE = 2
DRAG_CHAR = 0 ,
DRAG_WORD = 1 ,
DRAG_LINE = 2
} ;
friend void fl_text_drag_me ( int pos , Fl_Text_Display * d ) ;
typedef void ( * Unfinished_Style_Cb ) ( int , void * ) ;
/**
style attributes - currently not implemented !
*/
enum {
ATTR_NONE = 0 ,
ATTR_UNDERLINE = 1 ,
ATTR_HIDDEN = 2
} ;
/**
This structure associates the color , font , size of a string to draw
with an attribute mask matching attr
@ -96,7 +94,7 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -96,7 +94,7 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
struct Style_Table_Entry {
Fl_Color color ;
Fl_Font font ;
int size ;
Fl_Fontsize size ;
unsigned attr ;
} ;
@ -104,17 +102,20 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -104,17 +102,20 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
~ Fl_Text_Display ( ) ;
virtual int handle ( int e ) ;
void buffer ( Fl_Text_Buffer * buf ) ;
/**
Sets or g ets the current text buffer associated with the text widget .
Sets the current text buffer associated with the text widget .
Multiple text widgets can be associated with the same text buffer .
\ param buf new text buffer
*/
void buffer ( Fl_Text_Buffer & buf ) { buffer ( & buf ) ; }
/**
Gets the current text buffer associated with the text widget .
Multiple text widgets can be associated with the same text buffer .
\ return current text buffer
*/
Fl_Text_Buffer * buffer ( ) const { return mBuffer ; }
@ -126,11 +127,13 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -126,11 +127,13 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
/**
Gets the position of the text insertion cursor for text display
\ return insert position index into text buffer
*/
int insert_position ( ) const { return mCursorPos ; }
int in_selection ( int x , int y ) const ;
void show_insert_position ( ) ;
int move_right ( ) ;
int move_left ( ) ;
int move_up ( ) ;
@ -142,6 +145,7 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -142,6 +145,7 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
int rewind_lines ( int startPos , int nLines ) ;
void next_word ( void ) ;
void previous_word ( void ) ;
void show_cursor ( int b = 1 ) ;
/**
@ -152,42 +156,52 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -152,42 +156,52 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
void cursor_style ( int style ) ;
/**
Sets or gets the text cursor color .
Gets the text cursor color .
\ return cursor color
*/
Fl_Color cursor_color ( ) const { return mCursor_color ; }
/**
Sets or gets the text cursor color .
Sets the text cursor color .
\ param n new cursor color
*/
void cursor_color ( Fl_Color n ) { mCursor_color = n ; }
/**
Sets or gets the width / height of the scrollbars .
Gets the width / height of the scrollbars .
/ return width of scrollbars
*/
int scrollbar_width ( ) const { return scrollbar_width_ ; }
/**
Sets or gets the width / height of the scrollbars .
Sets the width / height of the scrollbars .
\ param W width of scrollbars
*/
void scrollbar_width ( int W ) { scrollbar_width_ = W ; }
/**
Gets the scrollbar alignment type
\ return scrollbar alignment
*/
Fl_Align scrollbar_align ( ) const { return scrollbar_align_ ; }
/**
Sets the scrollbar alignment type
\ param a new scrollbar alignment
*/
void scrollbar_align ( Fl_Align a ) { scrollbar_align_ = a ; }
/**
Moves the insert position to the beginning of the current word .
\ param pos start calculation at this index
\ return beginning of the wors
*/
int word_start ( int pos ) const { return buffer ( ) - > word_start ( pos ) ; }
/**
Moves the insert position to the end of the current word .
\ param pos start calculation at this index
\ return index of first character after the end of the word
*/
int word_end ( int pos ) const { return buffer ( ) - > word_end ( pos ) ; }
@ -203,42 +217,50 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -203,42 +217,50 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
/**
\ todo FIXME : get set methods pointing on shortcut_
have no effects as shortcut_ is unused in this class and derived !
\ return the current shortcut key
*/
int shortcut ( ) const { return shortcut_ ; }
/**
\ todo FIXME : get set methods pointing on shortcut_
have no effects as shortcut_ is unused in this class and derived !
\ param s the new shortcut key
*/
void shortcut ( int s ) { shortcut_ = s ; }
/**
Gets the default font used when drawing text in the widget .
\ return current text font face unless overriden by a style
*/
Fl_Font textfont ( ) const { return textfont_ ; }
/**
Sets the default font used when drawing text in the widget .
\ param s default text font face
*/
void textfont ( Fl_Font s ) { textfont_ = s ; }
/**
Gets the default size of text in the widget .
\ return current text height unless overriden by a style
*/
Fl_Fontsize textsize ( ) const { return textsize_ ; }
/**
Sets the default size of text in the widget .
\ param s new text size
*/
void textsize ( Fl_Fontsize s ) { textsize_ = s ; }
/**
Gets the default color of text in the widget .
\ return text color unless overriden by a style
*/
Fl_Color textcolor ( ) const { return textcolor_ ; }
/**
Sets the default color of text in the widget .
\ param n new text color
*/
void textcolor ( Fl_Color n ) { textcolor_ = n ; }
@ -266,7 +288,13 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
@@ -266,7 +288,13 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group
int leftCharIndex , int rightCharIndex ) ;
int find_x ( const char * s , int len , int style , int x ) const ;
enum { DRAW_LINE , FIND_INDEX , GET_WIDTH } ;
enum {
DRAW_LINE ,
FIND_INDEX ,
GET_WIDTH
} ;
int handle_vline ( int mode ,
int lineStart , int lineLen , int leftChar , int rightChar ,
int topClip , int bottomClip ,