Fl_Radio_Round_Button - set_selection_color doesn't work when custom draw on FL_ROUND_DOWN_BOX

14 views
Skip to first unread message

Dibo

unread,
Jul 29, 2026, 10:53:02 AMJul 29
to fltk.general
Hi,
I'm creating custom theme in my app written in CFLTK (actually PasFLTK binding).
Normally this code:

Fl_Radio_Round_Button_set_selection_color(rb1, Fl_rgb_color(255,0,0));

... correctly draw red circle when radiobutton is checked. But when I create custom draw callback on FL_ROUND_DOWN_BOX:

Fl_set_box_type_cb2(Fl_BoxType_RoundDownBox, @DrawBox_RoundDownBox, 1, 1, 2, 2, @DrawFocus);

procedure DrawBox_RoundDownBox(x: longint; y: longint; w: longint; h: longint; c: dword); cdecl;
begin
  // Border
  Fl_draw_circle(x, y, h, TPasFLFusionStyle.Colors[fscBorderButton]);
  // Background
  Fl_draw_circle(x+1, y+1, h-1, TPasFLFusionStyle.Colors[fscBackground2]);
end;  

Then it always draw "checked" circle with foreground color. I can't even change this behaviour and draw own "light". Is it a bug?

Regards

Matthias Melcher

unread,
Jul 31, 2026, 2:54:46 PMJul 31
to fltk.general

The original drawing function calls fl_draw_radio in fl_draw.cxx which draws the "checked" circle. The surrounding circular decoration is draw by calling draw_box for FL_ROUND_DOWN_BOX or FL_ROUND_UP_BOX . See Fl_Light_Button::draw().

Dibo

unread,
Aug 1, 2026, 9:24:10 AMAug 1
to fltk.general
You are right. Found it:

      case _FL_ROUND_UP_BOX :
        // Radio button...
        draw_box(down_box(), x()+dx, y()+dy, W, W, FL_BACKGROUND2_COLOR);
        if (value()) {

          // Draw round check mark of radio button

          int tW = (W - Fl::box_dw(down_box())) / 2 + 1;
          if ((W - tW) & 1) tW++; // Make sure difference is even to center
          int tdx = dx + (W - tW) / 2;
          int tdy = dy + (W - tW) / 2;
          fl_draw_radio(x() + tdx - 1, y() + tdy - 1, tW + 2, check_color);

        } // Radio button: if (value())
        break;

So it is hardcoded. draw_box(down_box()... is the part which call draw callbacks which I'm correctly handling and drawing own background. But from if (value())... it is hardcoded part and can't be overrided by any CFLTK callback.
The "check_color" color first is set from widget selection:
Fl_Color check_color = selection_color();

but then overrided with contrast color from background2:
  // select a color with enough contrast
  check_color = fl_contrast(check_color, FL_BACKGROUND2_COLOR);

So the only influence I have is to manipulate with FL_BACKGROUND2_COLOR but that will have affect on other parts of the theme. Or manipulate with selection_color of the widget which in case of contrast get me what I want. I think it is a mistake here but doable
Reply all
Reply to author
Forward
0 new messages