/**** * * Implementation of rolodex-menu.h. * */ #include "rolodex-menu.h" RolodexMenu::RolodexMenu(Name* n, Rolodex* r, RolodexMenuUI* rmui) : View(NULL, r) { /* * For convenience, save a copy of the model as a downcast value. */ this->r = r; /* * Store the parent view. */ this->rmui = rmui; /* * Make the window of this an IV pulldown menu. */ w = pm = new PulldownMenu(n->ConstConvert()); } RolodexMenu::~RolodexMenu() { } void RolodexMenu::Compose() { /* * Insert the four menu items, passing each the Rolodex model for * subsequent access in menu item Do functions. */ pm->Include(new AddMenuItem(r, rmui)); pm->Include(new DeleteMenuItem(r, rmui)); pm->Include(new ChangeMenuItem(r, rmui)); pm->Include(new FindCardMenuItem(r, rmui)); } AddMenuItem::AddMenuItem(Rolodex* r, RolodexMenuUI* rmui) : MenuItem("Add ...") { this->r = r; this->rmui = rmui; } DeleteMenuItem::DeleteMenuItem(Rolodex* r, RolodexMenuUI* rmui) : MenuItem("Delete ...") { this->r = r; this->rmui = rmui; } ChangeMenuItem::ChangeMenuItem(Rolodex* r, RolodexMenuUI* rmui) : MenuItem("Change ...") { this->r = r; this->rmui = rmui; } FindCardMenuItem::FindCardMenuItem(Rolodex* r, RolodexMenuUI* rmui) : MenuItem("Find ...") { this->r = r; this->rmui = rmui; } void AddMenuItem::Do() { /* * Bring up the add-card dialog, and pass the buck to there. Since this is * a non-model dialog interface, we won't come back here to call the model * to do the actual add. Rather, the OK button in the add-card dialog will * call the model add function. */ rmui->ShowAddCardDialog(); } void DeleteMenuItem::Do() { /* * Bring up the delete-card dialog. */ rmui->ShowDeleteCardDialog(); } void ChangeMenuItem::Do() { /* * Bring up the change-card dialog. */ rmui->ShowChangeCardDialog(); } void FindCardMenuItem::Do() { /* * Bring up the find-card dialog. */ rmui->ShowFindCardDialog(); }