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@13477 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9e566c05cb
commit
2a728dbdb4
4 changed files with 73 additions and 0 deletions
7
reference/CtrlMapper/CtrlMapper.lay
Normal file
7
reference/CtrlMapper/CtrlMapper.lay
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
LAYOUT(MyDlgLayout, 200, 88)
|
||||
ITEM(Label, dv___0, SetLabel(t_("Text")).LeftPosZ(8, 32).TopPosZ(8, 19))
|
||||
ITEM(EditString, text, LeftPosZ(44, 152).TopPosZ(8, 19))
|
||||
ITEM(Option, option, SetLabel(t_("Option")).LeftPosZ(44, 108).TopPosZ(36, 15))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(132, 64).TopPosZ(60, 24))
|
||||
END_LAYOUT
|
||||
|
||||
12
reference/CtrlMapper/CtrlMapper.upp
Normal file
12
reference/CtrlMapper/CtrlMapper.upp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
description "Using CtrlMapper to edit C++ structure in dialog\377";
|
||||
|
||||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp,
|
||||
CtrlMapper.lay;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
7
reference/CtrlMapper/CtrlRetriever.lay
Normal file
7
reference/CtrlMapper/CtrlRetriever.lay
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
LAYOUT(CtrlRetrieverLayout, 200, 88)
|
||||
ITEM(Label, dv___0, SetLabel(t_("Text")).LeftPosZ(8, 32).TopPosZ(8, 19))
|
||||
ITEM(EditString, text, LeftPosZ(44, 152).TopPosZ(8, 19))
|
||||
ITEM(Option, option, SetLabel(t_("Option")).LeftPosZ(44, 108).TopPosZ(36, 15))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(132, 64).TopPosZ(60, 24))
|
||||
END_LAYOUT
|
||||
|
||||
47
reference/CtrlMapper/main.cpp
Normal file
47
reference/CtrlMapper/main.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define LAYOUTFILE <CtrlMapper/CtrlMapper.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
struct MyStruct {
|
||||
String text;
|
||||
bool option;
|
||||
};
|
||||
|
||||
struct MyDlg : WithMyDlgLayout<TopWindow> {
|
||||
typedef MyDlg CLASSNAME;
|
||||
|
||||
void Map(CtrlMapper& m, MyStruct& s);
|
||||
|
||||
MyDlg();
|
||||
};
|
||||
|
||||
MyDlg::MyDlg()
|
||||
{
|
||||
CtrlLayoutOK(*this, "My Dialog");
|
||||
}
|
||||
|
||||
void MyDlg::Map(CtrlMapper& m, MyStruct& s)
|
||||
{
|
||||
m
|
||||
(text, s.text)
|
||||
(option, s.option)
|
||||
;
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
MyStruct data;
|
||||
data.text = "Some text";
|
||||
data.option = true;
|
||||
|
||||
MyDlg dlg;
|
||||
dlg.Map(CtrlMapper().ToCtrls(), data);
|
||||
if(dlg.Run() == IDOK)
|
||||
dlg.Map(CtrlMapper().ToValues(), data);
|
||||
|
||||
PromptOK(String() << "text: [* \1" << data.text << "\1]&"
|
||||
<< "option: [* " << data.option);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue