Virtually flickerless buttons for the BeOS
Download FButton for both PPC and x86.
FButton can be used just like BButton. In fact, if in your class description you do something like this:
private:
BButton *fQuit;
Leave it as is. Then, in your source code when you initialize the BButton:
fQuit = new BButton(frame, "fQuit", "Quit",
new BMessage(B_QUIT_REQUESTED),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
simply change "BButton" to "FButton":
fQuit = new FButton(frame, "fQuit", "Quit",
new BMessage(B_QUIT_REQUESTED),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
Of course, you'll have to include "FButton.h" at the top of the source file.
How does it work? The concept is very simple in fact.
The whole concept of flickering is that during a resize white gets drawn, then gray gets drawn, and so on. The quick succession of white, gray, white, gray is flicker. If you simply set the button's color to B_TRANSPARENT, the white is never drawn so during a resize you only see gray, gray, gray. Without the flicker However, for some reason the border around the BButton is never filled with gray, or with white. When the button wasn't transparent the border would be filled with white of course, but now that the border is never filled it just collects garbage, much like a locked window. The StrokeRect call in FButton::Draw() strokes a white rectangle around the BButton to clear out the garbage. The StrokeRect call in FButton::MouseDown() clears the black rectangle left over by BButton::MouseDown(). Voila!
Using FButton in your application? If so, please send an e-mail to seth@abisoft.com! :)