#include "MenuComponent.h" #include "Menu.h" #include "Menu_Item.h" #include "commondef.h" MenuComponent::MenuComponent() { if (!m_menu.get()) m_menu.reset(new Menu("Menu",DisType::Dis_Idel)); current_distype = DisType::Dis_Idel; cur_index = 0; } MenuComponent::~MenuComponent() { if (m_menu.get()) m_menu.reset(); } void MenuComponent::initmenu() { m_keytable.push_back({0,0,1,DisType::Dis_Idel}); //0 m_keytable.push_back({6,2,0,DisType::Dis_Set_ClearPaperPass}); //1 m_keytable.push_back({1,3,7,DisType::Dis_Set_PollPaperIntensity}); //2 #ifdef G200 m_keytable.push_back({2,4,11,DisType::Dis_Set_SleepMode}); //3 m_keytable.push_back({3,5,20,DisType::Dis_Set_TrayPosition}); //4 m_keytable.push_back({4,6,0,DisType::Dis_Set_Poweroff}); //5 #else m_keytable.push_back({2,5,11,DisType::Dis_Set_SleepMode}); //3 m_keytable.push_back({3,5,20,DisType::Dis_Set_TrayPosition}); //4 m_keytable.push_back({3,6,0,DisType::Dis_Set_Poweroff}); //5 #endif m_keytable.push_back({5,1,0,DisType::Dis_Set_Return});//6 m_keytable.push_back({10,8,2,DisType::Dis_Set_PollPI_High}); //7 m_keytable.push_back({7,9,2,DisType::Dis_Set_PollPI_Mid}); //8 m_keytable.push_back({8,10,2,DisType::Dis_Set_PollPI_Low}); //9 m_keytable.push_back({9,7,2,DisType::Dis_Set_Item_Return}); //10 m_keytable.push_back({19,12,3,DisType::Dis_Set_SleepMode_5M}); //11 m_keytable.push_back({11,13,3,DisType::Dis_Set_SleepMode_10M}); //12 m_keytable.push_back({12,14,3,DisType::Dis_Set_SleepMode_20M}); //13 m_keytable.push_back({13,15,3,DisType::Dis_Set_SleepMode_30M}); //14 m_keytable.push_back({14,16,3,DisType::Dis_Set_SleepMode_1H}); //15 m_keytable.push_back({15,17,3,DisType::Dis_Set_SleepMode_2H}); //16 m_keytable.push_back({16,18,3,DisType::Dis_Set_SleepMode_4H}); //17 m_keytable.push_back({17,19,3,DisType::Dis_Set_SleepMode_NEVER}); //18 m_keytable.push_back({18,11,3,DisType::Dis_Set_Item_Return});//19 m_keytable.push_back({23,21,4,DisType::Dis_Set_TrayPosition_High}); //20 m_keytable.push_back({20,22,4,DisType::Dis_Set_TrayPosition_Mid}); //21 m_keytable.push_back({21,23,4,DisType::Dis_Set_TrayPosition_Low});//22 m_keytable.push_back({22,20,4,DisType::Dis_Set_Item_Return});//23 // if (m_menu.get()) // { // unique_ptr menu_clearpass = std::make_unique("clearpass",DisType::Dis_Set_ClearPaperPass); // m_menu->add_menu_item(std::move(menu_clearpass)); // unique_ptr submenu_feedstrength = std::make_unique("feedstrenth",DisType::Dis_Set_PollPaperIntensity); // std::unique_ptr feeditemH = std::make_unique("feedhigh",DisType::Dis_Set_PollPI_High); // std::unique_ptr feeditemM = std::make_unique("feedmid",DisType::Dis_Set_PollPI_Mid); // std::unique_ptr feeditemL = std::make_unique("feedlow",DisType::Dis_Set_PollPI_Low); // submenu_feedstrength->add_menu_item(std::move(feeditemH)); // submenu_feedstrength->add_menu_item(std::move(feeditemM)); // submenu_feedstrength->add_menu_item(std::move(feeditemL)); // m_menu->add_menu_item(std::move(submenu_feedstrength)); // unique_ptr submenu_sleep = std::make_unique("sleepset",DisType::Dis_Set_SleepMode); // std::unique_ptr sleep30 = std::make_unique("30min",DisType::Dis_Set_SleepMode_30M); // std::unique_ptr sleep60 = std::make_unique("60min",DisType::Dis_Set_SleepMode_1H); // std::unique_ptr sleep120 = std::make_unique("120min",DisType::Dis_Set_SleepMode_2H); // std::unique_ptr sleepnever = std::make_unique("never",DisType::Dis_Set_SleepMode_NEVER); // submenu_sleep->add_menu_item(std::move(sleep30)); // submenu_sleep->add_menu_item(std::move(sleep60)); // submenu_sleep->add_menu_item(std::move(sleep120)); // submenu_sleep->add_menu_item(std::move(sleepnever)); // m_menu->add_menu_item(std::move(submenu_sleep)); // unique_ptr submenu_poweroff = std::make_unique("poweroff",DisType::Dis_Set_Poweroff); // m_menu->add_menu_item(std::move(submenu_poweroff)); // } } void MenuComponent::select() { if (m_menu.get()) { m_menu->select(); } } void MenuComponent::option(int key) { switch (key) { #ifdef G200 case 85: //Key_Menu cur_index = m_keytable[cur_index].enter; break; case 86: //Key_Left cur_index = m_keytable[cur_index].up; break; case 76: //Key_Right cur_index = m_keytable[cur_index].down; break; #else case 76: //Key_Menu cur_index = m_keytable[cur_index].enter; break; case 77: //Key_Right cur_index = m_keytable[cur_index].down; break; #endif default: break; } } DisType MenuComponent::getcurtype() { return m_keytable[cur_index].m_type; } void MenuComponent::setcurindex(int x) { if(x < 0 || x >= m_keytable.size()) return ; cur_index = x; printf("\n MenuComponent setcurindex %d",x); } int MenuComponent::getcurindex() { return cur_index; }