virtual void stateChanged(const ChangeEventUnrecPtr e)
	{
		while(UndoRedoListModel->getSize()-1 > TheUndoManager->numberOfRedos() + TheUndoManager->numberOfUndos())
		{
			UndoRedoListModel->popBack();
		}

		//Resize
		while(UndoRedoListModel->getSize()-1 < TheUndoManager->numberOfRedos() + TheUndoManager->numberOfUndos())
		{
			UndoRedoListModel->pushBack(boost::any(std::string("")));
		}

		UInt32 UndoCount(TheUndoManager->numberOfUndos());
		for(UInt32 i(0) ; i<UndoCount ; ++i)
		{
			UndoRedoListModel->set(i+1, boost::any(std::string(TheUndoManager->editToBeUndone(i)->getUndoPresentationName())));
		}
		UInt32 RedoCount(TheUndoManager->numberOfRedos());
		for(UInt32 i(0) ; i<RedoCount ; ++i)
		{
			UndoRedoListModel->set(i+TheUndoManager->numberOfUndos()+1, boost::any(std::string(TheUndoManager->editToBeRedone(i)->getRedoPresentationName())));
		}

		if((UndoCount == 0 && UndoButton->getEnabled()) ||
			(UndoCount != 0 && !UndoButton->getEnabled()) )
		{
				UndoButton->setEnabled(UndoCount != 0);
		}
		if((RedoCount == 0 && RedoButton->getEnabled()) ||
			(RedoCount != 0 && !RedoButton->getEnabled()) )
		{
				RedoButton->setEnabled(RedoCount != 0);
		}
	}
Пример #2
0
void handleUndoManagerStateChanged(ChangeEventDetails* const details,
                                   DefaultListModel* const UndoRedoListModel,
                                   UndoManagerPtr TheUndoManager,
                                   Button* const UndoButton,
                                   Button* const RedoButton)
{
    while(UndoRedoListModel->getSize()-1 > TheUndoManager->numberOfRedos() + TheUndoManager->numberOfUndos())
    {
        UndoRedoListModel->popBack();
    }

    //Resize
    while(UndoRedoListModel->getSize()-1 < TheUndoManager->numberOfRedos() + TheUndoManager->numberOfUndos())
    {
        UndoRedoListModel->pushBack(boost::any(std::string("")));
    }

    UInt32 UndoCount(TheUndoManager->numberOfUndos());
    for(UInt32 i(0) ; i<UndoCount ; ++i)
    {
        UndoRedoListModel->set(i+1, boost::any(std::string(TheUndoManager->editToBeUndone(i)->getUndoPresentationName())));
    }
    UInt32 RedoCount(TheUndoManager->numberOfRedos());
    for(UInt32 i(0) ; i<RedoCount ; ++i)
    {
        UndoRedoListModel->set(i+TheUndoManager->numberOfUndos()+1, boost::any(std::string(TheUndoManager->editToBeRedone(i)->getRedoPresentationName())));
    }

    if((UndoCount == 0 && UndoButton->getEnabled()) ||
       (UndoCount != 0 && !UndoButton->getEnabled()) )
    {
        UndoButton->setEnabled(UndoCount != 0);
    }
    if((RedoCount == 0 && RedoButton->getEnabled()) ||
       (RedoCount != 0 && !RedoButton->getEnabled()) )
    {
        RedoButton->setEnabled(RedoCount != 0);
    }
}