don't include dlfcn.h on win32
[dia.git] / lib / objchange.h
blob01b4c07cea9376fb424baecee337d7fb77f7a587
1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1999 Alexander Larsson
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #ifndef CHANGE_H
19 #define CHANGE_H
21 #include "diatypes.h"
23 typedef void (*ObjectChangeApplyFunc)(ObjectChange *change, Object *obj);
24 typedef void (*ObjectChangeRevertFunc)(ObjectChange *change, Object *obj);
25 typedef void (*ObjectChangeFreeFunc)(ObjectChange *change);
27 struct _ObjectChange {
28 /* If apply == transaction_point_pointer then this is a transaction
29 point */
30 ObjectChangeApplyFunc apply;
31 ObjectChangeRevertFunc revert;
32 ObjectChangeFreeFunc free; /* Remove extra data. Then this object is freed */
35 /******** Helper functions of objects: *************/
37 struct _ObjectState {
38 void (*free)(ObjectState *state); /* Frees pointers in the state,
39 not called if NULL */
43 Gets the internal state from the object.
44 This is used to snapshot the object state
45 so that it can be stored for undo/redo.
47 Need not save state that only depens on
48 the object and it's handles positions.
50 The calling function owns the returned reference.
52 typedef ObjectState * (*GetStateFunc) (Object* obj);
55 Sets the internal state from the object.
56 This is used to snapshot the object state
57 so that it can be stored for undo/redo.
59 The called function owns the reference and is
60 responsible for freeing it.
62 typedef void (*SetStateFunc) (Object* obj, ObjectState *state);
65 ObjectChange *new_object_state_change(Object *obj,
66 ObjectState *old_state,
67 GetStateFunc get_state,
68 SetStateFunc set_state );
70 #endif /* CHANGE_H */