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! » How to combine two widget-class in the topwindow
Re: How to combine two widget-class in the topwindow [message #2120 is a reply to message #2117] Sat, 01 April 2006 20:27 Go to previous messageGo to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
forlano wrote on Sat, 01 April 2006 18:56

Hello,

One more question...

I'm working with the designer, then copy and past the code as Fudadmin pointed out. It seems easy. Now I have many labels. They are all passive and show some text. I would like to declare just one label widget like this:

Label label;

and the use 'label' everywhere (I used to do so with another GUI in C). So I believed that the following code:

	label.SetLabel(t_("Label 1"));
	label.SetAlign(ALIGN_CENTER);
	label.LeftPosZ(236, 48);
	label.TopPosZ(96, 19);
	Add(label);

	label.SetLabel(t_("Label 2"));
	label.SetAlign(ALIGN_CENTER);
	label.LeftPosZ(136, 48);
	label.TopPosZ(46, 49);
	Add(label);


could show two labels. Instead seems that 'Label 2' override the first one. So at the end I see only 1, the last.
This means that I have to use two separate variables (object):

Label label, label1;
	label.SetLabel(t_("Label 1"));
	label.SetAlign(ALIGN_CENTER);
	label.LeftPosZ(236, 48);
	label.TopPosZ(96, 19);
	Add(label);

	label1.SetLabel(t_("Label 2"));
	label1.SetAlign(ALIGN_CENTER);
	label1.LeftPosZ(136, 48);
	label1.TopPosZ(46, 49);
	Add(label1);


and both appear. I would like to know if there is some trick to use the same object or I must in any case declare each object I use.

Thank you
Luigi


Label is a class (dead description, recipe, mold, pattern set of genes, etc.).
label1, label2 etc. are class instances (real live objects like someone's children).

By declareing:
Label label1, label2;
you instanciate them or make the very begining of life.

Then you shape them.
label1 - red hair, big ears...
label2 - yellow hair, small head...
etc...

Can you imagine the same child beeing a daughter and a son, having all green and red hair at the same time? Smile

...Unless you put some genes (methods) to do so at diferent times and positions.

E.g make a loop and make to display the same label with different params every 100ms. But this, I think, would create blinking and waste of computer power.
So maybe it's better to create a different label for different positions? Smile

Edit:
P.S. Btw, you can use an array of labels... and calculate their positions in a loop... Smile




[Updated on: Sat, 01 April 2006 20:31]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Mouse over button example -"catch me if you can..."
Next Topic: "Forlano tabs" - how to reduce a headache by the proper use of the designer...
Goto Forum:
  


Current Time: Mon May 13 05:29:32 CEST 2024

Total time taken to generate the page: 0.01951 seconds