2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
25 * $XConsortium: tmodeP.c /main/3 1995/11/06 17:54:59 rswiston $
27 * @(#)tmodeP.c 1.1 15 Jan 1995 cde_app_builder/src/ab
29 * RESTRICTED CONFIDENTIAL INFORMATION:
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
39 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
45 ** File: tmodeP.c - Common Test Mode functionality
49 #include <ab_private/trav.h>
50 #include <ab_private/util.h>
51 #include <ab_private/ui_util.h>
54 /*****************************************************************************
56 ** Private Function Declarations **
58 *****************************************************************************/
59 static ABObjList tmodeP_list_create(
62 static int tmodeP_list_destroy(
67 /*****************************************************************************
69 ** Function Definitions **
71 *****************************************************************************/
74 * Test Mode Data Structure
77 /* Create a Test Mode data structure and initialize it to it's defaults */
79 tmodeP_obj_create_data(
86 if (tmodeP_obj_has_data(obj))
87 tmodeP_obj_destroy_data(obj);
89 tmodeP_obj_data(obj) = (TestModeData) util_malloc(sizeof(TestModeDataRec));
91 if (!tmodeP_obj_has_data(obj))
94 return tmodeP_obj_construct_data(obj);
97 /* Destroy a Test Mode data structure */
99 tmodeP_obj_destroy_data(
106 if (tmodeP_obj_has_data(obj))
107 util_free(tmodeP_obj_data(obj));
109 tmodeP_obj_data(obj) = NULL;
113 /* Initialize a Test Mode data structure to it's defaults */
115 tmodeP_obj_construct_data(
119 if (!obj || !obj->test_mode_data)
122 tmodeP_obj_set_width( obj, 0);
123 tmodeP_obj_set_height(obj, 0);
124 tmodeP_obj_set_x( obj, 0);
125 tmodeP_obj_set_y( obj, 0);
134 static ABObjList wlist = NULL; /* windows in the project */
136 /* Create the window list. (and populate it) */
138 tmodeP_window_list_create(
146 tmodeP_list_destroy(wlist);
148 if ((wlist = tmodeP_list_create()) == NULL)
151 if (tmodeP_window_list_construct(project) != OK)
153 tmodeP_list_destroy(wlist);
160 /* Populate the window list */
162 tmodeP_window_list_construct(
170 if (!project || !wlist)
173 /* populate the list */
174 for (trav_open(&trav, project, AB_TRAV_WINDOWS);
175 (obj = trav_next(&trav)) != NULL; )
177 status = objlist_add_obj(wlist, obj, NULL);
180 tmodeP_obj_construct_flags(obj);
181 if (tmodeP_obj_create_data(obj) != OK)
183 "tmodeP_window_list_construct: Unable to create data.\n");
185 else if (status == ERR_DUPLICATE_KEY)
187 "tmodeP_window_list_construct: Duplicate window in obj structure.\n");
190 "tmodeP_window_list_construct: Unable to add window to list.\n");
197 /* UnPopulate the window list */
199 tmodeP_window_list_destruct(
209 /* trav the list of windows, destroying test data */
210 for (i=0; i < objlist_get_num_objs(wlist); i++)
212 obj = objlist_get_obj(wlist, i, NULL);
217 "tmodeP_window_list_destruct: %d window's obj is missing.\n", i);
221 tmodeP_obj_construct_flags(obj);
223 if (tmodeP_obj_has_data(obj))
225 if (tmodeP_obj_destroy_data(obj) == ERROR)
228 "tmodeP_window_list_destruct: Can't free test mode data for %d window.\n", i);
237 /* Destroy the window list */
239 tmodeP_window_list_destroy(
247 if (tmodeP_window_list_destruct() != OK)
248 util_dprintf(1, "tmodeP_window_list_destroy: Can't destroy some test mode data.\n");
250 /* destroy the list */
251 tmodeP_list_destroy(wlist);
258 ** iterate the supplied function over the window list
261 tmodeP_window_list_iterate(
271 objlist_iterate(wlist, fn);
275 ** foreach of the windows in the window list
276 ** find the window's shell
277 ** XtAddEventHandler() to the shell
278 ** client_data = obj.
281 tmodeP_window_list_add_handler(
282 EventMask event_mask,
284 XtEventHandler event_handler
294 /* trav the list of windows */
295 for (i=0; i < objlist_get_num_objs(wlist); i++)
297 obj = objlist_get_obj(wlist, i, NULL);
302 "tmodeP_window_list_add_handler: %d window is missing obj.\n", i);
309 "tmodeP_window_list_add_handler: no ui_handle %d window.\n", i);
313 w = ui_get_ancestor_shell(obj->ui_handle);
317 event_mask, /* EventMask */
318 nonmaskable, /* non-maskable events - Boolean */
319 event_handler, /* XtEventHandler */
320 (XtPointer) obj /* client_data */
327 ** foreach of the windows in the window list
328 ** find the window's shell
329 ** XtRemoveEventHandler() on the shell
330 ** client_data = obj.
333 tmodeP_window_list_remove_handler(
334 EventMask event_mask,
336 XtEventHandler event_handler
343 if (!wlist) /* can't remove the handlers from a */
344 return OK; /* non-existant list, but it's not an error */
346 /* trav the list of windows */
347 for (i=0; i < objlist_get_num_objs(wlist); i++)
349 obj = objlist_get_obj(wlist, i, NULL);
354 "tmodeP_window_list_remove_handler: %d window is missing obj.\n", i);
361 "tmodeP_window_list_remove_handler: no ui_handle %d window.\n", i);
365 w = ui_get_ancestor_shell(obj->ui_handle);
367 XtRemoveEventHandler(
369 event_mask, /* EventMask */
370 nonmaskable, /* non-maskable events - Boolean */
371 event_handler, /* XtEventHandler */
372 (XtPointer) obj /* client_data */
379 /*****************************************************************************
381 ** Private Function Definitions **
383 *****************************************************************************/
395 ABObjList list = NULL;
397 if ((list = objlist_create()) == NULL)
400 objlist_set_sort_order(list, OBJLIST_SORT_BEST);
412 objlist_destroy(list);