> > What part of this is it that you are having difficulty with?
>  
> I want to change the color every 2 seconds, I couldn't found 
> how to apply the example given to my class
> can you try and chage it with addtimeout ? 

Below is Brain's example reworked to use a simplified and corrected
version of your class.

Please, if you are going to post example code, make sure that it is *at
least* correct and valid.

If you want us to help you, you also need to try and help yourself!

In particular, I can't believe that you ever compiled that class code,
as it has typos in it and will not compile. Only post compile-able and
complete samples - broken fragments like that do not help anyone.

Also, the elaborate scheme you have devised for computing your widget
origin within the Info group looks to me to be such that the widgets may
be declared outside the boundary of their enclosing Fl_Group - this may
be what is causing your problems, as widgets that lie outside the bounds
of their parents will not be redrawn.

////////////////
/* BPT's box colour changer demo with Info class mods */

// fltk-config --compile test.cxx

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Output.H>

static Fl_Double_Window *my_window = (Fl_Double_Window *)0;

class Info : public Fl_Group
{
public:
        Fl_Output prenom_output, nom_output, login_output;
        Fl_Box B;

        Info(int x, int y, int w, int h):Fl_Group(x,y,w,h),
                prenom_output(x+100, y+20, 200, 20, "prenom"),
                nom_output   (x+100, y+45, 200, 20, "nom"),
                login_output (x+100, y+70, 200, 20, "login"),
                B(x+10, y+150, 100, 100, "Box")
        {
                B.color(FL_BLUE);
                B.box(FL_FLAT_BOX);
                end ();
        };

        ~Info(){};
}; // Info class

static Info *info = (Info *)0;

void v_change_color(void *) {
        static int x = 0;
        if (x == 0) {
                info->B.color(FL_RED);
                x = 1;
        }
        else {
                info->B.color(FL_BLUE);
                x = 0;
        }
        info->B.redraw();
        Fl::repeat_timeout(2.0, v_change_color);
} // v_change_color


int main(int argc, char **argv) {
        my_window = new Fl_Double_Window(600, 400);
        my_window->begin();

        info = new Info(10, 70, 580, 320);

        my_window->end();

        Fl::add_timeout(2.0, v_change_color);

        my_window->show(argc, argv);
        return Fl::run();
} // main

/* end of file */
///////////////
SELEX Galileo 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
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to