;------------------------------------------------------------------------------;
;+
; NAME: 
;		     eis_text_input_gui
; PURPOSE:
;		     This object
; INPUTS:
;		     GROUP -  
;-
;------------------------------------------------------------------------------;
FUNCTION eis_text_input_gui::Init , parentClass           ,                 $
                                    tlb                   ,                 $
                                    obstitle  = obstitle  ,                 $
                                    obs_dec   = obs_dec   ,                 $
                                    max_chars = max_chars

Self.parentClass  = parentClass
Self.group_leader = parentClass->tlbID()
IF (KEYWORD_SET(obstitle)  EQ 1) THEN Self.parameter = 'obstitle'
IF (KEYWORD_SET(obs_dec)   EQ 1) THEN Self.parameter = 'obs_dec'
;-------------------create the main base---------------------------------------;
Self.baseID                 = WIDGET_BASE(tlb ,               $
                                    ROW         = 1)


INPUT_EVENT  = {eis_text_input_gui_Event ,                                  $
                    type                 : "",                              $
                    eis_text_input_gui   : OBJ_NEW(),                       $
                    extra                : 0 }



INPUT_EVENT.eis_text_input_gui = Self
INPUT_EVENT.Type            = "INPUT_TEXT"
Self.inputID                = WIDGET_TEXT(Self.baseID             ,         $
                                    value       = 'None'          ,         $
                                    uValue      = INPUT_EVENT     ,         $
                                    xSize       = max_chars + 2   ,         $
                                    Event_Pro   = 'eis_text_input_gui_EV' , $
                                    /EDITABLE                     ,         $
                                    /ALL_EVENTS)

IF (KEYWORD_SET(max_chars) EQ 1) THEN Self->create_max_chars_label , max_chars

RETURN, 1

END
;______________________________________________________________________________
; 
;______________________________________________________________________________
PRO eis_text_input_gui::create_max_chars_label , max_chars

value = STRJOIN(['(',STRCOMPRESS(max_chars,/REMOVE_ALL),' chars max)'],/SINGLE)
aLabel                      = WIDGET_LABEL(Self.baseID ,                    $
                                    value       = value)

END
;______________________________________________________________________________
; 
;______________________________________________________________________________
PRO eis_text_input_gui_Cleanup , wid

WIDGET_CONTROL , wid , get_uvalue = eis_text_input_gui_Event
OBJ_DESTROY    , eis_text_input_gui_Event.eis_text_input_gui

END
;______________________________________________________________________________
; Cleanup
;______________________________________________________________________________
PRO eis_text_input_gui::CleanUp


END
;______________________________________________________________________________
;
;______________________________________________________________________________
PRO eis_text_input_gui::setProperty , title = title

IF (N_ELEMENTS(title) GT 0) THEN BEGIN

    WIDGET_CONTROL , Self.inputID , set_value = title

ENDIF

End
;______________________________________________________________________________
;
;______________________________________________________________________________
PRO eis_text_input_gui::GetProperty, title = title


End
;______________________________________________________________________________
; Event Handler wrapper
;______________________________________________________________________________
PRO eis_text_input_gui_EV , Event

;Get event handler structure containing eis_text_input_gui type object
Widget_CONTROL,Event.ID,get_uvalue = eis_text_input_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_text_input_gui's class member procedure "Handler"
eis_text_input_gui_Event.eis_text_input_gui->Handler,Event

END
;______________________________________________________________________________
;
; * THIS is the routine for putting in event handling NOT eis_text_input_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_text_input_gui::Handler, Event

WIDGET_CONTROL, Event.ID, Get_UValue = eis_text_input_gui_Event
CASE eis_text_input_gui_Event.Type OF
    "INPUT_TEXT" : Self->input_text
    ELSE          : print,eis_text_input_gui_Event.Type
ENDCASE
END
;;______________________________________________________________________________
;; Edit time
;;______________________________________________________________________________
;PRO eis_text_input_gui::return_input_text
;
;
;RETURN , input_text
;
;END
;______________________________________________________________________________
; Edit time
;______________________________________________________________________________
PRO eis_text_input_gui::input_text

; Get author from widget_text
WIDGET_CONTROL , Self.inputID , get_value = widValue
;IF (STRLEN(widValue) EQ 0) THEN BEGIN
;
;    label = STRUPCASE(Self.parameter)
;    mText = STRJOIN(["Input an",label, "value. Aborting."],' ',/SINGLE)
;    BEEP
;    d = DIALOG_MESSAGE(mText , /ERROR , DIALOG_PARENT = Self.baseID)
;    RETURN 
;
;ENDIF

CASE Self.parameter OF
    'obstitle' : text_input = {title:Self.parameter , str:widValue[0]}
    'obs_dec'  : text_input = {title:Self.parameter , str:widValue[0]}
    ELSE       : stop
ENDCASE

; Set Author Property
Self.parentClass->setProperty , text_input = text_input

END
;______________________________________________________________________________
; Define Data members
;______________________________________________________________________________
PRO	eis_text_input_gui__define

    struct          =	{ eis_text_input_gui                            ,     $
                                    tlbID           : 0L              ,     $
                                    parentClass     : OBJ_NEW()       ,     $
                                    group_leader    : 0L              ,     $
                                    baseID          : 0L              ,     $
                                    parameter       : ''              ,     $
                                    inputID         : 0L                    $
                      }


END
