Reusable Part S_190RPL

LANSA

Reusable Part S_190RPL

* ===================================================================;
*;
* Component : S_190RPL;
* Type : Reusable Component;
* Ancestor : PRIM_PANL (Primitive Panel);
*;
* Description : Reusable Poll List ;
*;
* Disclaimer : The following material is supplied as sample material;
* only. No warranty concerning this material or its use;
* in any way whatsoever is expressed or implied.;
*;
* ===================================================================;
;
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM DISPLAYPOSITION(1) HEIGHT(99) LAYOUTMANAGER(#ATLM_1) LEFT(0) TABPOSITION(1) TOP(0) WIDTH(468);
DEFINE_COM CLASS(#PRIM_ATLM) NAME(#ATLM_1);
DEFINE_COM CLASS(#PRIM_LTVW) NAME(#LTVW_1) DISPLAYPOSITION(1) HEIGHT(99) LEFT(0) PARENT(#COM_OWNER) SELECTIONSTYLE(Single) TABPOSITION(1) TOP(0) WIDTH(468);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_4) ATTACHMENT(Center) MANAGE(#LTVW_1) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_1) PARENT(#LTVW_1) SOURCE(#S_190PID) VISIBLE(False) WIDTH(20);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_2) DISPLAYPOSITION(1) PARENT(#LTVW_1) SOURCE(#S_190PDS) WIDTH(20) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_3) DISPLAYPOSITION(2) PARENT(#LTVW_1) SOURCE(#S_190PST) WIDTH(15);
;
define_evt PollSelected help('This event is signaled when the poll is selected');
;
define_pty name(CurrPoll) get(*auto #S_190PID ) ;
;
GROUP_BY NAME(#S_GRPPDF) FIELDS(#S_190PID #S_190PDS #S_190PPW #S_190PBN #S_190PST);
*;
* (Re)initialise the list of polls from file;
mthroutine uInit;
CLR_LIST #LTVW_1;
execute LOADPOLL with_parms(0);
ENDROUTINE;
*;
* Signal to external forms that the user has selected a poll from the list;
EVTROUTINE HANDLING(#LTVW_1.ItemGotFocus) ;
Signal PollSelected ;
ENDROUTINE;
*;
* Programmatically set the focus to an entry in the poll list ;
mthroutine uSetPoll;
Define_Map *Input #S_190PID #mS_190PID Desc('xxxx') Help('A different poll');
;
change #S_190PID #mS_190PID.value;
;
;
BEGIN_LOOP;
selectlist #LTVW_1;
continue if('#S_190PID *ne #mS_190PID.Value') ;
;
* the details for the selected entry are likely to have been changed;
FETCH #S_GRPPDF SETPDF with_key(#S_190PID);
UPD_ENTRY IN_LIST(#LTVW_1);
;
set #LTVW_1.CurrentItem Focus(True) Selected(TRUE) ensurevisible(TRUE);
;
* set the field #S_190PID to the current list entry ;
* The following relates to situations where the focus in a list view is set programmatically.;
* If the following logic was not present, #S_190PID would contain the value for the list entry that lost focus, instead;
* of the value for the list entry that just got focus. This would cause property CurrPoll to be wrong.;
CHANGE #STD_IDNO #LTVW_1.FocusItem.Entry;
GET_ENTRY #STD_IDNO #LTVW_1;
;
* signal to external forms that the program has selected a poll from the list;
signal PollSelected;
return;
endselect;
;
* no entry found that matches the poll requested - must be a new poll;
CHANGE (#S_190PDS #S_190PST) *NULL;
CHANGE #S_190PID #mS_190PID.Value;
FETCH #S_GRPPDF SETPDF with_key(#S_190PID);
;
ADD_ENTRY #LTVW_1;
END_LOOP;
endroutine;
*;
* (re)load all polls and set the focus to the first poll if no poll is specified;
subroutine LOADPOLL parms(#S_190PIDW);
DEFINE #S_190PIDW reffld(#S_190PID);
;
clr_list #LTVW_1;
Select #S_GRPPDF SETPDF;
add_entry #LTVW_1;
endselect;
;
if '#S_190PIDW *EQ 0';
* set focus to the first entry, if available ;
get_entry 1 #LTVW_1;
if_status *OKAY;
set #LTVW_1.CurrentItem Focus(True) Selected(TRUE) ensurevisible(TRUE);
;
* signal to external forms that the program has selected a poll from the list;
signal PollSelected;
endif;
else;
invoke #Com_Owner.uSetPoll mS_190PID(#S_190PIDW);
endif;
;
endroutine;
;
END_COM;