;+
; PROJECT
;          Solar-B EIS
;
; NAME
;          eis_stress_gui__DEFINE
;
; PURPOSE
;          Preferences GUI
;
; INPUTS
;          parentClass - the eis_mk_plan object
;
; CATEGORY
;          EIS Timeline Planning
;
; WRITTEN
;          John A Rainnie RAL 19-Jun-2008
;
; HISTORY
;          v0.1 25-Jun-2013 JAR
;               Moved images to new folder /ancillary/images/
;               Update path accordingly.
;
;-
;______________________________________________________________________________
FUNCTION eis_stress_gui::Init , parentClass

Self.parentClass  = parentClass
Self.group_leader = parentClass->tlbID()

;-------------------create the main base---------------------------------------;
pt_version = eis_get_pt_version_number()
widTitle = "Stress Management Tool" + pt_version
TLB_EVENT                  = {eis_stress_gui_Event}
TLB_EVENT.eis_stress_gui     = Self
TLB_EVENT.Type             = "TLB"
Self.tlbID                 = WIDGET_BASE(                                  $
                                   TITLE       = widTitle            ,     $
                                   COLUMN      = 1                   ,     $
                                   /FLOATING                         ,     $
                                   GROUP_LEADER = Self.group_leader  ,     $
                                   UValue      = TLB_EVENT )

Event_Pro = 'eis_stress_gui_EV'
; ______________________________________________________________________
;
; CP File (BASE 1)
;
; ______________________________________________________________________
value    = STRARR(4)
value[0] = "This is two kittens in a barrel, look at them in there, having"
value[1] = "a whale of a time. You see the one on the left? He's called"
value[2] = "Phillip. Now when you look into Phillip's eyes your stress will"
value[3] = "recede like an ocean. (Credit: Mighty Boosh)"
aLabel                     = WIDGET_TEXT(Self.tlbID                  ,     $
                                   value       = value               ,     $
                                   /WRAP                             ,     $
                                   ySize       = N_ELEMENTS(value)   ,     $
                                   xSize       = 60)


ICON_EVENT                 = {eis_stress_gui_Event}
ICON_EVENT.eis_stress_gui   = Self
ICON_EVENT.Type            = "DRAW"
Self.drawID                = WIDGET_DRAW(Self.tlbID                  ,     $
                                   XSize       = 441                 ,     $
                                   YSize       = 353                 ,     $
                                   /ALIGN_CENTER                     ,     $
                                   uvalue      = ICON_EVENT)

; ______________________________________________________________________
;
; Bottom base
;
; ______________________________________________________________________
bottomBase                  = WIDGET_BASE(Self.tlbID ,                      $
                                    ROW         = 1  ,                      $
                                    /GRID_LAYOUT)


QUIT_EVENT                 = {eis_stress_gui_Event}
QUIT_EVENT.eis_stress_gui    = Self
QUIT_EVENT.Type            = "QUIT"
quitbutton                 = WIDGET_BUTTON(bottomBase,                      $
                                    value       = ' Quit ',                  $
                                    Event_Pro   = 'eis_stress_gui_EV',     $
                                    uValue      = QUIT_EVENT)

RETURN, 1

END
;______________________________________________________________________________
;
;______________________________________________________________________________
PRO eis_stress_gui_Cleanup , wid

WIDGET_CONTROL , wid , get_uvalue = eis_stress_gui_Event
OBJ_DESTROY    , eis_stress_gui_Event.eis_stress_gui

END
;______________________________________________________________________________
; Cleanup
;______________________________________________________________________________
PRO eis_stress_gui::CleanUp


END
;______________________________________________________________________________
;
;______________________________________________________________________________
PRO eis_stress_gui::setProperty, start_time = start_time

IF (N_ELEMENTS(start_time) GT 0) THEN BEGIN

    stop

ENDIF

END
;______________________________________________________________________________
;
;______________________________________________________________________________
PRO eis_stress_gui::GetProperty, tlbID      = tlbID

tlbID      = Self.tlc_textID

END
;______________________________________________________________________________
; Return widget id
;______________________________________________________________________________
FUNCTION eis_stress_gui::tlbID

    RETURN, Self.tlbID
END
;______________________________________________________________________________
; Widget_Control wrapper
;______________________________________________________________________________
PRO eis_stress_gui::Control, _Ref_Extra=Widget_Control_Keywords

Widget_Control, Self.tlbID, _Extra=Widget_Control_Keywords

End
;______________________________________________________________________________
; Widget_Info wrapper
;______________________________________________________________________________
FUNCTION eis_stress_gui::Info, _Ref_Extra=Widget_Info_Keywords

Return, Widget_Info(Self.tlbID, _Extra=Widget_Info_Keywords)

End

;______________________________________________________________________________
; Realize wrapper
;______________________________________________________________________________
PRO eis_stress_gui::Realize

Widget_Control, Self.tlbID, /Realize

End

;______________________________________________________________________________
; XManager wrapper
;______________________________________________________________________________
PRO eis_stress_gui::XManager;,group=group

XMANAGER , "eis_stress_gui" ,   Self.tlbID ,                                 $
    Event_Handler  = "eis_stress_gui_EV",                                    $
    cleanup        = "eis_stress_gui_Cleanup",                               $
    GROUP_LEADER   = Self.group_leader ,                                    $
    /NO_BLOCK

end

;______________________________________________________________________________
;
;______________________________________________________________________________
PRO eis_stress_gui_Event__Define

    struct = {  eis_stress_gui_Event,                                              $
                Type            : "",        $ ;Unique identifier for event
                eis_stress_gui   : OBJ_NEW(), $ ;Reference to object passed
                extra           : 0          $ ;to - often object associated
             }
END
;______________________________________________________________________________
; Event Handler wrapper
;______________________________________________________________________________
PRO eis_stress_gui_EV , Event

;Get event handler structure containing eis_stress_gui type object
Widget_CONTROL,Event.ID,get_uvalue = eis_stress_gui_Event
;If a WIDGET_TAB event , just quit
IF (TAG_NAMES(event, /STRUCTURE_NAME) EQ 'WIDGET_TAB') THEN BEGIN
    ;print,'tab event'
    RETURN
ENDIF

;Call eis_stress_gui's class member procedure "Handler"
eis_stress_gui_Event.eis_stress_gui->Handler,Event

END
;______________________________________________________________________________
;
; * THIS is the routine for putting in event handling NOT eis_stress_gui_Ev above.
;
; Event Handler - handle events.  Derived classes must
; contain their own implementation in order to handle events or else pass in an
; procedure name/function name using the Event_Pro/Event_Func keywords to
; CWidget::Init()
;______________________________________________________________________________
PRO eis_stress_gui::Handler, Event

WIDGET_CONTROL, Event.ID, Get_UValue = eis_stress_gui_Event
CASE eis_stress_gui_Event.Type OF
   "QUIT"       : Self->Control, /Destroy
   "DRAW"       :
   ELSE         : print,eis_stress_gui_Event.Type
ENDCASE
END
;______________________________________________________________________________
;
;______________________________________________________________________________
PRO eis_stress_gui::draw

WIDGET_CONTROL , Self.drawID , get_value = drawID
WSET , drawID

;pathName = EXPAND_PATH(GETENV('ancillary'))
;baseName = 'kittensinabarrel.jpg'
;fileName = CONCAT_DIR(pathName , baseName)

; 25-Jun-2013 JAR
; Moved images to new folder /ancillary/images/
; Update path accordingly.
ancillary_folder = EXPAND_PATH(GETENV('ancillary'))
images_folder    = CONCAT_DIR(ancillary_folder,'images')
image_fileName   = CONCAT_DIR(images_folder,'kittensinabarrel.jpg')

; Ensure file is really there
IF (FILE_TEST(image_fileName) NE 1) THEN RETURN
READ_JPEG , image_fileName , kittens
TVSCL, kittens , true = 1

END
;______________________________________________________________________________
; Define Data members
;______________________________________________________________________________
PRO eis_stress_gui__define

    struct   = { eis_stress_gui                                      ,     $
                   tlbID                : 0L                         ,     $
                   group_leader         : 0L                         ,     $
                   parentClass          : OBJ_NEW()                  ,     $
                   drawID               : 0L                               $
               }


END