summaryrefslogtreecommitdiff
path: root/src/lib/undoredo.h
blob: 1d8a4233814776ebfa086c09210bb8966a065b43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

#ifndef _UNDOREDO_H
#define _UNDOREDO_H
typedef enum
{
   MEMENTO_NONE,
   MEMENTO_PROPERTY,
   MEMENTO_CALLBACK,
   MEMENTO_CALLBACK_ADD_DEL,
   MEMENTO_OBJ_CONTAINER_ITEM,
   MEMENTO_OBJ_CONTAINER_PROPERTY,
   MEMENTO_ITEM_CONTAINER_ITEM,
   MEMENTO_WIDGET
} Gui_Memento_Type;

typedef struct _Gui_Memento Gui_Memento;

/* There is Design patten Memento, which defines three parts.
 * Originator - is some object that has an internal state.
 *   Our Originator is Gui_Context and its state is some Widget and Property.
 * Memento - object(container) to keep originator's state.
 * Caretaker - does some action on Originator, but saves the state in the beginning.
 *
 * Gui_Context is also the Caretaker. */

/* Create new Memento Object */
Gui_Memento*
gui_memento_new(Dep_Id *wdg_id, Gui_Memento_Type type, void *old_pointer, void *new_pointer);

/* Delete Memento Object */
void
gui_memento_del(Gui_Memento *memento);

/* Get Memento type */
Gui_Memento_Type
gui_memento_type_get(const Gui_Memento *memento);

/* Append memento to the list of mementos */
void
gui_memento_append(Gui_Memento *head, Gui_Memento *in);

/* Get next Memento */
Gui_Memento*
gui_memento_next(const Gui_Memento *memento);

/* Functions to set/get state in Gui_Memento. */

/* Get widget. */
Dep_Id *
gui_memento_wdg_get(const Gui_Memento *memento);

/* Get old pointer to property/list. */
void *
gui_memento_old_pointer_get(const Gui_Memento *memento);

/* Get new pointer to property/list. */
void *
gui_memento_new_pointer_get(const Gui_Memento *memento);

/* Assigns source memento's new pointer to dest memento's new pointer.
 * source memento must be deleted. */
void
gui_mementos_squash(Gui_Memento *dest, Gui_Memento *source);

#endif