mirror of
https://github.com/fltk/fltk.git
synced 2026-06-05 16:12:13 +08:00
Fixed Fl_Text_Display redrawing for focus changes for primary selection and highlight
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@6011 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -669,6 +669,11 @@ void Fl_Text_Buffer::secondary_select_rectangular( int start, int end,
|
||||
redisplay_selection( &oldSelection, &mSecondary );
|
||||
}
|
||||
|
||||
int Fl_Text_Buffer::secondary_selection_position( int *start, int *end
|
||||
) {
|
||||
return mSecondary.position( start, end );
|
||||
}
|
||||
|
||||
int Fl_Text_Buffer::secondary_selection_position( int *start, int *end,
|
||||
int *isRect, int *rectStart, int *rectEnd ) {
|
||||
return mSecondary.position( start, end, isRect, rectStart,
|
||||
@@ -709,6 +714,11 @@ void Fl_Text_Buffer::highlight_rectangular( int start, int end,
|
||||
redisplay_selection( &oldSelection, &mHighlight );
|
||||
}
|
||||
|
||||
int Fl_Text_Buffer::highlight_position( int *start, int *end
|
||||
) {
|
||||
return mHighlight.position( start, end );
|
||||
}
|
||||
|
||||
int Fl_Text_Buffer::highlight_position( int *start, int *end,
|
||||
int *isRect, int *rectStart, int *rectEnd ) {
|
||||
return mHighlight.position( start, end, isRect, rectStart,
|
||||
|
||||
+36
-18
@@ -1662,16 +1662,22 @@ void Fl_Text_Display::draw_string( int style, int X, int Y, int toX,
|
||||
font = styleRec->font;
|
||||
fsize = styleRec->size;
|
||||
|
||||
if (style & (HIGHLIGHT_MASK | PRIMARY_MASK)) {
|
||||
if (style & PRIMARY_MASK) {
|
||||
if (Fl::focus() == this) background = selection_color();
|
||||
else background = fl_color_average(color(), selection_color(), 0.5f);
|
||||
} else if (style & HIGHLIGHT_MASK) {
|
||||
if (Fl::focus() == this) background = fl_color_average(color(), selection_color(), 0.8f);
|
||||
else background = fl_color_average(color(), selection_color(), 0.9f);
|
||||
} else background = color();
|
||||
|
||||
foreground = fl_contrast(styleRec->color, background);
|
||||
} else if (style & (HIGHLIGHT_MASK | PRIMARY_MASK)) {
|
||||
} else if (style & PRIMARY_MASK) {
|
||||
if (Fl::focus() == this) background = selection_color();
|
||||
else background = fl_color_average(color(), selection_color(), 0.5f);
|
||||
foreground = fl_contrast(textcolor(), background);
|
||||
} else if (style & HIGHLIGHT_MASK) {
|
||||
if (Fl::focus() == this) background = fl_color_average(color(), selection_color(), 0.8f);
|
||||
else background = fl_color_average(color(), selection_color(), 0.9f);
|
||||
foreground = fl_contrast(textcolor(), background);
|
||||
} else {
|
||||
foreground = textcolor();
|
||||
background = color();
|
||||
@@ -1707,6 +1713,7 @@ void Fl_Text_Display::draw_string( int style, int X, int Y, int toX,
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Clear a rectangle with the appropriate background color for "style"
|
||||
*/
|
||||
@@ -1716,27 +1723,25 @@ void Fl_Text_Display::clear_rect( int style, int X, int Y,
|
||||
if ( width == 0 )
|
||||
return;
|
||||
|
||||
if ( Fl::focus() != this ) {
|
||||
if (style & (HIGHLIGHT_MASK | PRIMARY_MASK)) {
|
||||
fl_color(fl_color_average(color(), selection_color(), 0.5f));
|
||||
if (style & PRIMARY_MASK) {
|
||||
if (Fl::focus()==this) {
|
||||
fl_color(selection_color());
|
||||
} else {
|
||||
fl_color( color() );
|
||||
fl_color(fl_color_average(color(), selection_color(), 0.5f));
|
||||
}
|
||||
} else if (style & HIGHLIGHT_MASK) {
|
||||
if (Fl::focus()==this) {
|
||||
fl_color(fl_color_average(color(), selection_color(), 0.8f));
|
||||
} else {
|
||||
fl_color(fl_color_average(color(), selection_color(), 0.9f));
|
||||
}
|
||||
fl_rectf( X, Y, width, height );
|
||||
} else if ( style & HIGHLIGHT_MASK ) {
|
||||
fl_color( fl_contrast(textcolor(), color()) );
|
||||
fl_rectf( X, Y, width, height );
|
||||
} else if ( style & PRIMARY_MASK ) {
|
||||
fl_color( selection_color() );
|
||||
fl_rectf( X, Y, width, height );
|
||||
} else {
|
||||
fl_color( color() );
|
||||
fl_rectf( X, Y, width, height );
|
||||
}
|
||||
fl_rectf( X, Y, width, height );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** Draw a cursor with top center at X, y.
|
||||
*/
|
||||
@@ -3219,8 +3224,21 @@ int Fl_Text_Display::handle(int event) {
|
||||
case FL_UNFOCUS:
|
||||
if (active_r() && window()) window()->cursor(FL_CURSOR_DEFAULT);
|
||||
case FL_FOCUS:
|
||||
if (buffer()->selected()) redraw();
|
||||
|
||||
if (buffer()->selected()) {
|
||||
int start, end;
|
||||
if (buffer()->selection_position(&start, &end))
|
||||
redisplay_range(start, end);
|
||||
}
|
||||
if (buffer()->secondary_selected()) {
|
||||
int start, end;
|
||||
if (buffer()->secondary_selection_position(&start, &end))
|
||||
redisplay_range(start, end);
|
||||
}
|
||||
if (buffer()->highlight()) {
|
||||
int start, end;
|
||||
if (buffer()->highlight_position(&start, &end))
|
||||
redisplay_range(start, end);
|
||||
}
|
||||
return 1;
|
||||
|
||||
case FL_KEYBOARD:
|
||||
|
||||
Reference in New Issue
Block a user