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 » Community » Newbie corner » Switch Control
Switch Control [message #25020] Sun, 07 February 2010 18:00 Go to next message
gedumer is currently offline  gedumer
Messages: 21
Registered: March 2006
Promising Member
There are no examples of the Switch Control (AKA. RadioButtons) in any of the examples nor in the tutorial so could someone who has used this control please help me? I have two Switch controls that I placed on my form using the Form Designer but I don't know how to use them.
Re: Switch Control [message #25021 is a reply to message #25020] Sun, 07 February 2010 18:49 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

gedumer wrote on Sun, 07 February 2010 18:00

There are no examples of the Switch Control (AKA. RadioButtons) in any of the examples nor in the tutorial so could someone who has used this control please help me? I have two Switch controls that I placed on my form using the Form Designer but I don't know how to use them.

Hi!

Simple reference program:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class guitest : public TopWindow {
public:
	typedef guitest CLASSNAME;
	Switch s;
	void change(){
		PromptOK(DeQtf("Switched to value "+AsString(~s)));	//"~s" is shorthand for s.GetData()
	}
	guitest(){
		Add(s);	s.SizePos(); //in your case, this is already done in layout
		s.Add("Case 1").Add(12,"Case 2").Add(13.5,"Case 3"); //chaining is possible ...
		s.Add("Something","Another case").DisableValue(12);  // ... but not mandatory
		s<<=12; //shorthand for s.SetData(12);
		s<<=THISBACK(change); // shorthand for s.WhenAction=THISBACK(change);
		// note the interesting overloading ;)
	}
};

GUI_APP_MAIN{
	guitest().Run();
}
Hope this helps Wink Also look at the commented overloaded operators - they are what makes the development rapid in U++. And one of the reasons why I love this framework Smile

Bye,Honza
Re: Switch Control [message #25022 is a reply to message #25021] Sun, 07 February 2010 19:58 Go to previous messageGo to next message
gedumer is currently offline  gedumer
Messages: 21
Registered: March 2006
Promising Member
It would be nice if there was an example in the distro which demonstrated this feature. It would be great if it was in the tutorial also.

Thanks for the info. I couldn't get it to work from the layout so I created and positioned them internally. Now that I know how, it's very easy.
Re: Switch Control [message #25024 is a reply to message #25022] Sun, 07 February 2010 21:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
gedumer wrote on Sun, 07 February 2010 13:58

It would be nice if there was an example in the distro which demonstrated this feature. It would be great if it was in the tutorial also.

Thanks for the info. I couldn't get it to work from the layout so I created and positioned them internally. Now that I know how, it's very easy.


Adopting dolik.rce's example to reference...

Mirek
Re: Switch Control [message #25088 is a reply to message #25021] Tue, 09 February 2010 23:42 Go to previous messageGo to next message
alendar is currently offline  alendar
Messages: 47
Registered: January 2010
Location: Idaho, USA
Member
Very nice, thank you.

cd7651feeb698f6ac6cec1f6deda5e5b
Switch Control, always displayed horizontaly [message #30105 is a reply to message #25088] Thu, 09 December 2010 12:32 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hi everybody,

I want to arrange swich items in my manner. How to do I can't!!

Thank you
Re: Switch Control, always displayed horizontaly [message #30107 is a reply to message #30105] Thu, 09 December 2010 13:08 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

ratah wrote on Thu, 09 December 2010 12:32

Hi everybody,

I want to arrange swich items in my manner. How to do I can't!!

Thank you

Hi Ratah,

The switch widget chooses between vertical and horizontal layout based on its size. If you make it tall and narrow it will be vertical, if you make it short and wide it will became horizontal. Changing the size of the widget at runtime (e.g. when the layout is resized), will recompute the best layout as well.

In case you are looking for way how to manage this manually, or for some more complex layouts like columns, then I'm afraid there is no such thing in Switch. You could of course derive your own widget based on Switch - the only thing you would have to override is the Paint() method. It should be quite easy, have a look at CtrlLib/Switch.cpp, line 152. It is only ~50 lines of code, most of which could be reused.

Best regards,
Honza
Re: Switch Control, always displayed horizontaly [message #30110 is a reply to message #30107] Thu, 09 December 2010 13:50 Go to previous message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Thank you so much Honza,
Of course I want to change the size dynamically!
I will try to make Rectangle tall, i do not want to override Paint method.
Thank you,
Previous Topic: Pretty GUIs
Next Topic: document icon, how to?
Goto Forum:
  


Current Time: Thu Mar 28 10:56:24 CET 2024

Total time taken to generate the page: 0.01735 seconds