Ignore:
Timestamp:
Mar 26, 2010, 3:13:31 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
0f7883, 71910a, abd4a1
Parents:
cbc639
Message:

Added mechanism that deactivates undo and redo menupoint if not applicable

Location:
molecuilder/src/Menu
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/Menu/ActionMenuItem.cpp

    rcbc639 r770138  
    2020
    2121ActionMenuItem::~ActionMenuItem()
    22 {
    23   // TODO Auto-generated destructor stub
    24 }
     22{}
    2523
    2624void ActionMenuItem::doTrigger() {
    2725  action->call();
    2826}
     27
     28bool ActionMenuItem::isActive() {
     29  return action->isActive();
     30}
  • molecuilder/src/Menu/ActionMenuItem.hpp

    rcbc639 r770138  
    2626  virtual void doTrigger();
    2727
     28  virtual bool isActive();
     29
    2830private:
    2931  Action* action; //!< this action will be called when the trigger matches
  • molecuilder/src/Menu/MenuItem.cpp

    rcbc639 r770138  
    7878  return added;
    7979}
     80
     81bool MenuItem::isActive(){
     82  return true;
     83}
  • molecuilder/src/Menu/MenuItem.hpp

    rcbc639 r770138  
    2121 */
    2222class MenuItem {
    23 private:
    24   char trigger;
    25   string *description;
    26   bool added;
    27 
    2823public:
    2924  MenuItem(char,const char*,Menu*);
     
    4136  bool wasAdded();
    4237
     38  virtual bool isActive();
     39
    4340protected:
    4441  void setDescription(string);
     42
     43private:
     44  char trigger;
     45  string *description;
     46  bool added;
    4547};
    4648
  • molecuilder/src/Menu/TextMenu.cpp

    rcbc639 r770138  
    5252
    5353void TextMenu::showEntry(MenuItem* entry){
    54   outputter << entry->formatEntry() << "\n";
     54  if(entry->isActive()==false){
     55    outputter << "(";
     56  }
     57  outputter << entry->formatEntry();
     58  if(entry->isActive()==false){
     59    outputter << ")";
     60  }
     61  outputter << "\n";
    5562}
    5663
     
    7582    list<MenuItem*>::iterator iter;
    7683    for(iter = items.begin(); iter!=items.end();iter++){
    77       somethingChosen |= (*iter)->checkTrigger(choice);
     84      if((*iter)->isActive()){
     85        somethingChosen |= (*iter)->checkTrigger(choice);
     86      }
    7887    }
    7988    // see if something was chosen and call default Item if not
Note: See TracChangeset for help on using the changeset viewer.