of_SetItemAttributes


pfcapsrv.pbl   >   pfc_n_cst_lvsrv_datasource   >   of_SetItemAttributes   

Full name pfc_n_cst_lvsrv_datasource.of_SetItemAttributes
Access public
Extend of integer
Return value integer
Prototype public function integer of_SetItemAttributes(n_ds,long,ref listviewitem)

Name Datatype
No Data

Name Datatype
li_Cnt Integer
li_Cols Integer
li_overlay Integer
li_picture Integer
li_state Integer
li_x Integer
li_y Integer
ll_Handle Long
ls_Column string
ls_key string
ls_Label string
ls_picture string

public function integer of_SetItemAttributes (n_ds ads_source, long al_row, ref listviewitem alvi_item);//////////////////////////////////////////////////////////////////////////////
//	Public Function:	of_SetItemAttributes
//	Arguments:		ads_source	The datasource used to get information for the listview attributes
//						al_Row		The row in the DataStore to use for the item's attributes.
//						alvi_Item	The pointer to a ListView item whose attributes are to be set.
//										Passed by reference
//	Returns:			Integer
//						Returns 1 if successful, -1 if an error occurred
//	Description:	Set the default attributes of a ListView item using data from the data source.
//////////////////////////////////////////////////////////////////////////////
//	Rev. History:	Version
//						6.0   Initial version
//////////////////////////////////////////////////////////////////////////////
//	Copyright © 1996-1999 Sybase, Inc. and its subsidiaries.  All rights reserved.  Any distribution of the 
// PowerBuilder Foundation Classes (PFC) source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//////////////////////////////////////////////////////////////////////////////
Integer			li_Cnt, li_Cols
Integer			li_picture, li_state, li_overlay, li_x, li_y
Long				ll_Handle
string			ls_Label, ls_Column, ls_picture, ls_key

// Validate required reference.
if IsNull(ilv_requestor) or not IsValid(ilv_requestor) then return -1
if IsNull(ads_source) or not IsValid(ads_source) then return -1
if IsNull(ads_source.inv_base) or not IsValid(ads_source.inv_base) then return -1

// Determine how to handle the pictures

// Large and Small Pictures
if Trim(inv_Attrib.is_PictureColumn) <> "" then
	if IsNumber(inv_Attrib.is_PictureColumn) then
		// The Picture Index is hard coded
		li_picture = Integer(inv_Attrib.is_PictureColumn)
	elseif Left(ads_source.Describe(inv_Attrib.is_PictureColumn + ".coltype"), 4) = "char" then
		// The column contains a bmp name, so add the picture
		ls_picture = ads_source.GetItemString(al_Row, inv_Attrib.is_PictureColumn)
		if not IsNull(ls_picture) then 
			ilv_requestor.AddSmallPicture(ls_picture)
			li_picture = ilv_requestor.AddLargePicture(ls_picture)
		else
			li_picture = 0
		end if
	else 
		// the column contains a index
		li_picture = ads_source.GetItemNumber(al_Row, inv_Attrib.is_PictureColumn)
	end if
end if
if IsNull(li_picture) then li_picture = 0
alvi_Item.PictureIndex = li_picture

// State Picture
if Trim(inv_Attrib.is_StateColumn) <> "" then
	if IsNumber(inv_Attrib.is_StateColumn) then
		// The Picture Index is hard coded
		li_state = Integer(inv_Attrib.is_StateColumn)
	elseif Left(ads_source.Describe(inv_Attrib.is_StateColumn + ".coltype"), 4) = "char" then
		// The column contains a bmp name, so add the picture
		ls_picture = ads_source.GetItemString(al_Row, inv_Attrib.is_StateColumn)
		if not IsNull(ls_picture) then 
			li_state = ilv_requestor.AddStatePicture(ls_picture)
		else
			li_state = 0
		end if
	else 
		// the column contains a index
		li_state = ads_source.GetItemNumber(al_Row, inv_Attrib.is_StateColumn)
	end if
end if
if IsNull(li_state) then li_state = 0
alvi_Item.StatePictureIndex = li_state

// Overlay Picture - cannot add it to the picture array
if Trim(inv_Attrib.is_OverlayColumn) <> "" then
	if IsNumber(inv_Attrib.is_OverlayColumn) then
		// The Index is hard coded
		li_overlay = Integer(inv_Attrib.is_OverlayColumn)
	else 
		// the column contains a index
		li_overlay = ads_source.GetItemNumber(al_Row, inv_Attrib.is_OverlayColumn)
	end if
end if
if IsNull(li_overlay) then li_overlay = 0
alvi_Item.OverlayPictureIndex = li_overlay

// Set the X and Y coordinates
if Trim(inv_Attrib.is_XPosColumn) <> "" then	li_x = ads_source.GetItemNumber(al_Row, inv_Attrib.is_XPosColumn)

if IsNull(li_x) then li_x = 0
alvi_Item.ItemX = li_x

if Trim(inv_Attrib.is_YPosColumn) <> "" then	li_y = ads_source.GetItemNumber(al_Row, inv_Attrib.is_YPosColumn)

if IsNull(li_y) then li_y = 0
alvi_Item.ItemY = li_y

// Set label with data from columns
li_Cols = UpperBound(inv_ColAttrib)
for li_Cnt = 1 to li_Cols
	ls_Column = ads_source.inv_base.of_GetItem(al_row, inv_ColAttrib[li_Cnt].is_Columns)
	if Trim(ls_Label) = "" then
		ls_Label = ls_Column
	else
		ls_Label = ls_Label + "~t" + ls_Column
	end if
next
alvi_Item.Label = ls_Label

//// Set data to be the unique key to be sure it can be found later
//ls_key = of_EncodeKey(ads_source, al_Row)
//if ls_key = "!" then return -1
//alvi_Item.Data = ls_key
	
return 1
end function

     
Name Owner
pfc_n_cst_lvsrv_datasource.pfc_setitemattributes pfc_n_cst_lvsrv_datasource

     
Name Owner
listview.addlargepicture listview
listview.addsmallpicture listview
listview.addstatepicture listview
datastore.describe datastore
datastore.getitemnumber datastore
datastore.getitemstring datastore
systemfunctions.integer systemfunctions
systemfunctions.isnull systemfunctions
systemfunctions.isnumber systemfunctions
systemfunctions.isvalid systemfunctions
systemfunctions.left systemfunctions
systemfunctions.trim systemfunctions
systemfunctions.upperbound systemfunctions
pfc_n_cst_dssrv.of_GetItem pfc_n_cst_dssrv

     
Full name
No Data

     
Name Scope
No Data