Implementing Multiple Undo/Redo 
Author Message
 Implementing Multiple Undo/Redo

Hi,

I am curious about how to implement mulitple undo/redo.

I have no idea where to start. I suppose it is some kind of ObjectList??
Has anybody attempted such a feat?

What is the magic behind it?

Regards,



Fri, 30 Jan 2004 07:27:50 GMT  
 Implementing Multiple Undo/Redo
I've recently implemented undo/redo using the Command design pattern.

(Descibed in the book Design Patterns by Gamma, Helm, Johnson, and
Vlissides, ISBN: 0201633612)



Quote:
> Hi,

> I am curious about how to implement mulitple undo/redo.

> I have no idea where to start. I suppose it is some kind of ObjectList??
> Has anybody attempted such a feat?

> What is the magic behind it?

> Regards,



Fri, 30 Jan 2004 19:14:04 GMT  
 Implementing Multiple Undo/Redo
Hi,

The general concept is that you are going to have to implement some type of
history storage. This history depends on the type of application.  If you
had a drawing application, the history might be actions like "Draw line
from 0,0 to 100,100".  You would have to have a way to store that action in
some way. Perhaps you have an array or a linked list of actions that have
been performed. When an undo is done, you rollback that action by examining
the most recent action object and determining how to roll this back for
your application.  In the drawing example, perhaps you determine that the
last action was this line draw. You then have to remove that line from the
picture and redraw the screen or that portion of the screen.  The things
that are done are determined by what you consider to be an action and how
the underlying data is stored so that you can undo it.

Also, the RichEdit control has the Undo/Redo functionality built-in. If you
are using TOM (Text Object Model), the method would be ITextDocument::Redo/
ITextDocument::Undo. Otherwise, the message to use is EM_UNDO.

In addition, there is an article in CodeGuru. I think it should be helpful:

http://codeguru.earthweb.com/misc/undo_manager.shtml

Regards,
Leo



Fri, 30 Jan 2004 21:05:17 GMT  
 Implementing Multiple Undo/Redo
Cool. Thanks a bunch. At least I know where to start.


Quote:
> Hi,

> The general concept is that you are going to have to implement some type
of
> history storage. This history depends on the type of application.  If you
> had a drawing application, the history might be actions like "Draw line
> from 0,0 to 100,100".  You would have to have a way to store that action
in
> some way. Perhaps you have an array or a linked list of actions that have
> been performed. When an undo is done, you rollback that action by
examining
> the most recent action object and determining how to roll this back for
> your application.  In the drawing example, perhaps you determine that the
> last action was this line draw. You then have to remove that line from the
> picture and redraw the screen or that portion of the screen.  The things
> that are done are determined by what you consider to be an action and how
> the underlying data is stored so that you can undo it.

> Also, the RichEdit control has the Undo/Redo functionality built-in. If
you
> are using TOM (Text Object Model), the method would be

ITextDocument::Redo/

- Show quoted text -

Quote:
> ITextDocument::Undo. Otherwise, the message to use is EM_UNDO.

> In addition, there is an article in CodeGuru. I think it should be
helpful:

> http://codeguru.earthweb.com/misc/undo_manager.shtml

> Regards,
> Leo



Sat, 31 Jan 2004 00:51:58 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Implementing Undo/Redo functionality

2. Help for implementing Undo/Redo for drawing

3. How to implement Undo/Redo

4. Multiple undo/Redo in CRichEdit?

5. Multiple undo/Redo in CRichEdit?

6. Multiple undo & redo

7. How do I get Undo/Redo back

8. MRU and Undo/Redo problems in VS.NET

9. Redo / Undo

10. undo/redo drop-down list

11. Undo & Redo Implementation

12. Generic Class for Undo/Redo in VC++

 

 
Powered by phpBB® Forum Software