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 » U++ Library support » U++ Widgets - General questions or Mixed problems » What Label.WhenAction supposed to do? - nothing [PARTLY SOLVED :)]
What Label.WhenAction supposed to do? - nothing [PARTLY SOLVED :)] [message #1804] Mon, 20 March 2006 08:01 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
What Label.WhenAction supposed to do?
And why this works for button but not for label?
#include <CtrlLib/CtrlLib.h>

void testAction()
{ PromptOK("testLabelAction");
}

GUI_APP_MAIN
{
	TopWindow w;
	Button b;
	Label l;

	w.Add(b);

	b.SetLabel("button - testAction");
	b.SetPos(b.PosLeft(10, 100), b.PosTop(10, 30));	
//	b.WhenPush=callback(testAction);  //both work
	b.WhenAction=callback(testAction);
	
	w.Add(l);
	l.SetLabel("label - testAction");
	l.SetPos(l.PosLeft(150, 100), l.PosTop(10, 30));
	l.WhenAction=callback(testAction);	
	
	w.Run();
}

[Updated on: Sun, 09 April 2006 03:41]

Report message to a moderator

Re: What Label.WhenAction supposed to do? [message #1805 is a reply to message #1804] Mon, 20 March 2006 09:10 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Mon, 20 March 2006 02:01

What Label.WhenAction supposed to do?
And why this works for button but not for label?
#include <CtrlLib/CtrlLib.h>

void testAction()
{ PromptOK("testLabelAction");
}

GUI_APP_MAIN
{
	TopWindow w;
	Button b;
	Label l;

	w.Add(b);

	b.SetLabel("button - testAction");
	b.SetPos(b.PosLeft(10, 100), b.PosTop(10, 30));	
//	b.WhenPush=callback(testAction);  //both work
	b.WhenAction=callback(testAction);
	
	w.Add(l);
	l.SetLabel("label - testAction");
	l.SetPos(l.PosLeft(150, 100), l.PosTop(10, 30));
	l.WhenAction=callback(testAction);	
	
	w.Run();
}




Nothing. WhenAction is unused in Label.

Mirek
Re: What Label.WhenAction supposed to do? [message #1841 is a reply to message #1804] Wed, 22 March 2006 17:24 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

the code you have posted was very important for me. I'am new of C++ and Ultimate++, but I've some experience with GUI using C API (Motif for example under Unix). Your code reminded me more or less what I've usually done in C style without to declare any class. Just each widget is child of someother and there are callback attached to them. I understand that the class method is elegant and powerful, but I'm a lazy man, Embarassed , and I do not want to loose time with C++ and its intricasy (at least not now). So your approach for me was a surprise and showed that, perhaps, I can program in a sort of C style.
I would like to know, before to start to port one my program in U++ (the wich GUI is in C), if the approach you have showed could break at some moment, for example in complex interface. In other term, is it mandatory to implement class/es to let a GUI interface to work, or can I live without them in Ultimate++?
In case I can avoid the class I would like to see your code, or a similar one, in the documentation to let know to the beginner how it is easy to program with Ultimate++ in contrast with other GUI toolkits.

Luigi

fudadmin wrote on Mon, 20 March 2006 02:01

#include <CtrlLib/CtrlLib.h>

void testAction()
{ PromptOK("testLabelAction");
}

GUI_APP_MAIN
{
	TopWindow w;
	Button b;
	Label l;

	w.Add(b);

	b.SetLabel("button - testAction");
	b.SetPos(b.PosLeft(10, 100), b.PosTop(10, 30));	
//	b.WhenPush=callback(testAction);  //both work
	b.WhenAction=callback(testAction);
	
	w.Add(l);
	l.SetLabel("label - testAction");
	l.SetPos(l.PosLeft(150, 100), l.PosTop(10, 30));
	l.WhenAction=callback(testAction);	
	
	w.Run();
}




Re: What Label.WhenAction supposed to do? [message #1842 is a reply to message #1841] Wed, 22 March 2006 17:34 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Wed, 22 March 2006 11:24


I would like to know, before to start to port one my program in U++ (the wich GUI is in C), if the approach you have showed could break at some moment, for example in complex interface.


Well, to be fair, probably yes - at some level you would have to start using more of C++ (mind you, U++ uses C++ very intensively).

OTOH, you will need not classes before they are really needed... Smile

Mirek
Re: What Label.WhenAction supposed to do? [message #1845 is a reply to message #1841] Wed, 22 March 2006 19:47 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Quote:

but I'm a lazy man, , and I do not want to loose time with C++ and its intricasy (at least not now). So your approach for me was a surprise and showed that, perhaps, I can program in a sort of C style.


Luigi, as an old C programmer I can tell you that you will lose more time with C programming style... Smile. I used this style in my example just for clarity and to have less lines...

And to make a shift from C to C++ you don't need to much time unless you spend time following tutorials which are written with a purpose to make money...

My guess is that your laziness simply hides fear of unknown...

My advice - do it in a lazy man's way Smile - learn from code samples, try to make programs and do not hesitate asking questions here!

Re: What Label.WhenAction supposed to do? [message #1860 is a reply to message #1845] Fri, 24 March 2006 00:05 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Wed, 22 March 2006 13:47


Luigi, as an old C programmer I can tell you that you will lose more time with C programming style... Smile. I used this style in my example just for clarity and to have less lines...

And to make a shift from C to C++ you don't need to much time unless you spend time following tutorials which are written with a purpose to make money...

My guess is that your laziness simply hides fear of unknown...

My advice - do it in a lazy man's way Smile - learn from code samples, try to make programs and do not hesitate asking questions here!


Thank you for your advice. I'll try to fill the gap. I know the principle of C++ and I've even written some thing many years ago. But when now I approached again the C++ to use it in GUI development I see it is a mess.

Please let me ask you what is the word THISBACK that appear in the code and in assist menu'. For example in the reference assembly the package 'menu':

#include <CtrlLib/CtrlLib.h>

struct App : public TopWindow {
	bool numbers_enabled;

	void Exit()
	{
		Close();
	}

	void EnableNumbers()
	{
		numbers_enabled = !numbers_enabled;
	}

	void ShowNumber(int n)
	{
		PromptOK(AsString(n));
	}

	void SubMenu(Bar& bar)
	{
		for(int i = 0; i < 10; i++)
			bar.Add(AsString(i), t_(THISBACK1)(ShowNumber, i));
	}

	void Menu(Bar& bar)
	{
		bar.Add("Enable numbers", THISBACK(EnableNumbers))
		   .Check(numbers_enabled);
		bar.Add(numbers_enabled, "Numbers", THISBACK(SubMenu));
		bar.Add("Exit", THISBACK(Exit))
		   .Key(K_CTRL_E);
	}

	void MainBar(Bar& bar)
	{
		bar.Add("Menu", THISBACK(Menu));
	}

	MenuBar menu;

	typedef App CLASSNAME;

	App()
	{
		numbers_enabled = false;
		AddFrame(menu);
		menu.Set(THISBACK(MainBar));
	}
};

GUI_APP_MAIN
{
	App().Run();
}


has some error somewhere because the compiler report:
C:\upp\reference\Menu\menu.cpp: In member function `void App::SubMenu(Bar&)':
C:\upp\reference\Menu\menu.cpp:24: error: `THISBACK1' undeclared (first use this function)

The THISBACK in assist sometime show the list of callback while sometime show nothing. Can you say two words about its purpose and how to use?

Many thanks in advance,
Luigi
Re: What Label.WhenAction supposed to do? [message #1864 is a reply to message #1860] Fri, 24 March 2006 09:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, for C programmer, the most likely explanation for "THISBACK" is "get a pointer to object method". "THICBACK1" means "get a pointer to the object method with parameter - when invoked, pass it a second parameter of THISBACK1".

There should not be error in reference/Menu. What U++ version exactly are you using?

Mirek
Re: What Label.WhenAction supposed to do? [message #1868 is a reply to message #1864] Fri, 24 March 2006 10:11 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Fri, 24 March 2006 03:20

There should not be error in reference/Menu. What U++ version exactly are you using?
Mirek


I'm using the last, 602, on an XP computer. The packages in example seem to work properly, while in reference sometime I get complain from compiler as that above.

Luigi
Re: What Label.WhenAction supposed to do? [message #1869 is a reply to message #1864] Fri, 24 March 2006 10:52 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Fri, 24 March 2006 03:20


There should not be error in reference/Menu. What U++ version exactly are you using?
Mirek


Just now I performed some test on another computer. It was OK with no error. Maybe the previous failure was due to some option I have modified in the original setting.

Luigi
Re: What Label.WhenAction supposed to do? [message #1870 is a reply to message #1869] Fri, 24 March 2006 11:01 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Fri, 24 March 2006 04:52

luzr wrote on Fri, 24 March 2006 03:20


There should not be error in reference/Menu. What U++ version exactly are you using?
Mirek


Just now I performed some test on another computer. It was OK with no error. Maybe the previous failure was due to some option I have modified in the original setting.

Luigi



Interesting... THISBACK1 macro is defined in Core/Callbacks.h and should be indirectly included via

#include <CtrlLib/CtrlLib.h>

Mirek
Previous Topic: CtrlLayoutOKCancel - detecting Cancel vs Bad input?
Next Topic: 603.r9 TreeCtrl etc. repaint optimization [BUG?]-No,feature.ParentCtrl and Ctrl
Goto Forum:
  


Current Time: Sat May 04 08:58:34 CEST 2024

Total time taken to generate the page: 0.01685 seconds