home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / XfeWidgets / Xfe / Logo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  20.2 KB  |  685 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /*-----------------------------------------*/
  19. /*                                                                        */
  20. /* Name:        <Xfe/Logo.c>                                            */
  21. /* Description:    XfeLogo widget source.                                    */
  22. /* Author:        Ramiro Estrugo <ramiro@netscape.com>                    */
  23. /*                                                                        */
  24. /*----------------------------------------------------------------------*/
  25.  
  26.  
  27. #include <Xfe/LogoP.h>
  28.  
  29. /*----------------------------------------------------------------------*/
  30. /*                                                                        */
  31. /* Warnings and messages                                                */
  32. /*                                                                        */
  33. /*----------------------------------------------------------------------*/
  34. #define MESSAGE1  "Cannot obtain geometry for pixmap number %d."
  35. #define MESSAGE2  "Pixmap %d is invalid."
  36. #define MESSAGE3  "Pixmap %d needs to have the same depth as the Logo widget."
  37. #define MESSAGE4  "Pixmap %d needs to have the dimensions as pixmap 0."
  38. #define MESSAGE5  "XmNpixmap & XmNanimationPixmaps must have same dimensions."
  39. #define MESSAGE6  "XmNanimationRunning is a read-only resource."
  40.  
  41. /*----------------------------------------------------------------------*/
  42. /*                                                                        */
  43. /* Core Class methods                                                    */
  44. /*                                                                        */
  45. /*----------------------------------------------------------------------*/
  46. static void     Initialize        (Widget,Widget,ArgList,Cardinal *);
  47. static void     Destroy            (Widget);
  48. static Boolean    SetValues        (Widget,Widget,Widget,ArgList,Cardinal *);
  49.  
  50. /*----------------------------------------------------------------------*/
  51. /*                                                                        */
  52. /* XfePrimitive Class methods                                            */
  53. /*                                                                        */
  54. /*----------------------------------------------------------------------*/
  55. static void    PreferredGeometry    (Widget,Dimension *,Dimension *);
  56. static void    PrepareComponents    (Widget,int);
  57.  
  58. /*----------------------------------------------------------------------*/
  59. /*                                                                        */
  60. /* XfeButton class methods                                                */
  61. /*                                                                        */
  62. /*----------------------------------------------------------------------*/
  63. static void    DrawPixmap            (Widget,XEvent *,Region,XRectangle *);
  64.  
  65. /*----------------------------------------------------------------------*/
  66. /*                                                                        */
  67. /* Misc XfeLogo functions                                                */
  68. /*                                                                        */
  69. /*----------------------------------------------------------------------*/
  70. static void    AnimationPrepare    (Widget);
  71.  
  72. /*----------------------------------------------------------------------*/
  73. /*                                                                        */
  74. /* Misc animation functions                                                */
  75. /*                                                                        */
  76. /*----------------------------------------------------------------------*/
  77. static void    AnimationTimeout    (XtPointer,XtIntervalId *);
  78. static void    RemoveTimeout        (Widget);
  79. static void    AddTimeout            (Widget);
  80.  
  81. /*----------------------------------------------------------------------*/
  82. /*                                                                        */
  83. /* XfeLogo Resources                                                    */
  84. /*                                                                        */
  85. /*----------------------------------------------------------------------*/
  86. static XtResource resources[] = 
  87. {
  88.     /* Callback resources */         
  89.     { 
  90.         XmNanimationCallback,
  91.         XmCCallback,
  92.         XmRCallback,
  93.         sizeof(XtCallbackList),
  94.         XtOffsetOf(XfeLogoRec , xfe_logo . animation_callback),
  95.         XmRImmediate, 
  96.         (XtPointer) NULL
  97.     },
  98.  
  99.     /* Resources */
  100.     { 
  101.         XmNanimationInterval,
  102.         XmCAnimationInterval,
  103.         XmRInt,
  104.         sizeof(int),
  105.         XtOffsetOf(XfeLogoRec , xfe_logo . animation_interval),
  106.         XmRImmediate, 
  107.         (XtPointer) XfeDEFAULT_ANIMATION_INTERVAL
  108.     },
  109.     { 
  110.         XmNanimationRunning,
  111.         XmCReadOnly,
  112.         XmRBoolean,
  113.         sizeof(Boolean),
  114.         XtOffsetOf(XfeLogoRec , xfe_logo . animation_running),
  115.         XmRImmediate, 
  116.         (XtPointer) False
  117.     },
  118.     { 
  119.         XmNcurrentPixmapIndex,
  120.         XmCCurrentPixmapIndex,
  121.         XmRCardinal,
  122.         sizeof(Cardinal),
  123.         XtOffsetOf(XfeLogoRec , xfe_logo . current_pixmap_index),
  124.         XmRImmediate, 
  125.         (XtPointer) 0
  126.     },
  127.     { 
  128.         XmNanimationPixmaps,
  129.         XmCAnimationPixmaps,
  130.         XmRPixmapTable,
  131.         sizeof(XfePixmapTable),
  132.         XtOffsetOf(XfeLogoRec , xfe_logo . animation_pixmaps),
  133.         XmRImmediate, 
  134.         (XtPointer) NULL
  135.     },
  136.     { 
  137.         XmNnumAnimationPixmaps,
  138.         XmCNumAnimationPixmaps,
  139.         XmRCardinal,
  140.         sizeof(Cardinal),
  141.         XtOffsetOf(XfeLogoRec , xfe_logo . num_animation_pixmaps),
  142.         XmRImmediate, 
  143.         (XtPointer) 0
  144.     },
  145.     { 
  146.         XmNresetWhenIdle,
  147.         XmCResetWhenIdle,
  148.         XmRBoolean,
  149.         sizeof(Boolean),
  150.         XtOffsetOf(XfeLogoRec , xfe_logo . reset_when_idle),
  151.         XmRImmediate, 
  152.         (XtPointer) True
  153.     },
  154.  
  155.     /* Force XmNbuttonLayout to XmBUTTON_PIXMAP_ONLY */
  156.     { 
  157.         XmNbuttonLayout,
  158.         XmCButtonLayout,
  159.         XmRButtonLayout,
  160.         sizeof(unsigned char),
  161.         XtOffsetOf(XfeLogoRec , xfe_button . button_layout),
  162.         XmRImmediate, 
  163.         (XtPointer) XmBUTTON_PIXMAP_ONLY
  164.     },
  165. };
  166.  
  167. /*----------------------------------------------------------------------*/
  168. /*                                                                        */
  169. /* XfeLogo widget class record initialization                            */
  170. /*                                                                        */
  171. /*----------------------------------------------------------------------*/
  172. _XFE_WIDGET_CLASS_RECORD(logo,Logo) =
  173. {
  174.     {
  175.         /* Core Part */
  176.         (WidgetClass) &xfeButtonClassRec,        /* superclass             */
  177.         "XfeLogo",                                /* class_name             */
  178.         sizeof(XfeLogoRec),                        /* widget_size            */
  179.         NULL,                                    /* class_initialize       */
  180.         NULL,                                    /* class_part_initiali    */
  181.         FALSE,                                  /* class_inited           */
  182.         Initialize,                             /* initialize             */
  183.         NULL,                                   /* initialize_hook        */
  184.         XtInheritRealize,                       /* realize                */
  185.         NULL,                                    /* actions                */
  186.         0,                                        /* num_actions            */
  187.         resources,                              /* resources              */
  188.         XtNumber(resources),                    /* num_resources          */
  189.         NULLQUARK,                              /* xrm_class              */
  190.         TRUE,                                   /* compress_motion        */
  191.         XtExposeCompressMaximal,                /* compress_exposure      */
  192.         TRUE,                                   /* compress_enterleave    */
  193.         FALSE,                                  /* visible_interest       */
  194.         Destroy,                                /* destroy                */
  195.         XtInheritResize,                        /* resize                 */
  196.         XtInheritExpose,                        /* expose                 */
  197.         SetValues,                              /* set_values             */
  198.         NULL,                                   /* set_values_hook        */
  199.         XtInheritSetValuesAlmost,                /* set_values_almost      */
  200.         NULL,                                    /* get_values_hook        */
  201.         NULL,                                   /* accept_focus           */
  202.         XtVersion,                              /* version                */
  203.         NULL,                                   /* callback_private       */
  204.         XtInheritTranslations,                    /* tm_table               */
  205.         XtInheritQueryGeometry,                    /* query_geometry         */
  206.         XtInheritDisplayAccelerator,            /* display accel          */
  207.         NULL,                                   /* extension              */
  208.     },
  209.  
  210.     /* XmPrimitive Part */
  211.     {
  212.         XmInheritBorderHighlight,                /* border_highlight     */
  213.         XmInheritBorderUnhighlight,                /* border_unhighlight     */
  214.         XtInheritTranslations,                  /* translations           */
  215.         XmInheritArmAndActivate,                /* arm_and_activate       */
  216.         NULL,                                    /* syn resources          */
  217.         0,                                        /* num syn_resources      */
  218.         NULL,                                    /* extension              */
  219.     },
  220.  
  221.     /* XfePrimitive Part */
  222.     {
  223.         XfeInheritBitGravity,                    /* bit_gravity            */
  224.         PreferredGeometry,                        /* preferred_geometry    */
  225.         XfeInheritMinimumGeometry,                /* minimum_geometry        */
  226.         XfeInheritUpdateRect,                    /* update_rect            */
  227.         PrepareComponents,                        /* prepare_components    */
  228.         XfeInheritLayoutComponents,                /* layout_components    */
  229.         XfeInheritDrawBackground,                /* draw_background        */
  230.         XfeInheritDrawShadow,                    /* draw_shadow            */
  231.         XfeInheritDrawComponents,                /* draw_components        */
  232.         NULL,                                    /* extension            */
  233.     },
  234.  
  235.     /* XfeLabel Part */
  236.     {
  237.         XfeInheritLayoutString,                    /* layout_string        */
  238.         XfeInheritDrawString,                    /* draw_string            */
  239.         XfeInheritDrawSelection,                /* draw_selection        */
  240.         XfeInheritGetLabelGC,                    /* get_label_gc            */
  241.         XfeInheritGetSelectionGC,                /* get_selection_gc        */
  242.         NULL,                                    /* extension            */
  243.     },
  244.  
  245.     /* XfeButton Part */
  246.     {
  247.         XfeInheritLayoutPixmap,                    /* layout_pixmap        */
  248.         DrawPixmap,                                /* draw_pixmap            */
  249.         XfeInheritDrawRaiseBorder,                /* draw_raise_border    */
  250.         XfeInheritArmTimeout,                    /* arm_timeout            */
  251.         NULL,                                    /* extension            */
  252.     },
  253.  
  254.     /* XfeLogo Part */
  255.     {
  256.         NULL,                                    /* extension            */
  257.     },
  258. };
  259.  
  260. /*----------------------------------------------------------------------*/
  261. /*                                                                        */
  262. /* xfeLogoWidgetClass declaration.                                        */
  263. /*                                                                        */
  264. /*----------------------------------------------------------------------*/
  265. _XFE_WIDGET_CLASS(logo,Logo);
  266.  
  267. /*----------------------------------------------------------------------*/
  268. /*                                                                        */
  269. /* Core Class methods                                                    */
  270. /*                                                                        */
  271. /*----------------------------------------------------------------------*/
  272. static void
  273. Initialize(Widget rw,Widget nw,ArgList args,Cardinal *nargs)
  274. {
  275.     XfeLogoPart * lp = _XfeLogoPart(nw);
  276.  
  277.     /* Allocate the copy GC */
  278.     lp->copy_GC = XfeAllocateCopyGc(nw);
  279.  
  280.     /* Initialize private members */
  281.     lp->timer_id = 0;
  282.     
  283.     /* Finish of initialization */
  284.     _XfePrimitiveChainInitialize(rw,nw,xfeLogoWidgetClass);
  285. }
  286. /*----------------------------------------------------------------------*/
  287. static void
  288. Destroy(Widget w)
  289. {
  290.     XfeLogoPart * lp = _XfeLogoPart(w);
  291.  
  292.     /* Release GCs */
  293.     XtReleaseGC(w,lp->copy_GC);
  294.  
  295.     /* Remove the timeout if needed */
  296.     RemoveTimeout(w);
  297. }
  298. /*----------------------------------------------------------------------*/
  299. static Boolean
  300. SetValues(Widget ow,Widget rw,Widget nw,ArgList args,Cardinal *nargs)
  301. {
  302.     XfeLogoPart *    np = _XfeLogoPart(nw);
  303.     XfeLogoPart *    op = _XfeLogoPart(ow);
  304.  
  305.     /* animation_running */
  306.     if (np->animation_running != op->animation_running)
  307.     {
  308.         np->animation_running = op->animation_running;
  309.  
  310.         _XfeWarning(nw,MESSAGE6);
  311.     }
  312.  
  313.     /* current_pixmap_index */
  314.     if (np->current_pixmap_index != op->current_pixmap_index)
  315.     {
  316.         _XfeConfigFlags(nw) |= XfeConfigExpose;
  317.     }
  318.  
  319.     /* animation_pixmaps */
  320.     if (np->animation_pixmaps != op->animation_pixmaps)
  321.     {
  322.         _XfeConfigFlags(nw) |= XfeConfigGLE;
  323.  
  324.         _XfePrepareFlags(nw) |= _XFE_PREPARE_LOGO_ANIMATION;
  325.  
  326.         np->current_pixmap_index = 0;
  327.     }
  328.  
  329.     /* num_animation_pixmaps */
  330.     if (np->num_animation_pixmaps != op->num_animation_pixmaps)
  331.     {
  332.         if (!np->animation_running)
  333.         {
  334.             _XfeConfigFlags(nw) |= XfeConfigExpose;
  335.         }
  336.  
  337.         np->current_pixmap_index = 0;
  338.     }
  339.  
  340.     return _XfePrimitiveChainSetValues(ow,rw,nw,xfeLogoWidgetClass);
  341. }
  342. /*----------------------------------------------------------------------*/
  343.  
  344. /*----------------------------------------------------------------------*/
  345. /*                                                                        */
  346. /* XfePrimitive methods                                                    */
  347. /*                                                                        */
  348. /*----------------------------------------------------------------------*/
  349. static void
  350. PreferredGeometry(Widget w,Dimension *width,Dimension *height)
  351. {
  352.     XfeButtonPart *    bp = _XfeButtonPart(w);
  353.     XfeLogoPart *    lp = _XfeLogoPart(w);
  354.  
  355.     Dimension        pixmap_width_save = bp->pixmap_rect.width;
  356.     Dimension        pixmap_height_save = bp->pixmap_rect.height;
  357.  
  358.     Dimension        pixmap_width;
  359.     Dimension        pixmap_height;
  360.  
  361.     XfeButtonWidgetClass bwc = (XfeButtonWidgetClass) xfeButtonWidgetClass;
  362.  
  363.     /* The first pixmap determines the dimensions */
  364.     if (lp->animation_pixmaps && lp->num_animation_pixmaps
  365.         && lp->animation_width && lp->animation_height)
  366.     {
  367.         pixmap_width = lp->animation_width;
  368.         pixmap_height = lp->animation_height;
  369.     }
  370.     else
  371.     {
  372.         pixmap_width = bp->pixmap_rect.width;
  373.         pixmap_height = bp->pixmap_rect.height;
  374.     }
  375.  
  376.     bp->pixmap_rect.width = pixmap_width;
  377.     bp->pixmap_rect.height = pixmap_height;
  378.  
  379.     /* Explicit invoke of XfeButton's preferred_geometry() method */
  380.     (*bwc->xfe_primitive_class.preferred_geometry)(w,width,height);
  381.  
  382.     bp->pixmap_rect.width = pixmap_width_save;
  383.     bp->pixmap_rect.height = pixmap_height_save;
  384. }
  385. /*----------------------------------------------------------------------*/
  386. static void
  387. PrepareComponents(Widget w,int flags)
  388. {
  389.     if (flags & _XFE_PREPARE_LOGO_ANIMATION)
  390.     {
  391.         AnimationPrepare(w);
  392.     }
  393. }
  394. /*----------------------------------------------------------------------*/
  395.  
  396. /*----------------------------------------------------------------------*/
  397. /*                                                                        */
  398. /* XfeButton class methods                                                */
  399. /*                                                                        */
  400. /*----------------------------------------------------------------------*/
  401. static void
  402. DrawPixmap(Widget w,XEvent * event,Region region,XRectangle * clip_rect)
  403. {
  404.     XfeButtonPart *    bp = _XfeButtonPart(w);
  405.     XfeLogoPart *    lp = _XfeLogoPart(w);
  406.     Pixmap            pixmap = XmUNSPECIFIED_PIXMAP;
  407.     Pixmap            pixmap_save = bp->pixmap;
  408.  
  409.     XfeButtonWidgetClass bwc = (XfeButtonWidgetClass) xfeButtonWidgetClass;
  410.  
  411.     /* Determine which pixmap to use */
  412.  
  413.  
  414.     /* If animation running, try to use one of the animation pixmaps */
  415.     if (lp->animation_running || !lp->reset_when_idle)
  416.     {
  417.         if (lp->animation_pixmaps &&
  418.             (lp->current_pixmap_index < lp->num_animation_pixmaps))
  419.         {
  420.             pixmap = lp->animation_pixmaps[lp->current_pixmap_index];
  421.         }
  422.         else
  423.         {
  424.             pixmap = bp->pixmap;
  425.         }
  426.     }
  427.     /* If animation not running, try to use the XfeButton's pixmap */
  428.     else
  429.     {
  430.         if (_XfePixmapGood(bp->pixmap))
  431.         {
  432.             pixmap = bp->pixmap;
  433.         }
  434.         else if (lp->animation_pixmaps &&
  435.                  (lp->current_pixmap_index < lp->num_animation_pixmaps))
  436.         {
  437.             pixmap = lp->animation_pixmaps[lp->current_pixmap_index];
  438.         }
  439.     }
  440.  
  441.     /* temporary replacement to fool the superclass' draw_pixmap() */
  442.     bp->pixmap = pixmap;
  443.  
  444.     /* Explicit invoke of XfeButton's draw_pixmap() method */
  445.     (*bwc->xfe_button_class.draw_pixmap)(w,event,region,clip_rect);
  446.  
  447.     bp->pixmap = pixmap_save;
  448. }
  449. /*----------------------------------------------------------------------*/
  450.  
  451. /*----------------------------------------------------------------------*/
  452. /*                                                                        */
  453. /* Misc XfeLogo functions                                                */
  454. /*                                                                        */
  455. /*----------------------------------------------------------------------*/
  456. static void
  457. AnimationPrepare(Widget w)
  458. {
  459.     XfeLogoPart *    lp = _XfeLogoPart(w);
  460.     XfeButtonPart *    bp = _XfeButtonPart(w);
  461.  
  462.     lp->animation_width = 0;
  463.     lp->animation_height = 0;
  464.  
  465.     /* Check pixmaps only if they exist */
  466.     if (lp->animation_pixmaps && lp->num_animation_pixmaps)
  467.     {
  468.         Cardinal    depth;
  469.         Cardinal    i;
  470.         Dimension    width;
  471.         Dimension    height;
  472.  
  473.         for(i = 0; i < lp->num_animation_pixmaps; i++)
  474.         {
  475.             /* Check geometry of good pixmaps only */
  476.             if (_XfePixmapGood(lp->animation_pixmaps[i]))
  477.             {
  478.                 /* Obtain geometry info for the pixmap */
  479.                 if (XfePixmapExtent(XtDisplay(w),lp->animation_pixmaps[i],
  480.                                     &width,&height,&depth))
  481.                 {
  482.                     /* Make sure all pixmaps have the same depth */
  483.                     if (depth != _XfeDepth(w))
  484.                     {
  485.                         _XfeArgWarning(w,MESSAGE3,i);
  486.                     }
  487.  
  488.                     /* The first pixmap determines the animation geomerty */
  489.                     if (i == 0)
  490.                     {
  491.                         lp->animation_width = width;
  492.                         lp->animation_height = height;
  493.                     }
  494.                     /* All other pixmaps must have the same geometry */
  495.                     else
  496.                     {
  497.                         if ((width != lp->animation_width) ||
  498.                             (height != lp->animation_height))
  499.                         {
  500.                             _XfeArgWarning(w,MESSAGE4,i);
  501.                         }
  502.                     }
  503.  
  504.  
  505.                 }
  506.                 /* Mark the pixmap unusable since no info was obtainable */
  507.                 else
  508.                 {
  509.                     lp->animation_pixmaps[i] = XmUNSPECIFIED_PIXMAP;
  510.  
  511.                     _XfeArgWarning(w,MESSAGE1,i);
  512.                 }
  513.             }
  514.             else
  515.             {
  516.                 _XfeArgWarning(w,MESSAGE2,i);
  517.             }
  518.         }
  519.  
  520.         if (lp->animation_width && lp->animation_height)
  521.         {
  522.             if (_XfePixmapGood(bp->pixmap))
  523.             {
  524.                 if ((bp->pixmap_rect.width != lp->animation_width) ||
  525.                     (bp->pixmap_rect.height != lp->animation_height))
  526.                 {
  527.                     bp->pixmap_rect.width = lp->animation_width;
  528.                     bp->pixmap_rect.height = lp->animation_height;
  529.  
  530.                     _XfeWarning(w,MESSAGE5);
  531.                 }
  532.             }
  533.             else
  534.             {
  535.                 bp->pixmap = lp->animation_pixmaps[0];
  536.  
  537.                 bp->pixmap_rect.width = lp->animation_width;
  538.                 bp->pixmap_rect.height = lp->animation_height;
  539.             }
  540.         }
  541.     }
  542.  
  543. }
  544. /*----------------------------------------------------------------------*/
  545.  
  546. /*----------------------------------------------------------------------*/
  547. /*                                                                        */
  548. /* Misc animation functions                                                */
  549. /*                                                                        */
  550. /*----------------------------------------------------------------------*/
  551. static void
  552. AnimationTimeout(XtPointer closure,XtIntervalId * id)
  553. {
  554.     Widget            w = (Widget) closure;
  555.     XfeLogoPart *    lp = _XfeLogoPart(w);
  556.     Cardinal        i;
  557.  
  558.     /*
  559.      *    Always clear timer_id, so we don't kill someone else's timer
  560.      *    by accident later.
  561.      */
  562.     lp->timer_id = 0;
  563.  
  564.     /* Make sure the widget is still alive */
  565.     if (!_XfeIsAlive(w))
  566.     {
  567.         return;
  568.     }
  569.  
  570.     /* Make sure the animation is running */
  571.     if (!lp->animation_running)
  572.     {
  573.         return;
  574.     }
  575.  
  576.     XtVaGetValues(w,XmNcurrentPixmapIndex,&i,NULL);
  577.  
  578.     i++;
  579.  
  580.     if (i == lp->num_animation_pixmaps)
  581.     {
  582.         i = 0;
  583.     }
  584.  
  585.     XtVaSetValues(w,XmNcurrentPixmapIndex,i,NULL);
  586.  
  587.     /* Invoke animation Callbacks */
  588.     _XfeInvokeCallbacks(w,lp->animation_callback,XmCR_ANIMATION,NULL,True);
  589.  
  590.     /* Add the timeout again */
  591.     AddTimeout(w);
  592. }
  593. /*----------------------------------------------------------------------*/
  594. static void
  595. AddTimeout(Widget w)
  596. {
  597.     XfeLogoPart *    lp = _XfeLogoPart(w);
  598.  
  599.     assert( _XfeIsAlive(w) );
  600.  
  601.     lp->timer_id = XtAppAddTimeOut(XtWidgetToApplicationContext(w),
  602.                                    lp->animation_interval,
  603.                                    AnimationTimeout,
  604.                                    (XtPointer) w);
  605. }
  606. /*----------------------------------------------------------------------*/
  607. static void
  608. RemoveTimeout(Widget w)
  609. {
  610.     XfeLogoPart *    lp = _XfeLogoPart(w);
  611.  
  612.     if (lp->timer_id)
  613.     {
  614.         XtRemoveTimeOut(lp->timer_id);
  615.  
  616.         lp->timer_id = 0;
  617.     }
  618. }
  619. /*----------------------------------------------------------------------*/
  620.  
  621.  
  622. /*----------------------------------------------------------------------*/
  623. /*                                                                        */
  624. /* XfeLogo Public Methods                                                */
  625. /*                                                                        */
  626. /*----------------------------------------------------------------------*/
  627. Widget
  628. XfeCreateLogo(Widget parent,char *name,Arg *args,Cardinal nargs)
  629. {
  630.     return (XtCreateWidget(name,xfeLogoWidgetClass,parent,args,nargs));
  631. }
  632. /*----------------------------------------------------------------------*/
  633. void
  634. XfeLogoAnimationStart(Widget w)
  635. {
  636.     XfeLogoPart *    lp = _XfeLogoPart(w);
  637.  
  638.     assert( _XfeIsAlive(w) );
  639.     assert( XfeIsLogo(w) );
  640.  
  641.     /* Make sure the animation is not already running */
  642.     if (lp->animation_running)
  643.     {
  644.         return;
  645.     }
  646.  
  647.     lp->animation_running = True;
  648.  
  649.     /* Add the timeout */
  650.     AddTimeout(w);
  651. }
  652. /*----------------------------------------------------------------------*/
  653. void
  654. XfeLogoAnimationStop(Widget w)
  655. {
  656.     XfeLogoPart *    lp = _XfeLogoPart(w);
  657.  
  658.     assert( _XfeIsAlive(w) );
  659.     assert( XfeIsLogo(w) );
  660.  
  661.     /* Make sure the animation is running */
  662.     if (!lp->animation_running)
  663.     {
  664.         return;
  665.     }
  666.  
  667.     lp->animation_running = False;
  668.  
  669.     /* Remove the timeout if needed */
  670.     RemoveTimeout(w);
  671.  
  672.     /* Redraw the widget */
  673.     XfeExpose(w,NULL,NULL);
  674. }
  675. /*----------------------------------------------------------------------*/
  676. void
  677. XfeLogoAnimationReset(Widget w)
  678. {
  679.     assert( _XfeIsAlive(w) );
  680.     assert( XfeIsLogo(w) );
  681.  
  682.     XtVaSetValues(w,XmNcurrentPixmapIndex,0,NULL);
  683. }
  684. /*----------------------------------------------------------------------*/
  685.