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 libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Destroy.c /main/12 1996/03/18 14:08:16 cde-hal $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Cde Help System
31 ** Description: This code frees the information associated with
34 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
36 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
37 ** (c) Copyright 1993, 1994 International Business Machines Corp.
38 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
39 ** (c) Copyright 1993, 1994 Novell, Inc.
40 ****************************************************************************
41 ************************************<+>*************************************/
47 #include <X11/Xatom.h>
57 #include "DisplayAreaP.h"
58 #include "CallbacksI.h"
61 #include "GraphicsI.h"
62 #include "HyperTextI.h"
63 #include "StringFuncsI.h"
68 /******** Private Function Declarations ********/
69 /******** End Public Function Declarations ********/
71 /******************************************************************************
73 * These are the public routines available.
75 *****************************************************************************/
76 /*********************************************************************
77 * Function: _DtHelpDisplayAreaClean
79 * _DtHelpDisplayAreaClean deallocates all paragraph, font, and
80 * graphic information associated with it.
82 *********************************************************************/
84 _DtHelpDisplayAreaClean (XtPointer client_data)
88 Atom xa_primary = XA_PRIMARY;
89 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
92 * remove the selection if necessary
94 _DtHelpLoseSelectionCB (pDAS->dispWid, &xa_primary);
99 if (NULL != pDAS->canvas)
100 _DtCanvasClean (pDAS->canvas);
105 if (XtIsRealized (pDAS->dispWid))
106 XClearArea(XtDisplay(pDAS->dispWid), XtWindow(pDAS->dispWid),
107 pDAS->decorThickness, pDAS->decorThickness,
108 pDAS->dispUseWidth, pDAS->dispUseHeight, False);
110 pDAS->toc_flag &= ~(_DT_HELP_TOC_ON);
113 * reset any scrollbars that are managed.
116 XtSetArg (args[n], XmNvalue , 0); ++n;
117 XtSetArg (args[n], XmNsliderSize , 1); ++n;
118 XtSetArg (args[n], XmNmaximum , 1); ++n;
119 XtSetArg (args[n], XmNpageIncrement, 1); ++n;
121 if (pDAS->vertScrollWid && XtIsManaged (pDAS->vertScrollWid))
122 XtSetValues (pDAS->vertScrollWid, args, n);
124 if (pDAS->horzScrollWid && XtIsManaged (pDAS->horzScrollWid))
125 XtSetValues (pDAS->horzScrollWid, args, n);
127 } /* End _DtHelpDisplayAreaClean */
129 /*********************************************************************
130 * Function: _DtHelpDisplayAreaDestroyCB
132 * _DtHelpDisplayAreaDestroyCB deallocates all information
133 * associated with it.
135 *********************************************************************/
137 _DtHelpDisplayAreaDestroyCB (
139 XtPointer client_data,
144 XrmName xrmList[_DtHelpFontQuarkNumber];
146 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
147 Boolean usedDef = False;
150 * do the gross cleaning
152 _DtHelpDisplayAreaClean(client_data);
154 if (NULL != pDAS->canvas)
155 _DtCanvasDestroy (pDAS->canvas);
157 dpy = XtDisplay(pDAS->dispWid);
161 XFreeGC (dpy, pDAS->normalGC);
162 XFreeGC (dpy, pDAS->pixmapGC);
163 XFreeGC (dpy, pDAS->invertGC);
164 if (pDAS->def_pix != 0 &&
165 XmDestroyPixmap(XDefaultScreenOfDisplay(dpy), pDAS->def_pix) == False)
166 XFreePixmap(dpy, pDAS->def_pix);
167 if (pDAS->context != NULL)
169 _DtGrDestroyContext(pDAS->context);
170 XtFree((char *) pDAS->context);
174 * destroy the widgets.
176 XtDestroyWidget(pDAS->dispWid);
178 if (pDAS->horzScrollWid != NULL)
179 XtDestroyWidget(pDAS->horzScrollWid);
180 if (pDAS->vertScrollWid != NULL)
181 XtDestroyWidget(pDAS->vertScrollWid);
184 * free the special characters
186 if (pDAS->spc_chars != NULL)
187 free ((char *) pDAS->spc_chars);
190 * free the font info.
192 _DtHelpGetStringQuarks(xrmList);
193 if (__DtHelpFontIndexGet(pDAS, xrmList, &strIdx) != 0)
196 if (pDAS->font_info.def_font_db != NULL)
197 XrmDestroyDatabase(pDAS->font_info.def_font_db);
198 if (pDAS->font_info.font_idx_db != NULL)
199 XrmDestroyDatabase(pDAS->font_info.font_idx_db);
200 if (pDAS->font_info.exact_fonts != NULL)
202 _DtHelpCeFreeStringArray(pDAS->font_info.exact_fonts);
203 free(pDAS->font_info.exact_idx);
205 if (pDAS->font_info.font_structs != NULL)
208 * if the string index is a positive number, this
209 * indicates that the string font is a font not
210 * a font set and it wouldn't be freed in this
213 for (i = 0; i < pDAS->font_info.struct_cnt; i++)
215 if (usedDef == True || i != strIdx)
216 XFreeFont(dpy, pDAS->font_info.font_structs[i]);
218 free(pDAS->font_info.font_structs);
220 if (pDAS->font_info.font_sets != NULL)
223 * if the string index is a negative number, this turns
224 * it to positive and the tests will succeed.
226 * if the string index was a font not a fontset, then
227 * this will turn the value negative and the test
228 * will never succeed.
230 strIdx = (-strIdx) - 1;
231 for (i = 0; i < pDAS->font_info.set_cnt; i++)
233 if (usedDef == True || i != strIdx)
234 XFreeFontSet(dpy, pDAS->font_info.font_sets[i]);
236 free(pDAS->font_info.font_sets);
237 free(pDAS->font_info.fs_metrics);
241 * free the locale dependant information
243 if (NULL != pDAS->cant_begin_chars)
244 free (pDAS->cant_begin_chars);
245 if (NULL != pDAS->cant_end_chars)
246 free (pDAS->cant_end_chars);
249 * destroy the display area pointer
251 XtFree ((char *) pDAS);
253 } /* End DtHelpDisplayAreaDestroy */