Fixes STR #3219, deactivate colors issue with Fl_Text_Display/Editor.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10705 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Greg Ercolano
2015-04-14 22:28:33 +00:00
parent 1bfb17fb55
commit f81374166b
+28 -15
View File
@@ -2164,6 +2164,11 @@ void Fl_Text_Display::draw_string(int style,
background = color(); background = color();
} }
if ( !active_r() ) {
foreground = fl_inactive(foreground);
background = fl_inactive(background);
}
if (!(style & TEXT_ONLY_MASK)) { if (!(style & TEXT_ONLY_MASK)) {
fl_color( background ); fl_color( background );
fl_rectf( X, Y, toX - X, mMaxsize ); fl_rectf( X, Y, toX - X, mMaxsize );
@@ -2222,21 +2227,23 @@ void Fl_Text_Display::clear_rect(int style,
if ( width == 0 ) if ( width == 0 )
return; return;
Fl_Color c;
if (style & PRIMARY_MASK) { if (style & PRIMARY_MASK) {
if (Fl::focus()==(Fl_Widget*)this) { if (Fl::focus()==(Fl_Widget*)this) {
fl_color(selection_color()); c = selection_color();
} else { } else {
fl_color(fl_color_average(color(), selection_color(), 0.4f)); c = fl_color_average(color(), selection_color(), 0.4f);
} }
} else if (style & HIGHLIGHT_MASK) { } else if (style & HIGHLIGHT_MASK) {
if (Fl::focus()==(Fl_Widget*)this) { if (Fl::focus()==(Fl_Widget*)this) {
fl_color(fl_color_average(color(), selection_color(), 0.5f)); c = fl_color_average(color(), selection_color(), 0.5f);
} else { } else {
fl_color(fl_color_average(color(), selection_color(), 0.6f)); c = fl_color_average(color(), selection_color(), 0.6f);
} }
} else { } else {
fl_color( color() ); c = color();
} }
fl_color(active_r() ? c : fl_inactive(c));
fl_rectf( X, Y, width, height ); fl_rectf( X, Y, width, height );
} }
@@ -2857,6 +2864,7 @@ void Fl_Text_Display::draw_line_numbers(bool /*clearAll*/) {
int Y, line, visLine, lineStart; int Y, line, visLine, lineStart;
char lineNumString[16]; char lineNumString[16];
int lineHeight = mMaxsize; int lineHeight = mMaxsize;
int isactive = active_r() ? 1 : 0;
// Don't draw if lineNumWidth == 0 (line numbers are hidden), // Don't draw if lineNumWidth == 0 (line numbers are hidden),
// or widget is not yet realized // or widget is not yet realized
@@ -2868,6 +2876,8 @@ void Fl_Text_Display::draw_line_numbers(bool /*clearAll*/) {
// and therefore clipping ranges may be invalid. // and therefore clipping ranges may be invalid.
int xoff = Fl::box_dx(box()); int xoff = Fl::box_dx(box());
int hscroll_h = mHScrollBar->visible() ? mHScrollBar->h() : 0; int hscroll_h = mHScrollBar->visible() ? mHScrollBar->h() : 0;
Fl_Color fgcolor = isactive ? linenumber_fgcolor() : fl_inactive(linenumber_fgcolor());
Fl_Color bgcolor = isactive ? linenumber_bgcolor() : fl_inactive(linenumber_bgcolor());
fl_push_clip(x() + xoff, fl_push_clip(x() + xoff,
y() + Fl::box_dy(box()), y() + Fl::box_dy(box()),
mLineNumWidth - xoff, mLineNumWidth - xoff,
@@ -2875,7 +2885,7 @@ void Fl_Text_Display::draw_line_numbers(bool /*clearAll*/) {
{ {
// Set background color for line number area -- LZA / STR# 2621 // Set background color for line number area -- LZA / STR# 2621
// Erase background // Erase background
fl_color(linenumber_bgcolor()); fl_color(bgcolor);
fl_rectf(x(), y(), mLineNumWidth, h()); fl_rectf(x(), y(), mLineNumWidth, h());
// Draw separator line // Draw separator line
@@ -2889,7 +2899,7 @@ void Fl_Text_Display::draw_line_numbers(bool /*clearAll*/) {
line = get_absolute_top_line_number(); line = get_absolute_top_line_number();
// set font color for line numbers // set font color for line numbers
fl_color(linenumber_fgcolor()); fl_color(fgcolor);
for (visLine=0; visLine < mNVisibleLines; visLine++) { for (visLine=0; visLine < mNVisibleLines; visLine++) {
lineStart = mLineStarts[visLine]; lineStart = mLineStarts[visLine];
if (lineStart != -1 && (lineStart==0 || buffer()->char_at(lineStart-1)=='\n')) { if (lineStart != -1 && (lineStart==0 || buffer()->char_at(lineStart-1)=='\n')) {
@@ -3588,16 +3598,19 @@ void Fl_Text_Display::draw(void) {
fl_push_clip(x(),y(),w(),h()); // prevent drawing outside widget area fl_push_clip(x(),y(),w(),h()); // prevent drawing outside widget area
// background color -- change if inactive
Fl_Color bgcolor = active_r() ? color() : fl_inactive(color());
// draw the non-text, non-scrollbar areas. // draw the non-text, non-scrollbar areas.
if (damage() & FL_DAMAGE_ALL) { if (damage() & FL_DAMAGE_ALL) {
// printf("drawing all (box = %d)\n", box()); // printf("drawing all (box = %d)\n", box());
if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) {
// if to printer, draw the background // if to printer, draw the background
fl_rectf(text_area.x, text_area.y, text_area.w, text_area.h, color() ); fl_rectf(text_area.x, text_area.y, text_area.w, text_area.h, bgcolor);
} }
// draw the box() // draw the box()
int W = w(), H = h(); int W = w(), H = h();
draw_box(box(), x(), y(), W, H, color()); draw_box(box(), x(), y(), W, H, bgcolor);
if (mHScrollBar->visible()) if (mHScrollBar->visible())
W -= scrollbar_width(); W -= scrollbar_width();
@@ -3607,20 +3620,20 @@ void Fl_Text_Display::draw(void) {
// left margin // left margin
fl_rectf(text_area.x-LEFT_MARGIN, text_area.y-TOP_MARGIN, fl_rectf(text_area.x-LEFT_MARGIN, text_area.y-TOP_MARGIN,
LEFT_MARGIN, text_area.h+TOP_MARGIN+BOTTOM_MARGIN, LEFT_MARGIN, text_area.h+TOP_MARGIN+BOTTOM_MARGIN,
color()); bgcolor);
// right margin // right margin
fl_rectf(text_area.x+text_area.w, text_area.y-TOP_MARGIN, fl_rectf(text_area.x+text_area.w, text_area.y-TOP_MARGIN,
RIGHT_MARGIN, text_area.h+TOP_MARGIN+BOTTOM_MARGIN, RIGHT_MARGIN, text_area.h+TOP_MARGIN+BOTTOM_MARGIN,
color()); bgcolor);
// top margin // top margin
fl_rectf(text_area.x, text_area.y-TOP_MARGIN, fl_rectf(text_area.x, text_area.y-TOP_MARGIN,
text_area.w, TOP_MARGIN, color()); text_area.w, TOP_MARGIN, bgcolor);
// bottom margin // bottom margin
fl_rectf(text_area.x, text_area.y+text_area.h, fl_rectf(text_area.x, text_area.y+text_area.h,
text_area.w, BOTTOM_MARGIN, color()); text_area.w, BOTTOM_MARGIN, bgcolor);
// draw that little box in the corner of the scrollbars // draw that little box in the corner of the scrollbars
if (mVScrollBar->visible() && mHScrollBar->visible()) if (mVScrollBar->visible() && mHScrollBar->visible())
@@ -3637,9 +3650,9 @@ void Fl_Text_Display::draw(void) {
text_area.w+LEFT_MARGIN+RIGHT_MARGIN, text_area.w+LEFT_MARGIN+RIGHT_MARGIN,
text_area.h); text_area.h);
fl_rectf(text_area.x-LEFT_MARGIN, mCursorOldY, fl_rectf(text_area.x-LEFT_MARGIN, mCursorOldY,
LEFT_MARGIN, mMaxsize, color()); LEFT_MARGIN, mMaxsize, bgcolor);
fl_rectf(text_area.x+text_area.w, mCursorOldY, fl_rectf(text_area.x+text_area.w, mCursorOldY,
RIGHT_MARGIN, mMaxsize, color()); RIGHT_MARGIN, mMaxsize, bgcolor);
fl_pop_clip(); fl_pop_clip();
} }