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 » Community » Newbie corner » How to Xmlize gridctrl
How to Xmlize gridctrl [message #44624] Sun, 26 April 2015 15:58 Go to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
Hi all,
I have some problem trying to xmlize my gridcrtl.

here is where i define my gridctrl:
BulloniCtrl::BulloniCtrl()
{
	// Carica DropList
	LoadDroplList();
	
	//Geometria
	alfa.SetInc(1).Min(0).Max(90);
	
	geomGrid.SetToolBar();
	geomGrid.Editing().Accepting().Canceling();
	geomGrid.EvenColor().ColoringMode(2);
	geomGrid.AddColumn(MAT_ID, t_("Materiale"));
	geomGrid.AddColumn(SP_ID,  t_("Spessore")).Fixed(60).Edit(sp);
	geomGrid.AddColumn(UM_ID,  t_("UM")).Fixed(35);
	geomGrid.AddColumn(CDR_ID, t_("Classe di resistenza")).Fixed(100).Edit(CdRdl);
	geomGrid.AddColumn("alfa", t_("Angolo α")).Edit(alfa);
	geomGrid.WhenChangeRow = THISBACK(Loadcdrdl);
	geomGrid.WhenAcceptedRow = THISBACK(OnGeometriaEdit);
	geomGrid.AddRow("Legno - t1:", "", "mm", "", 90);
	geomGrid.AddRow("Legno - t2:", "", "mm", "", 90);
	GetGridRows(geomGrid);
	
	//Connettore
	bullonedl	 	<<= THISBACK(OnBulloneEdit);
	CdRAcciaiodl	<<= THISBACK(Getfuk);
	fukEdit 		<<= THISBACK(OnfukEdit);
	Getfuk();
        .....


and here how I try to save it:
virtual void Xmlize(XmlIO xml)
	{
		ConnettoriCtrl::Xmlize(xml);
		xml
			("Geometria", 		geomGrid)
			("Connettore1", 	bullonedl)
			("Connettore2", 	passEdit)
			("Connettore3", 	AresEdit)
			("Connettore4", 	CdRAcciaiodl)
			("Connettore5", 	fukEdit)
			("RopeEffect1",		ropeOption)
			("RopeEffect2",		ArondellaEdit)
		;
	}


There are 2 variables I'm not able to xmlize and they are "sp" and "CdRdl" btw I have no problems with others columns. Someone can try to explain me where I am wrong???

Regards,
Matteo
Re: How to Xmlize gridctrl [message #44626 is a reply to message #44624] Sun, 26 April 2015 22:34 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Hi Matteo,

I'm not quite sure if I understand what variables are sd and CdRdl. Are they your internal variables, or are they belong to GridCtrl internals? If you try to serialize GridCtrl's internal members, this is definitely bad idea. At least because if author changes GridCtrl internals in some new revisions of U++, then you'll have to modify your sources each time it happens. C++ classes is something about hiding all the internals inside the class. Accessing any internals of any other class is generally a bad practice. Maybe it will be better to discuss what particular task are you trying to solve by serializing these two variables, than trying to access any GridCtrl's internals.

[Updated on: Sun, 26 April 2015 22:35]

Report message to a moderator

Re: How to Xmlize gridctrl [message #44627 is a reply to message #44626] Mon, 27 April 2015 21:51 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
I try to clarify my problem. My GridCtrl's have 2 Editable columns that are:
        geomGrid.AddColumn(SP_ID,  t_("Spessore")).Fixed(60).Edit(sp);
	geomGrid.AddColumn(CDR_ID, t_("Classe di resistenza")).Fixed(100).Edit(CdRdl);


Where sp and CdRdl are:
        EditDouble sp;
	DropList CdRdl;


Here is what happen when I try to Xmlize it:
                               <Geometria>
						<data>
							<item>
								<item type="String">Legno - t:</item>
								<item type="double" value="200"/>
								<item type="String">mm</item>
								<item type="WString">GL24h</item>
								<item type="double" value="0"/>
							</item>
							<item>
								<item type="String">Acciaio - s:</item>
								<item type="double" value="10"/>
								<item type="String">mm</item>
								<item type="WString">S235</item>
								<item type="double" value="90"/>
							</item>
						</data>
					</Geometria>


Where <item type="double" value="200"/> and <item type="WString">GL24h</item> are the right stored values of "sp" and "CdRdl".
Where I try to load this xml my GridCtrl is correctly loaded but "sp" and "CdRdl" are missing...


There is something more to do when I try to store/load columns with Editable values in GridCtrl or maybe the problem is not there?!

Regards,
Matteo
Re: How to Xmlize gridctrl [message #44628 is a reply to message #44627] Tue, 28 April 2015 07:05 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello idkfa46

AFAIK GridCtrl can Xmlize itself but cannot Xmlize editable fields. In fact if you try to Xmlize the editable fields you just save their values, but in any way an editable field represent a GridCtrl column.

In summary, you would have to Xmlize all GridCtrl. To store just a column you would have to extract it by hand and store it like for example a Vector<Value>, and load it and write it over a GridCtrl.

In addition please remember that when you Xmlize a Gridctrl, before load it you have to add all columns (AddColumn()) before.


Best regards
Iñaki
Re: How to Xmlize gridctrl [message #44631 is a reply to message #44624] Wed, 29 April 2015 21:35 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
Hi all,
thanks for your helps. I tryed to Xmlize a editable fields storing them in a Vector<Value> .

It works but I have an issue loading my xml. I can add them in a new row but I'm not able to edit an existent one.

here is my code (where geomGrid is my GridCtrl):
virtual void Xmlize(XmlIO xml)
	{
		Vector<Vector<Value> > grid;
		if(xml.IsStoring()){
			for(int r=0; r<geomGrid.GetCount(); r++){
				Vector<Value> row;
				for(int c=0; c<geomGrid.GetColumnCount(); c++){
					row << geomGrid.Get(r,c);
				}
				grid.Add(row);
			}
		}

		ConnettoriCtrl::Xmlize(xml);
		xml
			//("Geometria", 	geomGrid)
			("Geometria", 		grid)
			("Connettore1", 	bullonedl)
			("Connettore2", 	passEdit)
			("Connettore3", 	AresEdit)
			("Connettore4", 	CdRAcciaiodl)
			("Connettore5", 	fukEdit)
			("RopeEffect1",		ropeOption)
			("RopeEffect2",		ArondellaEdit)
		;

		if(xml.IsLoading()){
			for(int r=0; r<grid.GetCount(); r++){
				geomGrid.Add(grid[r]);
			}
		}
	}


it works with geomGrid.Add(grid[r]) but there is no way to edit the existing rows with

...
if(xml.IsLoading()){
       for(int r=0; r<grid.GetCount(); r++){
		geomGrid.Set(r, grid[r]);
       }
}
...


Where am I wrong again?

Regards,
Matteo
Re: How to Xmlize gridctrl [message #44633 is a reply to message #44631] Thu, 30 April 2015 08:34 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello

I am not sure that works.

Have you tried this?:

if(xml.IsLoading()){
       for(int r=0; r<grid.GetCount(); r++)
              for(int c=0; c<grid.GetColumnCount(); r++)
	              geomGrid.Set(r, c, grid[r][c]);
}


Best regards
Iñaki

[Updated on: Thu, 30 April 2015 08:35]

Report message to a moderator

Previous Topic: Starting a top window hidden?
Next Topic: How does one position the mouse cursor?
Goto Forum:
  


Current Time: Fri Mar 29 10:26:02 CET 2024

Total time taken to generate the page: 0.01436 seconds