1 /* $TOG: Control.c /main/18 1997/04/22 11:40:14 mgreess $
3 * (c) Copyright 1996 Digital Equipment Corporation.
4 * (c) Copyright 1992,1996 Hewlett-Packard Company.
5 * (c) Copyright 1996 International Business Machines Corp.
6 * (c) Copyright 1996 Sun Microsystems, Inc.
7 * (c) Copyright 1996 Novell, Inc.
8 * (c) Copyright 1996 FUJITSU LIMITED.
9 * (c) Copyright 1996 Hitachi.
12 /**---------------------------------------------------------------------
16 *** project: MotifPlus Widgets
18 *** description: Source code for DtControl class.
20 ***-------------------------------------------------------------------*/
23 /*-------------------------------------------------------------
29 #include <sys/types.h> /* needed for sys/stat.h on bsd4.3 */
34 #define X_INCLUDE_STRING_H
35 #define X_INCLUDE_TIME_H
36 #define XOS_USE_XT_LOCKING
37 #include <X11/Xos_r.h>
38 #include <Xm/GadgetP.h>
40 #include <Dt/Control.h>
41 #include <Dt/ControlP.h>
42 #include <Xm/ManagerP.h>
43 #include <Dt/MacrosP.h>
45 #include "DtWidgetI.h"
48 /******** Public Function Declarations ********/
50 extern Widget _DtCreateControl(
56 /******** End Public Function Declarations ********/
58 /******** Static Function Declarations ********/
60 static void ClickTimeout(
61 XtPointer client_data,
63 static void BusyTimeout(
64 XtPointer client_data,
66 static void DateTimeout(
67 XtPointer client_data,
69 static void PushAnimationTimeout(
70 XtPointer client_data,
72 static void DropAnimationTimeout(
73 XtPointer client_data,
75 static void FileCheckTimeout(
76 XtPointer client_data,
78 static void CheckFile(
80 static void ClassInitialize( void ) ;
81 static void ClassPartInitialize(
84 static void Destroy (Widget);
86 static void Initialize(
89 static Boolean SetValues(
97 static void GetPositions(
116 unsigned char s_type,
117 unsigned char fill_mode) ;
118 static void CallCallback(
123 static void UpdateGCs(
125 static void ReplaceJPDate(
130 /******** End Static Function Declarations ********/
133 /*-------------------------------------------------------------
135 **-------------------------------------------------------------
138 WidgetClass dtControlGadgetClass;
141 #define UNSPECIFIED_DIMENSION 9999
142 #define UNSPECIFIED_CHAR 255
145 static const char _DtMsgIndicator_0000[] = "/var/mail/";
146 #elif defined(__osf__)
147 static const char _DtMsgIndicator_0000[] = "/usr/spool/mail/";
149 static const char _DtMsgIndicator_0000[] = "/usr/mail/";
152 #define MAIL_DIR _DtMsgIndicator_0000
153 #define Min(x, y) (((x) < (y)) ? (x) : (y))
154 #define Max(x, y) (((x) > (y)) ? (x) : (y))
156 #define G_Width(r) (r -> rectangle.width)
157 #define G_Height(r) (r -> rectangle.height)
159 /*-------------------------------------------------------------
162 #define R_Offset(field) \
163 XtOffset (DtControlGadget, control.field)
164 static XtResource resources[] =
168 XmCBoolean, XmRBoolean, sizeof (Boolean),
169 R_Offset (_do_update), XmRImmediate, (XtPointer) FALSE
173 XmCBoolean, XmRBoolean, sizeof (Boolean),
174 R_Offset (use_embossed_text), XmRImmediate, (XtPointer) TRUE
178 XmCPushFunction, XmRFunction, sizeof (XtPointer),
179 R_Offset (push_function),
180 XmRImmediate, (XtPointer) NULL
184 XmCPushArgument, XmRPointer, sizeof (XtPointer),
185 R_Offset (push_argument),
186 XmRImmediate, (XtPointer) NULL
190 XmCDropAction, XmRString, sizeof (String),
191 R_Offset (drop_action),
192 XmRImmediate, (XtPointer) NULL
196 "PushAction", XmRString, sizeof (String),
197 R_Offset (push_action),
198 XmRImmediate, (XtPointer) NULL
202 XmCFormat, XmRString, sizeof (String),
204 XmRImmediate, (XtPointer) "%b%n%e"
208 XmCFormatJP, XmRString, sizeof (String),
209 R_Offset (format_jp),
210 XmRImmediate, (XtPointer) NULL
214 XmCSubpanel, XmRWidget, sizeof (Widget),
216 XmRImmediate, (XtPointer) NULL
220 XmCControlType, XmRControlType, sizeof (unsigned char),
221 R_Offset (control_type),
222 XmRImmediate, (XtPointer) XmCONTROL_NONE
226 XmCString, XmRString, sizeof (XmString),
227 R_Offset (file_name), XmRImmediate, (XtPointer) NULL
231 XmCAlternateImage, XmRString, sizeof (String),
232 R_Offset (alt_image), XmRImmediate, (XtPointer) NULL
236 XmCBoolean, XmRBoolean, sizeof (Boolean),
237 R_Offset (chime), XmRImmediate, (XtPointer) FALSE
240 XmNclientTimeoutInterval,
241 XmCInterval, XmRInt, sizeof (int),
242 R_Offset (max_blink_time), XmRImmediate, (XtPointer) 10000
246 XmCInterval, XmRInt, sizeof (int),
247 R_Offset (blink_time), XmRImmediate, (XtPointer) 500
251 XmCInterval, XmRInt, sizeof (int),
252 R_Offset (monitor_time), XmRImmediate, (XtPointer) 30000
255 XmNpushButtonClickTime,
256 XmCInterval, XmRInt, sizeof (int),
257 R_Offset (click_time),
258 XmRImmediate, (XtPointer) 1000
261 XmNuseLabelAdjustment,
262 XmCBoolean, XmRBoolean, sizeof (Boolean),
263 R_Offset (use_label_adj), XmRImmediate, (XtPointer) TRUE
269 static XmBaseClassExtRec controlBaseClassExtRec = {
270 NULL, /* Next extension */
271 NULLQUARK, /* record type XmQmotif */
272 XmBaseClassExtVersion, /* version */
273 sizeof(XmBaseClassExtRec), /* size */
274 XmInheritInitializePrehook, /* initialize prehook */
275 XmInheritSetValuesPrehook, /* set_values prehook */
276 XmInheritInitializePosthook, /* initialize posthook */
277 XmInheritSetValuesPosthook, /* set_values posthook */
278 (WidgetClass)&dtControlCacheObjClassRec, /* secondary class */
279 XmInheritSecObjectCreate, /* creation proc */
280 XmInheritGetSecResData, /* getSecResData */
281 {0}, /* fast subclass */
282 XmInheritGetValuesPrehook, /* get_values prehook */
283 XmInheritGetValuesPosthook, /* get_values posthook */
284 NULL, /* classPartInitPrehook */
285 NULL, /* classPartInitPosthook*/
286 NULL, /* ext_resources */
287 NULL, /* compiled_ext_resources*/
288 0, /* num_ext_resources */
289 FALSE, /* use_sub_resources */
290 XmInheritWidgetNavigable, /* widgetNavigable */
291 XmInheritFocusChange, /* focusChange */
294 /* ext rec static initialization */
295 externaldef (xmcontrolcacheobjclassrec)
296 DtControlCacheObjClassRec dtControlCacheObjClassRec =
299 /* superclass */ (WidgetClass) &xmExtClassRec,
300 /* class_name */ "DtControl",
301 /* widget_size */ sizeof(DtControlCacheObjRec),
302 /* class_initialize */ NULL,
303 /* chained class init */ NULL,
304 /* class_inited */ False,
305 /* initialize */ NULL,
306 /* initialize hook */ NULL,
310 /* resources */ NULL,
311 /* num_resources */ 0,
312 /* xrm_class */ NULLQUARK,
313 /* compress_motion */ False,
314 /* compress_exposure */ False,
315 /* compress enter/exit*/ False,
316 /* visible_interest */ False,
320 /* set_values */ NULL,
321 /* set values hook */ NULL,
322 /* set values almost */ NULL,
323 /* get values hook */ NULL,
324 /* accept_focus */ NULL,
325 /* version */ XtVersion,
326 /* callback offsetlst */ NULL,
327 /* default trans */ NULL,
328 /* query geo proc */ NULL,
329 /* display accelerator*/ NULL,
330 /* extension record */ (XtPointer)NULL,
334 /* synthetic resources */ NULL,
335 /* num_syn_resources */ 0,
336 /* extension */ NULL,
341 /*-------------------------------------------------------------
344 DtControlClassRec dtControlClassRec =
349 (WidgetClass) &dtIconClassRec, /* superclass */
350 "Control", /* class_name */
351 sizeof (DtControlRec), /* widget_size */
352 ClassInitialize, /* class_initialize */
353 ClassPartInitialize, /* class_part_initialize*/
354 False, /* class_inited */
355 (XtInitProc) Initialize, /* initialize */
356 NULL, /* initialize_hook */
360 resources, /* resources */
361 XtNumber (resources), /* num_resources */
363 NULLQUARK, /* xrm_class */
364 True, /* compress_motion */
365 True, /* compress_exposure */
366 True, /* compress_enterleave */
367 False, /* visible_interest */
368 Destroy, /* destroy */
369 XtInheritResize, /* resize */
370 XtInheritExpose, /* expose */
371 (XtSetValuesFunc)SetValues, /* set_values */
372 NULL, /* set_values_hook */
373 XtInheritSetValuesAlmost, /* set_values_almost */
374 NULL, /* get_values_hook */
375 NULL, /* accept_focus */
376 XtVersion, /* version */
377 NULL, /* callback private */
379 NULL, /* query_geometry */
380 NULL, /* display_accelerator */
381 (XtPointer)&controlBaseClassExtRec, /* extension */
388 (XtWidgetProc) XmInheritBorderHighlight, /* border_highlight */
389 (XtWidgetProc) XmInheritBorderUnhighlight, /* border_unhighlight */
390 (XtActionProc) XmInheritArmAndActivate, /* arm_and_activate */
391 (XmWidgetDispatchProc) XmInheritInputDispatch, /* input_dispatch */
392 (XmVisualChangeProc) XmInheritVisualChange, /* visual_change */
393 NULL, /* get_resources */
394 0, /* num_get_resources */
395 XmInheritCachePart, /* class_cache_part */
396 NULL, /* extension */
402 (GetSizeProc) GetSize, /* get_size */
403 (GetPositionProc) GetPositions, /* get_positions */
404 (DrawProc) Draw, /* draw */
405 (CallCallbackProc) CallCallback, /* call_callback */
406 (UpdateGCsProc) UpdateGCs, /* update_gcs */
407 True, /* optimize_redraw */
408 NULL, /* class_cache_part */
409 NULL, /* extension */
415 NULL, /* class_cache_part */
416 NULL, /* extension */
421 WidgetClass dtControlGadgetClass = (WidgetClass) &dtControlClassRec;
425 /*-------------------------------------------------------------
427 **-------------------------------------------------------------
430 /*-------------------------------------------------------------
432 ** Check for change in file, reset timeout.
433 ** An XtTimerCallbackProc.
437 XtPointer client_data,
440 DtControlGadget g = (DtControlGadget) client_data;
441 XtAppContext app_context =
442 XtWidgetToApplicationContext ((Widget) g);
447 XtAppAddTimeOut (app_context, G_MonitorTime (g),
448 FileCheckTimeout, (XtPointer) g);
452 /*-------------------------------------------------------------
454 ** Check for change in file size
461 Boolean file_changed;
463 struct stat stat_buf;
465 if (stat (G_FileName (g), &stat_buf) == 0)
467 file_size = stat_buf.st_size;
470 switch (G_ControlType (g))
472 case XmCONTROL_MONITOR:
473 file_changed = (file_size == 0) ? False : True;
478 file_changed = False;
479 else if (stat_buf.st_atime > stat_buf.st_mtime)
480 file_changed = False;
481 else if (file_size == G_FileSize (g))
482 file_changed = G_FileChanged (g);
483 else if (file_size > G_FileSize (g))
486 file_changed = False;
490 G_FileSize (g) = file_size;
491 if (file_changed != G_FileChanged (g))
494 CallCallbackProc call_callback;
497 expose = XtCoreProc((Widget)g, expose);
498 call_callback = C_CallCallback(XtClass(g));
501 G_FileChanged (g) = file_changed;
502 (*call_callback) ((DtIconGadget) g, G_Callback (g), XmCR_MONITOR, NULL);
503 (*expose)((Widget)g, NULL, NULL);
504 XmUpdateDisplay ((Widget) g);
510 /*-------------------------------------------------------------
512 ** An XtTimerCallbackProc.
517 XtPointer client_data,
520 DtControlGadget g = (DtControlGadget) client_data;
522 G_ClickTimer (g) = 0;
527 /*-------------------------------------------------------------
530 ** An XtTimerCallbackProc.
534 XtPointer client_data,
537 DtControlGadget g = (DtControlGadget) client_data;
538 XtAppContext app_context = XtWidgetToApplicationContext((Widget) g);
540 CallCallbackProc call_callback;
543 expose = XtCoreProc((Widget)g, expose);
544 call_callback = C_CallCallback(XtClass((Widget)g));
547 if ((G_Busy (g) > 0) && (G_BlinkElapsed (g) < G_MaxBlinkTime (g)))
549 G_Set (g) = ! G_Set (g);
551 XtAppAddTimeOut (app_context, G_BlinkTime (g),
552 BusyTimeout, (XtPointer) g);
553 G_BlinkElapsed (g) += G_BlinkTime (g);
558 G_BlinkTimer (g) = NULL;
559 G_BlinkElapsed (g) = 0;
561 (*call_callback) ((DtIconGadget) g, G_Callback (g), XmCR_BUSY_STOP, NULL);
564 (*expose) ((Widget) g, NULL, False);
569 /*-------------------------------------------------------------
571 ** Update date strings.
572 ** An XtTimerCallbackProc.
576 XtPointer client_data,
579 DtControlGadget g = (DtControlGadget) client_data;
580 XtAppContext app_context =
581 XtWidgetToApplicationContext ((Widget) g);
583 _Xltimeparams localtime_buf;
587 unsigned long tilMidnight;
588 Boolean old_format = False;
594 timeptr = _XLocaltime(&tse, localtime_buf);
595 strftime ((char*) sTime, 128, G_Format (g), timeptr);
596 if (g->control.format_jp != NULL && strlen(g->control.format_jp) != 0)
597 ReplaceJPDate(sTime, g->control.format_jp, timeptr->tm_wday);
599 /* Break time string between date and day of week.
602 s2 = strchr (sTime, '\n');
608 s3 = strchr (s2+1, '\n');
620 /* Create date string.
626 XmStringFree(G_String(g));
627 G_String (g) = XmStringCreate (s1, XmFONTLIST_DEFAULT_TAG);
628 XmStringExtent (G_FontList (g), G_String (g),
629 &(G_StringWidth (g)), &(G_StringHeight (g)));
631 if (G_AltString (g) != NULL)
633 XmStringFree (G_AltString (g));
634 G_AltString (g) = NULL;
635 G_AltStringHeight (g) = 0;
636 G_AltStringWidth (g) = 0;
641 if (!G_UseLabelAdjustment (g))
648 if (G_AltString (g) != NULL)
649 XmStringFree (G_AltString (g));
650 G_AltString (g) = XmStringCreate (s1, XmFONTLIST_DEFAULT_TAG);
651 XmStringExtent (G_FontList (g), G_AltString (g),
652 &(G_AltStringWidth (g)), &(G_AltStringHeight (g)));
653 XmStringFree(G_String(g));
654 G_String (g) = XmStringCreate (s2, XmFONTLIST_DEFAULT_TAG);
655 XmStringExtent (G_FontList (g), G_String (g),
656 &(G_StringWidth (g)), &(G_StringHeight (g)));
663 expose = XtCoreProc((Widget)g, expose);
665 (*expose) ((Widget) g, NULL, False);
666 XmUpdateDisplay ((Widget) g);
668 /* Compute milliseconds until midnight:
669 * a. compute current time in seconds
670 * b. subtract that from number of seconds in a day.
671 * c. multiply by 1000 to get milliseconds.
674 tilMidnight = 1000 * (86400 - ((3600 * timeptr->tm_hour) +
675 (60 * timeptr->tm_min) +
678 if (G_Format (g) != NULL)
681 XtAppAddTimeOut (app_context, tilMidnight,
682 DateTimeout, (XtPointer) g);
692 /*-------------------------------------------------------------
694 **-------------------------------------------------------------
699 /*-------------------------------------------------------------
701 **-------------------------------------------------------------
705 /*-------------------------------------------------------------
710 ClassInitialize( void )
712 controlBaseClassExtRec.record_type = XmQmotif;
716 /*-------------------------------------------------------------
717 ** ClassPartInitialize
724 dtControlCacheObjClassRec.object_class.resources =
725 dtIconCacheObjClassRec.object_class.resources;
727 dtControlCacheObjClassRec.object_class.num_resources =
728 dtIconCacheObjClassRec.object_class.num_resources;
733 /*-------------------------------------------------------------
735 ** Initialize a new gadget instance.
742 DtControlGadget request = (DtControlGadget) request_w,
743 new = (DtControlGadget) new_w;
744 XmManagerWidget mw = (XmManagerWidget) XtParent (new);
745 XtAppContext app_context =
746 XtWidgetToApplicationContext (new_w);
750 UpdateGCsProc update_gcs;
752 G_MonitorTimer (new) = 0;
753 G_ClickTimer (new) = 0;
754 G_DateTimer (new) = 0;
755 G_BlinkTimer (new) = 0;
756 G_PushAnimationTimer (new) = 0;
757 G_DropAnimationTimer (new) = 0;
759 G_FileSize (new) = 0;
760 G_FileChanged (new) = False;
763 G_AltString (new) = NULL;
764 G_AltStringWidth (new) = 0;
765 G_AltStringHeight (new) = 0;
767 /* Initialize animation data.
769 G_NumPushImages (new) = 0;
770 G_MaxPushImages (new) = 0;
771 G_PushImagePosition (new) = 0;
772 G_PushDelays (new) = NULL;
773 G_PushPixmaps (new) = NULL;
774 G_PushMasks (new) = NULL;
776 G_NumDropImages (new) = 0;
777 G_MaxDropImages (new) = 0;
778 G_DropImagePosition (new) = 0;
779 G_DropDelays (new) = NULL;
780 G_DropPixmaps (new) = NULL;
781 G_DropMasks (new) = NULL;
783 /* Copy drop argument.
785 if (G_DropAction (new) != NULL)
787 String str = G_DropAction (new);
788 G_DropAction (new) = XtMalloc (strlen (str) + 1);
789 strcpy (G_DropAction (new), str);
792 if (G_PushAction (new) != NULL)
794 String str = G_PushAction (new);
795 G_PushAction (new) = XtMalloc (strlen (str) + 1);
796 strcpy (G_PushAction (new), str);
799 /* Validate control type.
801 if (G_ControlType (new) != XmCONTROL_NONE &&
802 G_ControlType (new) != XmCONTROL_SWITCH &&
803 G_ControlType (new) != XmCONTROL_BUTTON &&
804 G_ControlType (new) != XmCONTROL_BLANK &&
805 G_ControlType (new) != XmCONTROL_DATE &&
806 G_ControlType (new) != XmCONTROL_BUSY &&
807 G_ControlType (new) != XmCONTROL_CLIENT &&
808 G_ControlType (new) != XmCONTROL_MAIL &&
809 G_ControlType (new) != XmCONTROL_MONITOR)
811 G_ControlType (new) == XmCONTROL_NONE;
814 if (G_ControlType (new) == XmCONTROL_SWITCH)
815 G_ShadowType (new) = (G_Set (new)) ? XmSHADOW_IN : XmSHADOW_OUT;
817 if ( ((G_ControlType (new) == XmCONTROL_MONITOR) ||
818 (G_ControlType (new) == XmCONTROL_MAIL) ||
819 (G_ControlType (new) == XmCONTROL_BUSY)) &&
820 (G_AltImage (new) != NULL))
823 /* Copy string or default to user mail directory.
825 if ((G_ControlType (new) == XmCONTROL_MONITOR) ||
826 (G_ControlType (new) == XmCONTROL_MAIL))
828 if (G_FileName (new) == NULL)
830 if (G_ControlType (new) == XmCONTROL_MAIL)
832 if ((str = getenv ("MAIL")) == NULL)
834 str = getenv ("LOGNAME");
836 XtMalloc (strlen (MAIL_DIR) + strlen (str) + 1);
837 strcpy (G_FileName (new), MAIL_DIR);
838 strcat (G_FileName (new), str);
842 G_FileName (new) = XtMalloc (strlen (str) + 1);
843 strcpy (G_FileName (new), str);
849 str = G_FileName (new);
850 G_FileName (new) = XtMalloc (strlen (str) + 1);
851 strcpy (G_FileName (new), str);
854 G_FileChanged (new) = False;
857 /* Get alternate pixmap and mask.
860 XmGetPixmap (XtScreen (new), G_AltImage (new),
861 G_PixmapForeground (new),
862 G_PixmapBackground (new));
864 _DtGetMask (XtScreen (new), G_AltImage (new));
865 G_AltImage (new) = NULL;
867 if ((G_AltPix (new) != XmUNSPECIFIED_PIXMAP) &&
868 ((G_ControlType (new) == XmCONTROL_MONITOR) ||
869 (G_ControlType (new) == XmCONTROL_MAIL)))
872 G_MonitorTimer (new) =
873 XtAppAddTimeOut (app_context, G_MonitorTime (new),
874 FileCheckTimeout, (XtPointer) new);
877 /* Check for Control state change.
882 G_AltPix (new) = XmUNSPECIFIED_PIXMAP;
883 G_AltMask (new) = XmUNSPECIFIED_PIXMAP;
884 G_MonitorTimer (new) = 0;
887 if (G_ControlType (new) == XmCONTROL_DATE)
891 DateTimeout ((XtPointer) new_w, NULL);
893 if (G_Width (request) == 0 || G_Height (request) == 0)
895 GetSizeProc get_size;
898 get_size = C_GetSize(XtClass(new));
900 (*get_size) ((DtIconGadget) new, &w, &h);
901 if (G_Width (request) == 0)
903 if (G_Height (request) == 0)
908 G_ArmedGC (new) = NULL;
910 G_TopShadowGC (new) = NULL;
911 G_BottomShadowGC (new) = NULL;
912 G__DoUpdate (new) = True;
914 update_gcs = C_UpdateGCs(XtClass(new));
916 (*update_gcs) ((DtIconGadget) new);
917 G__DoUpdate (new) = False;
922 /*-------------------------------------------------------------
924 ** Release resources allocated for gadget.
931 DtControlGadget g = (DtControlGadget) w;
933 if (G_FileName (g) != NULL)
934 XtFree (G_FileName (g));
936 if (G_NumPushImages (g) > 0)
938 XtFree ((char*) G_PushDelays (g));
939 XtFree ((char*) G_PushPixmaps (g));
940 XtFree ((char*) G_PushMasks (g));
942 if (G_NumDropImages (g) > 0)
944 XtFree ((char*) G_DropDelays (g));
945 XtFree ((char*) G_DropPixmaps (g));
946 XtFree ((char*) G_DropMasks (g));
948 if (G_DropAction (g) != NULL)
949 XtFree (G_DropAction (g));
950 if (G_PushAction (g) != NULL)
951 XtFree (G_PushAction (g));
953 if (G_AltString (g) != NULL)
954 XmStringFree (G_AltString (g));
956 if (G_ClickTimer (g))
957 XtRemoveTimeOut (G_ClickTimer (g));
958 if (G_BlinkTimer (g))
959 XtRemoveTimeOut (G_BlinkTimer (g));
960 if (G_MonitorTimer (g))
961 XtRemoveTimeOut (G_MonitorTimer (g));
963 XtRemoveTimeOut (G_DateTimer (g));
964 if (G_PushAnimationTimer (g))
965 XtRemoveTimeOut (G_PushAnimationTimer (g));
966 if (G_DropAnimationTimer (g))
967 XtRemoveTimeOut (G_DropAnimationTimer (g));
972 /*-------------------------------------------------------------
984 DtControlGadget request_c = (DtControlGadget) request_w,
985 current_c = (DtControlGadget) current_w,
986 new_c = (DtControlGadget) new_w;
988 String file_name = G_FileName (new);
990 Boolean redraw_flag = False;
993 if (strcmp(G_Format(new_c),G_Format(current_c)) &&
994 G_ControlType (new_c) == XmCONTROL_DATE)
996 if (G_DateTimer (new_c))
997 XtRemoveTimeOut (G_DateTimer (new_c));
999 if (G_Format(new_c) != NULL)
1000 DateTimeout ((XtPointer) new_w, NULL);
1003 if (G_ImageName (new_c) && (G_ImageName (current_c) != G_ImageName (new_c)))
1010 /* Copy drop argument.
1012 if (G_DropAction (new) != G_DropAction (current))
1014 String str = G_DropAction (new);
1015 if (G_DropAction (current) != NULL)
1016 XtFree (G_DropAction (current));
1017 G_DropAction (new) = XtMalloc (strlen (str) + 1);
1018 strcpy (G_DropAction (new), str);
1021 if (G_PushAction (new) != G_PushAction (current))
1023 String str = G_PushAction (new);
1024 if (G_PushAction (current) != NULL)
1025 XtFree (G_PushAction (current));
1026 G_PushAction (new) = XtMalloc (strlen (str) + 1);
1027 strcpy (G_PushAction (new), str);
1030 /* Copy string or default to user mail directory.
1032 if ((G_ControlType (new) == XmCONTROL_MONITOR) ||
1033 (G_ControlType (new) == XmCONTROL_MAIL))
1035 if (G_FileName (new) != G_FileName (current))
1037 if (G_FileName (current) != NULL)
1038 XtFree (G_FileName (current));
1039 if (G_FileName (new) != NULL)
1041 file_name_size = strlen (G_FileName (new));
1042 G_FileName (new) = XtMalloc (file_name_size);
1043 strcpy (G_FileName (new), file_name);
1048 return (redraw_flag);
1053 /*-------------------------------------------------------------
1055 **-------------------------------------------------------------
1059 /*-------------------------------------------------------------
1061 **-------------------------------------------------------------
1064 /*-------------------------------------------------------------
1074 Dimension s_t = G_ShadowThickness (g);
1075 Dimension h_t = G_HighlightThickness (g);
1076 Dimension p_w = G_PixmapWidth (g);
1077 Dimension p_h = G_PixmapHeight (g);
1078 Dimension m_w = G_MarginWidth (g);
1079 Dimension m_h = G_MarginHeight (g);
1080 Dimension s_w = G_StringWidth (g);
1081 Dimension s_h = G_StringHeight (g);
1082 Dimension v_pad = 2 * (s_t + h_t + m_h);
1083 Dimension h_pad = 2 * (s_t + h_t + m_w);
1084 Dimension spacing = G_Spacing (g);
1086 if (((p_w == 0) && (p_h == 0)) || ((s_w == 0) && (s_h == 0)))
1089 if (G_ControlType (g) == XmCONTROL_DATE)
1091 /* Adjust size based on second date string.
1093 if ( (G_StringWidth (g) > 0) &&
1094 (G_AltStringWidth (g) > G_StringWidth (g)) )
1095 s_w = G_AltStringWidth (g);
1096 if ( (G_StringWidth (g) > 0) && (G_AltStringWidth (g) > 0) )
1097 s_h += spacing + G_AltStringHeight (g);
1101 /* Add left and right spacing for string.
1107 /* Get width and height.
1109 switch ((int) G_PixmapPosition (g))
1112 case XmPIXMAP_BOTTOM:
1113 *w = Max (p_w, s_w) + h_pad;
1114 *h = p_h + s_h + v_pad + spacing;
1117 case XmPIXMAP_RIGHT:
1118 *w = p_w + s_w + h_pad + spacing;
1119 *h = Max (p_h, s_h) + v_pad;
1121 case XmPIXMAP_MIDDLE:
1122 *w = Max (p_w, s_w) + h_pad;
1123 *h = Max (p_h, s_h) + v_pad;
1130 /*-------------------------------------------------------------
1132 ** Get positions of string and pixmap.
1146 Dimension p_w = G_PixmapWidth (g),
1147 p_h = G_PixmapHeight (g),
1148 s_w = G_StringWidth (g),
1149 s_h = G_StringHeight (g),
1150 m_w = G_MarginWidth (g),
1151 m_h = G_MarginHeight (g),
1152 spacing = G_Spacing (g),
1153 h_pad = s_t + h_t + m_w,
1154 v_pad = s_t + h_t + m_h,
1155 width = w - 2 * h_pad,
1156 height = h - 2 * v_pad;
1157 Position p_x = h_pad,
1161 unsigned char align = G_Alignment (g);
1163 if (((p_w == 0) && (p_h == 0)) || ((s_w == 0) && (s_h == 0)))
1168 switch ((int) G_PixmapPosition (g))
1171 if (align == XmALIGNMENT_CENTER)
1173 if (p_w && width > p_w)
1174 p_x += (width - p_w)/2U;
1175 if (s_w && width > s_w)
1176 s_x += (width - s_w)/2U;
1178 else if (align == XmALIGNMENT_END)
1180 if (p_w && width > p_w)
1182 if (s_w && width > s_w)
1185 if (p_h && ((unsigned)height > (p_h + s_h + spacing)))
1186 p_y += (height - p_h - s_h - spacing)/2U;
1188 s_y = p_y + p_h + spacing;
1190 s_y += (height - s_h)/2U;
1192 case XmPIXMAP_BOTTOM:
1193 if (align == XmALIGNMENT_CENTER)
1195 if (p_w && width > p_w)
1196 p_x += (width - p_w)/2U;
1197 if (s_w && width > s_w)
1198 s_x += (width - s_w)/2U;
1200 else if (align == XmALIGNMENT_END)
1202 if (p_w && width > p_w)
1204 if (s_w && width > s_w)
1207 if (s_h && ((unsigned)height > (p_h + s_h + spacing)))
1208 s_y += (height - p_h - s_h - spacing)/2U;
1210 p_y = s_y + s_h + spacing;
1212 p_y += (height - p_h)/2U;
1215 if (p_h && height > p_h)
1216 p_y += (height - p_h)/2U;
1217 s_x += p_w + spacing;
1218 if (s_h && height > s_h)
1219 s_y += (height - s_h)/2U;
1221 if (p_w && width > p_w + spacing + s_w)
1222 p_x += (width - p_w - spacing - s_w)/2;
1223 if (s_w && width > p_w + spacing + s_w)
1224 s_x += (width - p_w - spacing - s_w)/2;
1227 case XmPIXMAP_RIGHT:
1228 if (s_h && height > s_h)
1229 s_y += (height - s_h)/2U;
1230 p_x += s_w + spacing;
1231 if (p_w && ((unsigned)width > (p_w + spacing + s_w)))
1232 p_x += (width - p_w - spacing - s_w)/2U;
1233 if (s_w && ((unsigned)width > (p_w + spacing + s_w)))
1234 s_x += (width - p_w - spacing - s_w)/2U;
1235 if (p_h && height > p_h)
1236 p_y += (height - p_h)/2U;
1238 case XmPIXMAP_MIDDLE:
1239 if (p_w && width > p_w)
1240 p_x += (width - p_w)/2U;
1241 if (s_w && width > s_w)
1242 s_x += (width - s_w)/2U;
1243 if (s_h && height > s_h)
1244 s_y += (height - s_h)/2U;
1245 if (p_h && height > p_h)
1246 p_y += (height - p_h)/2U;
1258 /*-------------------------------------------------------------
1260 ** Draw gadget to drawable.
1272 unsigned char s_type,
1273 unsigned char fill_mode )
1275 XmManagerWidget mgr = (XmManagerWidget) XtParent (g);
1276 Display * d = XtDisplay (g);
1279 Position p_x, p_y, s_x, s_y;
1280 Dimension width = 0, height = 0;
1281 unsigned char behavior = G_Behavior (g);
1282 Position adj_x, adj_y;
1286 Dimension left = 0, right = 0, top = 0, bottom = 0;
1288 Boolean bClearArea = False;
1289 Boolean bClearShadow = False;
1291 GetPositionProc get_positions;
1293 bMono = (((G_Foreground (g) == BlackPixelOfScreen (XtScreen (g))) ||
1294 (G_Foreground (g) == WhitePixelOfScreen (XtScreen (g)))) &&
1295 ((G_Background (g) == BlackPixelOfScreen (XtScreen (g))) ||
1296 (G_Background (g) == WhitePixelOfScreen (XtScreen (g)))) );
1298 /* Select gc to fill background.
1300 if (G_ControlType (g) == XmCONTROL_SWITCH)
1301 gc = bMono ? M_BackgroundGC (mgr) : G_BackgroundGC (g);
1302 else if ((G_Armed (g)) && (fill_mode != XmFILL_PARENT))
1303 gc = G_ArmedBackgroundGC (g);
1305 gc = M_BackgroundGC (mgr);
1307 if ((fill_mode != XmFILL_NONE) && (fill_mode != XmFILL_TRANSPARENT))
1310 /* Select pixmap and mask.
1314 /* Terminate animation sequence.
1316 if (G_PushImagePosition (g) > G_NumPushImages (g))
1317 G_PushImagePosition (g) = 0;
1318 if (G_DropImagePosition (g) > G_NumDropImages (g))
1319 G_DropImagePosition (g) = 0;
1321 /* Use animation image.
1323 if (G_PushImagePosition (g) > 0)
1325 index = (G_PushImagePosition (g)) - 1;
1326 if ((index == 0) || (bMono))
1330 pix = G_PushPixmaps (g)[index];
1331 mask = G_PushMasks (g)[index];
1332 ++G_PushImagePosition (g);
1334 else if (G_DropImagePosition (g) > 0)
1336 index = G_DropImagePosition (g) - 1;
1341 pix = G_DropPixmaps (g)[index];
1342 mask = G_DropMasks (g)[index];
1343 ++G_DropImagePosition (g);
1346 /* Use alternate image.
1348 else if ( ( ((G_ControlType (g) == XmCONTROL_MONITOR) ||
1349 (G_ControlType (g) == XmCONTROL_MAIL)) &&
1350 (G_AltPix (g) != XmUNSPECIFIED_PIXMAP) &&
1351 G_FileChanged (g) ) ||
1352 ( (G_ControlType (g) == XmCONTROL_BUSY) &&
1353 (G_AltPix (g) != XmUNSPECIFIED_PIXMAP) &&
1354 G_Busy (g) && G_Set (g)) )
1357 mask = G_AltMask (g);
1360 /* Use normal image.
1371 /* Erase shadow - top, left, right, bottom.
1373 XFillRectangle (d, drawable, gc, x + h_t, y + h_t,
1375 XFillRectangle (d, drawable, gc, x + h_t, y + h_t + s_t,
1376 s_t, h - 2 * (h_t + s_t));
1377 XFillRectangle (d, drawable, gc, x + w - h_t - s_t, y + h_t + s_t,
1378 s_t, h - 2 * (h_t + s_t));
1379 XFillRectangle (d, drawable, gc, x + h_t, y + h - h_t - s_t,
1382 else if (bClearArea)
1385 XFillRectangle (d, drawable, gc, x + h_t, y + h_t,
1386 w - 2 * h_t, h - 2 * h_t);
1389 /* Get pixmap and string positions.
1392 get_positions = C_GetPositions(XtClass(g));
1394 (*get_positions) ((DtIconGadget) g, w, h, h_t, s_t, &p_x, &p_y, &s_x, &s_y);
1396 /* Select and display pixmap.
1401 /* Compute display region.
1403 if ((width == 0) && (height == 0))
1405 width = ((unsigned)(p_x + s_t + h_t) >= G_Width (g))
1406 ? 0 : Min ((unsigned)G_PixmapWidth (g),
1407 G_Width (g) - p_x - s_t - h_t);
1408 height = ((unsigned)(p_y + s_t + h_t) >= G_Height (g))
1409 ? 0 : Min ((unsigned)G_PixmapHeight (g),
1410 G_Height (g) - p_y - s_t - h_t);
1414 if (mask != XmUNSPECIFIED_PIXMAP)
1417 XSetClipMask (XtDisplay(g), gc, mask);
1418 XSetClipOrigin (XtDisplay(g), gc, x + p_x, y + p_y);
1421 gc = G_NormalGC (g);
1425 if ((width > 0 && height > 0) &&
1426 (gc != NULL) && (pix != XmUNSPECIFIED_PIXMAP))
1427 XCopyArea (d, pix, drawable, gc, 0, 0,
1428 width, height, x + p_x, y + p_y);
1433 clip.x = x + h_t + s_t;
1434 clip.y = y + h_t + s_t;
1435 clip.width = G_Width (g) - (2 * (h_t + s_t));
1436 clip.height = G_Height (g) - (2 * (h_t + s_t));
1438 if ((G_String (g)) && (clip.width > 0 && clip.height > 0))
1440 if (G_ControlType (g) == XmCONTROL_DATE)
1442 if ( (G_StringHeight (g) > 0) && (G_AltStringHeight (g) > 0) )
1444 unsigned pad_factor;
1446 if (G_UseLabelAdjustment (g))
1451 v_pad = ((unsigned)G_Height(g) >
1452 (G_StringHeight(g) + G_AltStringHeight(g))) ?
1453 (G_Height (g) - G_StringHeight (g) -
1454 G_AltStringHeight (g)) / pad_factor : 0;
1460 XmStringDrawImage (d, drawable, G_FontList (g), G_String (g),
1461 G_NormalGC (g), x + s_x, y + s_y,
1462 clip.width, XmALIGNMENT_BEGINNING,
1463 XmSTRING_DIRECTION_L_TO_R, &clip);
1467 if (G_UseEmbossedText (g))
1468 XmStringDraw (d, drawable, G_FontList (g), G_String (g),
1469 G_BottomShadowGC (g), x + s_x + 1, y + s_y + 1,
1470 clip.width, XmALIGNMENT_BEGINNING,
1471 XmSTRING_DIRECTION_L_TO_R, &clip);
1472 XmStringDraw (d, drawable, G_FontList (g), G_String (g),
1473 G_NormalGC (g), x + s_x, y + s_y,
1474 clip.width, XmALIGNMENT_BEGINNING,
1475 XmSTRING_DIRECTION_L_TO_R, &clip);
1478 if (G_Width (g) > G_AltStringWidth (g))
1479 s_x = (G_Width (g) - G_AltStringWidth (g)) / 2U;
1481 if (G_UseLabelAdjustment (g))
1482 s_y = ((G_Height (g) - G_AltStringWidth (g)) + 5);
1484 s_y += G_StringHeight (g);
1488 XmStringDrawImage (d, drawable, G_FontList (g),
1490 G_NormalGC (g), x + s_x, y + s_y,
1491 clip.width, XmALIGNMENT_BEGINNING,
1492 XmSTRING_DIRECTION_L_TO_R, &clip);
1496 if (G_UseEmbossedText (g))
1497 XmStringDraw (d, drawable, G_FontList (g),
1499 G_BottomShadowGC (g), x + s_x + 1, y + s_y + 1,
1500 clip.width, XmALIGNMENT_BEGINNING,
1501 XmSTRING_DIRECTION_L_TO_R, &clip);
1502 XmStringDraw (d, drawable, G_FontList (g),
1504 G_NormalGC (g), x + s_x, y + s_y,
1505 clip.width, XmALIGNMENT_BEGINNING,
1506 XmSTRING_DIRECTION_L_TO_R, &clip);
1513 if ((s_x - 2U) >= (h_t + s_t))
1514 XFillRectangle (d, drawable, G_ArmedBackgroundGC (g),
1515 x + s_x - 2, y + s_y,
1516 2, G_StringHeight (g));
1517 XmStringDrawImage (d, drawable, G_FontList (g), G_String (g),
1518 G_NormalGC (g), x + s_x, y + s_y,
1519 clip.width, XmALIGNMENT_BEGINNING,
1520 XmSTRING_DIRECTION_L_TO_R, &clip);
1521 if ((s_x + G_StringWidth (g) + 2U) <= (G_Width (g) - h_t - s_t))
1522 XFillRectangle (d, drawable, G_ArmedBackgroundGC (g),
1523 x + s_x + G_StringWidth (g), y + s_y,
1524 2, G_StringHeight (g));
1528 if (G_UseEmbossedText (g))
1529 XmStringDraw (d, drawable, G_FontList (g), G_String (g),
1530 G_BottomShadowGC (g), x + s_x + 1, y + s_y + 1,
1531 clip.width, XmALIGNMENT_BEGINNING,
1532 XmSTRING_DIRECTION_L_TO_R, &clip);
1533 XmStringDraw (d, drawable, G_FontList (g), G_String (g),
1534 G_NormalGC (g), x + s_x, y + s_y,
1535 clip.width, XmALIGNMENT_BEGINNING,
1536 XmSTRING_DIRECTION_L_TO_R, &clip);
1543 switch (G_ControlType (g))
1545 case XmCONTROL_BLANK:
1546 case XmCONTROL_DATE:
1549 case XmCONTROL_CLIENT:
1553 /* Use black and white.
1556 if (G_Foreground (g) == WhitePixelOfScreen (XtScreen (g)))
1558 gcTS = G_BackgroundGC (g);
1559 gcBS = G_NormalGC (g);
1563 gcBS = G_BackgroundGC (g);
1564 gcTS = G_NormalGC (g);
1569 gcTS = M_BottomShadowGC (mgr);
1570 gcBS = M_TopShadowGC (mgr);
1572 /* Drop inner shadow if secondary since no fill.
1574 XmeDrawShadows (d, drawable, gcTS, gcBS,
1575 x + left - s_t, y + top - s_t,
1576 w - left - right + (2 * s_t),
1577 h - top - bottom + (2 * s_t),
1578 s_t, XmSHADOW_ETCHED_OUT);
1582 case XmCONTROL_BUTTON:
1583 case XmCONTROL_MONITOR:
1584 case XmCONTROL_MAIL:
1585 switch (G_Behavior (g))
1589 XmeDrawShadows(d, drawable,
1590 M_TopShadowGC(mgr), M_BottomShadowGC(mgr),
1592 w - 2*h_t, h - 2*h_t, s_t, XmSHADOW_IN);
1595 if ( (G_Armed (g) && !G_Set (g)) ||
1596 (!G_Armed (g) && G_Set (g)) )
1597 XmeDrawShadows(d, drawable,
1598 M_TopShadowGC(mgr), M_BottomShadowGC(mgr),
1600 w - 2*h_t, h - 2*h_t, s_t, XmSHADOW_IN);
1604 case XmCONTROL_SWITCH:
1605 if (!G_FillOnArm (g))
1607 gcTS = G_BottomShadowGC (g);
1608 gcBS = G_TopShadowGC (g);
1612 if (G_Foreground (g) == WhitePixelOfScreen (XtScreen (g)))
1614 gcTS = G_BackgroundGC (g);
1615 gcBS = G_NormalGC (g);
1619 gcTS = G_NormalGC (g);
1620 gcBS = G_BackgroundGC (g);
1623 XmeDrawShadows (d, drawable, gcTS, gcBS,
1624 x + h_t, y + h_t, w - 2*h_t, h - 2*h_t, 1,
1627 ++x; ++y; w -= 2; h -= 2; --s_t;
1630 if ( (G_Armed (g) && !G_Set (g)) ||
1631 (!G_Armed (g) && G_Set (g)) )
1633 gcTS = G_BottomShadowGC (g);
1634 gcBS = G_TopShadowGC (g);
1638 gcTS = G_TopShadowGC (g);
1639 gcBS = G_BottomShadowGC (g);
1641 XmeDrawShadows (d, drawable, gcTS, gcBS,
1642 x + h_t, y + h_t, w - 2*h_t, h - 2*h_t, s_t,
1650 /*-------------------------------------------------------------
1652 ** Call callback, if any, with reason and event.
1661 DtControlCallbackStruct cb_data;
1662 XtAppContext app_context = XtWidgetToApplicationContext ((Widget) g);
1664 if ((reason == XmCR_ACTIVATE) && (G_Behavior (g) == XmICON_BUTTON))
1666 if (G_ClickTimer (g) != 0)
1670 XtAppAddTimeOut (app_context, G_ClickTime (g),
1671 ClickTimeout, (XtPointer) g);
1676 cb_data.reason = reason;
1677 cb_data.event = event;
1678 cb_data.control_type = G_ControlType (g);
1679 cb_data.set = G_Set (g);
1680 cb_data.push_function = G_PushFunction (g);
1681 cb_data.push_argument = G_PushArgument (g);
1682 cb_data.subpanel = G_Subpanel (g);
1683 cb_data.file_size = G_FileSize (g);
1684 XtCallCallbackList ((Widget) g, cb, &cb_data);
1691 /*-------------------------------------------------------------
1693 ** Get normal and background graphics contexts.
1694 ** Use standard mask to maximize caching opportunities.
1701 XtGCMask value_mask;
1702 XmManagerWidget mw = (XmManagerWidget) XtParent(g);
1706 if (!G__DoUpdate (g))
1710 XtReleaseGC ((Widget)mw, G_NormalGC (g));
1712 XtReleaseGC ((Widget)mw, G_ClipGC (g));
1713 if (G_BackgroundGC (g))
1714 XtReleaseGC ((Widget)mw, G_BackgroundGC (g));
1715 if (G_ArmedBackgroundGC (g))
1716 XtReleaseGC ((Widget)mw, G_ArmedBackgroundGC (g));
1717 if (G_TopShadowGC (g))
1718 XtReleaseGC ((Widget)mw, G_TopShadowGC (g));
1719 if (G_BottomShadowGC (g))
1720 XtReleaseGC ((Widget)mw, G_BottomShadowGC (g));
1724 font_rtn = XmeRenderTableGetDefaultFont (G_FontList (g), &font);
1725 value_mask = GCForeground | GCBackground | GCFont | GCFillStyle;
1726 if (G_UseEmbossedText (g))
1727 values.foreground = WhitePixelOfScreen (XtScreen (g));
1729 values.foreground = G_Foreground (g);
1730 values.background = G_Background (g);
1732 values.fill_style = FillSolid;
1733 values.font = font->fid;
1734 G_NormalGC (g) = XtGetGC ((Widget)mw, value_mask, &values);
1736 /* Get top shadow GC.
1738 if (G_ControlType (g) == XmCONTROL_SWITCH)
1739 values.foreground = G_PixmapBackground (g);
1741 values.foreground = mw -> manager.top_shadow_color;
1742 values.background = G_Background (g);
1743 G_TopShadowGC (g) = XtGetGC ((Widget)mw, value_mask, &values);
1745 /* Get bottom shadow GC.
1747 if (G_ControlType (g) == XmCONTROL_SWITCH)
1748 values.foreground = G_PixmapForeground (g);
1750 values.foreground = mw -> manager.bottom_shadow_color;
1751 values.background = G_Background (g);
1752 G_BottomShadowGC (g) = XtGetGC ((Widget)mw, value_mask, &values);
1754 /* Get background GC.
1756 values.foreground = G_Background (g);
1757 values.background = G_Foreground (g);
1758 G_BackgroundGC (g) = XtGetGC ((Widget)mw, value_mask, &values);
1760 /* Get armed background GC.
1762 values.foreground = G_ArmColor (g);
1763 values.background = G_Background (g);
1764 G_ArmedBackgroundGC (g) = XtGetGC ((Widget)mw, value_mask, &values);
1768 if (G_Mask(g) != XmUNSPECIFIED_PIXMAP)
1770 value_mask |= GCClipMask;
1771 values.clip_mask = G_Mask(g);
1773 values.foreground = G_Foreground (g);
1774 values.background = G_Background (g);
1775 G_ClipGC (g) = XtGetGC ((Widget)mw, value_mask, &values);
1779 /*-------------------------------------------------------------
1780 ** Public Entry Points
1781 **-------------------------------------------------------------
1785 /*-------------------------------------------------------------
1786 ** Push Animation Timeout
1787 ** An XtTimerCallbackProc.
1790 PushAnimationTimeout(
1791 XtPointer client_data,
1794 DtControlGadget g = (DtControlGadget) client_data;
1795 XtAppContext app_context = XtWidgetToApplicationContext ((Widget) g);
1796 XtExposeProc expose;
1798 if ((G_PushImagePosition (g) > 0) &&
1799 (G_PushImagePosition (g) <= G_NumPushImages (g)))
1801 G_PushAnimationTimer (g) =
1802 XtAppAddTimeOut (app_context,
1803 G_PushDelays (g)[G_PushImagePosition (g) - 1],
1804 PushAnimationTimeout, (XtPointer) g);
1806 if (G_PushImagePosition (g) > 1)
1809 expose = XtCoreProc((Widget)g, expose);
1811 (*expose) ((Widget) g, NULL, NULL);
1816 /*-------------------------------------------------------------
1817 ** _DtControlDoPushAnimation
1818 ** Do Push animation.
1819 **-------------------------------------------------------------
1822 _DtControlDoPushAnimation(
1825 DtControlGadget g = (DtControlGadget) w;
1826 XtAppContext app_context = XtWidgetToApplicationContext (w);
1828 if ((G_NumPushImages (g) > 0) && (G_PushImagePosition (g) == 0))
1830 G_PushImagePosition (g) = 1;
1831 PushAnimationTimeout ((XtPointer) g, NULL);
1836 /*-------------------------------------------------------------
1837 ** _DtControlAddPushAnimationImage
1838 ** Add Push animation image.
1839 **-------------------------------------------------------------
1842 _DtControlAddPushAnimationImage(
1847 DtControlGadget g = (DtControlGadget) w;
1848 XmManagerWidget mw = (XmManagerWidget) XtParent (w);
1851 XtGCMask value_mask;
1853 /* Allocate blocks of animation data.
1855 if (G_NumPushImages (g) == G_MaxPushImages (g))
1857 G_MaxPushImages (g) += NUM_LIST_ITEMS;
1858 G_PushDelays (g) = (int*)
1859 XtRealloc ((char*) G_PushDelays (g),
1860 G_MaxPushImages (g) *sizeof (int));
1861 G_PushPixmaps (g) = (Pixmap*)
1862 XtRealloc ((char*) G_PushPixmaps (g),
1863 G_MaxPushImages (g) *sizeof (Pixmap));
1864 G_PushMasks (g) = (Pixmap*)
1865 XtRealloc ((char*) G_PushMasks (g),
1866 G_MaxPushImages (g) *sizeof (Pixmap));
1869 /* Allocate animation image.
1871 i = G_NumPushImages (g)++;
1872 G_PushDelays (g)[i] = delay;
1873 G_PushPixmaps (g)[i] = XmGetPixmap (XtScreen (g), image,
1874 G_PixmapForeground (g),
1875 G_PixmapBackground (g));
1876 G_PushMasks (g)[i] = _DtGetMask (XtScreen (g), image);
1880 /*-------------------------------------------------------------
1881 ** Drop Animation Timeout
1882 ** An XtTimerCallbackProc.
1885 DropAnimationTimeout(
1886 XtPointer client_data,
1889 DtControlGadget g = (DtControlGadget) client_data;
1890 XtAppContext app_context = XtWidgetToApplicationContext ((Widget) g);
1891 XtExposeProc expose;
1893 if ((G_DropImagePosition (g) > 0) &&
1894 (G_DropImagePosition (g) <= G_NumDropImages (g)))
1896 G_DropAnimationTimer (g) =
1897 XtAppAddTimeOut (app_context,
1898 G_DropDelays (g)[G_DropImagePosition (g) - 1],
1899 DropAnimationTimeout, (XtPointer) g);
1903 expose = XtCoreProc((Widget)g, expose);
1905 (*expose) ((Widget) g, NULL, NULL);
1909 /*-------------------------------------------------------------
1910 ** _DtControlDoDropAnimation
1911 ** Do drop animation.
1912 **-------------------------------------------------------------
1915 _DtControlDoDropAnimation(
1918 DtControlGadget g = (DtControlGadget) w;
1919 XtAppContext app_context = XtWidgetToApplicationContext (w);
1921 if ((G_NumDropImages (g) > 0) && (G_DropImagePosition (g) == 0))
1923 G_DropImagePosition (g) = 1;
1924 DropAnimationTimeout ((XtPointer) g, NULL);
1929 /*-------------------------------------------------------------
1930 ** _DtControlAddDropAnimationImage
1931 ** Add drop animation image.
1932 **-------------------------------------------------------------
1935 _DtControlAddDropAnimationImage(
1940 DtControlGadget g = (DtControlGadget) w;
1941 XmManagerWidget mw = (XmManagerWidget) XtParent (w);
1944 XtGCMask value_mask;
1946 /* Allocate blocks of animation data.
1948 if (G_NumDropImages (g) == G_MaxDropImages (g))
1950 G_MaxDropImages (g) += NUM_LIST_ITEMS;
1951 G_DropDelays (g) = (int*)
1952 XtRealloc ((char*) G_DropDelays (g),
1953 G_MaxDropImages (g) *sizeof (int));
1954 G_DropPixmaps (g) = (Pixmap*)
1955 XtRealloc ((char*) G_DropPixmaps (g),
1956 G_MaxDropImages (g) *sizeof (Pixmap));
1957 G_DropMasks (g) = (Pixmap*)
1958 XtRealloc ((char*) G_DropMasks (g),
1959 G_MaxDropImages (g) *sizeof (Pixmap));
1962 /* Allocate animation image.
1964 i = G_NumDropImages (g)++;
1965 G_DropDelays (g)[i] = delay;
1966 G_DropPixmaps (g)[i] = XmGetPixmap (XtScreen (g), image,
1967 G_PixmapForeground (g),
1968 G_PixmapBackground (g));
1969 G_DropMasks (g)[i] = _DtGetMask (XtScreen (g), image);
1973 /*-------------------------------------------------------------
1974 ** _DtControlSetFileChanged
1975 ** Set file changed.
1976 **-------------------------------------------------------------
1979 _DtControlSetFileChanged(
1983 DtControlGadget g = (DtControlGadget) w;
1984 XtExposeProc expose;
1986 if ((G_ControlType (g) == XmCONTROL_MONITOR) ||
1987 (G_ControlType (g) == XmCONTROL_MAIL))
1989 G_FileChanged (g) = b;
1991 expose = XtCoreProc((Widget)g, expose);
1993 (*expose) ((Widget) g, NULL, False);
1998 /*-------------------------------------------------------------
1999 ** _DtControlSetBusy
2001 **-------------------------------------------------------------
2008 DtControlGadget g = (DtControlGadget) w;
2010 if (G_ControlType (g) != XmCONTROL_BUSY)
2015 G_BlinkElapsed (g) = 0;
2017 if (G_Busy (g) == 1)
2019 CallCallbackProc call_callback;
2022 call_callback = C_CallCallback(XtClass(g));
2024 (*call_callback) ((DtIconGadget) g, G_Callback (g), XmCR_BUSY_START,
2026 BusyTimeout ((XtPointer) w, NULL);
2037 /*-------------------------------------------------------------
2039 ** Create a new gadget instance.
2040 **-------------------------------------------------------------
2049 return (XtCreateWidget (name, dtControlGadgetClass,
2050 parent, arglist, argcount));
2054 ReplaceJPDate(char *date, char *jpstr, int wday)
2062 _Xstrtokparams strtok_buf;
2064 s = (char *)malloc((strlen(jpstr) + 1) * sizeof(char));
2066 for(p = _XStrtok(s, ",", strtok_buf), i = 0;
2067 p != NULL && i < wday ;
2068 p = _XStrtok(NULL, ",", strtok_buf), i++)
2074 strcpy(abday, nl_langinfo(ABDAY_1 + wday));
2075 if((rp = strstr(date, abday)) != NULL) {
2076 for(i = 0, j = 0, sp = date; date[j] != '\0'; sp++) {
2078 for(k = 0; k < strlen(p); k++)
2079 newdate[i++] = p[k];
2083 newdate[i++] = date[j++];
2086 strcpy(date, newdate);
2093 _DtControlGetMonitorState(Widget w)
2095 DtControlGadget g = (DtControlGadget) w;
2097 if (G_FileChanged (g))
2098 return(DtMONITOR_ON);
2100 return(DtMONITOR_OFF);