Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / abobj_edit.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23
24 /*
25  *      $XConsortium: abobj_edit.h /main/3 1995/11/06 17:15:39 rswiston $
26  *
27  *      @(#)abobj_edit.h        1.1 15 Feb 1994 
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *      
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement between
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
35  *      Sun's specific written approval.  This document and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  */
42
43 #ifndef _ABOBJ_EDIT_H_
44 #define _ABOBJ_EDIT_H_
45
46 #include <ab_private/abobj.h>
47
48 /*
49  * Declarations for edit features
50  */
51
52 /*
53  * Size of each malloc'd block for clipboard/undo buffer
54  */
55 #define ABOBJ_CLIPBOARD_BLOCK_SIZE      10
56 #define ABOBJ_UNDO_BLOCK_SIZE           10
57
58 /*
59  * Edit operations
60  */
61 typedef enum
62 {
63     AB_EDIT_CUT = 0,
64     AB_EDIT_COPY,
65     AB_EDIT_PASTE,
66     AB_EDIT_DELETE,
67     AB_EDIT_NUM_VALUES
68 } AB_EDIT_TYPE;
69
70 /*
71  * Supported actions that can be undone
72  */
73 typedef enum
74 {
75     AB_UNDO_NO_TYPE = 0,
76     AB_UNDO_CUT,
77     AB_UNDO_DELETE,
78     AB_UNDO_PASTE,
79     AB_UNDO_MOVE,
80     AB_UNDO_RESIZE,
81     AB_UNDO_GROUP,
82     AB_UNDO_UNGROUP,
83     AB_UNDO_NUM_VALUES
84 } AB_UNDO_TYPE;
85
86 /*
87 ** Supported initiator locations of a paste operation
88 */
89 typedef enum
90 {
91     AB_PASTE_INITIATOR_NO_TYPE = 0,
92     AB_PASTE_INITIATOR_OBJ_MENU,        /* Object popup menu */
93     AB_PASTE_INITIATOR_BRWS_MENU,       /* Browser popup menu */
94     AB_PASTE_INITIATOR_BRWS_EDIT_MENU,  /* Browser's edit menu */
95     AB_PASTE_INITIATOR_PAL_EDIT_MENU,   /* Palette's edit menu */
96     AB_PASTE_INITIATOR_NUM_VALUES
97 } AB_PASTE_INITIATOR_TYPE;
98
99
100 /*
101  * Data structures for clipboard/undo
102  * What follows are data structures that are used to store
103  * ABOBj's and related data for undo and the clipboard.
104  *
105  * The two main data structures are:
106  *      AB_CLIPBOARD_REC        and
107  *      AB_UNDO_REC
108  *
109  * AB_UNDO_REC is a bit complicated because it consists
110  * of data for cut/delete/paste/move/resize/group/ungroup
111  * which are all contained in a union.
112  */
113
114 /*
115  * Additional info needed for clipboard
116  */
117 typedef struct _AB_CLIPB_INFO
118 {
119     ABObj       dup_obj;        /* duplicated object, not just ptr to */
120     ABObj       action_list;    /* duplicated ACTIONS for object and it's descendants */
121     char        *other_stuff;   /* placeholder for now, will be filled 
122                                  * in later */
123 }AB_CLIPB_INFO, *ABClipbInfo;
124
125 /*
126  * Additional info needed for undoing cut
127  */
128 typedef struct _AB_UNDO_CUT_INFO
129 {
130     ABObj       dup_obj;
131     ABObj       from_action_list;       /* duplicated ACTIONS for object (object == source) */
132     ABObj       to_action_list;         /* duplicated ACTIONS for object (object == target) */
133     ABObj       parent;                 /* POINTER to parent */
134     ABObj       pane_sibling;           /* POINTER to sibling - used for layers */
135 } AB_UNDO_CUT_INFO, *ABUndoCutInfo;
136
137 /*
138  * Additional info needed for undoing move
139  */
140 typedef struct _AB_UNDO_MOVE_INFO
141 {
142     int         x;
143     int         y;
144 } AB_UNDO_MOVE_INFO, *ABUndoMoveInfo;
145
146 /*
147  * Additional info needed for undoing resize
148  */
149 typedef struct _AB_UNDO_RESIZE_INFO
150 {
151     int         width;
152     int         height;
153 } AB_UNDO_RESIZE_INFO, *ABUndoResizeInfo;
154
155 /*
156  * Additional info needed for undoing ungroup
157  */
158 typedef struct _AB_UNDO_UNGROUP_INFO
159 {
160     ABObj       dup_old_group;          /* DUPLICATE of ungrouped group */
161     ABObj       *member_list;           /* List of POINTERS to members */
162     int         member_count;
163 } AB_UNDO_UNGROUP_INFO, *ABUndoUngroupInfo;
164
165 /*
166  * Union of additional info for undo actions
167  */
168 typedef union _AB_UNDO_EXTRA_INFO
169 {
170     AB_UNDO_CUT_INFO            cut;
171     /* undo for cut == undo for delete */
172     /* don't need special info for undoing paste */
173     AB_UNDO_MOVE_INFO           move;
174     AB_UNDO_RESIZE_INFO         resize;
175     AB_UNDO_UNGROUP_INFO        ungroup;
176     /* don't need special info for undoing group */
177 }AB_UNDO_EXTRA_INFO, *ABUndoExtraInfo;
178
179 /*
180  * Info for undoing an action on ONE object
181  */
182 typedef struct _AB_UNDO_INFO
183 {
184     AB_UNDO_TYPE        type;
185     AB_UNDO_EXTRA_INFO  info;
186 }AB_UNDO_INFO, *ABUndoInfo;
187
188 /*
189  * Data structure for clipboard
190  */
191 typedef struct _AB_CLIPBOARD_REC{
192     ABObj               *list;  /* List of POINTERS to copied/cut objects */
193     AB_CLIPB_INFO       *info_list;
194     int                 count;
195     int                 action_count;
196     int                 size;
197 } AB_CLIPBOARD_REC, *ABClipboardRec;
198
199 /*
200  * Type for ABUndoFunc
201  */
202 struct _AB_UNDO_REC;            /* forward ref for ABUndoFunc */
203 typedef void AB_UNDO_FUNC(struct _AB_UNDO_REC *undo_rec);
204 typedef AB_UNDO_FUNC *ABUndoFunc;
205
206 /*
207  * Data structure for undo buffer
208  */
209 typedef struct _AB_UNDO_REC{
210     ABObj               *list;
211     AB_UNDO_INFO        *info_list;
212     ABUndoFunc          undo_func;
213     int                 count;
214     int                 action_count;
215     int                 size;
216 } AB_UNDO_REC, *ABUndoRec;
217
218
219 /*
220  * Editing functions
221  */
222 extern void     abobj_edit_init(
223                 );
224
225 extern int      abobj_cut(
226                 );
227
228 extern int      abobj_copy(
229                 );
230
231 extern int      abobj_paste(
232                 AB_PASTE_INITIATOR_TYPE initiator
233                 );
234
235 extern int      abobj_delete(void);
236
237 extern int      abobj_undo(void);
238
239 extern int      abobj_cancel_undo(void);
240
241 extern BOOL     abobj_undo_active(
242                 );
243
244 /*
245  * CLIPBOARD manipulating functions
246  */
247 extern BOOL     abobj_clipboard_is_empty(
248                 );
249
250 extern BOOL     abobj_in_clipboard(
251                     ABObj       obj
252                 );
253
254 extern void     abobj_clipboard_clear(
255                 );
256
257 extern void     abobj_clipboard_set(
258                     ABObj       *obj,
259                     int         count
260                 );
261
262 extern void     abobj_clipboard_add(
263                     ABObj       *obj,
264                     int         count
265                 );
266
267 /*
268  * Function to set undo buffer
269  */
270 extern int      abobj_set_undo(
271                     ABObj               *obj,
272                     int                 count,
273                     ABUndoFunc          undo_func,
274                     AB_UNDO_TYPE        undo_type
275                 );
276
277 extern void     abobj_setup_undo_cut_layer(
278                     ABObj       layer,
279                     ABObj       last_pane
280                 );
281
282 /*
283  * Xt Callbacks for editing functions:
284  *      undo
285  *      cut
286  *      copy
287  *      paste
288  *      delete
289  */
290 extern void     abobj_undo_cb(
291                     Widget      widget,
292                     XtPointer   client_data,
293                     XtPointer   call_data
294                 );
295
296 extern void     abobj_cut_cb(
297                     Widget      widget,
298                     XtPointer   client_data,
299                     XtPointer   call_data
300                 );
301
302 extern void     abobj_copy_cb(
303                     Widget      widget,
304                     XtPointer   client_data,
305                     XtPointer   call_data
306                 );
307
308 extern void     abobj_paste_cb(
309                     Widget      widget,
310                     XtPointer   client_data,
311                     XtPointer   call_data
312                 );
313
314 extern void     abobj_delete_cb(
315                     Widget      widget,
316                     XtPointer   client_data,
317                     XtPointer   call_data
318                 );
319
320 #endif /* _ABOBJ_EDIT_H_ */