// ** my constructor! CtrlLayout ( *this, "Window title" ); //menup is MenuBar created with layoutfile! menup.Set([=](Bar& bar) { bar.Sub("Cadastros", [=](Bar& bar) { bar.Sub("Contas",[=](Bar& bar){ bar.Sub("Disponibilidades",[=](Bar& bar){ bar.Add(false,"Caixa", THISFN(go1)); bar.Add("Bancos", THISFN(go2)); }); bar.Add("Despesas", THISFN(go3)); }); bar.Add("Clientes", THISFN(go4)); }); bar.Add("Sai", THISBACK(Close)); });
LOG("HERE " << bar.GetFirstChild()->GetFirstChild()->GetDesc()); LOG("HERE next " << bar.GetFirstChild()->GetFirstChild()->GetNext()->GetDesc());
LOG("CHILD ? " << bar.GetFirstChild()->GetFirstChild()->GetChildCount() );
void MyApp::CastradosMenu(Bar& bar) { bar.Add(my_name, [=] { PromptOK("something") }); if(should_have_something) bar.Add("something", ...); .... } MyApp::MyApp() { menup.Set([=](Bar& bar) { bar.Sub("Cadastros", [=](Bar& bar) { CastradosMenu(bar); }); }); }
#include <CtrlLib/Ctr<lLib.h> using namespace Upp; struct MenuTest : TopWindow { ArrayCtrl list; MenuTest() { SetRect(0, 0, 1024, 768); Sizeable().Zoomable().CenterScreen(); // Let's Configure the array. Add(list.SizePos()); list.AddColumn("Text").Edit(Single<EditString>()); list.AddColumn("State").Ctrls<Option>(); list.ColumnWidths("200, 20"); list.Moving().Track().Appending().Removing().SetEditable(); // Fill the array. for(int i = 0; i < 10; i++) list.Add(AsString(i), (bool) false); // Override the popup menu of the array list.WhenBar = [=](Bar& bar) { // RE-add the main popup menu of ArrayCtrl. list.StdBar(bar); int n = list.GetCount(); // Don't append the user menu to the array menu if the array is empty... if(n <= 0) return; bar.Separator(); for(int i = 0; i < list.GetCount(); i++) { bool enable = list.Get(i, 1); String text = list.Get(i, 0); bar.Add(enable, text, [=]{ PromptOK(text); }); // action! } }; } }; GUI_APP_MAIN { MenuTest().Run(); }