#include "Meny.h" #include "Button.h" #include "Action.h" using namespace std; using namespace terminal_star85; extern terminal term; Ptr Meny::create(int x1, int y1, int x2, int y2, bool isHor){ return Ptr(new Meny(x1, y1, x2, y2, isHor)); } Meny::Meny(int x1, int y1, int x2, int y2, bool isHor): Component(x1, y1, x2, y2), isHor(isHor){ comp = Compound::create(x1, y1, x2, y2); } void Meny::show(){ comp->show(); } bool Meny::handle_event(Event eve){ comp->handle_event(eve); } void Meny::add(string men, Ptr act){ menVec.push_back(make_pair(men, act)); comp->remove_all(); pair uprl = comp->getUprl(); pair lowr = comp->getLowr(); uprl.first += 1; uprl.second += 1; lowr.first -= 1; lowr.second -=1; int intervall; if (isHor){ intervall = (lowr.first - uprl.first) / menVec.size(); for (int i = 0; i < menVec.size(); i++){ comp->add(Button::create(uprl.first + (i * intervall) + (i?1:0), uprl.second, (i+1add_com(terminal::Rightarrowkey, mk_action(this, &Meny::next_right)); comp->add_com(terminal::Leftarrowkey, mk_action(this, &Meny::next_left)); comp->add_com(terminal::Uparrowkey, mk_action(this, &Meny::next_up)); comp->add_com(terminal::Downarrowkey, mk_action(this, &Meny::next_down)); }else{ intervall = (lowr.second - uprl.second) / menVec.size(); } } void Meny::add_com(terminal::Keycodes key, Ptr act){ comp->add_com(key, act); } void Meny::next_left(){ pair curpos; term.curget(curpos.first, curpos.second); } void Meny::next_right(){ } void Meny::next_up(){ } void Meny::next_down(){ }