/*
** MotiLib.c ( Motifation generated - Version 1.1.0e (14.1.1992) )
**
** @Motifation@allow-overwrite@
** If you want to protect this file to be overwritten by Motifation
** modify the line above.
**
** This file was generated on: Mon Jun 29 15:22:58 1992
*/

#include <X11/Intrinsic.h>
#include <X11/cursorfont.h>
#include <Xm/RowColumn.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>

extern XtAppContext application_context;
static MoWaitCursorCounter = 0;

/*******************************************************
**
*/
void MoPostPopupMenu( widget, popup, event, dispatch )
   Widget widget;
   Widget popup;
   XButtonPressedEvent *event;
   Boolean *dispatch;
{
   Arg args[1];
   unsigned int wbutton;

   XtSetArg( args[0], XmNwhichButton, &wbutton );
   XtGetValues( popup, args, 1 );
   if( event->button == wbutton ) {
      XmMenuPosition( popup, event );
      XtManageChild( popup );
   }
}

/*******************************************************
**
*/
void MoFlushEvents()
{
   XEvent event;

   while( XtAppPending( application_context )) {
      XtAppNextEvent( application_context, &event );
      XtDispatchEvent( &event );
   }
}

/*******************************************************
**
*/
void MoShowWaitCursor()
{
   extern Widget appshell;

   if( appshell && XtIsRealized( appshell ) ) {
      XDefineCursor( XtDisplay( appshell ), XtWindow( appshell ),
        XCreateFontCursor( XtDisplay( appshell ), XC_watch ) );
      if( MoWaitCursorCounter > 0 )
        MoWaitCursorCounter++;
      else
        MoWaitCursorCounter = 1;
      MoFlushEvents();
   }
}

/*******************************************************
**
*/
void MoHideWaitCursor()
{
   extern Widget appshell;

   if( appshell && XtIsRealized( appshell ) ) {
      MoWaitCursorCounter--;
      if( MoWaitCursorCounter == 0 )
         XUndefineCursor( XtDisplay( appshell ), XtWindow( appshell ) );
      MoFlushEvents();
   }
}

/*******************************************************
**
*/
Boolean MoToggleButtonGetState( widget )
   Widget widget;
{
   if( XmIsToggleButton( widget ) )
      return( XmToggleButtonGetState( widget ) );
   else
      return( XmToggleButtonGadgetGetState( widget ) );
}

/*******************************************************
**
*/
void MoToggleButtonSetState( widget, state, notify )
   Widget widget;
   Boolean state;
   Boolean notify;
{
   if( XmIsToggleButton( widget ) )
      XmToggleButtonSetState( widget, state, notify );
   else
      XmToggleButtonGadgetSetState( widget, state, notify );
}

