FLTK logo

[master] cf4a832 - Adding Text_Display color variables. (#384)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] cf4a832 - Adding Text_Display color variables. (#384) "Matthias Melcher" Jan 30, 2022  
 
commit cf4a832e6a801b46c38f6236369c74056e8f89ec
Author:     Matthias Melcher <github@matthiasm.com>
AuthorDate: Sun Jan 30 22:14:40 2022 +0100
Commit:     GitHub <noreply@github.com>
CommitDate: Sun Jan 30 22:14:40 2022 +0100

    Adding Text_Display color variables. (#384)

 FL/Fl_Text_Display.H    | 39 +++++++++++++++++++++++++++++++++++++++
 src/Fl_Text_Display.cxx | 34 ++++++++++++++++++++++++++++------
 2 files changed, 67 insertions(+), 6 deletions(-)

diff --git FL/Fl_Text_Display.H FL/Fl_Text_Display.H
index 375ee4e..21f0d63 100644
--- FL/Fl_Text_Display.H
+++ FL/Fl_Text_Display.H
@@ -391,6 +391,42 @@ public:
    */
   void textcolor(Fl_Color n) {textcolor_ = n;}
 
+  /**
+   Sets the underline color for style attribute ATTR_GRAMMAR.
+   \param color underline color
+   */
+  void grammar_underline_color(Fl_Color color) { grammar_underline_color_ = color; }
+
+  /**
+   Gets the underline color for style attribute ATTR_GRAMMAR.
+   \return underline color
+   */
+  Fl_Color grammar_underline_color() const { return grammar_underline_color_;}
+
+  /**
+   Sets the underline color for style attribute ATTR_SPELLING.
+   \param color underline color
+   */
+  void spelling_underline_color(Fl_Color color) { spelling_underline_color_ = color; }
+
+  /**
+   Gets the underline color for style attribute ATTR_SPELLING.
+   \return underline color
+   */
+  Fl_Color spelling_underline_color() const { return spelling_underline_color_;}
+
+  /**
+   Sets the background color for the secondary selection block.
+   \param color background color
+   */
+  void secondary_selection_color(Fl_Color color) { secondary_selection_color_ = color; }
+
+  /**
+   Gets the background color for the secondary selection block.
+   \return background color color
+   */
+  Fl_Color secondary_selection_color() const { return secondary_selection_color_;}
+
   int wrapped_column(int row, int column) const;
   int wrapped_row(int row) const;
   void wrap_mode(int wrap, int wrap_margin);
@@ -604,6 +640,9 @@ protected:
   Fl_Font textfont_;
   Fl_Fontsize textsize_;
   Fl_Color textcolor_;
+  Fl_Color grammar_underline_color_;
+  Fl_Color spelling_underline_color_;
+  Fl_Color secondary_selection_color_;
 
   // Line number margin and width
   int mLineNumLeft, mLineNumWidth;
diff --git src/Fl_Text_Display.cxx src/Fl_Text_Display.cxx
index b263117..1f02c34 100644
--- src/Fl_Text_Display.cxx
+++ src/Fl_Text_Display.cxx
@@ -164,6 +164,9 @@ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l)
   textfont_ = FL_HELVETICA;             // textfont()
   textsize_ = FL_NORMAL_SIZE;           // textsize()
   textcolor_ = FL_FOREGROUND_COLOR;     // textcolor()
+  grammar_underline_color_ = FL_RED;
+  spelling_underline_color_ = FL_BLUE;
+  secondary_selection_color_ = FL_GRAY;
   mLineNumLeft = 0;             // XXX: UNUSED
   mLineNumWidth = 0;
 
@@ -2319,17 +2322,36 @@ void Fl_Text_Display::draw_string(int style,
       } else {
         background = fl_color_average(bgbasecolor, selection_color(), 0.6f);
       }
+    } else if (style & SECONDARY_MASK) {
+      if (Fl::focus() == (Fl_Widget*)this) {
+        background = fl_color_average(bgbasecolor, secondary_selection_color(), 0.5f);
+      } else {
+        background = fl_color_average(bgbasecolor, secondary_selection_color(), 0.6f);
+      }
     } else {
       background = bgbasecolor;
     }
     foreground = (style & PRIMARY_MASK) ? fl_contrast(styleRec->color, background) : styleRec->color;
   } else if (style & PRIMARY_MASK) {
-    if (Fl::focus() == (Fl_Widget*)this) background = selection_color();
-    else background = fl_color_average(color(), selection_color(), 0.4f);
+    if (Fl::focus() == (Fl_Widget*)this) {
+      background = selection_color();
+    } else {
+      background = fl_color_average(color(), selection_color(), 0.4f);
+    }
     foreground = fl_contrast(textcolor(), background);
   } else if (style & HIGHLIGHT_MASK) {
-    if (Fl::focus() == (Fl_Widget*)this) background = fl_color_average(color(), selection_color(), 0.5f);
-    else background = fl_color_average(color(), selection_color(), 0.6f);
+    if (Fl::focus() == (Fl_Widget*)this) {
+      background = fl_color_average(color(), selection_color(), 0.5f);
+    } else {
+      background = fl_color_average(color(), selection_color(), 0.6f);
+    }
+    foreground = fl_contrast(textcolor(), background);
+  } else if (style & SECONDARY_MASK) {
+    if (Fl::focus() == (Fl_Widget*)this) {
+      background = secondary_selection_color();
+    } else {
+      background = fl_color_average(color(), secondary_selection_color(), 0.4f);
+    }
     foreground = fl_contrast(textcolor(), background);
   } else {
     foreground = textcolor();
@@ -2367,10 +2389,10 @@ void Fl_Text_Display::draw_string(int style,
             goto DRAW_UNDERLINE;
             break;
           case ATTR_GRAMMAR:
-            fl_color(FL_BLUE);
+            fl_color(grammar_underline_color());
             goto DRAW_DOTTED_UNDERLINE;
           case ATTR_SPELLING:
-            fl_color(FL_RED);
+            fl_color(spelling_underline_color());
           DRAW_DOTTED_UNDERLINE:
             fl_line_style(FL_DOT, pitch);
           DRAW_UNDERLINE:
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.