mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-16 14:16:09 -06:00
ide: Layout code generator can now generate event handlers for buttons #922
git-svn-id: svn://ultimatepp.org/upp/trunk@7870 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
0942ac2ff0
commit
b7d8ff4ced
2 changed files with 31 additions and 7 deletions
|
|
@ -72,5 +72,6 @@ LAYOUT(VisGenLayout, 724, 488)
|
|||
ITEM(CodeEditor, view, LeftPosZ(172, 544).TopPosZ(8, 440))
|
||||
ITEM(Button, ok, SetLabel(t_("Copy to clipboard")).LeftPosZ(524, 124).TopPosZ(456, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(652, 64).TopPosZ(456, 24))
|
||||
ITEM(Option, buttons, SetLabel(t_("Create button events")).LeftPosZ(12, 152).TopPosZ(228, 16))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -55,9 +55,26 @@ void VisGenDlg::Refresh()
|
|||
String n = ~name;
|
||||
if(IsNull(n))
|
||||
n = GetName();
|
||||
|
||||
String b1, b2, b3;
|
||||
if(buttons) {
|
||||
for(int i = 0; i < layout.item.GetCount(); i++) {
|
||||
String bn = layout.item[i].variable;
|
||||
if(layout.item[i].type == "Button" && findarg(bn, "cancel", "ok", "exit") < 0) {
|
||||
String mn = InitCaps(bn);
|
||||
if(b1.GetCount() == 0)
|
||||
b1 = b2 = "\n";
|
||||
b1 << '\t' << "void " << mn << "();\n";
|
||||
b2 << '\t' << bn << " <<= THISBACK(" << mn << ");\n";
|
||||
b3 << '\n' << "void " << n << "::" << mn << "()\n{\n}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(q == 0) {
|
||||
s << "class " << n << " : public With" << layout.name << "<TopWindow> {\n"
|
||||
<< "\ttypedef " << n << " CLASSNAME;\n"
|
||||
<< b1
|
||||
<< "\n"
|
||||
<< "public:\n"
|
||||
<< "\t" << n << "();\n"
|
||||
|
|
@ -65,22 +82,25 @@ void VisGenDlg::Refresh()
|
|||
<< "\n"
|
||||
<< n << "::" << n << "()\n"
|
||||
<< "{\n"
|
||||
<< oce;
|
||||
s << "(*this, \"\");\n";
|
||||
s << "}\n";
|
||||
<< oce << "(*this, \"\");\n"
|
||||
<< b2
|
||||
<< "}\n"
|
||||
<< b3;
|
||||
}
|
||||
else
|
||||
if(q == 1) {
|
||||
s << "struct " << n << " : With" << layout.name << "<TopWindow> {\n"
|
||||
<< "\ttypedef " << n << " CLASSNAME;\n"
|
||||
<< b1
|
||||
<< "\t" << n << "();\n"
|
||||
<< "};\n"
|
||||
<< "\n"
|
||||
<< n << "::" << n << "()\n"
|
||||
<< "{\n"
|
||||
<< oce;
|
||||
s << "(*this, \"\");\n";
|
||||
s << "}\n";
|
||||
<< oce << "(*this, \"\");\n"
|
||||
<< b2
|
||||
<< "}\n"
|
||||
<< b3;
|
||||
}
|
||||
else
|
||||
if(q == 2) {
|
||||
|
|
@ -134,10 +154,12 @@ void VisGenDlg::Refresh()
|
|||
void VisGenDlg::Type()
|
||||
{
|
||||
String n = GetName();
|
||||
buttons.Disable();
|
||||
switch((int)~type) {
|
||||
case 0:
|
||||
case 1:
|
||||
name <<= GetName();
|
||||
buttons.Enable();
|
||||
break;
|
||||
case 2:
|
||||
name <<= "dlg";
|
||||
|
|
@ -161,7 +183,8 @@ VisGenDlg::VisGenDlg(LayoutData& layout, const Vector<int>& cursor)
|
|||
name1 <<=
|
||||
toupper2 <<=
|
||||
quotes2 <<=
|
||||
name2 <<= THISBACK(Refresh);
|
||||
name2 <<=
|
||||
buttons <<= THISBACK(Refresh);
|
||||
Refresh();
|
||||
view.Highlight("cpp");
|
||||
view.HideBar();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue