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" - how to reduce a headache by the proper use of the designer...
"Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2135] Sun, 02 April 2006 12:11 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
I christened this topic "Forlano tabs" - how to reduce a headache by the proper use of the designer... because it's a continuation of forlano's series of "U++ beginners fundamental questions" which you can find in other parts of our forums... (inc. "How to combine two widget-class in the topwindow" )

So, why the code below and "program all your widgets by hand" is a headache?
//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");


1. This way can't go through all your forms quickly and "visually" and add new widgets during the process of improvements.
2. Accessing labels only by index is a headache, too.

[to be continued...]
P.S Comments are welcome!

[Updated on: Sun, 02 April 2006 12:12]

Report message to a moderator

Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2137 is a reply to message #2135] Sun, 02 April 2006 12:17 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
P.P.S Luigi, could you please post your *.iml file text here to make my life easier Smile?

[Updated on: Sun, 02 April 2006 12:18]

Report message to a moderator

Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2143 is a reply to message #2135] Sun, 02 April 2006 13:17 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sun, 02 April 2006 12:11


1. This way can't go through all your forms quickly and "visually" and add new widgets during the process of improvements.
2. Accessing labels only by index is a headache, too.

[to be continued...]
P.S Comments are welcome!



My comment: YOU ARE RIGHT!!!

I lost many hours to wright it and I'm not at all satisfact. Now I must retouch some widget with the result to retouch again all their position. Crying or Very Sad

I want to know the more intelligent way. Rolling Eyes

PS: which file do you need? what is *.iml? In the package directory there is nothing that end with *iml. Please specify better. Anyway I attach the *.lay file I used for the previous test (it is mask2 layout)
  • Attachment: editmask.lay
    (Size: 4.66KB, Downloaded 1595 times)
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2146 is a reply to message #2143] Sun, 02 April 2006 13:28 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 Sun, 02 April 2006 12:17

fudadmin wrote on Sun, 02 April 2006 12:11


1. This way can't go through all your forms quickly and "visually" and add new widgets during the process of improvements.
2. Accessing labels only by index is a headache, too.

[to be continued...]
P.S Comments are welcome!



My comment: YOU ARE RIGHT!!!

I lost many hours to wright it and I'm not at all satisfact. Now I must retouch some widget with the result to retouch again all their position. Crying or Very Sad

I want to know the more intelligent way. Rolling Eyes

PS: which file do you need? what is *.iml? In the package directory there is nothing that end with *iml. Please specify better. Anyway I attach the *.lay file I used for the previous test (it is mask2 layout)


Sorry, I meant *.lay!
*.iml is a file where you keep your "intelligent" icons... Smile
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2147 is a reply to message #2146] Sun, 02 April 2006 13:30 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
One more question - are you going to have some parts in your tabs which are all the same in all tabs?
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2148 is a reply to message #2147] Sun, 02 April 2006 13:43 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sun, 02 April 2006 13:30

One more question - are you going to have some parts in your tabs which are all the same in all tabs?


No, each tabs has its specific widgets.
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2149 is a reply to message #2148] Sun, 02 April 2006 13:50 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 Sun, 02 April 2006 12:43

fudadmin wrote on Sun, 02 April 2006 13:30

One more question - are you going to have some parts in your tabs which are all the same in all tabs?


No, each tabs has its specific widgets.


But as I can see from your mask and mask2 - they both have "Add Player", "Modify Player", and "Clear Data"?
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2150 is a reply to message #2149] Sun, 02 April 2006 14:11 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sun, 02 April 2006 13:50

forlano wrote on Sun, 02 April 2006 12:43

fudadmin wrote on Sun, 02 April 2006 13:30

One more question - are you going to have some parts in your tabs which are all the same in all tabs?


No, each tabs has its specific widgets.


But as I can see from your mask and mask2 - they both have "Add Player", "Modify Player", and "Clear Data"?


Please forget (delete) mask layout. It was my first temptive. Then I've abandoned it in favor of mask2.
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2151 is a reply to message #2150] Sun, 02 April 2006 14:22 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 Sun, 02 April 2006 13:11



Please forget (delete) mask layout. It was my first temptive. Then I've abandoned it in favor of mask2.


I did so because I guessed that... Smile
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2153 is a reply to message #2151] Sun, 02 April 2006 15:19 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
So, here we go:
#include <CtrlLib/CtrlLib.h>
//"Forlano tabs example"- might not be very correct but might be usuful for learning...
//with added added one layout from the designer

//Step1 - if you want to use layouts - always include something like this
#define LAYOUTFILE "editmask.lay"
#include <CtrlCore/lay.h>

//Step 2 - please check that you have LAYOUT(Tab1Layout, 680, 368)
//personally I find renaming layouts faster in text mode...
//Step 3 - the Tab1 class below is pasted from automatically generated by the Designer
//using Alt_C first option "Dialog class"

class Tab1 : public WithTab1Layout<TopWindow> {
public:

	typedef Tab1 CLASSNAME;

	Tab1();
};

Tab1::Tab1()
{
	CtrlLayout(*this, "");
}

//the code below is what you had had before, except Step 4 

//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 {
	Tab1 tab1;  //Step 4 - this is your new tab!!!
	LuigiTab tab2,tab3; //tab1 removed 
public:

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

//the code below is all the same

Now you can make your tab1 changes using the designer... Smile
What's next? Smile

[Updated on: Sun, 02 April 2006 15:56]

Report message to a moderator

Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2157 is a reply to message #2153] Sun, 02 April 2006 15:56 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
What next.. I guess you will want to have some columns in your ArrayCtrl...
You will need 2 more steps:
1. Create a name for it in your *.lay file e.g. - arr
2. initialize it in the constructor like this:
Tab1::Tab1()
{
	CtrlLayout(*this, "");
	arr.AddColumn("col1");
	arr.AddColumn("col2");
	arr.AddColumn("col3");	
}

Edit:
or
Tab1::Tab1()
{
	CtrlLayout(*this, "");
      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");
}

[Updated on: Sun, 02 April 2006 16:21]

Report message to a moderator

Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2163 is a reply to message #2157] Sun, 02 April 2006 18:51 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sun, 02 April 2006 15:56

What next.. I guess you will want to have some columns in your ArrayCtrl...
You will need 2 more steps:
1. Create a name for it in your *.lay file e.g. - arr
2. initialize it in the constructor like this:
Tab1::Tab1()
{
	CtrlLayout(*this, "");
	arr.AddColumn("col1");
	arr.AddColumn("col2");
	arr.AddColumn("col3");	
}

Edit:
or
Tab1::Tab1()
{
	CtrlLayout(*this, "");
      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");
}



Fantastic... Shocked
It is very easy. Only one stupid problem. I used
#define "editmask.lay"

but the compiler didn't see it. So I tried
#define LAYOUTFILE <tabs/Tab1Layout.lay>

with no result. At the end I tried
#define LAYOUTFILE "c:\MyApps\tabs\editmask.lay"

and works. Do you know how to fix this problem?
Luigi
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2164 is a reply to message #2157] Sun, 02 April 2006 18:54 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
3 more questions:
1. How many records are you going to have?
2. Where are you going to keep them: database,xml,txt etc?
3. Any conversions?
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2166 is a reply to message #2164] Sun, 02 April 2006 19:47 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sun, 02 April 2006 18:54

3 more questions:
1. How many records are you going to have?
2. Where are you going to keep them: database,xml,txt etc?
3. Any conversions?


1. a maximum of 999;

2. simply txt file (csv format, separated by ';');

3. Conversion? If I do not understand I suppose it means no concersion.

Luigi
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2167 is a reply to message #2163] Sun, 02 April 2006 19:58 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 Sun, 02 April 2006 17:51


...
It is very easy. Only one stupid problem. I used
1. #define "editmask.lay"

but the compiler didn't see it. So I tried
2. #define LAYOUTFILE <tabs/Tab1Layout.lay>

with no result. At the end I tried
#define LAYOUTFILE "c:\MyApps\tabs\editmask.lay"

and works. Do you know how to fix this problem?
Luigi


1. as you should know from C experience #define is a substitutor.
If you write only on part of it, it your compiler replaces it with nothing. This is useful only in #ifdefs or if you want to not use what you define... Smile

2. This has to be the name of your layout file and of your widget layout

3. It is sufficient to write just
#define LAYOUTFILE "editmask.lay"
if you keep this file in your package folder where other files reside e.g in c:\MyApps\tabs\ ...Smile

forlano wrote on Sun, 02 April 2006 17:51


Fantastic... Shocked


...And remember I told you - do not struggle alone and do it in a lazy man's way? When you wrote in our label topic:
Quote:


but I'm a lazy man, Embarassed , and I do not want to loose time...


And then in this topic you wrote:
Quote:

...I lost many hours to wright it and I'm not at all satisfact. Now I must retouch some widget with the result to retouch again all their position. Sad

That means you are not lazy enough... Laughing ... to be an inventor... Wink
I guess Mirek and Tom are lazy enough... Smile That's why they invented Ultimate++... to let us all enjoy our laziness!
So, from now on, if you feel that some tasks with Ultimate++ are not enjoyable - ask how they can be converted... Smile
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2168 is a reply to message #2166] Sun, 02 April 2006 20:00 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 Sun, 02 April 2006 18:47


3. Conversion? If I do not understand I suppose it means no concersion.
Luigi

coversion e.g txt files to xml... or the other way round...
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2169 is a reply to message #2168] Sun, 02 April 2006 20:01 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
What next?
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2170 is a reply to message #2167] Sun, 02 April 2006 20:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Quote:


3. It is sufficient to write just
#define LAYOUTFILE "editmask.lay"
if you keep this file in your package folder where other files reside e.g in c:\MyApps\tabs\ ...Smile



Unfortuantely, this works only with MSC compilers.

Portable way is

#define LAYOUTFILE <MyPackage/my_layout.lay>

Quote:


I guess Mirek and Tom are lazy enough... Smile



Yes, I am Wink

Mirek

[Updated on: Sun, 02 April 2006 20:25]

Report message to a moderator

Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2171 is a reply to message #2167] Sun, 02 April 2006 20:46 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sun, 02 April 2006 19:58


1. as you should know from C experience #define is a substitutor.
If you write only on part of it, it your compiler replaces it with nothing. This is useful only in #ifdefs or if you want to not use what you define... Smile



ooops... I mean #include and not define.

Quote:


3. It is sufficient to write just
#define LAYOUTFILE "editmask.lay"
if you keep this file in your package folder where other files reside e.g in c:\MyApps\tabs\ ...Smile




In this way doesn't work on my PC. But it works in the other way, so let's save time and forget about it (the lazy man spirit sometime come out Smile )
Quote:


forlano wrote on Sun, 02 April 2006 17:51


Fantastic... Shocked


...And remember I told you - do not struggle alone and do it in a lazy man's way? When you wrote in our label topic:
Quote:


but I'm a lazy man, Embarassed , and I do not want to loose time...


And then in this topic you wrote:
Quote:

...I lost many hours to wright it and I'm not at all satisfact. Now I must retouch some widget with the result to retouch again all their position. Sad

That means you are not lazy enough... Laughing ... to be an inventor... Wink
I guess Mirek and Tom are lazy enough... Smile That's why they invented Ultimate++... to let us all enjoy our laziness!
So, from now on, if you feel that some tasks with Ultimate++ are not enjoyable - ask how they can be converted... Smile


After you spent a lot of time for me, I was forced to produce something... unfortunately it was useless Smile . But I learned the lesson.
This tool is really great... and the forum is even greater.

The next step is to fill the fields with some data (the drop list need some data like: item1, item2, item3), retrieve them and accomodate in the arrayctrl. By the way, the last coloumn should contain a checkbox (on/off) that should be set by default to on. Later we collect the data from the array and save them in txt file ';' separated.

I've no idea about how to fill the drop list, and how to add a checkbox inside the arrayctrl. For the rest I can try. I'll do it tomorrow afternoon and post here the code. For the moment I guess I must define a callback for the button "Add" that do the job.

Thanks a lot,
Luigi
Re: "Forlano tabs" - how to reduce a headache by the proper use of the designer... [message #2172 is a reply to message #2170] Sun, 02 April 2006 20:47 Go to previous messageGo to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Sun, 02 April 2006 19:25

Quote:


3. It is sufficient to write just
#define LAYOUTFILE "editmask.lay"
if you keep this file in your package folder where other files reside e.g in c:\MyApps\tabs\ ...Smile



Unfortuantely, this works only with MSC compilers.

Portable way is

#define LAYOUTFILE <MyPackage/my_layout.lay>
...
Mirek



Sorry, sometimes I'm too much lazy Smile
Previous Topic: How to combine two widget-class in the topwindow
Next Topic: Getting data in a row of ArrCtrl
Goto Forum:
  


Current Time: Thu Apr 18 10:58:53 CEST 2024

Total time taken to generate the page: 0.03395 seconds