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 |
|
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?
...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?
Edit:
P.S. Btw, you can use an array of labels... and calculate their positions in a loop...
[Updated on: Sat, 01 April 2006 20:31] Report message to a moderator
|
|
|
|
|
How to combine two widget-class in the topwindow
By: forlano on Thu, 30 March 2006 14:20
|
|
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Thu, 30 March 2006 15:06
|
|
|
Re: How to combine two widget-class in the topwindow
By: forlano on Thu, 30 March 2006 22:04
|
|
|
Re: How to combine two widget-class in the topwindow
By: mirek on Thu, 30 March 2006 22:17
|
|
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Fri, 31 March 2006 19:17
|
|
|
Re: How to combine two widget-class in the topwindow
By: forlano on Fri, 31 March 2006 23:14
|
|
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Fri, 31 March 2006 23:40
|
|
|
Re: How to combine two widget-class in the topwindow
By: forlano on Fri, 31 March 2006 23:52
|
|
|
Re: How to combine two widget-class in the topwindow
By: forlano on Sat, 01 April 2006 12:34
|
|
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 14:31
|
|
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 15:24
|
|
|
Re: How to combine two widget-class in the topwindow
By: forlano on Sat, 01 April 2006 17:40
|
|
|
Re: How to combine two widget-class in the topwindow
By: forlano on Sat, 01 April 2006 19:56
|
|
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 20:27
|
|
|
Re: How to combine two widget-class in the topwindow
By: mirek on Sat, 01 April 2006 20:36
|
|
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 20:48
|
|
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 21:03
|
|
|
Re: How to combine two widget-class in the topwindow
By: mirek on Sat, 01 April 2006 21:09
|
|
|
Re: How to combine two widget-class in the topwindow
By: forlano on Sun, 02 April 2006 10:22
|
|
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sun, 02 April 2006 12:39
|
Goto Forum:
Current Time: Mon May 13 05:29:32 CEST 2024
Total time taken to generate the page: 0.01951 seconds
|