diff --git a/uppsrc/ide/LayDes/LayDes.lay b/uppsrc/ide/LayDes/LayDes.lay index 919a93364..77f4bab7b 100644 --- a/uppsrc/ide/LayDes/LayDes.lay +++ b/uppsrc/ide/LayDes/LayDes.lay @@ -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 diff --git a/uppsrc/ide/LayDes/visgen.cpp b/uppsrc/ide/LayDes/visgen.cpp index 7b47a1dd6..5c097a876 100644 --- a/uppsrc/ide/LayDes/visgen.cpp +++ b/uppsrc/ide/LayDes/visgen.cpp @@ -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 << " {\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 << " {\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& cursor) name1 <<= toupper2 <<= quotes2 <<= - name2 <<= THISBACK(Refresh); + name2 <<= + buttons <<= THISBACK(Refresh); Refresh(); view.Highlight("cpp"); view.HideBar();