Home » Community » Newbie corner » Switch Control
Switch Control [message #25020] |
Sun, 07 February 2010 18:00 |
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 |
|
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 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
Bye,Honza
|
|
|
|
|
|
|
Re: Switch Control, always displayed horizontaly [message #30107 is a reply to message #30105] |
Thu, 09 December 2010 13:08 |
|
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
|
|
|
|
Goto Forum:
Current Time: Sat Sep 21 02:57:40 CEST 2024
Total time taken to generate the page: 0.04102 seconds
|