On Tuesday, 27 April 2021 at 12:57:55 UTC+1 pvrose wrote:
Is there a way to globally change styles for buttons? Or do you have to code each one individually?
Hi Phil,
If I were being glib, I might say yes.
But that wouldn't be answering the question you are really asking, which is whether there exists some "magic" setting we can toggle that will then change all the buttons to the FLAT style in one go, and the answer to *that* is no.
However, if you do want to change the buttons, there are a few ways to go:
1: Just set 'em all to FL_FLAT_BOX individually when you declare 'em. It's only one line of code extra per widget...
2: Walk the widget hierarchy and set each widget as you go. A PITA to do, but allows the button style to be changed "dynamically" at runtime.
3: Derive your own button class and add a (static) method that allows the style to be changed "globally" on the fly. Now, I've done this in the past, but don't really recall the details. ISTR that I had to tweak the draw() method of the derived class to check the "global" style for each redraw(), such that setting the "global" flag and calling redraw() on the main window had the desired effect. But... I can't find the an actual example here.