;+
; NAME:
;	ROBTEST
;
; PURPOSE:
;	This routine is a template for widgets that use the XManager.  Use
;	this template instead of writing your widget applications from
;	"scratch".
;
; CATEGORY:
;	Widgets.
;
; CALLING SEQUENCE:
;	robtest
;
; INPUTS:
;
; OPTIONAL INPUT PARAMETERS:
;
; KEYWORD PARAMETERS:
;	GROUP:	The widget ID of the widget that calls robtest.  When this
;		ID is specified, the death of the caller results in the death
;		of robtest.
;
; OUTPUTS:
;
; OPTIONAL OUTPUT PARAMETERS:
;
; COMMON BLOCKS:
;
; SIDE EFFECTS:
;	Initiates the XMANAGER if it is not already running.
;
; RESTRICTIONS:
;
; PROCEDURE:
;	Create and register the widget and then exit.
;
; MODIFICATION HISTORY:
;	Created from a template written by: Steve Richards, January, 1991.
;-

;------------------------------------------------------------------------------
;	procedure robtest_bck
;------------------------------------------------------------------------------
; This routine performs the background tasks while the XManager awaits new
; events.
;*** This is the background task.  If you need to update your widget while
;*** waiting for events, the task should go inside this routine.  The task
;*** should be very simple and quick or else it will bog down the processing
;*** of events and other background tasks.  If robtest does not require
;*** a background task, this routine should be removed from this file and the
;*** line at the bottom of the file that reads:
;*** 		BACKGROUND = "robtest_bck", $
;*** should be removed.
;------------------------------------------------------------------------------

PRO robtest_bck, baseid


;*** here is where the background task should go


END ;============== end of robtest background task routine ================



;------------------------------------------------------------------------------
;	procedure robtest_ev
;------------------------------------------------------------------------------
; This procedure processes the events being sent by the XManager.
;*** This is the event handling routine for the robtest widget.  It is 
;*** responsible for dealing with the widget events such as mouse clicks on
;*** buttons in the robtest widget.  The tool menu choice routines are 
;*** already installed.  This routine is required for the robtest widget to
;*** work properly with the XManager.
;------------------------------------------------------------------------------
PRO robtest_ev, event

WIDGET_CONTROL, event.id, GET_UVALUE = eventval		;find the user value
							;of the widget where
							;the event occured
CASE eventval OF

;*** here is where you would add the actions for your events.  Each widget
;*** you add should have a unique string for its user value.  Here you add
;*** a case for each of your widgets that return events and take the
;*** appropriate action.

  "XLOADCT": XLoadct, GROUP = event.top			;XLoadct is the library
							;routine that lets you
							;select and adjust the
							;color palette being
							;used.

  "XPALETTE": XPalette, GROUP = event.top		;XPalette is the
							;library routine that
							;lets you adjust 
							;individual color
							;values in the palette.

  "XMANTOOL": XMTool, GROUP = event.top			;XManTool is a library
							;routine that shows 
							;which widget
							;applications are 
							;currently registered
							;with the XManager as
							;well as which
							;background tasks.

  "EXIT": WIDGET_CONTROL, event.top, /DESTROY		;There is no need to
							;"unregister" a widget
							;application.  The
							;XManager will clean
							;the dead widget from
							;its list.

  ELSE: MESSAGE, "Event User Value Not Found"		;When an event occurs
							;in a widget that has
							;no user value in this
							;case statement, an
							;error message is shown
ENDCASE

END ;============= end of robtest event handling routine task =============



;------------------------------------------------------------------------------
;	procedure robtest
;------------------------------------------------------------------------------
; This routine creates the widget and registers it with the XManager.
;*** This is the main routine for the robtest widget.  It creates the
;*** widget and then registers it with the XManager which keeps track of the 
;*** currently active widgets.  
;------------------------------------------------------------------------------
PRO robtest, GROUP = GROUP

;*** If robtest can have multiple copies running, then delete the following
;*** line and the comment for it.  Often a common block is used that prohibits
;*** multiple copies of the widget application from running.  In this case, 
;*** leave the following line intact.

IF(XRegistered("robtest") NE 0) THEN RETURN		;only one instance of
							;the robtest widget
							;is allowed.  If it is
							;already managed, do
							;nothing and return

;*** Next the main base is created.  You will probably want to specify either
;*** a ROW or COLUMN base with keywords to arrange the widget visually.

robtestbase = WIDGET_BASE(TITLE = "robtest")		;create the main base

;*** Here some default controls are built in a menu.  The descriptions of these
;*** procedures can be found in the robtest_ev routine above.  If you would
;*** like to add other routines or remove any of these, remove them both below
;*** and in the robtest_ev routine.

XPdMenu, [	'"Done"				EXIT',		$
		'"Tools"	{',				$
				'"XLoadct"	XLOADCT',	$
				'"XPalette"	XPALETTE',	$
				'"XManagerTool"	XMANTOOL',	$
				'}'],				$
	 robtestbase

;*** Typically, any widgets you need for your application are created here.
;*** Create them and use robtestbase as their base.  They will be realized
;*** (brought into existence) when the following line is executed.

WIDGET_CONTROL, robtestbase, /REALIZE			;create the widgets
							;that are defined

XManager, "robtest", robtestbase, $			;register the widgets
		BACKGROUND = "robtest_bck", $
		EVENT_HANDLER = "robtest_ev", $	;with the XManager
		GROUP_LEADER = GROUP			;and pass through the
							;group leader if this
							;routine is to be 
							;called from some group
							;leader.

END ;==================== end of robtest main routine =======================