reference: Switch example

git-svn-id: svn://ultimatepp.org/upp/trunk@2028 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-02-07 20:27:34 +00:00
parent b67abc0708
commit ec1f65c296
6 changed files with 69 additions and 0 deletions

View file

@ -1,3 +1,5 @@
description "DropTree example\377";
uses
CtrlLib;

4
reference/DropTree/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _DropTree_icpp_init_stub
#define _DropTree_icpp_init_stub
#include "CtrlLib/init"
#endif

View file

@ -0,0 +1,10 @@
uses
CtrlLib;
file
switch.lay,
main.cpp;
mainconfig
"" = "GUI";

4
reference/Switch/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Switch_icpp_init_stub
#define _Switch_icpp_init_stub
#include "CtrlLib/init"
#endif

42
reference/Switch/main.cpp Normal file
View file

@ -0,0 +1,42 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define LAYOUTFILE <Switch/switch.lay>
#include <CtrlCore/lay.h>
struct MyApp1 : public TopWindow {
typedef MyApp1 CLASSNAME;
Switch s;
void Change(){
PromptOK("Switched to value " + AsString(~s));
}
MyApp1() {
Title("Switch example");
Add(s);
s.SizePos();
s.Add("Case 1")
.Add(12,"Case 2")
.Add(13.5,"Case 3");
s.Add("Something", "Another case");
s.DisableValue(12);
s <<= 13.5;
s <<= THISBACK(Change);
}
};
GUI_APP_MAIN
{
MyApp1().Run();
WithSwitchLayout<TopWindow> dlg;
CtrlLayoutOKCancel(dlg, "Switch example - with layout");
dlg.s1 <<= 0;
dlg.s2 <<= 2;
if(dlg.Execute() != IDOK)
return;
PromptOK(String().Cat() << "First: " << ~dlg.s1 << ", second: " << ~dlg.s2);
}

View file

@ -0,0 +1,7 @@
LAYOUT(SwitchLayout, 288, 104)
ITEM(Switch, s1, SetLabel(t_("Case 1\nCase 2\nCase 3")).LeftPosZ(8, 72).TopPosZ(8, 56))
ITEM(Switch, s2, SetLabel(t_("Case 1\nCase 2\nCase 3")).LeftPosZ(84, 196).TopPosZ(48, 16))
ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(80, 8).BottomPosZ(6, 22))
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 80).BottomPosZ(6, 22))
END_LAYOUT