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
How to combine two widget-class in the topwindow [message #2038] Thu, 30 March 2006 14:20 Go to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

after your precious feedback I was able to build a marvellous menubar with many menu. It is very easy.

Now the problem (for me) is how to combine two o more classes.
Let me refer to a concrete case. In the reference assembly we have the packages Menu and StatusBar. In the first one I found the class App for the menu, while in the second one I have the class App2 (actually named App too) for the status bar.
The silly question is: How to let appear in one top window the menu and the status bar?

I have put in one file both code and tried the stupid

GUI_APP_MAIN
{
App().Run();
App2().Run();
}

that opened two separate top windows (two different applications). I was not luckier with Open() method.

Many thanks in advance,
Luigi
Re: How to combine two widget-class in the topwindow [message #2039 is a reply to message #2038] Thu, 30 March 2006 15:06 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
#include <CtrlLib/CtrlLib.h>

//you can keep this (and more like this) class declarations in one yourApp.h file
class App : public TopWindow {
private:
	bool numbers_enabled;
	//declare your widgets by adding below...
	MenuBar      menu;
	StatusBar    status;
	InfoCtrl     info1;
public:
	void Exit() {Close();}

	void EnableNumbers()     {numbers_enabled = !numbers_enabled;}
	void ShowNumber(int n)   {PromptOK(AsString(n));}
	void TestEdit()          {PromptOK("fromEdit");}  //added  No3 - your func
	void Dummy()             {PromptOK("your function needs to be implemented!");}
	//useful to have one dummy function while work in progress...
	//...to fill calling "gaps"
	//add here more funcs to call from menus,,,

	//bar declarations
	void SubSubMenu(Bar& bar);
	void FileMenu(Bar& bar);
	void EditMenu(Bar& bar);
	void HelpMenu(Bar& bar);
	void TopMenus(Bar& bar);
	
	typedef App CLASSNAME;
	
	App();
};

//while all implementations below you can keep in one or more *.cpp files (split by classes) 
void App::SubSubMenu(Bar& bar) {
	for(int i = 0; i < 10; i++)
		bar.Add(AsString(i), THISBACK1(ShowNumber, i));
}


void App::FileMenu(Bar& bar) { //confusing name changed from "Menu" to "File"...
	bar.Add("Enable numbers", THISBACK(EnableNumbers)).Check(numbers_enabled);
	bar.Add(numbers_enabled, "Numbers", THISBACK(SubSubMenu));
	bar.Add("Exit", THISBACK(Exit)).Key(K_CTRL_E);
}


//added No2 - your extra menu item and subItems 
void App::EditMenu(Bar& bar) {
	bar.Add("EditMy_1", THISBACK(TestEdit)).Key(K_CTRL_D);
	bar.Add("Copy", THISBACK(Dummy)).Key(K_CTRL_C);
	bar.Add("Cut", THISBACK(Dummy)).Key(K_CTRL_X);
	bar.Add("Paste", THISBACK(Dummy)).Key(K_CTRL_V);
	//add more items here...
}

void App::HelpMenu(Bar& bar)
{
	bar.Add("Help", THISBACK(Dummy)).Key(K_F1);
	bar.Add("About...", THISBACK(Dummy));
}


void App::TopMenus(Bar& bar){  //row of top menu "labels" - what you see without opening menus...
	bar.Add("File", THISBACK(FileMenu));
	bar.Add("Edit", THISBACK(EditMenu));  //added Step1 - extra menu item on Main & callback
	bar.Add("Help", THISBACK(HelpMenu));
}


App::App()
{
	//initialize your members on App creation (constructor)
	numbers_enabled = true;
	AddFrame(menu);
	menu.Set(THISBACK(TopMenus));

	//status stuff
	status.AddFrame(info1.Width(250));
	AddFrame(status.Height(25));
	info1="info1: Welcome to the Ultimate++ !";
}


GUI_APP_MAIN
{
	App().Title("Forlano Menu and Status -v1").Zoomable().Sizeable().Run();
}

[Updated on: Thu, 30 March 2006 19:39]

Report message to a moderator

Re: How to combine two widget-class in the topwindow [message #2047 is a reply to message #2039] Thu, 30 March 2006 22:04 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Thank you very much!

I've done some experiment. After adding another "InfoCtrl info2" the constructor look:

App::App()
{
    //initialize your members on App creation (constructor)
	numbers_enabled = false;
	AddFrame(menu);
	menu.Set(THISBACK(MainBar));

	//status stuff
	AddFrame(status);
	status.AddFrame(info1.Left(200));
//	status.Height(25);
	info1=" info1: Welcome to the Ultimate++ !";

	status.AddFrame(info2.Left(200));
//	AddFrame(status.Height(25));
	info2=" info2: Welcome to the Ultimate++ !";
}


So, if I've understood, a complex interface with many classes should be merged in the constructor of the application.
I hope to be able now to add a tabbed window (with 4 pages) between the menu and the status bar.
Because each page contains several widgets I'm afraid that the final constructor of the application will become a mess.
I hope to write for each page a class and simply invoke it in order to simplify the constructor. Perhaps I must create just a big widget to attach it somewhere in the page. In Motif this was possible. Are there example about the creation of a Widget?
(Please be patient if I said silly thing... I'm just starting Smile )

Luigi
Re: How to combine two widget-class in the topwindow [message #2051 is a reply to message #2047] Thu, 30 March 2006 22:17 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Thu, 30 March 2006 15:04

Thank you very much!

I've done some experiment. After adding another "InfoCtrl info2" the constructor look:

App::App()
{
    //initialize your members on App creation (constructor)
	numbers_enabled = false;
	AddFrame(menu);
	menu.Set(THISBACK(MainBar));

	//status stuff
	AddFrame(status);
	status.AddFrame(info1.Left(200));
//	status.Height(25);
	info1=" info1: Welcome to the Ultimate++ !";

	status.AddFrame(info2.Left(200));
//	AddFrame(status.Height(25));
	info2=" info2: Welcome to the Ultimate++ !";
}


So, if I've understood, a complex interface with many classes should be merged in the constructor of the application.
I hope to be able now to add a tabbed window (with 4 pages) between the menu and the status bar.
Because each page contains several widgets I'm afraid that the final constructor of the application will become a mess.
I hope to write for each page a class and simply invoke it in order to simplify the constructor. Perhaps I must create just a big widget to attach it somewhere in the page. In Motif this was possible. Are there example about the creation of a Widget?
(Please be patient if I said silly thing... I'm just starting Smile )

Luigi


Well, to define layout of subdialog, simply use layout desinger and design them visualy. Then craate member variable for each of layout (deriving from ParentCtrl) and add those member variables as tabs.

Mirek
Re: How to combine two widget-class in the topwindow [message #2090 is a reply to message #2047] Fri, 31 March 2006 19:17 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
forlano wrote on Thu, 30 March 2006 21:04



1. So, if I've understood, a complex interface with many classes should be merged in the constructor of the application.
I hope to be able now to add a tabbed window (with 4 pages) between the menu and the status bar.

Because each page contains several widgets I'm afraid that the final constructor of the application will become a mess.

I hope to write for each page a class and simply invoke it in order to simplify the constructor. Perhaps I must create just a big widget to attach it somewhere in the page. In Motif this was possible.

2. Are there example about the creation of a Widget?

3. (Please be patient if I said silly thing... I'm just starting Smile )

Luigi


1. Complex interfaces should be more or less evenly distributed among classes and their constructors. That's why classes exists!

2. I personally know 3 main ways of creating widgets:
2.1. As Mirek mentioned here - with Layout Designer
2.2 Program everything yourself by hand
2.3 Copy code from *.lay files and create your own programmed classes.
Which case you would like to discuss?

3. Don't worry about our patience! By asking questions you are helping future generations of U++ users. So, please ask more often! Smile
Re: How to combine two widget-class in the topwindow [message #2100 is a reply to message #2090] Fri, 31 March 2006 23:14 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Fri, 31 March 2006 19:17


1. Complex interfaces should be more or less evenly distributed among classes and their constructors. That's why classes exists!
2. I personally know 3 main ways of creating widgets:
2.1 As Mirek mentioned here - with Layout Designer
2.2 Program everything yourself by hand
2.3 Copy code from *.lay files and create your own programmed classes.
Which case you would like to discuss?



The package AddressBook shows how to integrate the product of the Layout Designer with the code. Unfortunately I saw strange signs like <...> , Embarassed , that I do not understand yet... So points 2.1 and 2.3 cannot be discussed with me, at least not in the immediate future.

Fortunatly remains another possibility, 2.2. It should be the most general approach although at the cost to write more code lines... but I'm ready.

The current problem is to put between the menubar and the status bar a group of 4 tab pages. Each of them will contain other widgets. I've inquired the available documentation and the code example to get useful advices but both AddressBook and theIde packages use layout files. So I do not know how to let appear some thing that could resemble a tabbed window. Nevertheless I tried many weird things like that below good to open a window but without tabs.
Any advices for a minimalist approach as the example below? After that something will appear I will try to merge it with the menu and status bar and then start to fill each tab.
Thank you,
Luigi

#include <CtrlLib/CtrlLib.h>

GUI_APP_MAIN
{  
    TopWindow w;
    TabCtrl tab0, tab1;

    //AddFrame(tab0);
	w.Add(tab0, "one");
	w.Add(tab1, "two");	
	w.Run();
}
Re: How to combine two widget-class in the topwindow [message #2101 is a reply to message #2100] Fri, 31 March 2006 23:40 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
forlano wrote on Fri, 31 March 2006 22:14


The current problem is to put between the menubar and the status bar a group of 4 tab pages. Each of them will contain other widgets.


did you mean this?:
#include <CtrlLib/CtrlLib.h>

GUI_APP_MAIN
{
	TopWindow w;
	TabCtrl tabs;
	w.Add(tabs.SizePos()); //fills all available space...
	tabs.Add("one");
	tabs.Add("two");
	tabs.Add("three");
	//add more accordingly or create in a a loop...
	
	w.Run();
}

[Updated on: Fri, 31 March 2006 23:40]

Report message to a moderator

Re: How to combine two widget-class in the topwindow [message #2102 is a reply to message #2101] Fri, 31 March 2006 23:52 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Fri, 31 March 2006 23:40


did you mean this?:
#include <CtrlLib/CtrlLib.h>

GUI_APP_MAIN
{
	TopWindow w;
	TabCtrl tabs;
	w.Add(tabs.SizePos()); //fills all available space...
	tabs.Add("one");
	tabs.Add("two");
	tabs.Add("three");
	//add more accordingly or create in a a loop...
	
	w.Run();
}



Wonderful! I meant just it.
Re: How to combine two widget-class in the topwindow [message #2104 is a reply to message #2101] Sat, 01 April 2006 12:34 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
I've included your lines and now the constructor is the following:

#include <CtrlLib/CtrlLib.h>
App::App()
{
    //initialize your members on App creation (constructor)
	numbers_enabled = false;
	AddFrame(menu);
	menu.Set(THISBACK(MainBar));

	//tabs stuff
    //AddFrame(tabs); // doesn't work
	Add(tabs.SizePos()); //fills all available space...
	tabs.Add("one");
	tabs.Add("two");
	tabs.Add("three");
	tabs.Add("four");

	//status stuff
	AddFrame(status);
	status.AddFrame(info1.Left(200));
//	status.Height(25);
	info1=" info1: Welcome to the Ultimate++ !";

	status.AddFrame(info2.Left(200));
//	AddFrame(status.Height(25));
	info2=" info2: Welcome to the Ultimate++ !";
}
}


As you see I tried to use a Frame even for tabs, but I got weird things on the screen. I've not clear when the Frame should be used. May I change its look?

The next step is to fill tab "one". As test case I would like to get a simplified version of the AddressBook package (without menu) and realize a sort of widget-class. Then attach it in tab "one".
I hope to realize it in a reasonable time (I'm not going to use the designer).

Luigi
Re: How to combine two widget-class in the topwindow [message #2108 is a reply to message #2104] Sat, 01 April 2006 14:31 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Here we go:
#include <CtrlLib/CtrlLib.h>
//tabs example- not very correct but might be usuful for learning...

//personalized tab (1 child) widget
class LuigiTab : public ParentCtrl {
	Button btn;
	DocEdit doc;
public:

	typedef LuigiTab CLASSNAME;
	LuigiTab();
	~LuigiTab(){;}
};

LuigiTab::LuigiTab() {
	btn.SetLabel("Just Button");
	btn.SetRect(20,20,100,25);
	Add(btn);
	//I strongly recommend to learn positioning from Designer- use Ctrl-T!
	doc.LeftPosZ(30, 500).TopPosZ(50, 300);
	Add(doc);
	
}



//personalized tabs (many -container) widget
class LuigiTabs : public TabCtrl {
	LuigiTab tab1,tab2,tab3;
public:

	typedef LuigiTabs CLASSNAME;
	LuigiTabs();
	~LuigiTabs(){;}
};


LuigiTabs::LuigiTabs() {
	tab1.SizePos();
	tab2.SizePos();
	tab3.SizePos();


	Add(tab1,"one");
	Add(tab2,"two");
	Add(tab3,"three");
}


//you can keep this (and more like this) class declarations in one yourApp.h file
class App : public TopWindow {
private:
	bool numbers_enabled;
	//prepare to add your widgets by declaring below...
	MenuBar      menu;
	LuigiTabs    tabs;  //inserted declaration of personalized... - see class
	StatusBar    status;
	InfoCtrl     info1;
public:
	void Exit() {Close();}

	void EnableNumbers()     {numbers_enabled = !numbers_enabled;}
	void ShowNumber(int n)   {PromptOK(AsString(n));}
	void TestEdit()          {PromptOK("fromEdit");}  //added  No3 - your func
	void Dummy()             {PromptOK("your function needs to be implemented!");}
	//useful to have one dummy function while work in progress...
	//...to fill calling "gaps"
	//add here more funcs to call from menus,,,

	//bar declarations
	void SubSubMenu(Bar& bar);
	void FileMenu(Bar& bar);
	void EditMenu(Bar& bar);
	void HelpMenu(Bar& bar);
	void TopMenus(Bar& bar);
	
	typedef App CLASSNAME;
	
	App();
};

//while all implementations below you can keep in one or more *.cpp files (split by classes) 
void App::SubSubMenu(Bar& bar) {
	for(int i = 0; i < 10; i++)
		bar.Add(AsString(i), THISBACK1(ShowNumber, i));
}


void App::FileMenu(Bar& bar) { //confusing name changed from "Menu" to "File"...
	bar.Add("Enable numbers", THISBACK(EnableNumbers)).Check(numbers_enabled);
	bar.Add(numbers_enabled, "Numbers", THISBACK(SubSubMenu));
	bar.Add("Exit", THISBACK(Exit)).Key(K_CTRL_E);
}


//added No2 - your extra menu item and subItems 
void App::EditMenu(Bar& bar) {
	bar.Add("EditMy_1", THISBACK(TestEdit)).Key(K_CTRL_D);
	bar.Add("Copy", THISBACK(Dummy)).Key(K_CTRL_C);
	bar.Add("Cut", THISBACK(Dummy)).Key(K_CTRL_X);
	bar.Add("Paste", THISBACK(Dummy)).Key(K_CTRL_V);
	//add more items here...
}

void App::HelpMenu(Bar& bar)
{
	bar.Add("Help", THISBACK(Dummy)).Key(K_F1);
	bar.Add("About...", THISBACK(Dummy));
}


void App::TopMenus(Bar& bar){  //row of top menu "labels" - what you see without opening menus...
	bar.Add("File", THISBACK(FileMenu));
	bar.Add("Edit", THISBACK(EditMenu));  //added Step1 - extra menu item on Main & callback
	bar.Add("Help", THISBACK(HelpMenu));
}


App::App()
{
	//initialize your members on App creation (constructor)
	numbers_enabled = true;
	AddFrame(menu);
	menu.Set(THISBACK(TopMenus));

	//use Add not AddFrame -in most cases. use Assistant to see the return values 
	Add(tabs.SizePos());
	
	//status stuff
	status.AddFrame(info1.Width(250));
	AddFrame(status.Height(25));
	info1="info1: Welcome to the Ultimate++ !";
}


GUI_APP_MAIN
{
	App().Title("Forlano Menu, Tabs and Status -v1").Zoomable().Sizeable().Run();
}


Luigi, please study this example and ask questions immediately. Don't waste your time struggling alone!... Smile
Re: How to combine two widget-class in the topwindow [message #2109 is a reply to message #2108] Sat, 01 April 2006 15:24 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Also, I would strongly recommend for you to make the design of your each tab layout and post as text here (switch to text mode with Ctrl_T in Designer). Then we could imagine what do you want to achieve.
Re: How to combine two widget-class in the topwindow [message #2115 is a reply to message #2108] Sat, 01 April 2006 17:40 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sat, 01 April 2006 14:31

Here we go:
[snip]
Luigi, please study this example and ask questions immediately. Don't waste your time struggling alone!... Smile


Wow... Shocked , I'm very impressed.
I'll study the example and then use the designer. I was unaware of CTRL-T key (I opened the .lay file with a text editor).

Next time I'll post something made with the designer to show you that I am studying seriously Smile and that your lecture are very useful.

Thanks again,
Luigi
Re: How to combine two widget-class in the topwindow [message #2117 is a reply to message #2115] Sat, 01 April 2006 19:56 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
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
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 next 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

Re: How to combine two widget-class in the topwindow [message #2121 is a reply to message #2120] Sat, 01 April 2006 20:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, each label has to have its own variable (in U++, those variables are actual GUI elements, not just some info that is placed to dialog definition).

However, you can do this:

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

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


Mirek
Re: How to combine two widget-class in the topwindow [message #2122 is a reply to message #2121] Sat, 01 April 2006 20:48 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Sat, 01 April 2006 19:36

Well, each label has to have its own variable (in U++, those variables are actual GUI elements, not just some info that is placed to dialog definition).

However, you can do this:

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

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


Mirek



Or, yes, like this. But in this case some strange symbols <..> come to help and instantiation of children(daughters-labels) is achieved by labels.Add() - each label is then created "inside".
Re: How to combine two widget-class in the topwindow [message #2123 is a reply to message #2121] Sat, 01 April 2006 21:03 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Sat, 01 April 2006 19:36

Well, each label has to have its own variable (in U++, those variables are actual GUI elements, not just some info that is placed to dialog definition).

However, you can do this:

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

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


Mirek



Btw, now I'm lost - what is labels?
Re: How to combine two widget-class in the topwindow [message #2124 is a reply to message #2123] Sat, 01 April 2006 21:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Sat, 01 April 2006 14:03

luzr wrote on Sat, 01 April 2006 19:36

Well, each label has to have its own variable (in U++, those variables are actual GUI elements, not just some info that is placed to dialog definition).

However, you can do this:

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

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


Mirek



Btw, now I'm lost - what is labels?


Ooops, should be "label".

Mirek
Re: How to combine two widget-class in the topwindow [message #2130 is a reply to message #2120] Sun, 02 April 2006 10:22 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sat, 01 April 2006 20:27


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



Yes, I agree it's not confortable for the child... and maybe for the parents too Razz .
Here is my new achievement. I used your method of copy and past from designer after CTRL+T. About Designer I will report later in the appropriate place of the forum. Below is the code I have modified being all the rest of the program remained the same.

//personalized tab (1 child) widget
class LuigiTab : public ParentCtrl {
	Button btnAdd, btnDel, btnClear, btnModify;
	DocEdit doc;
	LabelBox lbox;
	Label label[10];
	EditString editName, editCountry, editBirth, editNatRat,
	           editNatId, editFIDEId, editFIDERat;
	DropList editTitle;
	Option tsex;
	EditInt kcoeff;
	ArrayCtrl arr;
	
public:

	typedef LuigiTab CLASSNAME;
	LuigiTab();
	~LuigiTab(){;}
};

LuigiTab::LuigiTab() {
		
	// label
	lbox.SetLabel(t_("Edit Player")).LeftPosZ(16, 648).TopPosZ(16, 80);
	Add(lbox);
	
	label[0].SetLabel(t_("Name")).SetAlign(ALIGN_CENTER).LeftPosZ(28, 132).TopPosZ(32, 19);
	Add(label[0]);
	
	label[1].SetLabel(t_("Fed")).SetAlign(ALIGN_CENTER).LeftPosZ(168, 40).TopPosZ(32, 19);
	Add(label[1]);
	
	label[2].SetLabel(t_("Birthday")).SetAlign(ALIGN_CENTER).LeftPosZ(208, 56).TopPosZ(32, 19);
	Add(label[2]);
	
	label[3].SetLabel(t_("Gender")).SetAlign(ALIGN_CENTER).LeftPosZ(264, 56).TopPosZ(32, 19);
	Add(label[3]);
	
	label[4].SetLabel(t_("Title")).SetAlign(ALIGN_CENTER).LeftPosZ(324, 40).TopPosZ(32, 19);
	Add(label[4]);
	
	label[5].SetLabel(t_("ID FIDE")).SetAlign(ALIGN_CENTER).LeftPosZ(380, 48).TopPosZ(32, 19);
	Add(label[5]);
	
	label[6].SetLabel(t_("Rat FIDE")).SetAlign(ALIGN_CENTER).LeftPosZ(440, 48).TopPosZ(32, 19);
	Add(label[6]);
	
	label[7].SetLabel(t_("ID Nat")).SetAlign(ALIGN_CENTER).LeftPosZ(496, 48).TopPosZ(32, 19);
	Add(label[7]);
	
	label[8].SetLabel(t_("Rat Nat")).SetAlign(ALIGN_CENTER).LeftPosZ(558, 48).TopPosZ(32, 19);
	Add(label[8]);
	
	label[9].SetLabel(t_("K")).SetAlign(ALIGN_CENTER).LeftPosZ(616, 24).TopPosZ(32, 19);
	Add(label[9]);
	
	//active widget
	editName.MaxLen(25).LeftPosZ(28, 136).TopPosZ(56, 19);
	Add(editName);
	
	editCountry.MaxLen(3).LeftPosZ(172, 32).TopPosZ(56, 19);
	Add(editCountry);

	editNatId.MaxLen(8).LeftPosZ(496, 48).TopPosZ(56, 19);
	Add(editNatId);

	editBirth.MaxLen(10).LeftPosZ(212, 56).TopPosZ(56, 19);
	Add(editBirth);
	
	editFIDERat.MaxLen(8).LeftPosZ(440, 48).TopPosZ(56, 19);
	Add(editFIDERat);
	
	tsex.SetLabel(t_("Male")).LeftPosZ(280, 42).TopPosZ(56, 20);
	Add(tsex);
	
	editTitle.DisplayAll(true).LeftPosZ(328, 42).TopPosZ(56, 20);
	Add(editTitle);
	
	editFIDEId.MaxLen(8).LeftPosZ(380, 48).TopPosZ(56, 19);
	Add(editFIDEId);

	editNatRat.MaxLen(8).LeftPosZ(554, 56).TopPosZ(56, 19);
	Add(editNatRat);
		
	kcoeff.Min(0).Max(100).LeftPosZ(620, 24).TopPosZ(56, 19);
	Add(kcoeff);
	
    // button
	btnAdd.SetLabel(t_("Add Player")).LeftPosZ(24, 96).TopPosZ(116, 24);
	Add(btnAdd);

	btnModify.SetLabel(t_("Modify Player")).LeftPosZ(148, 96).TopPosZ(116, 24);
	Add(btnModify);
		
	btnDel.SetLabel(t_("Delete Player")).LeftPosZ(56, 96).TopPosZ(328, 24);
	Add(btnDel);
	
	btnClear.SetLabel(t_("Clear Data")).LeftPosZ(284, 96).TopPosZ(116, 24);
	Add(btnClear);
	
	// array ctrl
	arr.Moving(true).Removing(true).AppendLine(true).Inserting(true).LeftPosZ(16, 648).TopPosZ(172, 148);
	Add(arr);
		
	arr.AddColumn("Name");
	arr.AddColumn("Fed");
	arr.AddColumn("Birthday");
	arr.AddColumn("Gender");
	arr.AddColumn("Title");
	arr.AddColumn("ID FIDE");
	arr.AddColumn("Rat FIDE");
	arr.AddColumn("ID Nat");
	arr.AddColumn("Rat Nat");
	arr.AddColumn("K");
	arr.AddColumn("Available");


At the moment this class is instancied in each tab while I want it stays only in tab 1. I believe I must realize a different class for each tab like:
class LuigiTab1 : public ParentCtrl // tab 1
class LuigiTab2 : public ParentCtrl // tab 2
class LuigiTab3 : public ParentCtrl // tab 3

and then create an instance for each of them.

I need to add data to the drop list button. Unfortunatly I have no example in the documentation and I do not know how to do.

In the coloumn available of the arrayctrl I would like to have a chekbox (checked means available, and unchecked unavailable). Any suggestion?

In the addressbook package there is an example similar to what I want to do: simply fill the fields and then push the data in then arrayctrl. This is my next task.

The geometry of the whole tab is not perfect but now it is important to learn how to dispatch the data between the object and how to retrieve them. The beauty can wait.
Thank you,

Luigi
Re: How to combine two widget-class in the topwindow [message #2141 is a reply to message #2130] Sun, 02 April 2006 12:39 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
P.S Luigi, I've started a new topic "Forlano tabs...". Post all your follow up questions there, please.
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: Thu Mar 28 18:56:38 CET 2024

Total time taken to generate the page: 0.01631 seconds