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: Resize.c /main/5 1995/10/26 12:31:25 rswiston $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Display Area Library
31 ** Description: This body of code handles direct resize requests from
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.
42 ****************************************************************************
43 ************************************<+>*************************************/
53 #include "DisplayAreaP.h"
54 #include "CallbacksI.h"
57 #include "XUICreateI.h"
62 /******** Private Function Declarations ********/
63 /******** End Private Function Declarations ********/
65 /******** Private Variables ********/
66 /******** End Private Variables ********/
68 /*********************************************************************
70 *********************************************************************/
72 /*********************************************************************
74 *********************************************************************/
75 /*********************************************************************
76 * Function: ResizeDisplayArea
78 * ResizeDisplayArea resizes the Display Area and re-formats the
79 * text based on a row and column values given.
81 *********************************************************************/
83 _DtHelpResizeDisplayArea (
85 XtPointer client_data,
91 unsigned long char_width;
95 Dimension vertWidth = 0;
96 Dimension horzHeight = 0;
101 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
111 /* Set the size of the text view area to the requested number of columns */
113 char_width = pDAS->charWidth * columns;
115 newWidth = char_width / 10 + (char_width % 10 ? 1 : 0) +
116 2 * (pDAS->decorThickness + pDAS->marginWidth);
117 newHeight = pDAS->lineHeight * rows + 2 * pDAS->decorThickness;
120 * get the width and height of the scroll bars.
123 if (pDAS->vertScrollWid)
125 XtSetArg (args[0], XmNwidth , &vertWidth);
126 XtGetValues (pDAS->vertScrollWid, args, 1);
129 if (pDAS->horzScrollWid)
131 XtSetArg (args[0], XmNheight , &horzHeight);
132 XtGetValues (pDAS->horzScrollWid, args, 1);
136 * loop a couple of times at most to get the sizing correct.
137 * This is caused by the fact we can't do a set values on
138 * the drawn button itself, someone above it is rejecting
139 * the resize request. So, resize the great-grandparent
140 * (a couple of times if necessary).
144 * take into consideration the scrollbars.
147 tstHeight = newHeight;
148 if (pDAS->vertScrollWid &&
149 _DtHelpIS_AS_NEEDED(pDAS->neededFlags, _DtHelpVERTICAL_SCROLLBAR)
150 && pDAS->vertIsMapped)
152 if (tstWidth > vertWidth)
153 tstWidth -= vertWidth;
157 if (pDAS->horzScrollWid &&
158 _DtHelpIS_AS_NEEDED(pDAS->neededFlags, _DtHelpHORIZONTAL_SCROLLBAR)
159 && pDAS->horzIsMapped)
161 if (tstHeight > horzHeight)
162 tstHeight -= horzHeight;
168 if (tstWidth == pDAS->dispWidth && tstHeight == pDAS->dispHeight)
172 * kludge around the fact that some parent is not letting
173 * me resize the drawn button. Get the parent's size and
177 XtSetArg(args[n], XmNwidth, &oldWidth); ++n;
178 XtSetArg(args[n], XmNheight, &oldHeight); ++n;
179 XtGetValues(parent, args, n);
182 * calculate its new size
184 oldWidth = oldWidth - pDAS->dispWidth + tstWidth;
185 oldHeight = oldHeight - pDAS->dispHeight + tstHeight;
188 * set my parent's size to affect me.
191 XtSetArg(args[n], XmNwidth, oldWidth); ++n;
192 XtSetArg(args[n], XmNheight, oldHeight); ++n;
193 XtSetValues(parent, args, n);
195 } while (count++ < 2);
198 * check to see if the Set Values on my parent took care of everything.
200 if (pDAS->vertScrollWid &&
201 _DtHelpIS_AS_NEEDED(pDAS->neededFlags, _DtHelpVERTICAL_SCROLLBAR)
202 && pDAS->vertIsMapped)
204 if (newWidth > vertWidth)
205 newWidth -= vertWidth;
210 if (pDAS->horzScrollWid &&
211 _DtHelpIS_AS_NEEDED(pDAS->neededFlags, _DtHelpHORIZONTAL_SCROLLBAR)
212 && pDAS->horzIsMapped)
214 if (newHeight > horzHeight)
215 newHeight -= horzHeight;
220 if (newWidth == pDAS->dispWidth && newHeight == pDAS->dispHeight)
225 _DtHelpClearSelection (pDAS);
229 * reset the scroll bars and possibly reformat the text.
231 _DtHelpSetScrollBars (client_data, newWidth, newHeight);
232 if (XtIsRealized (pDAS->dispWid))
233 _DtHelpCleanAndDrawWholeCanvas(client_data);
235 } /* End _DtHelpResizeDisplayArea */