> i faced two main problem :
> 
>  1)  when i do by declaring gases class in the main
>   gases *g;
>   g=new gases();
> 
>   then
>   gaz1->value(g->read_value2());
> 
>   it just give me the last number i entered; and this is 
> reasonable because i return the last
>   value However i need to read all 10 numbers

GUI systems are event driven.

Once you enter the Fl::run() loop, the only way you can interact with
the program is by causing some event that will casue it to react...
So, your test code, which simply attempts to read from the command line
will never work, since you have not provided any mechanism for fltk to
interaact with the command line.

Perhaps, in your example case, a simple polling loop, driven by
Fl::add_timeout(..) could be used to poll the command line for input.

However, I think (for the purposes of your example) you would be better
having a widget (such as an Fl_Input) that takes keyboard input directly
and using that to enter values to pass to your progress bar.

For a real program, you need to have some means (either polling or via
some direct event) to update the GUI as your inputs change.

Anyway, here's a fluid file of a simple example that shows how to use
add_timeout and polling to update a progress bar. Perhaps this will help
you to understand what needs to be done in your program.

----------------------------------------------
# data file for the Fltk User Interface Designer (fluid)
version 1.0107 
header_name {.h} 
code_name {.cxx}
decl {\#include <stdlib.h>} {} 

decl {\#include <stdio.h>} {} 

decl {char label_string[128];} {} 

decl {int keep_ticking = 0;} {} 

Function {do_anim(void *)} {open return_type void
} {
  code {// do_anim code start
  if (keep_ticking){
  int value = (int)(slide->value() + 11.1);
  if (value > 359) value = value - 360;
  slide->value(value);

  sprintf(label_string, "@+30%04d|>", value);
  symbol_but->copy_label(label_string);
  symbol_but->redraw();

  Fl::repeat_timeout(0.1, do_anim);
  }

// do_anim code end} {selected
  }
} 

Function {} {open
} {
  Fl_Window {} {
    label {Angle Test} open
    xywh {504 51 222 195} type Double visible
  } {
    Fl_Button symbol_but {
      label [EMAIL PROTECTED]|>}
      xywh {70 6 95 55} box ENGRAVED_BOX
    }
    Fl_Value_Slider slide {
      label Angle
      callback {// spin callback
  int value = (int)(slide->value() + 0.45);

  sprintf(label_string, "@+30%04d|>", value);
  puts(label_string); fflush(stdout);
  symbol_but->copy_label(label_string);
  symbol_but->redraw();

// end of spin callback;}
      xywh {21 81 190 26} type Horizontal align 66 maximum 359.9 step
0.1 textsize 12
    }
    Fl_Button quit {
      label Quit
      callback {exit(0);}
      xywh {148 162 64 23} box THIN_UP_BOX
    }
    Fl_Button anim {
      label Start
      callback {int state = anim->value();

if (state) {
        keep_ticking = 1;
        Fl::add_timeout(0.1, do_anim);
        anim->label("Stop");
}
else {
        keep_ticking = 0;
        anim->label("Start");
}}
      xywh {20 162 64 23} type Toggle box THIN_UP_BOX
    }
  }
  code {Fl::visible_focus(0); // supress visible focus indication} {}
} 
---------------------------------------------- 




SELEX Sensors and Airborne Systems Limited
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