Search code examples
colorswindowfltk

Change the border coloring of window


I am trying to create a window with custom coloring. I can see how to change the background color of the window when using something like FL_BORDER_BOX (how to change the background color of Fl_Window by pressing Fl_Button), but I can not find out how to change the border color from black. Any help would be appreciated!

Thanks!

This is using C/C++ and FLTK btw.


Solution

  • Instead of using FL_BORDER_BOX, use FL_BORDER_FRAME. The foreground colour of the frame can be changed.

    Fl_Box changeling = new Fl_Box(10, 10, 100, 20);
    changeling.box(FL_BORDER_FRAME);
    changeling.color(FL_RED);
    

    A list of the box types can be found in http://www.fltk.org/doc-1.1/common.html under Box Types

    EDIT If you wish to have a different colour inside, then draw two boxes

    int x = 10, y = 10, w = 180, h = 100;
    Fl_Box box(x, y, w, h);
    box.box(FL_BORDER_FRAME);
    box.color(FL_BLUE, FL_RED);
    Fl_Box inner(x + 1, y + 1, w - 2, h - 2);
    inner.box(FL_FLAT_BOX);
    inner.color(FL_YELLOW);