File: pfc_u_plb.sru
Size: 12427
Date: Tue, 22 Jan 2008 23:30:02 +0100
$PBExportHeader$pfc_u_plb.sru
$PBExportComments$PFC PictureListBox class
forward
global type pfc_u_plb from picturelistbox
end type
end forward

global type pfc_u_plb from picturelistbox
integer width = 347
integer height = 248
integer taborder = 1
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
boolean vscrollbar = true
borderstyle borderstyle = stylelowered!
string picturename[] = {"Custom039!"}
long picturemaskcolor = 553648127
event type integer pfc_selectall ( )
event type integer pfc_invertselection ( )
end type
global pfc_u_plb pfc_u_plb

forward prototypes
public function integer of_getparentwindow (ref window aw_parent)
public function integer of_getselected (ref n_cst_itemattrib anv_itemattrib[])
protected function integer of_messagebox (string as_id, string as_title, string as_text, icon ae_icon, button ae_button, integer ai_default)
end prototypes

event pfc_selectall;//////////////////////////////////////////////////////////////////////////////
// Event:         pfc_selectall
// Arguments:     None
// Returns:       Integer
//                The number of selected rows.
//                0 - If this is not a valid operation.)
// Description:      Select all the rows.
//////////////////////////////////////////////////////////////////////////////
// Rev. History:  Version
//                5.0   Initial version
//                8.0   Change to not loop thru items, for performance
//////////////////////////////////////////////////////////////////////////////
/*
 * Open Source PowerBuilder Foundation Class Libraries
 *
 * Copyright (c) 2004-2005, All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted in accordance with the GNU Lesser General
 * Public License Version 2.1, February 1999
 *
 * http://www.gnu.org/copyleft/lesser.html
 *
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals and was originally based on software copyright (c) 
 * 1996-2004 Sybase, Inc. http://www.sybase.com.  For more
 * information on the Open Source PowerBuilder Foundation Class
 * Libraries see http://pfc.codexchange.sybase.com
*/
//////////////////////////////////////////////////////////////////////////////

//Only a valid operation when MultiSelect is set to True.
If this.MultiSelect Then
   // Change state for all items
   this.SetState( 0, True )
   //Number of selected items
   Return this.TotalItems()
End If

//Not a valid operation
Return 0
end event

event pfc_invertselection;//////////////////////////////////////////////////////////////////////////////
//
// Event:         pfc_invertselection
//
// (Arguments:    None)
//
// (Returns:      Integer
//                The number of selected rows.
//                0 - If this is not a valid operation.)
//
// Description:   Invert the rows.
//
//////////////////////////////////////////////////////////////////////////////
// 
// Revision History
//
// Version
// 5.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
/*
 * Open Source PowerBuilder Foundation Class Libraries
 *
 * Copyright (c) 2004-2005, All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted in accordance with the GNU Lesser General
 * Public License Version 2.1, February 1999
 *
 * http://www.gnu.org/copyleft/lesser.html
 *
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals and was originally based on software copyright (c) 
 * 1996-2004 Sybase, Inc. http://www.sybase.com.  For more
 * information on the Open Source PowerBuilder Foundation Class
 * Libraries see http://pfc.codexchange.sybase.com
*/
//
//////////////////////////////////////////////////////////////////////////////

integer  li_totalitems
long     ll_item

//Only a valid operation when MuliSelect is set to True.
If this.MultiSelect Then
   li_totalitems = this.TotalItems()
   //Loop through all items - Inverting each item
   For ll_item = 1 to li_totalitems
      this.SetState(ll_item, (Not this.State(ll_item)=1) )
   Next
   //Number of selected items
   Return this.TotalSelected()
End If

//Not a valid operation
Return 0
end event

public function integer of_getparentwindow (ref window aw_parent);//////////////////////////////////////////////////////////////////////////////
//
// Function:  of_GetParentWindow
//
// Access:  public
//
// Arguments:
// aw_parent   The Parent window for this object (passed by reference).
//    If a parent window is not found, aw_parent is NULL
//
// Returns:  integer
//  1 = success
// -1 = error
//
// Description:    Calculates the parent window of a window object
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
/*
 * Open Source PowerBuilder Foundation Class Libraries
 *
 * Copyright (c) 2004-2005, All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted in accordance with the GNU Lesser General
 * Public License Version 2.1, February 1999
 *
 * http://www.gnu.org/copyleft/lesser.html
 *
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals and was originally based on software copyright (c) 
 * 1996-2004 Sybase, Inc. http://www.sybase.com.  For more
 * information on the Open Source PowerBuilder Foundation Class
 * Libraries see http://pfc.codexchange.sybase.com
*/
//
//////////////////////////////////////////////////////////////////////////////

powerobject lpo_parent

lpo_parent = this.GetParent()

// Loop getting the parent of the object until it is of type window!
do while IsValid (lpo_parent) 
   if lpo_parent.TypeOf() <> window! then
      lpo_parent = lpo_parent.GetParent()
   else
      exit
   end if
loop

if IsNull(lpo_parent) Or not IsValid (lpo_parent) then
   setnull(aw_parent)   
   return -1
end If

aw_parent = lpo_parent
return 1

end function

public function integer of_getselected (ref n_cst_itemattrib anv_itemattrib[]);////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Function:      of_GetSelected
//
// Access:        public
//
// Arguments:     
// anv_itemattrib[]  NonVisual with an Index and a Text variable.
//
// Returns:       Integer
//                The number of selected entries.
//                0 - If this is not a valid operation.
//
// Description:   Populate the passed nonvisual object with all the selected
//                entries from this control.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
/*
 * Open Source PowerBuilder Foundation Class Libraries
 *
 * Copyright (c) 2004-2005, All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted in accordance with the GNU Lesser General
 * Public License Version 2.1, February 1999
 *
 * http://www.gnu.org/copyleft/lesser.html
 *
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals and was originally based on software copyright (c) 
 * 1996-2004 Sybase, Inc. http://www.sybase.com.  For more
 * information on the Open Source PowerBuilder Foundation Class
 * Libraries see http://pfc.codexchange.sybase.com
*/
//
//////////////////////////////////////////////////////////////////////////////

integer  li_totalitems
long     ll_item
integer  li_cnt=0

//Only a valid operation when MuliSelect is set to True.
If this.MultiSelect Then
   li_totalitems = this.TotalItems()
   //Loop through all items 
   For ll_item = 1 to li_totalitems
      If this.State(ll_item)=1 Then
         //Put this item into the NonVisual.
         li_cnt++
         anv_itemattrib[li_cnt].ii_index = ll_item
         anv_itemattrib[li_cnt].is_itemtext = this.Text(ll_item)
      End If
   Next
   //Number of selected items that were added.
   Return li_cnt
End If

//Not a valid operation
Return 0

end function

protected function integer of_messagebox (string as_id, string as_title, string as_text, icon ae_icon, button ae_button, integer ai_default);//////////////////////////////////////////////////////////////////////////////
//
// Function:         of_MessageBox
//
// Access:           protected
//
// Arguments:
// as_id       An ID for the Message.
// as_title    Text for title bar
// as_text     Text for the actual message.
// ae_icon     The icon you want to display on the MessageBox.
// ae_button   Set of CommandButtons you want to display on the MessageBox.
// ai_default  The default button.
//
// Returns:  integer
// Return value of the MessageBox.
//
// Description:
// Display a PowerScript MessageBox.  
// Allow PFC MessageBoxes to be manipulated prior to their actual display.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
/*
 * Open Source PowerBuilder Foundation Class Libraries
 *
 * Copyright (c) 2004-2005, All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted in accordance with the GNU Lesser General
 * Public License Version 2.1, February 1999
 *
 * http://www.gnu.org/copyleft/lesser.html
 *
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals and was originally based on software copyright (c) 
 * 1996-2004 Sybase, Inc. http://www.sybase.com.  For more
 * information on the Open Source PowerBuilder Foundation Class
 * Libraries see http://pfc.codexchange.sybase.com
*/
//
//////////////////////////////////////////////////////////////////////////////

Return MessageBox(as_title, as_text, ae_icon, ae_button, ai_default)
end function

event getfocus;//////////////////////////////////////////////////////////////////////////////
//
// Event:         getfocus
//
// (Arguments:    None)
//
// (Returns:      None)
//
// Description:   If appropriate, notify the parent window that this
//                control got focus.
//
//////////////////////////////////////////////////////////////////////////////
// 
// Revision History
//
// Version
// 5.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
/*
 * Open Source PowerBuilder Foundation Class Libraries
 *
 * Copyright (c) 2004-2005, All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted in accordance with the GNU Lesser General
 * Public License Version 2.1, February 1999
 *
 * http://www.gnu.org/copyleft/lesser.html
 *
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals and was originally based on software copyright (c) 
 * 1996-2004 Sybase, Inc. http://www.sybase.com.  For more
 * information on the Open Source PowerBuilder Foundation Class
 * Libraries see http://pfc.codexchange.sybase.com
*/
//
//////////////////////////////////////////////////////////////////////////////

window   lw_parent

//Check for microhelp requirements.
If gnv_app.of_GetMicrohelp() Then
   //Notify the parent.
   of_GetParentWindow(lw_parent)
   If IsValid(lw_parent) Then
      lw_parent.Dynamic Event pfc_ControlGotFocus (this)
   End If
End If

end event

on pfc_u_plb.create
end on

on pfc_u_plb.destroy
end on