;+
;
; file UVSP_CATWIDHELP.PRO  - includes CATWIDHELP_EV, UVSP_CATWIDHELP
;
;-


;+
;
; NAME: 
;  	CATWIDHELP_EV
;
; PURPOSE:
;       Handle events for UVSP_CATWIDHELP
;
; CATEGORY:
;       UVSP Catalog
;
; CALLING SEQUENCE:
; 	XMANAGER, 'UVSPCATHELP', BASE, EVENT_HANDLER='CATWIDHELP_EV'
;
; CALLED BY:
;       UVSP_CATWIDHELP
;
; CALLS TO:
;	none
;
; INPUTS:
;       none explicit, only through the XMANAGER
;		the wdidget ID for the text widget is passed in UVALUE
;
; OPTIONAL INPUTS:
;	none
;
; OUTPUTS:
;       none
;
; OPTIONAL OUTPUTS:
;	none
;
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	none
;
; RESTRICTIONS:
;	none
;
; PROCEDURE:
;	Process the event for the user selected item.  If event is a list
;	event the display the appropriate help information.
;
; MODIFICATION HISTORY:
;	Oct 93 - Elaine Einfalt (HSTX)
;
;-

pro catwidhelp_ev, event

widget_control, event.id,  get_uvalue=input
widget_control, event.top, get_uvalue=text	; ID for text widget

type = strmid(tag_names(event, /structure_name), 7, 4)

case type of 
 'BUTT' : widget_control, event.top, /destroy
 'LIST'   : begin

     value = input(event.index)

     case value of
      'Getting started'   : hlp = [ $
		'UVSP_CAT is an IDL program designed to access the',$
		'UVSP catalog file and search for UVSP experiments',$
		'that meet the current parameter settings. ',$
		' ',$
		'Ideally the location of the catalog is designated',$
		'by a logical or environment definition called',$
		'UVSP$CATALOG or UVSP_CATALOG. Examples of these ',$
		'assignments are given below. If the catalog location',$
		'is not predefined, then you will be prompted for',$
		'the location.',$
		' ',$
        	'VMS example (Entered at the DCL level):  ',$
		'  $ DEFINE UVSP$CATALOG SDAC::SYS$DATA5:CATALOG.CAT', $
		' ',$
		'UNIX example (Entered at the shell level): ',$
		'  > setenv UVSP$CATALOG /usr/users/Data/CATALOG.CAT', $
		' ',$
		'In order to run the catalog search program, ',$
		'enter IDL and type:',$
		' ',$
		'  IDL> result = uvsp_cat()',$
		' ',$
		'This help routine may be execute independently by',$
		'entering (at the IDL prompt):',$
		' ',$
		'  IDL> UVSP_CATWIDHELP ',$
		' ',$
		'For result discussion see "Output Results"',$
		'For allowed keywords see "Keywords"',$
		'For terminal and widget modes see "Terminal/Widget modes"',$
		' ']
	
      'Keywords' : hlp= [ $
		'There are several keywords that may be used with',$
		'the call to the UVSP_CAT program. ',$
		' ',$
		'  result = uvsp_cat([/screen, font=font, /nofull, /noreset])',$
		' ',$
		' SCREEN:  If set, then the interface is in screen,',$
		'          not widget, mode.  All input and output',$
		'          is directed to the terminal screen.',$
		'          By default, if widgets are available ',$
		'          then widgets will be used. ',$
		' ',$
		' FONT	:  The hardware font to be used by the ',$
		'          program''s widgets. This only applies to',$
		'          when executing in widget mode, and is ',$
		'          ignored in screen mode.',$  
		'          In the event that the widget does not',$
		'          fit on your monitor, then pass in a font',$
		'          with a smaller size.  The font may be ',$
	 	'          selected during interactively during ',$
		'          program execution, for any future ',$
		'          widgets that are created. ',$
		'          Wildcards are allowed.  ',$
		' ',$
		'NOFULL	:  By default the entire catalog is read ',$
		'          into memory. If this keyword is set then',$
		'          only the maximum extent of the experiment',$
		'          range is placed in memory.  If you select ',$
		'          time or experiment ranges that includes',$
		'          experiments 1 and 99771, then the entire ',$
		'          catalog is placed in memory in order to ',$
		'          access the first and the last experiments.',$
		'          Once the whole catalog is in memory,',$
		'          subsequent program calls ingore the ',$
		'          keyword /NOFULL.',$
		' ',$
		'NORESET : If set, then your last parameter values ', $
		'          are retained as the current settings.  ',$
		'          By default, the default parameters are ',$
		'          reset to all possible values.',$
		'          Note that "SPEC" means spectra only, so ',$
		'          that is set to NO.',$
		' ' ,$
		'There are some other keywords, that are applicable ',$
		'only when the catalog program is called by a parent',$
		'widget.  View the comments in the program UVSP_CAT',$
		'in order to obtain specific information.',$
		' ']

      'Insert blank lines...' : hlp = [ $
		'In the widget menu there is a button selection ',$
		'that reads "Insert blank lines between orbits".',$
		'When this button is turned on (click within the',$
		'framed area), then time gaps between experiments,',$
		'that are greater than 6 minutes, will result in a',$
		'blank line.  These spacers may assist with viewing',$
		'the output display.',$
		' ']

      'RESET'   : hlp = [ $
		'The "RESET" button is really a pull down menu of',$
		'buttons.  To use, click on "RESET" then on the',$
		'parameter you wish to reset, to the default setting.',$
		'The default value is such that all experiments will',$
		'qualify during the search.',$
		' ']

      'HELP'    : hlp = ['The "HELP" button displays this help menu.',$
		' ',$
		'This help routine may be execute independently by',$
		'entering (at the IDL prompt):',$
		' ',$
		'  IDL> UVSP_CATWIDHELP ',$
		' ',$
		'Note: The terminal/screen mode has it''s own help',$
		'information.  To access screen/terminal mode help',$
		'enter (at the IDL prompt) :',$
		'    result = UVSP_CAT(/SCREEN,/NOFULL)',$
		'then to the "Enter command> " prompt enter HELP',$
		' ']

      'FONT'    : hlp = [ $
		'The "FONT" button allow you to interactively pick',$
		'the font to be used by the widget menues.  ',$
		'The current widget menu will not be affected, but',$
		'subsequent calls to UVSP_CAT will use the selected',$
		'font.  Feel free to select a font, "QUIT", and ',$
		'reenter the UVSP_CAT program to get the new font.',$
		' ',$
		'You will must likely prefer to use a proportional',$
		'font, like courier, so that widget output is lined',$
		'up in columns.',$
		' ',$
		'It may may be necessary to select a smaller font,',$
		'if the original font is too large to allow the ',$
		'entire widget menu to be displayed.  For your ',$
		'information, the last item in in the widget display ',$
		'is the "MAN" button.',$
		' ',$
		'NOTE: This help widget and the individual parameter',$
		'widgets do not use the user selected font.  They',$
		'will use the session default fonts.',$
		' ',$
		'NOTE: Widget fonts are only available in IDL ',$
		'Version 3, or better.  If this is a problem for ',$
		'then call the catalog program in screen (not widget)',$
		'mode. This is done by the following call :',$
		' ',$
		'    result = UVSP_CAT(/screen)',$
		' ',$
		'For a discussion of the keyword /SCREEN, see "Keywords".',$
		' ']
	
      'Output Results'    : hlp = [ $
		'There are five possible output results for the UVSP',$
		'catalog program. Four of these are explicitly selected',$
		'by clicking on the desired output button. Any, all or',$
		'or none of these four output options may be selected.',$
		' ',$
		'Most of these outputs will have an additional ',$
		'output besides the result returned in your variable.',$
		' ',$
		'NOTE: In order to obtain the result, you will need',$
		'to click on the "QUIT" button.  The additional',$
		'output, mentioned above and discussed below, will',$
		'occur concurrent with catalog searchs.',$
		' ',$
		'The following discuss each output option forms. ',$
		' ',$
		'   ARRAY :  ',$
		'       The result: A N+2 string array where N is the ',$
		'                   number of qualifing experiments.',$
		'                   This array contains 2 title lines',$
		'                   and N number of 132 character',$
		'                   catalog entries.',$
		'       Additional output: none',$
		' ',$
		'   SCREEN : ',$
		'       The result: A null string.',$
		'       Additional output: A list widget that displays',$
		'                   each of the qualify catalog entries.',$
		'                   It is possible to obtain events from',$
		'		    this list widget, if you write your',$
		'                   own parent widget with event handler.',$
		' ',$
		'   DISK FILE :',$
		'       The result: A null string.',$
		'       Additional output: A disk file that is N+2 lines',$
		'                   in length, where N is the number of',$
		'                   qualifing experiments.  This file',$
		'                   contains 2 title lines and N number',$
		'                   of 132 character catalog entries.',$
		'                   The files are named with the form: ',$
		' ',$
		'                    UVSPCAT.hhmmss  where hhmmss is',$
		'                                    then hour, minute,',$
		'                                    and second the file',$
		'                                    was created.',$
		' ',$
		'   PRINTER :',$
		'       The result: A null string.',$
		'       Additional output: The qualifing experiments are',$
		'                   output to the default printer.  A ',$
		'                   temporary disk file (named UVSPCAT.LIS)',$
		'                   is created and printed.  In VMS, this',$
		'                   file is also deleted.',$
		' ',$
		'   When none of these options are set, then the fifth',$
		'                output form is used.',$
		'       The result: A long array containing the experiment',$
		'                   numbers for the qualifing experiments.',$
		'       Additional output: A list widget that displays',$
		'                   each of the qualify experiment numbers.',$
		'                   It is possible to obtain events from',$
		'                   this list widget, if you write your',$
		'                   own parent widget with event handler.',$
		' ']

      'SEARCH'  : hlp = [ $

		'The "SEARCH" button initiates the search of the UVSP',$
		'catalog user the currently set parameters to determine',$
		'which experiment will qualify.',$
		' ',$
		'If the /NOFULL keyword is set, then now is the time',$
		'that the required part of the catalog will be placed',$
		'into memory.',$
		' ']

      'QUIT'    : hlp = [ $
		'The "QUIT" button terminate the catalog program.  This',$
		'will destroy the parameter selection widget and any list',$
		'widgets currently active.',$
		' ',$
		'Once the catalog search program has terminate, then any',$
		'useful results may be found in the variable you used to',$
		'call the program.  See "Output Results".',$
		' ']

      'Parameter buttons' : hlp = [ $
		'Use the parameter buttons to select the values',$
		'that will be used to find qualifing experiments.',$
		' ',$
		'To the right of the button, the current parameter',$
		'setting are listed.  If you select new parameter',$
		'settings any valid values will be listed here.  ',$
		'Invalid values are rejected.',$
		' ',$
		'Once you click on a parameter selection button,',$
		'a widget will be created to accept your input.',$
		' ',$
		'The following is a description on the parameter',$
		'input widget:',$
		' ',$
		'   "Enter new XXX and RETURN:"',$
		' ',$
		'            XXX represents the parameter selected.',$
		'            You click the mouse in this text window',$
		'            in order to type your input.',$
		' ',$ 
		'	          NOTE: Multiple inputs separated by',$
		'                                     commas are allow.',$
		' ',$ 
		'            Once you have entered your input then ',$
		'            press the RETURN key.',$
		'            You will now see your input displayed on the',$
		'            last button in the widget.  These inputs will',$
		'            only be accepted as parameter inputs, if they',$
		'            are valid inputs.  It is for this reason',$
		'            that you should review the parameter settings',$
		'            before pressing the "SEARCH" button.',$
		' ',$
		'   "Current parameter for XXX:"',$
		' ',$
		'            XXX represents the parameter selected.',$
		'            This window displays the current valid',$
		'            parameters.  This is different than the',$
		'            the values displayed on the ready button,',$
		'            if you have already input some values.  ',$
		'            The values in the current parameter window ',$
		'            have been validated, as you input will be',$
		'            once you press the "READY: ..." button.',$
		' ',$
		'   A parameter help window:',$
		' ',$
		'            This is a window that provides help for ',$
		'            the individual parameters.  Use the scroll',$
		'            bar to the right if more than a page of ',$
		'            help is present.',$
		'            This help section will describes each of the',$
		'            parameters.',$
		' ',$
		'   "CANCEL: Preserves current parameters..."',$
		' ',$
		'            This button will exit the parameter input',$
		'            widget without using any of the value you',$
		'            just input.',$
		' ',$
		'   "READY: ..."',$
		' ',$
		'            This button verifies the input you just',$
		'            entered and terminates the parameter',$
		'            input widget.  As you enter values in the',$
		'            "Enter new XXX and RETURN" window they will',$
		'            appear as part of the name of this button.',$
		'            Invalid input will be truncated to valid',$
		'            range values or rejected.',$
		' ']

      'Terminal/Widget modes' : hlp = [ $
		'The following is a brief list of differences between',$
		'WIDGET mode and SCREEN/terminal modes. The keyword',$
		'/SCREEN and the availability of widgets will determine',$
		'in which modes the program will execute. ',$
                ' ',$
		' WIDGET MODE : If keyword /SCREEN is not set, this is ',$
		'               the default if your system has widgets ',$
		'               available, then parameter inputs and ',$
		'               command actions are performed through a',$
		'               widget interface. ',$
		' SCREEN MODE : If keyword /SCREEN is set then the catalog',$
		'               program will execute in terminal mode. All ',$
		'               input and output is directed to the terminal',$
		'               screen. Use this mode if widgets are not ',$
		'               available or you don''t have IDL version 3.0',$
		'               or better. ',$
		' ',$
		' WIDGET MODE : You may select as many of the listed output',$
		'               forms as desired.  See "Output Results".',$
		' SCREEN MODE : You will be prompted to select one of the 5',$
		'               output forms.',$
		' ',$
		' WIDGET MODE : Widget help is this display and the ',$
		'               parameter help appears when the individual',$
		'               parameter buttons are selected.',$
		'               This help program may also be executed',$
		'               independently of any programs by entering,',$	
		'               at the IDL prompt, UVSP_CATWIDGHLP.',$
		' SCREEN MODE : Screen help is specific to executing in ',$
		'               the UVSP catalog program in screen mode.',$
		' ']

     else: print,'Error - unknown list item.'
     endcase


     widget_control, text, set_value=hlp


   end
else: print,'Error - unsupported widget type.'
endcase

return
end


;+
;
; NAME: 
;	UVSP_CATWIDHELP
;
; PURPOSE:
;       Provide help for the meaning of the buttons, in widget mode
;
; CATEGORY:
;	UVSP Catalog
;
; CALLING SEQUENCE:
;	UVSP_CATWIDHELP, GROUP=GROUP
;
; CALLED BY:
;	UVSP_CATWIDGET
;
; CALLS TO:
;	CATWIDHELP_EV   throught the XMANAGER
;
; INPUTS:
;       none 
;
; OPTIONAL INPUTS:
;	GROUP		is the widget ID of the parent widget
;
; OUTPUTS:
;       none
;
; OPTIONAL OUTPUTS:
;	none
;
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	Creates a helpful widget
;
; RESTRICTIONS:
;	Needs widget ability
;
; PROCEDURE:
;	Create a widget, part list widget (for the help items) and part
;	text widget (to display the help information).
;
; MODIFICATION HISTORY:
;	OCT 93 - Elaine Einfalt (HSTX)
;
;-

pro uvsp_catwidhelp, group=group


 if xregistered('UVSPCATHELP') then return

 if n_elements(group) eq 0 $
   then base = widget_base(title='UVSP Catalog Help', /row) $
   else base = widget_base(title='UVSP Catalog Help', /row, $
						xoffset=20, yoffset=20)

 select = widget_base(base, /column)

    done = widget_button(select, value='Done with Help', uvalue='DONE') 

    lab = widget_label(select, value='Select the topic of interest,')
    lab = widget_label(select, value='then click on that item.')
    lab = widget_label(select, value=' ')


    topics = [	'Getting started', 		$
		'Keywords',			$
		'Insert blank lines...', 	$
		'RESET',			$
		'HELP',				$
		'FONT',				$
		'Output Results', 		$
		'SEARCH',			$
		'QUIT',				$
		'Parameter buttons',		$
		'Terminal/Widget modes']


    list = widget_list(select, value=topics, uvalue=topics, ysize=15)

 text = widget_text(base, /scroll, /frame, xsize=55)

 widget_control, base, /realize
 widget_control, base, set_uvalue=text

 if n_elements(group) eq 0 $
    then xmanager, 'UVSPCATHELP', base, event_handler='CATWIDHELP_EV'  $
    else xmanager, 'UVSPCATHELP', base, event_handler='CATWIDHELP_EV', $
								group=group

return
end
