mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
.tutorial
git-svn-id: svn://ultimatepp.org/upp/trunk@15651 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d18b121a38
commit
70d8b6d67a
20 changed files with 60 additions and 77 deletions
|
|
@ -5,7 +5,7 @@ using namespace Upp;
|
|||
GUI_APP_MAIN
|
||||
{
|
||||
TopWindow w;
|
||||
w.Title("My application").MinimizeBox().Sizeable();
|
||||
w.Title("My application").Zoomable().Sizeable();
|
||||
w.SetRect(0, 0, 200, 300);
|
||||
w.Run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using namespace Upp;
|
|||
|
||||
struct MyAppWindow : TopWindow {
|
||||
virtual void Paint(Draw& w) override {
|
||||
w.DrawRect(GetSize(), SWhite);
|
||||
w.DrawRect(GetSize(), SWhite());
|
||||
w.DrawText(20, 20, "Hello world!", Arial(30), Magenta);
|
||||
}
|
||||
|
||||
|
|
@ -16,6 +16,6 @@ struct MyAppWindow : TopWindow {
|
|||
GUI_APP_MAIN
|
||||
{
|
||||
MyAppWindow app;
|
||||
app.SetRect(0, 0, 200, 100);
|
||||
app.SetRect(0, 0, 400, 100);
|
||||
app.Run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
using namespace Upp;
|
||||
|
||||
struct MyAppWindow : TopWindow {
|
||||
virtual void Close() override {
|
||||
void Close() override {
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual void LeftDown(Point pos, dword flags) override {
|
||||
void LeftDown(Point pos, dword flags) override {
|
||||
(new MyAppWindow)->OpenMain();
|
||||
}
|
||||
|
||||
virtual void Paint(Draw& w) override {
|
||||
w.DrawRect(GetSize(), SWhite);
|
||||
void Paint(Draw& w) override {
|
||||
w.DrawRect(GetSize(), SWhite());
|
||||
w.DrawText(0, 0, "Click the view area to open next window!", Arial(20));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct MyAppWindow : TopWindow {
|
|||
int result = Null;
|
||||
MenuBar menu;
|
||||
for(int i = 0; i < 10; i++)
|
||||
menu.Add(AsString(i), [&, i] { result = i; });
|
||||
menu.Add(AsString(i), [=, &result] { result = i; });
|
||||
menu.Separator();
|
||||
menu.Add("Exit", [=] { Exit(); });
|
||||
menu.Execute();
|
||||
|
|
|
|||
|
|
@ -11,31 +11,23 @@ struct MyAppWindow : TopWindow {
|
|||
ToolBar tool;
|
||||
StatusBar status;
|
||||
|
||||
void MenuFn() {
|
||||
PromptOK("Fn activated!");
|
||||
}
|
||||
|
||||
void BarFn() {
|
||||
PromptOK("Fn2 activated!");
|
||||
}
|
||||
|
||||
void Exit() {
|
||||
if(PromptOKCancel("Exit MyApp?"))
|
||||
Break();
|
||||
}
|
||||
typedef MyAppWindow CLASSNAME; // so that we can use THISFN shortcut
|
||||
|
||||
void SubBar(Bar& bar) {
|
||||
bar.AddMenu("Function", TutorialImg::Fn(), [=] { MenuFn(); })
|
||||
.Help("This invokes MenuFn method of tutorial example");
|
||||
bar.Add(TutorialImg::Fn2(), [=] { BarFn(); })
|
||||
.Help("This invokes BarFn method of tutorial example");
|
||||
bar.Add("Exit", TutorialImg::Exit(), [=] { Exit(); });
|
||||
bar.AddMenu("Function", TutorialImg::Fn(), [=] { // AddMenu - only in menu
|
||||
PromptOK("Fn activated!");
|
||||
}).Help("This invokes MenuFn method of tutorial example");
|
||||
bar.Add(TutorialImg::Fn2(), [=] { // does not have image - not in toolbar
|
||||
PromptOK("Fn2 activated!");
|
||||
}).Help("This invokes BarFn method of tutorial example");
|
||||
bar.Add("Exit", TutorialImg::Exit(), [=] { // in both toolbar and menu
|
||||
if(PromptOKCancel("Exit MyApp?"))
|
||||
Break();
|
||||
});
|
||||
}
|
||||
|
||||
void MainMenu(Bar& bar) {
|
||||
bar.Sub("Menu", [=](Bar& bar) {
|
||||
SubBar(bar);
|
||||
});
|
||||
bar.Sub("Menu", THISFN(SubBar));
|
||||
}
|
||||
|
||||
MyAppWindow() {
|
||||
|
|
@ -45,10 +37,10 @@ struct MyAppWindow : TopWindow {
|
|||
AddFrame(tool);
|
||||
AddFrame(status);
|
||||
AddFrame(InsetFrame());
|
||||
menu.Set([=](Bar& bar) { MainMenu(bar); });
|
||||
menu.WhenHelp = status; // callback cast to fix it for older CLANG version in C++11
|
||||
tool.Set([=](Bar& bar) { SubBar(bar); });
|
||||
tool.WhenHelp = status; // callback cast to fix it for older CLANG version in C++11
|
||||
menu.Set(THISFN(MainMenu));
|
||||
menu.WhenHelp = status;
|
||||
tool.Set([=](Bar& bar) { SubBar(bar); }); // equivalent to THISFN(SubBar)
|
||||
tool.WhenHelp = status;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ struct MyAppWindow : TopWindow {
|
|||
|
||||
MyAppWindow() {
|
||||
Title("My application with button");
|
||||
Add(button.LeftPos(10, 100).TopPos(10, 30));
|
||||
Add(button.LeftPos(10, 200).TopPos(10, 60));
|
||||
button.SetLabel("Click me!");
|
||||
button << [=] {
|
||||
PromptOK("You have clicked the button!");
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ struct MyAppWindow : TopWindow {
|
|||
MyAppWindow() {
|
||||
Title("My application with button").Sizeable();
|
||||
*this
|
||||
<< lt.SetLabel("left-top").LeftPos(10, 100).TopPos(10, 20)
|
||||
<< rt.SetLabel("right-top").RightPos(10, 100).TopPos(10, 20)
|
||||
<< lb.SetLabel("left-bottom").LeftPos(10, 100).BottomPos(10, 20)
|
||||
<< rb.SetLabel("right-bottom").RightPos(10, 100).BottomPos(10, 20)
|
||||
<< lv.SetLabel("left-vsize").LeftPos(10, 100).VSizePos(40, 40)
|
||||
<< ht.SetLabel("hsize-pos").HSizePos(120, 120).TopPos(10, 20)
|
||||
<< hv.SetLabel("hsize-vsize").HSizePos(120, 120).VSizePos(40, 40)
|
||||
<< cb.SetLabel("hcenter-bottom").HCenterPos(90).BottomPos(10, 20)
|
||||
<< rc.SetLabel("right-vcenter").RightPos(10, 100).VCenterPos(40)
|
||||
<< lt.SetLabel("left-top").LeftPos(10, 200).TopPos(10, 40)
|
||||
<< rt.SetLabel("right-top").RightPos(10, 200).TopPos(10, 40)
|
||||
<< lb.SetLabel("left-bottom").LeftPos(10, 200).BottomPos(10, 40)
|
||||
<< rb.SetLabel("right-bottom").RightPos(10, 200).BottomPos(10, 40)
|
||||
<< lv.SetLabel("left-vsize").LeftPos(10, 200).VSizePos(60, 60)
|
||||
<< ht.SetLabel("hsize-pos").HSizePos(220, 220).TopPos(10, 40)
|
||||
<< hv.SetLabel("hsize-vsize").HSizePos(220, 220).VSizePos(60, 60)
|
||||
<< cb.SetLabel("hcenter-bottom").HCenterPos(200).BottomPos(10, 40)
|
||||
<< rc.SetLabel("right-vcenter").RightPos(10, 200).VCenterPos(40)
|
||||
;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ struct MyAppWindow : TopWindow {
|
|||
|
||||
MyAppWindow() {
|
||||
Title("My application with font-zoomed button").Sizeable();
|
||||
*this << button.SetLabel("Button").LeftPosZ(10, 64).TopPosZ(10, 24);
|
||||
*this << button.SetLabel("Button").LeftPos(Zx(10), Zy(64)).TopPosZ(10, 24);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
LAYOUT(DlgLayout, 208, 64)
|
||||
ITEM(Label, dv___0, SetLabel(t_("Label")).LeftPosZ(8, 36).TopPosZ(8, 19))
|
||||
ITEM(EditString, text, LeftPosZ(48, 92).TopPosZ(8, 19))
|
||||
ITEM(Option, option, SetLabel(t_("Option")).LeftPosZ(8, 108).TopPosZ(32, 15))
|
||||
ITEM(Upp::Label, dv___0, SetLabel(t_("Label")).LeftPosZ(8, 36).TopPosZ(8, 19))
|
||||
ITEM(Upp::EditString, text, LeftPosZ(48, 92).TopPosZ(8, 19))
|
||||
ITEM(Upp::Option, option, SetLabel(t_("Option")).LeftPosZ(8, 108).TopPosZ(32, 15))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using namespace Upp;
|
|||
GUI_APP_MAIN
|
||||
{
|
||||
TopWindow app;
|
||||
app.SetRect(0, 0, 200, 20);
|
||||
app.SetRect(0, 0, Zx(200), Zy(20));
|
||||
EditString text;
|
||||
app.Add(text.TopPosZ(0, 20).HSizePos());
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using namespace Upp;
|
|||
GUI_APP_MAIN
|
||||
{
|
||||
TopWindow app;
|
||||
app.SetRect(0, 0, 200, 20);
|
||||
app.SetRect(0, 0, Zx(200), Zy(20));
|
||||
EditString text;
|
||||
app.Add(text.TopPosZ(0, 20).HSizePos());
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using namespace Upp;
|
|||
GUI_APP_MAIN
|
||||
{
|
||||
TopWindow app;
|
||||
app.SetRect(0, 0, 200, 20);
|
||||
app.SetRect(0, 0, Zx(200), Zy(20));
|
||||
EditDate date;
|
||||
app.Add(date.TopPosZ(0, 20).HSizePos());
|
||||
app.Run();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using namespace Upp;
|
|||
GUI_APP_MAIN
|
||||
{
|
||||
TopWindow app;
|
||||
app.SetRect(0, 0, 200, 60);
|
||||
app.SetRect(0, 0, Zx(200), Zy(60));
|
||||
EditDate date1, date2, date3;
|
||||
date1 <<= date2 <<= date3 <<= GetSysDate();
|
||||
date1.ClearModify();
|
||||
|
|
|
|||
|
|
@ -5,14 +5,10 @@ using namespace Upp;
|
|||
struct MyAppWindow : TopWindow {
|
||||
Button exit;
|
||||
|
||||
void Exit() {
|
||||
Break(999);
|
||||
}
|
||||
|
||||
MyAppWindow() {
|
||||
SetRect(0, 0, 100, 100);
|
||||
SetRect(0, 0, Zx(100), Zy(100));
|
||||
Add(exit.SetLabel("exit").LeftPosZ(10, 64).TopPosZ(10, 24));
|
||||
exit << [=] { Exit(); };
|
||||
exit << [=] { Break(999); };
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ struct MyAppWindow : TopWindow {
|
|||
Button exit;
|
||||
|
||||
MyAppWindow() {
|
||||
SetRect(0, 0, 100, 100);
|
||||
SetRect(0, 0, Zx(100), Zy(100));
|
||||
Add(exit.SetLabel("exit").LeftPosZ(10, 64).TopPosZ(10, 24));
|
||||
exit <<= Breaker(999);
|
||||
exit << Breaker(999);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ struct MyAppWindow : TopWindow {
|
|||
EditDate date;
|
||||
|
||||
MyAppWindow() {
|
||||
SetRect(0, 0, 200, 90);
|
||||
SetRect(0, 0, Zx(200), Zy(90));
|
||||
Add(date.LeftPosZ(10, 80).TopPosZ(10, 20));
|
||||
Add(ok.SetLabel("OK").LeftPosZ(10, 64).TopPosZ(40, 24));
|
||||
Add(cancel.SetLabel("Cancel").LeftPosZ(100, 64).TopPosZ(40, 24));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
LAYOUT(Gui21Layout, 200, 100)
|
||||
ITEM(MyCtrl, myctrl, LeftPosZ(44, 120).TopPosZ(36, 28))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,10 @@ using namespace Upp;
|
|||
struct NonModalDialog : public TopWindow {
|
||||
Button b;
|
||||
|
||||
void DoClose() {
|
||||
Close();
|
||||
}
|
||||
|
||||
NonModalDialog() {
|
||||
SetRect(0, 0, 200, 50);
|
||||
SetRect(0, 0, Zx(200), Zy(50));
|
||||
Add(b.SetLabel("Close non-modal dialog").SizePos());
|
||||
b << [=] { DoClose(); };
|
||||
b << [=] { Close(); };
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -20,17 +16,15 @@ struct MainWindow : public TopWindow {
|
|||
NonModalDialog dlg;
|
||||
Button b;
|
||||
|
||||
void DoOpen() {
|
||||
MainWindow() {
|
||||
SetRect(0, 0, Zx(400), Zy(100));
|
||||
Add(b.SetLabel("Open/close non-modal dialog").SizePos());
|
||||
b << [=] {
|
||||
if(dlg.IsOpen())
|
||||
dlg.Close();
|
||||
else
|
||||
dlg.Open(this);
|
||||
}
|
||||
|
||||
MainWindow() {
|
||||
SetRect(0, 0, 400, 100);
|
||||
Add(b.SetLabel("Open/close non-modal dialog").SizePos());
|
||||
b << [=] { DoOpen(); };
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ trTR("Benim ba\305\237vurum")
|
|||
zhCN("\346\210\221\347\232\204\346\207\211\347\224\250\347\250\213\345\272\217")
|
||||
|
||||
T_("Hello translation engine!")
|
||||
csCZ("Ahoj p\305\231eklada\304\215!")
|
||||
csCZ("Ahoj p\305\231eklada\304\215i!")
|
||||
deDE("Hallo \303\234bersetzungsmaschine!")
|
||||
esES("\302\241Hola motor de traducci\303\263n!")
|
||||
frFR("Bonjour le moteur de traduction!")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue