File: w_dropdown_standard_images.srw
Size: 4317
Date: Mon, 07 Apr 2008 21:32:03 +0200
$PBExportHeader$w_dropdown_standard_images.srw
forward
global type w_dropdown_standard_images from w_base_dropdown
end type
type cbx_large from u_cbx within w_dropdown_standard_images
end type
type uo_gradient from u_st_gradient within w_dropdown_standard_images
end type
type lv_1 from u_lv within w_dropdown_standard_images
end type
end forward

shared variables
boolean sb_LargeImages
end variables

global type w_dropdown_standard_images from w_base_dropdown
cbx_large cbx_large
uo_gradient uo_gradient
lv_1 lv_1
end type
global w_dropdown_standard_images w_dropdown_standard_images

type variables
Private:
boolean IsFileName
string ls_prefix
end variables

on w_dropdown_standard_images.create
int iCurrent
call super::create
this.cbx_large=create cbx_large
this.uo_gradient=create uo_gradient
this.lv_1=create lv_1
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cbx_large
this.Control[iCurrent+2]=this.uo_gradient
this.Control[iCurrent+3]=this.lv_1
end on

on w_dropdown_standard_images.destroy
call super::destroy
destroy(this.cbx_large)
destroy(this.uo_gradient)
destroy(this.lv_1)
end on

event ke_postinit;call super::ke_postinit;long n
listviewitem llvi
CResource lnv

//create headers
lv_1.AddColumn("Resource", Left!, (lv_1.width - 100) / 2)
lv_1.AddColumn("Index", Left!, (lv_1.width - 100) / 2)

//add resource constants to listview
lnv = CREATE CResource

FOR n = 1 to CResource.TOTAL_ALL
   llvi.Label = lnv.BUTTONS[n] + "~t" + STRING(n)
   llvi.PictureIndex = n
   llvi.Data = n
   lv_1.AddITem(llvi)
NEXT

DESTROY lnv

//determine display
IF sb_LargeImages THEN
   cbx_large.Checked = TRUE
   lv_1.View = ListViewLargeIcon!
END IF

//sort by label, focus
lv_1.Sort(ascending!, 1)
lv_1.SetFocus()

end event

event ke_initvalue;call super::ke_initvalue;string ls_img
long ll_pos
n_svc_mgr lnv_svc
n_svc_isempty lnv_check

lnv_svc.of_LoadSvc(lnv_check, CSvc.ISEMPTY)

IF NOT ISNULL(value) THEN
   ls_img = STRING(value)
   IF NOT lnv_check.of_IsEmpty(ls_img) THEN
      ll_pos = POS(ls_img, ".")
      IF ll_pos > 0 THEN
         IsFileName = TRUE
         ls_prefix = MID(ls_img, 1, 3)
         ls_img = MID(ls_img, 4, ll_pos - 4)
      END IF
      
      //select item
      n_svc_resource lnv_r
      
      lnv_svc.of_LoadSvc(lnv_r, CSvc.RESOURCE)
      ll_pos = lnv_r.of_standardimageindexfromstring(ls_img)
      IF ll_pos <> Cret.FAILURE THEN
         n_svc_lv lnv_lv
         listviewitem llvi
         
         lnv_svc.of_LoadSvc(lnv_lv, CSvc.LV)
         lnv_lv.of_finditem(lnv_svc, lv_1, llvi, ls_img, TRUE, TRUE)
//       lnv_lv.of_ensurevisible(lnv_svc, lv_1, ll_pos)
//       lv_1.GetItem(ll_pos, llvi)
//       llvi.Selected = TRUE
//       lv_1.SetItem(ll_pos, llvi)
      END IF
   END IF
END IF
end event

event ke_preopen;call super::ke_preopen;uo_gradient.of_SetColor(CColor.ORANGE)
uo_gradient.of_SetFontColor(CColor.BLACK)
end event

type cbx_large from u_cbx within w_dropdown_standard_images
integer x = 1134
integer y = 960
integer width = 402
long backcolor = 1073741824
string text = "Large Images"
boolean #anchorright = true
boolean #anchorbottom = true
end type

event clicked;call super::clicked;sb_LargeImages = Checked
cbx_large.Checked = Checked
IF Checked THEN
   lv_1.View = ListViewLargeIcon!
ELSE
   lv_1.View = ListViewReport!
END IF
end event

type uo_gradient from u_st_gradient within w_dropdown_standard_images
integer height = 92
integer taborder = 10
long #sizeorder = 1
boolean #dock = true
long #docktype = 1
string #text = "Select Image"
integer #fontsize = 12
boolean #fontbold = true
end type

on uo_gradient.destroy
call u_st_gradient::destroy
end on

type lv_1 from u_lv within w_dropdown_standard_images
integer x = 384
integer y = 208
integer taborder = 10
boolean extendedselect = false
boolean #standardimages = true
long #sizeorder = 2
boolean #dock = true
long #docktype = 5
long #dockpadbottom = 20
string #dock_control_top = "uo_gradient"
string #dock_control_bottom = "cbx_large"
end type

event itemactivate;call super::itemactivate;listviewitem llvi
string ls_label
IF index > 0 THEN
   GetItem(index, llvi)
   ls_label = llvi.Label
   
   IF isFileName THEN
      ls_label = ls_prefix + ls_label + ".bmp"
   END IF
   
   inv_dropdown.of_SetReturnValue(ls_label)
END IF
end event