FLTK logo

[fltk.general] Subclassing a plastic Fl_Button

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

Subclassing a plastic Fl_Button Gonzalo Garramuño Aug 11, 2021  
  I would like to subclass a plastic Fl_Button and change it to a flat drawing before getting pressed.  I would like to set it up in the constructor.  However, the following does not work:


    Button::Button( int X, int Y, int W, int H, const char* L ) :
        Fl_Button( X, Y, W, H, L )
    {
        box( FL_FLAT_BOX ); // here it does not work
    }

    void Button::draw()
    {
        if (type() == FL_HIDDEN_BUTTON) return;
        Fl_Color col = value() ? selection_color() : color();
        box( FL_FLAT_BOX );  // here it works
        draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(), col);
        draw_backdrop();
        if (labeltype() == FL_NORMAL_LABEL && value()) {
            Fl_Color c = labelcolor();
            labelcolor(fl_contrast(c, col));
            draw_label();
            labelcolor(c);
        } else draw_label();
        if (Fl::focus() == this) draw_focus();
    }

Can someone explain me why and how do I go around it?

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/7480598b-6813-fa46-75f0-e3ab05b7b3c9%40gmail.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

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