GIDForums  

Go Back   GIDForums > Computer Programming Forums > FLTK Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-Feb-2009, 09:27
minsk minsk is offline
New Member
 
Join Date: Feb 2009
Posts: 2
minsk is on a distinguished road

How can I really use FL/Fl_Input?


How can I really use FL/Fl_Input??? eg. Fl_Input *a=new Fl_Input(10,10,100,100,""), all I found on those manuals is how to copy the value, but what if I really wanna work with that value? I want to use the data that user is entering, multiplying by 10, and show it on an output. How can I achieve this? thank you all in advance, johnny
  #2  
Old 06-Feb-2009, 13:57
Newhunter Newhunter is offline
Awaiting Email Confirmation
 
Join Date: Jan 2009
Location: Rio de Janeiro, Brasil
Posts: 11
Newhunter will become famous soon enough

Re: Hi everyone, I need some help..


Hey man, take a look at this code that I wrote:


CPP / C++ / C Code:
class Main_Window : public Fl_Window{ ///Main_Window inherits of Fl_Window
public:
	Fl_Input* input[3];
	Fl_Output* out[3];
	Fl_Button *Button_ok,*Button_sair;
	
	//Constructor
	Main_Window(int w,int h,const char *name=0) : Fl_Window(w,h,name){
		input[0] = new Fl_Input(50,50,130,20,"Nome");
		input[1] = new Fl_Input(50,75,70,20,"Tel");
		input[2] = new Fl_Float_Input(50,100,70,20,"Float");
		Button_ok = new Fl_Button(30,150,70,30,"OK");
		Button_sair = new Fl_Button(170,150,70,30,"Sair");
		
		Button_sair->callback(Button_sair_callback);
		Button_ok->callback(Button_ok_callback,this);

		end();
		show();
	}
private:   //private members

	static void Button_ok_callback(Fl_Widget *w,void* v){
		((Main_Window*)v)->catch_value();

	}
	static void Button_sair_callback(Fl_Widget *w,void* v=0 ){
		exit(0);
	}
	static void Button_close_callback(Fl_Widget *w,void* wi){
		w->~Fl_Widget();  //destrutor do Widget
		((Fl_Window*)wi)->~Fl_Window();  //destrutor da janela win(saída)

	}
	void catch_value(){
		Fl_Window *win = new Fl_Window(300,200,"Results");
		win->begin();
		out[0] = new Fl_Output(50,50,130,20,"Nome: ");
		out[1] = new Fl_Output(50,75,70,20,"Tel: ");
		out[2] = new Fl_Output(70,110,100,20,"New Float: ");
		Fl_Button *Button_close = new Fl_Button(20,150,50,20,"Close");
		win->end();
	
		Button_close->callback(Button_close_callback,win);
		
		input[0]->clear_changed();
		input[1]->clear_changed();
		
		out[0]->value(input[0]->value());
		out[1]->value(input[1]->value());

		double x =  atof(input[2]->value());
		x *= 2;
		char c[20];
		gcvt(x,10,c);
		
		printf("%s",c);
		out[2]->value(c);
		
		win->show();

	}
};

void main(){
	Main_Window *window = new Main_Window(400,400,"Input Window");
	Fl::run();
}

I caught the value of input[2] multiplied by 2 and I attributed to out[2].

See what do you think!!

Bye!!
  #3  
Old 08-Feb-2009, 09:24
minsk minsk is offline
New Member
 
Join Date: Feb 2009
Posts: 2
minsk is on a distinguished road

Re: Hi everyone, I need some help..


Newhunter, you're a genious. Works like a charm, thank you. I'm not that used with FLTK, and the manual is difficult, I guess you can learn better by example. Anyway thanks.
  #4  
Old 09-Feb-2009, 04:46
Newhunter Newhunter is offline
Awaiting Email Confirmation
 
Join Date: Jan 2009
Location: Rio de Janeiro, Brasil
Posts: 11
Newhunter will become famous soon enough

Re: How can I really use FL/Fl_Input?


You're welcome. I am happy that it was useful.

See ya!
 
 

Recent GIDBlogNot selected for officer school by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:56.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.