Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » "Forlano tabs" - fill EditFields from ArrayCtrl Row...
"Forlano tabs" - fill EditFields from ArrayCtrl Row... [message #2212] Tue, 04 April 2006 04:51 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
If you had asked this way you would have got it faster... Smile
class Tab1 : public WithTab1Layout<TopWindow> {
public:
typedef Tab1 CLASSNAME;
	Tab1();
	void AddPlayer(); //callback from Add_Player button
	void MaskDefaultValue(); //callback from Clera button
	void FillFieldsFromRow();
};

void Tab1::FillFieldsFromRow(){
	int int_row=arr.GetCursor();
	editName    <<= arr.Get(int_row, "Name");      //0
	editCountry <<= arr.Get(int_row, "Country");   //1
	editBirth   <<= arr.Get(int_row, "Birthday");  //2
	tsex        <<= arr.Get(int_row, "Gender");    //3
	editTitle   <<= arr.Get(int_row, "Title");     //4
	editFIDEId  <<= arr.Get(int_row, "IDFIDE");    //5
	editFIDERat <<= arr.Get(int_row, "RatFIDE");   //6
	editNatId   <<= arr.Get(int_row, "IDNat");     //7
	editNatRat  <<= arr.Get(int_row, "RatNat");    //8
	kcoeff      <<= arr.Get(int_row, "K");         //9
	optAvail    <<= arr.Get(int_row, "Avail");     //10 "Avail" doesn't work? ArrayCtrl.cpp line 198 assertion failed
//Edit: a comma was missing in constructor...
}


Tab1::Tab1()
{
	CtrlLayout(*this, "");
	              //id, label, width
	arr.AddColumn("Name", "Name", 10);          //0
	arr.AddColumn("Country", "Fed", 3);         //1
	arr.AddColumn("Birthday", "Birthday", 4);   //2
	arr.AddColumn("Gender", "Gender", 4);       //3
	arr.AddColumn("Title", "Title", 4);         //4
	arr.AddColumn("IDFIDE", "ID FIDE", 4);      //5
	arr.AddColumn("RatFIDE", "Rat FIDE", 4);    //6
	arr.AddColumn("IDNat", "ID Nat", 4);        //7
	arr.AddColumn("RatNat", "Rat Nat", 4);      //8
	arr.AddColumn("K", "K", 3);                 //9
	arr.AddColumn("Avail", "Avail?", 3).Ctrls<Option>();  //10
	// how to set ON the checkbox?
	optAvail.Set(1);
	editName.MaxLen(6); //you can enter 26

	//drop list widget
	editTitle.Add(1, "First");
	editTitle.Add(2, "Second");
	editTitle.Add(3, "Third");

	//set the callback for the Add_Player button
	btnAdd <<= THISBACK(AddPlayer);
	btnClear <<= THISBACK(MaskDefaultValue);
	//to retrieve the row?
	arr.WhenLeftClick = THISBACK(FillFieldsFromRow);
	
	//fill with default value
	MaskDefaultValue();
}

[Updated on: Wed, 05 April 2006 14:35]

Report message to a moderator

Re: "Forlano tabs" - fill EditFields from ArrayCtrl Row... [message #2218 is a reply to message #2212] Tue, 04 April 2006 10:56 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1060
Registered: March 2006
Location: Italy
Experienced Contributor
fudadmin wrote on Tue, 04 April 2006 04:51

If you had asked this way you would have got it faster... Smile
class Tab1 : public WithTab1Layout<TopWindow> {
public:
typedef Tab1 CLASSNAME;
	Tab1();
	void AddPlayer(); //callback from Add_Player button
	void MaskDefaultValue(); //callback from Clera button
	void FillFieldsFromRow();
};

void Tab1::FillFieldsFromRow(){
	int int_row=arr.GetCursor();
	editName    <<= arr.Get(int_row, "Name");      //0
	editCountry <<= arr.Get(int_row, "Country");   //1
	editBirth   <<= arr.Get(int_row, "Birthday");  //2
	tsex        <<= arr.Get(int_row, "Gender");    //3
	editTitle   <<= arr.Get(int_row, "Title");     //4
	editFIDEId  <<= arr.Get(int_row, "IDFIDE");    //5
	editFIDERat <<= arr.Get(int_row, "RatFIDE");   //6
	editNatId   <<= arr.Get(int_row, "IDNat");     //7
	editNatRat  <<= arr.Get(int_row, "RatNat");    //8
	kcoeff      <<= arr.Get(int_row, "K");         //9
	optAvail    <<= arr.Get(int_row, 10);     //10 "Avail" doesn't work? ArrayCtrl.cpp line 198 assertion failed
}


Tab1::Tab1()
{
	CtrlLayout(*this, "");
	              //id, label, width
	arr.AddColumn("Name", "Name", 10);          //0
	arr.AddColumn("Country", "Fed", 3);         //1
	arr.AddColumn("Birthday", "Birthday", 4);   //2
	arr.AddColumn("Gender", "Gender", 4);       //3
	arr.AddColumn("Title", "Title", 4);         //4
	arr.AddColumn("IDFIDE", "ID FIDE", 4);      //5
	arr.AddColumn("RatFIDE", "Rat FIDE", 4);    //6
	arr.AddColumn("IDNat", "ID Nat", 4);        //7
	arr.AddColumn("RatNat", "Rat Nat", 4);      //8
	arr.AddColumn("K", "K", 3);                 //9
	arr.AddColumn("Avail" "Avail?", 3).Ctrls<Option>();  //10
	// how to set ON the checkbox?
	optAvail.Set(1);
	editName.MaxLen(6); //you can enter 26

	//drop list widget
	editTitle.Add(1, "First");
	editTitle.Add(2, "Second");
	editTitle.Add(3, "Third");

	//set the callback for the Add_Player button
	btnAdd <<= THISBACK(AddPlayer);
	btnClear <<= THISBACK(MaskDefaultValue);
	//to retrieve the row?
	arr.WhenLeftClick = THISBACK(FillFieldsFromRow);
	
	//fill with default value
	MaskDefaultValue();
}



Very nice code.
... and of course varying int_row over all the row in a loop I get all the data of the array. It is amazing simply!

Luigi

[Updated on: Wed, 05 April 2006 13:01] by Moderator

Report message to a moderator

Re: "Forlano tabs" - fill EditFields from ArrayCtrl Row... [message #2220 is a reply to message #2218] Tue, 04 April 2006 17:29 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1060
Registered: March 2006
Location: Italy
Experienced Contributor
Just a little note.
I tried the above code and the application crashed when I left_click not on the record inside the arrayctrl. In this case the int_row is equal to -1. To prevent it I've added the line:

if (int_row < 0) return;

under the declaration of int_row and seems to work.
Luigi
Re: "Forlano tabs" - fill EditFields from ArrayCtrl Row... [message #2221 is a reply to message #2220] Tue, 04 April 2006 17:36 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
forlano wrote on Tue, 04 April 2006 16:29

Just a little note.
I tried the above code and the application crashed when I left_click not on the record inside the arrayctrl. In this case the int_row is equal to -1. To prevent it I've added the line:

if (int_row < 0) return;

under the declaration of int_row and seems to work.
Luigi


thanks, I didn't test "the bad cases"... Smile
Also, wouldn't it be better to send int_row as a param?
Previous Topic: Getting data in a row of ArrCtrl
Next Topic: How to call the methods of a class from another class
Goto Forum:
  


Current Time: Sun Aug 18 15:56:46 CEST 2019

Total time taken to generate the page: 0.00705 seconds