On 10.08.2010, at 18:21, Greg Ercolano wrote:
> I find a need for a draw_focus() method that takes an Fl_Color as an argument.
> There are cases where the background color of the focus box is not the 
> widget's color().
>
> One such case is Fl_Tree, where items can each have a different background 
> color
> (eg. the selection color)
>
> Unless I'm missing something, Fl::draw_focus() as it stands only assumes
> the widget's color().

  ... as the background color.

> I'd like to suggest a second call that has the color as an option,
> an the current call be a wrapper for the new call, eg:
>
>      // NEW METHOD
>      void Fl_Widget::draw_focus(.. Fl_Color C, ..) {
>        ..
>      }
>      // CURRENT METHOD
>      void Fl_Widget::draw_focus(..) {
>        draw_focus(.. color(), ..);
>      }

Hmm, to be precise, you mean "the *background* color as an option".
The focus box is drawn with black, unless the widget's color() doesn't
give enough contrast.

That would be something like the following (I added the color
as the last argument and added one more 'const' as well):

Index: src/Fl_Widget.cxx
===================================================================
--- src/Fl_Widget.cxx   (revision 7679)
+++ src/Fl_Widget.cxx   (working copy)
@@ -183,7 +183,7 @@

  /** Draws a focus box for the widget at the given position and size */
  void
-Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H) const {
+Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H, Fl_Color bg) 
const {
    if (!Fl::visible_focus()) return;
    switch (B) {
      case FL_DOWN_BOX:
@@ -196,7 +196,7 @@
        break;
    }

-  fl_color(fl_contrast(FL_BLACK, color()));
+  fl_color(fl_contrast(FL_BLACK, bg));

  #if defined(USE_X11) || defined(__APPLE_QUARTZ__)
    fl_line_style(FL_DOT);
Index: FL/Fl_Widget.H
===================================================================
--- FL/Fl_Widget.H      (revision 7679)
+++ FL/Fl_Widget.H      (working copy)
@@ -172,8 +172,9 @@
    void draw_box(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color c) const;
    void draw_backdrop() const;
    /** draws a focus rectangle around the widget */
-  void draw_focus() {draw_focus(box(),x(),y(),w(),h());}
-  void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const;
+  void draw_focus() const {draw_focus(box(),x(),y(),w(),h(),color());}
+  void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const 
{draw_focus(t,x,y,w,h,color());}
+  void draw_focus(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color bg) const;
    void draw_label() const;
    void draw_label(int, int, int, int) const;



Is this what you mean?

Or did you want to specify the (exact) color to draw the dotted
focus box with?

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

Reply via email to