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
23 /* $XConsortium: TitleBox.c /main/14 1996/10/14 10:48:11 pascale $
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1990,1996 Hewlett-Packard Company.
27 * (c) Copyright 1996 International Business Machines Corp.
28 * (c) Copyright 1996 Sun Microsystems, Inc.
29 * (c) Copyright 1996 Novell, Inc.
30 * (c) Copyright 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
34 /**---------------------------------------------------------------------
38 *** project: MotifPlus Widgets
40 *** description: Source code for DtTitleBox class.
42 ***-------------------------------------------------------------------*/
45 /*-------------------------------------------------------------
49 #include <Xm/LabelG.h>
50 #if RiversVersion == _31
51 #include <Xm/ManagerP.h>
52 #include <Xm/GadgetP.h>
53 #endif /* RiversVersion == _31 */
55 #include <Dt/TitleBoxP.h>
56 #include <Dt/MacrosP.h>
57 #include <Dt/DtMsgsP.h>
58 #include "DtWidgetI.h"
63 /******** Public Function Declarations ********/
65 extern Widget _DtCreateTitleBox(
70 extern Widget _DtTitleBoxGetTitleArea(
72 extern Widget _DtTitleBoxGetWorkArea(
75 #define Max(x, y) (((x) > (y)) ? (x) : (y))
76 /******** End Public Function Declarations ********/
78 /******** Static Function Declarations ********/
80 static void ConfigureChildren(
81 DtTitleBoxWidget manager) ;
83 DtTitleBoxWidget manager,
90 static void GetTitleString(
91 DtTitleBoxWidget manager,
94 static void ClassInitialize( void ) ;
95 static void ClassPartInitialize(
97 static void Initialize(
98 DtTitleBoxWidget request,
99 DtTitleBoxWidget new) ;
101 DtTitleBoxWidget manager) ;
103 DtTitleBoxWidget manager) ;
104 static void Redisplay(
105 DtTitleBoxWidget manager,
108 static Boolean SetValues(
109 DtTitleBoxWidget current,
110 DtTitleBoxWidget request,
111 DtTitleBoxWidget new) ;
112 static XtGeometryResult QueryGeometry(
113 DtTitleBoxWidget manager,
114 XtWidgetGeometry *request,
115 XtWidgetGeometry *reply) ;
116 static XtGeometryResult GeometryManager(
118 XtWidgetGeometry *request,
119 XtWidgetGeometry *reply) ;
120 static void ChangeManaged(
121 DtTitleBoxWidget manager) ;
122 static void InsertChild(
124 static void ConstraintInitialize(
128 /******** End Static Function Declarations ********/
131 /*-------------------------------------------------------------
132 ** Forward Declarations
135 #define UNSPECIFIED_CHAR 255
136 #define UNSPECIFIED_DIMENSION 9999
137 #define MARGIN_DEFAULT 10
139 #define WARN_CHILD_TYPE _DtMsgDialogBox_0000
140 #define WARN_SHADOW_TYPE _DtMsgIcon_0005
141 #define WARN_TITLE_POSITION _DtMsgTitleBox_0000
142 #define WARN_TITLE_ALIGNMENT _DtMsgTitleBox_0001
144 #define MESSAGE2 _DtMsgTitleBox_0002
145 #define MESSAGE3 _DtMsgTitleBox_0003
146 #define MESSAGE4 _DtMsgTitleBox_0004
148 extern void _DtRegisterNewConverters( void ) ;
151 /*-------------------------------------------------------------
152 ** Translations and Actions
157 /*-------------------------------------------------------------
161 /* Define offset macros.
163 #define TB_Offset(field) \
164 XtOffset (DtTitleBoxWidget, title_box.field)
165 #define TBC_Offset(field) \
166 XtOffset (DtTitleBoxConstraintPtr, title_box_constraint.field)
168 static XtResource resources[] =
172 XmCShadowThickness, XmRShort, sizeof (short),
173 XtOffset (DtTitleBoxWidget, manager.shadow_thickness),
174 XmRImmediate, (XtPointer) UNSPECIFIED_DIMENSION
178 XmCMarginWidth, XmRHorizontalDimension, sizeof (Dimension),
179 TB_Offset (margin_width),
180 XmRImmediate, (XtPointer) UNSPECIFIED_DIMENSION
184 XmCMarginHeight, XmRVerticalDimension, sizeof (Dimension),
185 TB_Offset (margin_height),
186 XmRImmediate, (XtPointer) UNSPECIFIED_DIMENSION
190 XmCShadowType, XmRShadowType, sizeof (unsigned char),
191 TB_Offset (shadow_type),
192 XmRImmediate, (XtPointer) UNSPECIFIED_CHAR
196 XmCTitleSpacing, XmRHorizontalDimension, sizeof (Dimension),
197 TB_Offset (title_spacing),
198 XmRImmediate, (XtPointer) UNSPECIFIED_DIMENSION
202 XmCTitlePosition, XmRTitlePosition, sizeof (unsigned char),
203 TB_Offset (title_position), XmRImmediate, (XtPointer) XmTITLE_TOP
207 XmCAlignment, XmRAlignment, sizeof (unsigned char),
208 TB_Offset (title_alignment),
209 XmRImmediate, (XtPointer) XmALIGNMENT_BEGINNING
213 XmCXmString, XmRXmString, sizeof (XmString),
214 TB_Offset (title_string),
215 XmRImmediate, (XtPointer) XmUNSPECIFIED_STRING
219 XmCFontList, XmRFontList, sizeof (XmFontList),
220 TB_Offset (font_list), XmRImmediate, (XtPointer) NULL
224 /* Synthetic Resources
226 static XmSyntheticResource syn_resources[] =
229 XmNtitleString, sizeof (XmString),
230 TB_Offset (title_string),
231 (XmExportProc) GetTitleString,
235 XmNmarginWidth, sizeof (Dimension),
236 TB_Offset (margin_width),
237 (XmExportProc) XmeFromHorizontalPixels,
238 (XmImportProc) XmeToHorizontalPixels
241 XmNmarginHeight, sizeof (Dimension),
242 TB_Offset (margin_height),
243 (XmExportProc) XmeFromVerticalPixels,
244 (XmImportProc) XmeToVerticalPixels,
248 /* Constraint Resources
250 static XtResource constraints[] =
254 XmCChildType, XmRChildType, sizeof (unsigned char),
255 TBC_Offset (child_type), XmRImmediate, (XtPointer) XmWORK_AREA
260 /*-------------------------------------------------------------
263 DtTitleBoxClassRec dtTitleBoxClassRec =
268 (WidgetClass) &xmManagerClassRec, /* superclass */
269 "DtTitleBox", /* class_name */
270 sizeof (DtTitleBoxRec), /* widget_size */
271 ClassInitialize, /* class_initialize */
272 ClassPartInitialize, /* class_part_initialize*/
273 False, /* class_inited */
274 (XtInitProc) Initialize, /* initialize */
275 NULL, /* initialize_hook */
276 XtInheritRealize, /* realize */
279 resources, /* resources */
280 XtNumber (resources), /* num_resources */
281 NULLQUARK, /* xrm_class */
282 True, /* compress_motion */
283 True, /* compress_exposure */
284 True, /* compress_enterleave */
285 False, /* visible_interest */
286 (XtWidgetProc) Destroy, /* destroy */
287 (XtWidgetProc) Resize, /* resize */
288 (XtExposeProc) Redisplay, /* expose */
289 (XtSetValuesFunc) SetValues, /* set_values */
290 NULL, /* set_values_hook */
291 XtInheritSetValuesAlmost, /* set_values_almost */
292 NULL, /* get_values_hook */
293 NULL, /* accept_focus */
294 XtVersion, /* version */
295 NULL, /* callback private */
296 XtInheritTranslations, /* tm_table */
297 XtInheritQueryGeometry, /* query_geometry */
298 NULL, /* display_accelerator */
299 NULL, /* extension */
305 (XtGeometryHandler) GeometryManager,/* geometry_manager */
306 (XtWidgetProc) ChangeManaged, /* change_managed */
307 (XtWidgetProc) InsertChild, /* insert_child */
308 XtInheritDeleteChild, /* delete_child */
309 NULL, /* extension */
315 constraints, /* constraint_resources */
316 XtNumber (constraints), /* num_constraint_resources */
317 sizeof (DtTitleBoxConstraintRec), /* constraint_record */
318 (XtInitProc) ConstraintInitialize, /* constraint_initialize */
319 NULL, /* constraint_destroy */
320 NULL, /* constraint_set_values */
321 NULL, /* extension */
327 XtInheritTranslations, /* default_translations */
328 syn_resources, /* syn_resources */
329 XtNumber (syn_resources), /* num_syn_resources */
330 NULL, /* syn_cont_resources */
331 0, /* num_syn_cont_resources */
332 XmInheritParentProcess, /* parent_process */
333 NULL, /* extension */
339 NULL, /* extension */
343 WidgetClass dtTitleBoxWidgetClass = (WidgetClass) &dtTitleBoxClassRec;
347 /*-------------------------------------------------------------
349 **-------------------------------------------------------------
352 /*-------------------------------------------------------------------------
354 ** Set positions and sizes of title and work area.
358 DtTitleBoxWidget manager )
360 Widget title_area = M_TitleArea (manager),
361 work_area = M_WorkArea (manager);
362 Position ta_x = 0, ta_y = 0, wa_x = 0, wa_y = 0;
363 Dimension ta_w = 0, ta_h = 0, ta_bw = 0,
364 wa_w = 0, wa_h = 0, wa_bw = 0,
365 w = M_Width (manager),
366 h = M_Height (manager),
367 s_t = M_ShadowThickness (manager),
368 m_w = M_MarginWidth (manager),
369 m_h = M_MarginHeight (manager),
370 ta_sp = M_TitleSpacing (manager);
372 unsigned char align = M_TitleAlignment (manager);
373 XtWidgetGeometry ta_reply;
375 title_top = (M_TitlePosition (manager) == XmTITLE_TOP) ? True : False;
377 /* Set position and size of title area.
381 XtQueryGeometry (title_area, NULL, &ta_reply);
382 ta_w = ta_reply.width;
383 ta_h = ta_reply.height;
385 if (ta_w + 2U * ta_sp > (M_Width (manager) - 2U * ta_sp))
386 ta_w = M_Width (manager) - 2 * ta_sp;
392 if (align == XmALIGNMENT_BEGINNING)
394 else if (align == XmALIGNMENT_END)
395 ta_x = w - ta_sp - ta_w;
397 ta_x = (w - ta_w) / 2U;
399 ta_y = (title_top) ? 0 : h - ta_h;
401 ta_bw = P_BorderWidth (title_area);
402 XmeConfigureObject (title_area, ta_x, ta_y, ta_w, ta_h, ta_bw);
405 /* Set position and size of work area.
410 wa_y = (title_top) ? Max (s_t, ta_h) + m_h : s_t + m_h;
411 wa_w = w - 2 * (m_w + s_t);
414 wa_h = h - Max (s_t, ta_h) - s_t - 2 * m_h;
417 wa_bw = P_BorderWidth (work_area);
418 XmeConfigureObject (work_area,
419 wa_x, wa_y, wa_w, wa_h, wa_bw);
425 /*-------------------------------------------------------------------------
427 ** Calculate desired size based on children.
431 DtTitleBoxWidget manager,
439 Widget title_area = M_TitleArea (manager),
440 work_area = M_WorkArea (manager);
441 XtWidgetGeometry ta_reply, wa_reply;
442 Dimension s_t = M_ShadowThickness (manager),
443 m_w = M_MarginWidth (manager),
444 m_h = M_MarginHeight (manager),
445 ta_sp = M_TitleSpacing (manager);
448 /* Optimize title area change if possible.
450 if (work_area && (wa_w == 0) && (wa_h == 0))
452 if ((ta_w != 0) && (ta_h == 0))
454 if ((M_Width (manager) >=
455 M_Width (work_area) + (2U * ta_sp)) &&
456 (M_Height (manager) >= Max (ta_h, s_t) +
457 M_Height (work_area) + s_t + (2U * m_h)))
459 wa_w = M_Width (work_area);
460 wa_h = M_Height (work_area);
464 if ((wa_w == 0) && (wa_h == 0))
466 XtQueryGeometry (work_area, NULL, &wa_reply);
467 wa_w = wa_reply.width;
468 wa_h = wa_reply.height;
471 if (title_area && (ta_w == 0) && (ta_h == 0))
473 XtQueryGeometry (title_area, NULL, &ta_reply);
474 ta_w = ta_reply.width;
475 ta_h = ta_reply.height;
478 *w = Max (wa_w + (2U * (m_w + s_t)), ta_w + (2U * ta_sp));
481 *h = Max (s_t, ta_h) + wa_h + (2 * m_h) + s_t;
488 /*-------------------------------------------------------------
490 ** Get string from title label.
494 DtTitleBoxWidget manager,
498 Arg al[10]; /* arg list */
499 register int ac; /* arg count */
500 Widget title_area = M_TitleArea (manager);
501 XmString string = NULL;
506 XtSetArg (al[ac], XmNlabelString, &string); ac++;
507 XtGetValues (title_area, al, ac);
510 *value = (XtArgVal) string;
515 /*-------------------------------------------------------------
517 **-------------------------------------------------------------
521 /*-------------------------------------------------------------
523 **-------------------------------------------------------------
526 /*-------------------------------------------------------------------------
528 ** Initialize widget class.
531 ClassInitialize( void )
533 _DtRegisterNewConverters ();
537 /*-------------------------------------------------------------------------
538 ** ClassPartInitialize
539 ** Initialize widget class data.
549 /*-------------------------------------------------------------
551 ** Initialize a new widget instance.
555 DtTitleBoxWidget request,
556 DtTitleBoxWidget new )
558 Arg al[10]; /* arg list */
559 register int ac; /* arg count */
561 XmString title_string = NULL;
563 /* Check for unspecified dimensions.
565 if (M_MarginWidth (request) == UNSPECIFIED_DIMENSION)
566 M_MarginWidth (new) = MARGIN_DEFAULT;
567 if (M_MarginHeight (request) == UNSPECIFIED_DIMENSION)
568 M_MarginHeight (new) = MARGIN_DEFAULT;
569 if (M_TitleSpacing (request) == UNSPECIFIED_DIMENSION)
570 M_TitleSpacing (new) = UNSPECIFIED_DIMENSION;
571 if (M_ShadowThickness (new) == UNSPECIFIED_DIMENSION)
573 if (XtIsShell (XtParent (new)))
574 M_ShadowThickness (new) = 1;
576 M_ShadowThickness (new) = 2;
579 /* Validate shadow type.
581 if (M_ShadowType (new) == UNSPECIFIED_CHAR)
583 if (XtIsShell (XtParent (new)))
584 M_ShadowType (new) = XmSHADOW_OUT;
586 M_ShadowType (new) = XmSHADOW_ETCHED_IN;
588 else if (M_ShadowType (new) != XmSHADOW_IN &&
589 M_ShadowType (new) != XmSHADOW_OUT &&
590 M_ShadowType (new) != XmSHADOW_ETCHED_IN &&
591 M_ShadowType (new) != XmSHADOW_ETCHED_OUT)
593 XmeWarning ((Widget)new, WARN_SHADOW_TYPE);
596 /* Validate title position.
598 if (M_TitlePosition (new) != XmTITLE_TOP &&
599 M_TitlePosition (new) != XmTITLE_BOTTOM)
601 XmeWarning ((Widget)new, WARN_TITLE_POSITION);
604 /* Validate title alignment.
606 if (M_TitleAlignment (new) != XmALIGNMENT_BEGINNING &&
607 M_TitleAlignment (new) != XmALIGNMENT_CENTER &&
608 M_TitleAlignment (new) != XmALIGNMENT_END)
610 XmeWarning ((Widget)new, WARN_TITLE_ALIGNMENT);
613 /* Check width and height.
615 if (M_Width (new) == 0)
617 M_Width (new) = 2 * (M_ShadowThickness (new) +
618 M_MarginWidth (new));
619 if (M_Width (new) == 0)
622 if (M_Height (new) == 0)
624 M_Height (new) = 2 * (M_ShadowThickness (new) +
625 M_MarginHeight (new));
626 if (M_Height (new) == 0)
630 M_OldWidth (new) = M_Width (new);
631 M_OldHeight (new) = M_Height (new);
632 M_OldShadowThickness (new) = M_ShadowThickness (new);
635 M_WorkArea (new) = NULL;
637 /* Create title_area unless title explicitly set to null;
638 * use name if unspecified.
640 if (! M_TitleString (new))
642 M_TitleArea (new) = NULL;
646 if (M_TitleString (new) == XmUNSPECIFIED_STRING && M_Name (new))
648 M_TitleString (new) = XmStringCreateLocalized(M_Name (new));
649 title_string = M_TitleString (new);
652 XtSetArg (al[ac], XmNchildType, XmTITLE_AREA); ac++;
653 XtSetArg (al[ac], XmNmarginWidth, 2); ac++;
654 XtSetArg (al[ac], XmNmarginHeight, 0); ac++;
655 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
656 XtSetArg (al[ac], XmNhighlightThickness, 0); ac++;
657 XtSetArg (al[ac], XmNlabelString, M_TitleString (new)); ac++;
658 if (M_FontList (new))
660 XtSetArg (al[ac], XmNfontList, M_FontList (new));
663 title = XmCreateLabelGadget ((Widget)new, "title", al, ac);
664 M_TitleArea (new) = title;
665 XtManageChild (title);
667 if (M_TitleSpacing (new) == UNSPECIFIED_DIMENSION)
668 M_TitleSpacing (new) =
669 Max (P_Height (title)/2U, M_ShadowThickness (new));
671 M_TitleString (new) = XmUNSPECIFIED_STRING;
672 M_FontList (new) = NULL;
673 if (title_string != NULL)
674 XmStringFree (title_string);
678 /*-------------------------------------------------------------
680 ** Release resources allocated for widget instance.
684 DtTitleBoxWidget manager )
686 /* Superclass does all the work so far.
692 /*-------------------------------------------------------------
694 ** Update size of children.
698 DtTitleBoxWidget manager )
700 Widget title_area = M_TitleArea (manager);
701 Dimension s_t = M_OldShadowThickness (manager),
702 w = M_OldWidth (manager),
703 h = M_OldHeight (manager);
706 /* Clear shadow and save shadow data.
708 if (XtIsRealized ((Widget)manager))
710 _XmClearShadowType ((Widget)manager, w, h, s_t, 0);
712 if ((M_TitlePosition (manager) == XmTITLE_BOTTOM) &&
713 (M_Height (manager) > h))
715 y = h - P_Height (title_area);
716 XClearArea (XtDisplay (manager), XtWindow (manager),
717 0, y, M_Width (manager),
718 M_Height (manager) - y, False);
722 M_OldWidth (manager) = M_Width (manager);
723 M_OldHeight (manager) = M_Height (manager);
724 M_OldShadowThickness (manager) = M_ShadowThickness (manager);
726 ConfigureChildren (manager);
728 /* Draw shadow and title.
730 if (XtIsRealized ((Widget)manager))
731 Redisplay (manager, NULL, NULL);
736 /*-------------------------------------------------------------
742 DtTitleBoxWidget manager,
746 Widget title_area = M_TitleArea (manager),
747 work_area = M_WorkArea (manager);
748 Position title_x = M_X (title_area),
749 title_y = M_Y (title_area);
750 Dimension title_width = M_Width (title_area),
751 title_height = M_Height (title_area);
753 Display * d = XtDisplay (manager);
754 Dimension w = M_Width (manager),
755 h = M_Height (manager),
756 s_t = M_ShadowThickness (manager);
761 Boolean s_out = False,
763 Drawable drawable = XtWindow (manager);
765 y = title_height / 2 - s_t / 2;
767 /* Redisplay work area.
769 if (work_area && XmIsGadget (work_area) && XtIsManaged (work_area))
773 expose = XtCoreProc(work_area, expose);
776 (*expose) (work_area, event, region);
781 if (M_ShadowThickness (manager) > 0)
784 if (M_TitlePosition (manager) == XmTITLE_BOTTOM)
786 XmeDrawShadows(d, XtWindow(manager),
787 M_TopShadowGC(manager),
788 M_BottomShadowGC(manager),
789 x, y, w, h, s_t, M_ShadowType(manager));
792 /* Redisplay title area.
794 if (title_area && XtIsManaged (title_area))
796 XClearArea (d, XtWindow (manager), title_x, title_y,
797 title_width, title_height, False);
798 if (XmIsGadget (title_area))
802 expose = XtCoreProc(title_area, expose);
805 (*expose) (title_area, event, region);
813 /*-------------------------------------------------------------
815 ** Handle changes in resource data.
821 DtTitleBoxWidget current,
822 DtTitleBoxWidget request,
823 DtTitleBoxWidget new )
825 Widget title = M_TitleArea (new);
826 Boolean redisplay_flag = False,
829 Arg al[10]; /* arg list */
830 register int ac; /* arg count */
832 /* Validate title position.
834 if (M_TitlePosition (new) != M_TitlePosition (current) &&
835 M_TitlePosition (new) != XmTITLE_TOP &&
836 M_TitlePosition (new) != XmTITLE_BOTTOM)
838 XmeWarning ((Widget)new, WARN_TITLE_POSITION);
839 M_TitlePosition (new) = M_TitlePosition (current);
842 /* Validate title alignment.
844 if (M_TitleAlignment (new) != M_TitleAlignment (current) &&
845 M_TitleAlignment (new) != XmALIGNMENT_BEGINNING &&
846 M_TitleAlignment (new) != XmALIGNMENT_CENTER &&
847 M_TitleAlignment (new) != XmALIGNMENT_END)
849 XmeWarning ((Widget)new, WARN_TITLE_ALIGNMENT);
850 M_TitleAlignment (new) = M_TitleAlignment (current);
853 /* Validate shadow type.
855 if (M_ShadowType (new) != M_ShadowThickness (current) &&
856 M_ShadowType (new) != XmSHADOW_IN &&
857 M_ShadowType (new) != XmSHADOW_OUT &&
858 M_ShadowType (new) != XmSHADOW_ETCHED_IN &&
859 M_ShadowType (new) != XmSHADOW_ETCHED_OUT)
861 XmeWarning ((Widget)new, WARN_SHADOW_TYPE);
862 M_ShadowType (new) = M_ShadowThickness (current);
865 /* Check for redisplay; query and update kids if no resize.
867 if (M_MarginWidth (new) != M_MarginWidth (current) ||
868 M_MarginHeight (new) != M_MarginHeight (current) ||
869 M_ShadowThickness (new) != M_ShadowThickness (current))
871 redisplay_flag = True;
872 if (M_Width (new) == M_Width (current) &&
873 M_Height (new) == M_Height (current))
875 GetSize (new, 0, 0, 0, 0,
876 &(M_Width (new)), &(M_Height (new)));
877 ConfigureChildren (new);
881 else if (M_TitleSpacing (new) != M_TitleSpacing (current) ||
882 M_TitlePosition (new) != M_TitlePosition (current) ||
883 M_TitleAlignment (new) != M_TitleAlignment (current))
885 redisplay_flag = True;
886 ConfigureChildren (new);
888 else if (M_ShadowType (new) != M_ShadowThickness (current))
890 redisplay_flag = True;
893 /* Update title if string or font changed.
896 if (M_TitleString (current) != M_TitleString (new))
899 XtSetArg (al[ac], XmNlabelString, M_TitleString (new)); ac++;
901 if (M_FontList (current) != M_FontList (new))
904 XtSetArg (al[ac], XmNfontList, M_FontList (new));
909 XtSetValues (title, al, ac);
911 M_TitleString (new) = XmUNSPECIFIED_STRING;
913 M_FontList (new) = NULL;
914 redisplay_flag = True;
917 return (redisplay_flag);
922 /*-------------------------------------------------------------
924 ** Handle query geometry request.
926 static XtGeometryResult
928 DtTitleBoxWidget manager,
929 XtWidgetGeometry *request,
930 XtWidgetGeometry *reply )
932 Position x = M_X (manager),
934 Dimension w = M_Width (manager),
935 h = M_Height (manager),
936 bw = M_BorderWidth (manager),
939 Boolean x_req = request->request_mode & CWX,
940 y_req = request->request_mode & CWY,
941 width_req = request->request_mode & CWWidth,
942 height_req = request->request_mode & CWHeight,
943 bw_req = request->request_mode & CWBorderWidth;
945 /* Compute preferred size if preferred width or height requested.
947 if (width_req || height_req)
948 GetSize (manager, 0, 0, 0, 0, &new_w, &new_h);
952 reply->request_mode = request->request_mode;
953 reply->x = request->x;
954 reply->y = request->y;
955 reply->width = (width_req) ? new_w : request->width;
956 reply->height = (height_req) ? new_h : request->height;
957 reply->border_width = request->border_width;
959 /* If no change return no; otherwise yes.
961 if ((!width_req || (width_req && w == new_w)) &&
962 (!height_req || (height_req && h == new_h)))
963 return (XtGeometryNo);
965 return (XtGeometryYes);
970 /*-------------------------------------------------------------
972 **-------------------------------------------------------------
975 /*-------------------------------------------------------------
977 ** Handle geometry request from title area or work area.
979 static XtGeometryResult
982 XtWidgetGeometry *request,
983 XtWidgetGeometry *reply )
985 DtTitleBoxWidget manager = (DtTitleBoxWidget) XtParent (kid);
986 Widget title_area = M_TitleArea (manager),
987 work_area = M_WorkArea (manager);
988 Dimension ta_w = 0, ta_h = 0, ta_bw = 0,
990 w = M_Width (manager),
991 h = M_Height (manager),
992 sp = M_TitleSpacing (manager);
993 Boolean query_only = request->request_mode & XtCWQueryOnly,
994 x_req = request->request_mode & CWX,
995 y_req = request->request_mode & CWY,
996 width_req = request->request_mode & CWWidth,
997 height_req = request->request_mode & CWHeight,
998 bw_req = request->request_mode & CWBorderWidth,
1000 XtGeometryResult result, parent_result;
1001 XtWidgetGeometry parent_req, parent_reply;
1004 /* Check for width, height, and borderwidth requests.
1006 if (!width_req && !height_req)
1009 return (XtGeometryNo);
1011 return (XtGeometryYes);
1019 /* Compute desired size.
1021 if (kid == title_area)
1023 ta_w = (width_req) ? request->width : P_Width (kid);
1024 ta_h = (height_req) ? request->height : P_Height (kid);
1025 ta_bw = (bw_req) ? request->border_width : P_BorderWidth (kid);
1029 wa_w = (width_req) ? request->width : P_Width (kid);
1030 wa_h = (height_req) ? request->height : P_Height (kid);
1033 GetSize (manager, ta_w, ta_h, wa_w, wa_h, &w, &h);
1035 /* Request change from parent if necessary.
1037 if (w != M_Width (manager) || h != M_Height (manager))
1039 parent_req.request_mode = CWWidth | CWHeight;
1040 parent_req.width = w;
1041 parent_req.height = h;
1042 if (almost || query_only)
1043 parent_req.request_mode |= XtCWQueryOnly;
1045 XtMakeGeometryRequest ((Widget)manager, &parent_req,
1047 if (kid == (Widget) title_area)
1048 parent_result = XtGeometryYes;
1051 parent_result = XtGeometryYes;
1053 /* Reply to kid based on reply from parent.
1055 switch ((int) parent_result)
1059 result = XtGeometryYes;
1062 XtWidgetProc resize;
1063 if (kid == title_area)
1064 XmeConfigureObject (title_area,
1069 resize = XtCoreProc(XtParent(kid), resize);
1071 (*resize) (XtParent (kid));
1072 result = XtGeometryDone;
1076 result = XtGeometryNo;
1079 case XtGeometryAlmost:
1081 result = XtGeometryNo;
1089 /*-------------------------------------------------------------
1091 ** Handle change in set of managed children.
1095 DtTitleBoxWidget manager )
1097 Dimension w = M_Width (manager),
1098 h = M_Height (manager);
1100 /* Compute desired size.
1102 GetSize (manager, 0, 0, 0, 0, &w, &h);
1104 /* Try to change size to fit children
1106 if (w != M_Width (manager) || h != M_Height (manager))
1108 switch (XtMakeResizeRequest ((Widget) manager, w, h, &w, &h))
1110 case XtGeometryAlmost:
1111 XtMakeResizeRequest ((Widget) manager, w, h,
1120 /* Set positions and sizes of children.
1122 ConfigureChildren (manager);
1123 XmeNavigChangeManaged ((Widget)manager);
1128 /*-------------------------------------------------------------
1136 DtTitleBoxConstraint constraint = (DtTitleBoxConstraint)
1137 M_TitleBoxConstraint (child);
1139 XmManagerWidgetClass mc = (XmManagerWidgetClass)
1140 xmManagerWidgetClass;
1141 unsigned char child_type;
1142 XtWidgetProc insert_child;
1145 insert_child = mc->composite_class.insert_child;
1147 (* insert_child) (child);
1149 w = (DtTitleBoxWidget) XtParent (child);
1151 if (constraint->child_type == XmWORK_AREA)
1153 if (! M_WorkArea (w))
1155 M_WorkArea (w) = child;
1158 else if (constraint->child_type == XmTITLE_AREA)
1160 if (! M_TitleArea (w))
1162 M_TitleArea (w) = child;
1169 /*-------------------------------------------------------------
1171 **-------------------------------------------------------------
1173 /*-------------------------------------------------------------
1174 ** ConstraintInitialize
1178 ConstraintInitialize(
1182 DtTitleBoxWidget manager = (DtTitleBoxWidget) XtParent (new);
1183 DtTitleBoxConstraint constraint = M_TitleBoxConstraint (new);
1185 /* Validate child type.
1187 if (constraint->child_type != XmWORK_AREA &&
1188 constraint->child_type != XmTITLE_AREA)
1190 XmeWarning (new, WARN_CHILD_TYPE);
1191 if (! M_WorkArea (manager))
1193 constraint->child_type = XmWORK_AREA;
1195 else if (! M_TitleArea (manager))
1197 constraint->child_type = XmTITLE_AREA;
1203 /*-------------------------------------------------------------
1205 **-------------------------------------------------------------
1207 /* All inherited from superclass.
1212 /*-------------------------------------------------------------
1213 ** Public Entry Points
1214 **-------------------------------------------------------------
1217 /*-------------------------------------------------------------
1218 ** _DtCreateTitleBox
1219 ** Create a new DtTitleBox instance.
1220 **-------------------------------------------------------------
1229 return (XtCreateWidget (name, dtTitleBoxWidgetClass,
1230 parent, arglist, argcount));
1234 /*-------------------------------------------------------------
1235 ** _DtTitleBoxGetTitleArea
1236 ** Return TitleBox title area;
1237 **-------------------------------------------------------------
1240 _DtTitleBoxGetTitleArea(
1243 DtTitleBoxWidget mgr = (DtTitleBoxWidget) w;
1244 Widget rtn_w = M_TitleArea (mgr);
1250 /*-------------------------------------------------------------
1251 ** _DtTitleBoxGetWorkArea
1252 ** Return TitleBox work area;
1253 **-------------------------------------------------------------
1256 _DtTitleBoxGetWorkArea(
1259 DtTitleBoxWidget mgr = (DtTitleBoxWidget) w;
1260 Widget rtn_w = M_WorkArea (mgr);