//------------------------------------------------------------------------------ // gui tools classes -- // (C) Nicola Pozzobon 2008-2010, DipFIS UniPD -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "gui_Menu.cpp" // [Author] "Nicola Pozzobon" // [Version] "0.5" // [Modified by] "Nicola Pozzobon" // [Last revision] "22 Jan 2009" // [Language] "C++" // [Compiler] "Visual C++ 8.x 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Source for the gui_Menu class" // [Key documentation] // "Visual C++ Reference Help" // "Root reference guide" // {Trace} //______________________________________________________________________________ // Standard component // Root Component #include "TSystem.h" // advanced #include //NP** Needed to handle list of entries // Application component #include "global.h" #include "gui_Menu.h" // CINT Preprocessor class import definition ClassImp(gui_Menu) //______________________________________________________________________________ gui_Menu::gui_Menu(const char* label, TGMenuBar* menubar) { // 'label' is the text appearing into the menu // 'menubar' is the actual main menu bar where // the "local" menu is attached // Debug dbg_Print("gui_Menu::gui_Menu:(const char*, TGMenuBar*)", DBG_LVL_ZERO); // Sets up the menu menu = menubar->AddPopup(label); menu->Connect(menu, "Activated(int)", "gui_Menu", this, "mnu_Do(int)"); } //______________________________________________________________________________ gui_Menu::gui_Menu(const char* label) { // 'label' is the text appearing into the menu // it is assumed by default that the menu will be added to the main menu bar // Debug dbg_Print("gui_Menu::gui_Menu:(const char*)", DBG_LVL_ZERO); // Sets up the menu menu_Name.Form(label); menu = container_Menu()->AddPopup(label); menu->Connect(menu, "Activated(int)", "gui_Menu", this, "mnu_Do(int)"); // Refresh Update(); } /* //______________________________________________________________________________ gui_Menu(const gui_Menu&) { // Copy Constructor dbg_Print("gui_Menu::gui_Menu: copy constructor", DBG_LVL_ZERO); } //______________________________________________________________________________ const gui_Menu& operator=(const gui_Menu&) { // Operator= dbg_Print("gui_Menu::operator=: copy operator", DBG_LVL_ZERO); } */ //______________________________________________________________________________ //gui_Menu::gui_Menu(const char* label, gui_Bar* guibar) //{ // 'label' is the text appearing into the menu // 'guibar' is the actual main menu bar where // the "local" menu is attached // Debug // dbg_Print("gui_Menu::gui_Menu: default constructor", DBG_LVL_ZERO); // Sets up the menu // TGMenuBar* appoggio = guibar->root(); // menu = appoggio->AddPopup(label); // menu->Connect(menu, "Activated(int)", "gui_Menu", this, "mnu_Do(int)"); //update(); //NP** Still problems in handling the update from gui_Main (static class) //} //______________________________________________________________________________ gui_Menu::~gui_Menu() { // Default destructor. dbg_Print("gui_Menu::gui_Menu: default destructor", DBG_LVL_ZERO); // Remove the object from the container menu bar gui_Object::container_Menu()->RemovePopup(menu_Name); // Deletes the root object delete menu; } //______________________________________________________________________________ void gui_Menu::mnu_Entry(const char* label, Int_t ijk) { // We need some more explanation here.... menu->AddEntry(label, ijk); } //______________________________________________________________________________ void gui_Menu::mnu_Separator() { // Add menu separator menu->AddSeparator(); } //______________________________________________________________________________ void gui_Menu::mnu_List(std::vector entry_list) { Int_t pres_no = 0; while (menu->GetEntry(pres_no+1) != 0) pres_no++; for(Int_t cnt=0; cntAddSeparator(); else menu->AddEntry(entry_list[cnt], ++pres_no); } } //______________________________________________________________________________ void gui_Menu::mnu_Do(int t) { // This function is called whenever any entry is pressed, as it has been // linked to the associated root TGPopupMenu when it was instantiated. dbg_Print("gui_Menu::mnu_Do:(Int)", DBG_LVL_FLOW); // Calls the associated handler, if anyone, passing the ID as argument //NP** NOT THIS WAY: gui_Object::task_Call(gui_Object::obj_Id()); // ROOT and CINT need the parameter of the clicked entry, as the // object ID fits well this role only for buttons. // Buttons are 1-entry objects, Menus are n-entries objects gui_Object::task_Call(t); } //______________________________________________________________________________ const TGPopupMenu* gui_Menu::Root() const { // Returns the pointer to the embedded root object return menu; }