diff --git a/reference/Layout/Layout.lay b/reference/Layout/Layout.lay index aed103ef4..d27383f5f 100644 --- a/reference/Layout/Layout.lay +++ b/reference/Layout/Layout.lay @@ -4,3 +4,4 @@ LAYOUT(DialogLayout, 148, 68) ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(76, 64).TopPosZ(36, 24)) ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(8, 64).TopPosZ(36, 24)) END_LAYOUT + diff --git a/reference/Layouts/Layouts.h b/reference/Layouts/Layouts.h new file mode 100644 index 000000000..37e798655 --- /dev/null +++ b/reference/Layouts/Layouts.h @@ -0,0 +1,17 @@ +#ifndef _Layouts_Layouts_h_ +#define _Layouts_Layouts_h_ + +#include + +using namespace Upp; + +#define LAYOUTFILE // Layouts will be visible in all files that #include Layouts.h +#include + +// FirstTabDlg will be visible in all files that #include Layouts.h +struct FirstTabDlg : WithFirstTabLayout { // ParentCtrl is a good base class for tabs + typedef FirstTabDlg CLASSNAME; + FirstTabDlg(); +}; + +#endif diff --git a/reference/Layouts/Layouts.upp b/reference/Layouts/Layouts.upp new file mode 100644 index 000000000..bda34d879 --- /dev/null +++ b/reference/Layouts/Layouts.upp @@ -0,0 +1,14 @@ +description "Using multiple layouts for various purposes\377"; + +uses + CtrlLib; + +file + layoutfile1.lay, + layoutfile2.lay, + Layouts.h, + main.cpp; + +mainconfig + "" = "GUI SSE2"; + diff --git a/reference/Layouts/init b/reference/Layouts/init new file mode 100644 index 000000000..b2945d3a9 --- /dev/null +++ b/reference/Layouts/init @@ -0,0 +1,4 @@ +#ifndef _Layouts_icpp_init_stub +#define _Layouts_icpp_init_stub +#include "CtrlLib/init" +#endif diff --git a/reference/Layouts/layoutfile1.lay b/reference/Layouts/layoutfile1.lay new file mode 100644 index 000000000..b03461c5b --- /dev/null +++ b/reference/Layouts/layoutfile1.lay @@ -0,0 +1,9 @@ +LAYOUT(FirstTabLayout, 400, 200) + ITEM(Label, dv___0, SetLabel(t_("This is first layout")).LeftPosZ(12, 124).TopPosZ(8, 21)) + ITEM(Button, dialog, SetLabel(t_("Push to invoke dialog")).LeftPosZ(12, 128).TopPosZ(40, 24)) +END_LAYOUT + +LAYOUT(SecondTabLayout, 400, 200) + ITEM(Label, dv___0, SetLabel(t_("This is second layout")).LeftPosZ(12, 124).TopPosZ(8, 21)) +END_LAYOUT + diff --git a/reference/Layouts/layoutfile2.lay b/reference/Layouts/layoutfile2.lay new file mode 100644 index 000000000..eaeb8e9f4 --- /dev/null +++ b/reference/Layouts/layoutfile2.lay @@ -0,0 +1,10 @@ +LAYOUT(DialogLayout, 196, 96) + ITEM(Label, dv___0, SetLabel(t_("This is some dialog")).LeftPosZ(8, 116).TopPosZ(8, 21)) + ITEM(Label, info, SetLabel(t_("INFO...")).LeftPosZ(8, 116).TopPosZ(32, 21)) + ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(120, 68).TopPosZ(64, 24)) +END_LAYOUT + +LAYOUT(MainLayout, 488, 276) + ITEM(TabCtrl, tabs, LeftPosZ(4, 480).TopPosZ(4, 268)) +END_LAYOUT + diff --git a/reference/Layouts/main.cpp b/reference/Layouts/main.cpp new file mode 100644 index 000000000..5123abc2e --- /dev/null +++ b/reference/Layouts/main.cpp @@ -0,0 +1,53 @@ +#include "Layouts.h" + +#define LAYOUTFILE // Layouts will be local to main.cpp +#include + +FirstTabDlg::FirstTabDlg() // Constructor needs to be in .cpp +{ + CtrlLayout(*this); // Places widgets into positions +} + +struct SecondTabDlg : WithSecondTabLayout { // Local to main.cpp + typedef SecondTabDlg CLASSNAME; + SecondTabDlg(); +}; + +SecondTabDlg::SecondTabDlg() +{ + CtrlLayout(*this); +} + +struct MainDlg : WithMainLayout { // Local to main.cpp + typedef MainDlg CLASSNAME; + + FirstTabDlg tab1; + SecondTabDlg tab2; + + void DoDialog(); + + MainDlg(); +}; + +void MainDlg::DoDialog() +{ + WithDialogLayout dlg; // Variant without class, good for simple modal dialogs + CtrlLayoutOK(dlg, "Dialog"); // OK means dialog has normal 'ok' button that needs setting up + dlg.info = String().Cat() << "Today is: " << GetSysDate(); + if(dlg.Execute() != IDOK) + return; +} + +MainDlg::MainDlg() +{ + CtrlLayout(*this, "Layouts"); + tabs.Add(tab1.SizePos(), "Tab1"); // SizePos() means dialog fills the whole are of tab + tabs.Add(tab2.SizePos(), "Tab2"); + + tab1.dialog <<= THISBACK(DoDialog); // When pushing 'dialog' button, DoDialog is invoked +} + +GUI_APP_MAIN +{ + MainDlg().Run(); +}