File: w_dropdown_time.srw
Size: 2098
Date: Mon, 07 Apr 2008 21:32:03 +0200
$PBExportHeader$w_dropdown_time.srw
forward
global type w_dropdown_time from w_base_dropdown
end type
type lb_1 from u_lb within w_dropdown_time
end type
end forward

global type w_dropdown_time from w_base_dropdown
integer width = 283
integer height = 384
lb_1 lb_1
end type
global w_dropdown_time w_dropdown_time

on w_dropdown_time.create
int iCurrent
call super::create
this.lb_1=create lb_1
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.lb_1
end on

on w_dropdown_time.destroy
call super::destroy
destroy(this.lb_1)
end on

event key;call super::key;IF key = KeyEnter! THEN
   IF ISVALID(inv_dropdown) THEN
      time lt
      string ls
      ls = lb_1.SelectedItem()
      IF ls = CString.EMPTY THEN RETURN
      lt = TIME(ls)
      inv_dropdown.POST of_SetReturnValue(lt)
   END IF
END IF
end event

event ke_initvalue;call super::ke_initvalue;time lt
integer li

IF ISNULL(value) THEN RETURN

TRY
   lt = TIME(value)
   li = lb_1.FindItem(STRING(lt, "h:mm AM/PM"), 0)
   IF li > 0 THEN lb_1.SelectItem(li)
CATCH (RuntimeError ex)
   //swallow
END TRY
end event

event ke_preopen;call super::ke_preopen;long n
string ls_val

lb_1.AddItem("12:00 AM")
lb_1.AddItem("12:30 AM")
FOR n = 1 to 11
   ls_val = STRING(n) + ":"
   lb_1.AddItem(ls_val + "00 AM")
   lb_1.AddItem(ls_val + "30 AM")
NEXT
lb_1.AddItem("12:00 PM")
lb_1.AddItem("12:30 PM")
FOR n = 1 to 11
   ls_val = STRING(n) + ":"
   lb_1.AddItem(ls_val + "00 PM")
   lb_1.AddItem(ls_val + "30 PM")
NEXT

end event

event ke_postinit;call super::ke_postinit;this.Resize(lb_1.Width + 8, lb_1.Height + 8)
end event

type lb_1 from u_lb within w_dropdown_time
integer width = 329
integer height = 448
integer taborder = 10
boolean border = false
boolean vscrollbar = true
boolean sorted = false
borderstyle borderstyle = stylebox!
end type

event doubleclicked;call super::doubleclicked;IF ISVALID(inv_dropdown) THEN
   time lt
   string ls
   ls = lb_1.SelectedItem()
   IF ls = CString.EMPTY THEN RETURN
   lt = TIME(ls)
   inv_dropdown.POST of_SetReturnValue(lt)
END IF
end event