mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.reference
git-svn-id: svn://ultimatepp.org/upp/trunk@8207 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1a7f809891
commit
f9294fce1d
7 changed files with 108 additions and 0 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
17
reference/Layouts/Layouts.h
Normal file
17
reference/Layouts/Layouts.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef _Layouts_Layouts_h_
|
||||
#define _Layouts_Layouts_h_
|
||||
|
||||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define LAYOUTFILE <Layouts/layoutfile1.lay> // Layouts will be visible in all files that #include Layouts.h
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
// FirstTabDlg will be visible in all files that #include Layouts.h
|
||||
struct FirstTabDlg : WithFirstTabLayout<ParentCtrl> { // ParentCtrl is a good base class for tabs
|
||||
typedef FirstTabDlg CLASSNAME;
|
||||
FirstTabDlg();
|
||||
};
|
||||
|
||||
#endif
|
||||
14
reference/Layouts/Layouts.upp
Normal file
14
reference/Layouts/Layouts.upp
Normal file
|
|
@ -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";
|
||||
|
||||
4
reference/Layouts/init
Normal file
4
reference/Layouts/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _Layouts_icpp_init_stub
|
||||
#define _Layouts_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#endif
|
||||
9
reference/Layouts/layoutfile1.lay
Normal file
9
reference/Layouts/layoutfile1.lay
Normal file
|
|
@ -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
|
||||
|
||||
10
reference/Layouts/layoutfile2.lay
Normal file
10
reference/Layouts/layoutfile2.lay
Normal file
|
|
@ -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
|
||||
|
||||
53
reference/Layouts/main.cpp
Normal file
53
reference/Layouts/main.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include "Layouts.h"
|
||||
|
||||
#define LAYOUTFILE <Layouts/layoutfile2.lay> // Layouts will be local to main.cpp
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
FirstTabDlg::FirstTabDlg() // Constructor needs to be in .cpp
|
||||
{
|
||||
CtrlLayout(*this); // Places widgets into positions
|
||||
}
|
||||
|
||||
struct SecondTabDlg : WithSecondTabLayout<ParentCtrl> { // Local to main.cpp
|
||||
typedef SecondTabDlg CLASSNAME;
|
||||
SecondTabDlg();
|
||||
};
|
||||
|
||||
SecondTabDlg::SecondTabDlg()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
}
|
||||
|
||||
struct MainDlg : WithMainLayout<TopWindow> { // Local to main.cpp
|
||||
typedef MainDlg CLASSNAME;
|
||||
|
||||
FirstTabDlg tab1;
|
||||
SecondTabDlg tab2;
|
||||
|
||||
void DoDialog();
|
||||
|
||||
MainDlg();
|
||||
};
|
||||
|
||||
void MainDlg::DoDialog()
|
||||
{
|
||||
WithDialogLayout<TopWindow> 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue