You have to realize a blinking message, or an object which
periodically swaps two images :
think of an alarm icon.
The alarm is sounding, and the icon keeps alternating red/yellow horn
images until the user pushes the ack button.
Use a timer to blink... but things are not always smooth blinking.
Not a big problem, anyway... just would like to know if there is a
clever way to assure a smooth blinking
(usually we are speaking of small objects).
Not really sure this is what was being asked, but here's a simple demo of
blinking widgets.
Maybe this is what was wanted?
--
//
// Flashing Boxes
//
#include FL/Fl.H
#include FL/Fl_Double_Window.H
#include FL/Fl_Button.H
#include FL/Fl_Box.H
static Fl_Double_Window *main_win = 0;
static Fl_Button *quit_bt = 0;
static Fl_Box *box1 = 0;
static Fl_Box *box2 = 0;
static void cb_quit(Fl_Widget *, void *) {
main_win-hide();
} // cb_quit
void update_box1(void *) {
static int state = 0;
if(state) {
state = 0;
box1-color(FL_GREEN);
}
else {
state = -1;
box1-color(FL_RED);
}
Fl::repeat_timeout(0.7, update_box1);
box1-redraw();
} // update_box1
void update_box2(void *) {
static int state = 0;
static int step = 1;
const int thd = 15;
state += step;
if(state = thd) {
step = -1;
}
else if (state = 0) {
step = 1;
}
float alpha = (float)state / (float)thd;
Fl_Color col = fl_color_average(FL_RED, FL_BACKGROUND_COLOR, alpha);
box2-color(col);
Fl::repeat_timeout(0.05, update_box2);
box2-redraw();
} // update_box2
int main(int argc, char ** argv) {
main_win = new Fl_Double_Window(370, 230, Flashing Widgets);
main_win-begin();
box1 = new Fl_Box(10, 10, 60, 30, ALERT!);
box1-box(FL_FLAT_BOX);
box1-color(FL_GREEN);
box2 = new Fl_Box(80, 10, 60, 30, ALERT!);
box2-box(FL_FLAT_BOX);
box2-color(FL_BACKGROUND_COLOR);
quit_bt = new Fl_Button(300, 190, 60, 30, Quit);
quit_bt-box(FL_THIN_UP_BOX);
quit_bt-callback(cb_quit);
main_win-end();
main_win-show(argc,argv);
Fl::add_timeout(0.3, update_box1);
Fl::add_timeout(0.05, update_box2);
return Fl::run();
} // main
// end of file //
Selex ES Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14
3EL
A company registered in England Wales. Company no. 02426132
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk