Forum > FPSpreadsheet


<< < (2/2)

Its not hugely hard to implement yourself. Its just a case of working what are the changes you want to 'undo' and storing a representation of them on a circular buffer.

I made a undo/redo unit for KMemo, - its almost certainly no direct use to you unless you use KMemo but it  might give you a few ideas to follow up on. KMemo, being a text thingo, is text focused.

Sounds like you will want to record control positions, just a case of, perhaps, making a record that contains the name of a control, its position. Poke that record into the buffer each time someone moves moves things. On undo, Pop each record back out and restore the control to the position recorded in the popped record.

Obviously, some housekeeping is required, you need to manage the most recent and oldest record, decide when to throw away the oldest to make room for a new one. And probably implement some sort of delay before recording a new record to make sure the user has finished moving ...


Dead giveaway:
It is a stack. (or basicallly a singly linked list)

If you can't write a stack you are not a programmer.( Yet 8) :D)

Happy new year!

p.s.  I propose you order although that may seem a blatant advert, it is not! all example code compiles with FreePascal.
There are many more links about algorithms and data structures. You will NEED that knowlege at some point.
Use a TStack<T>............


[0] Message Index

[*] Previous page

Go to full version