Reusable S_201RSB
* ===================================================================;
*;
* Component : S_201RSB;
* Type : Reusable Component;
* Ancestor : PRIM_PANL (Primitive Panel);
*;
* Description : Simple String editor - scope(*Shared) version;
*;
* Full Description: This reusable component is used to provide a very;
* simple editor of a list of strings. It is iedntical to S_201RSA;
* except for using option scope(*Shared) on one line .... which;
* radically alters its behavior;
*;
* ===================================================================;
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM DISPLAYPOSITION(1) HEIGHT(140) LEFT(0) TABPOSITION(1) TOP(0) WIDTH(377);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_1) CAPTION('Editor Number nnn') DISPLAYPOSITION(1) HEIGHT(137) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TABSTOP(False) TOP(0) WIDTH(374);
DEFINE_COM CLASS(#PRIM_LTVW) NAME(#TEXT_LIST) DISPLAYPOSITION(1) FULLROWSELECT(True) HEIGHT(89) LEFT(8) PARENT(#GPBX_1) SELECTIONSTYLE(Single) TABPOSITION(1) TOP(18) WIDTH(274);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_1) CAPTION('Current List of Text Strings') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#TEXT_LIST) SOURCE(#STD_TEXT) WIDTH(20) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#STD_TEXT.Visual) NAME(#STD_TEXT) DISPLAYPOSITION(2) HEIGHT(21) LEFT(8) MARGINLEFT(0) PARENT(#GPBX_1) TABPOSITION(2) TOP(107) WIDTH(274);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#ADD_BUTTON) BUTTONDEFAULT(True) CAPTION('&Add') DISPLAYPOSITION(3) LEFT(286) PARENT(#GPBX_1) TABPOSITION(3) TOP(19);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#UPDATE_BUTTON) CAPTION('&Update') DISPLAYPOSITION(4) ENABLED(False) LEFT(286) PARENT(#GPBX_1) TABPOSITION(4) TOP(48);
;
* Define the text string list manager --- Note: SCOPE(*SHARED);
;
DEFINE_COM CLASS(#S_201RSO) NAME(#TEXT_MANAGER) SCOPE(*Shared);
;
* Define the uCaption property that allows the user to set the caption;
;
DEFINE_PTY NAME(uCaption) SET(SetuCaption);
;
* ===================================================================;
* Handle Component Initialization;
* ===================================================================;
;
EVTROUTINE HANDLING(#COM_OWNER.Initialize) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
CLR_LIST NAMED(#Text_List);
ENDROUTINE;
;
* ===================================================================;
* Handle Setting of the Caption;
* ===================================================================;
;
PTYROUTINE NAME(SetuCaption);
DEFINE_MAP FOR(*Input) CLASS(#Std_Text) NAME(#Pty_001);
SET COM(#GpBX_1) CAPTION(#Pty_001);
ENDROUTINE;
;
* ===================================================================;
* Handle Add button usage;
* ===================================================================;
;
EVTROUTINE HANDLING(#ADD_BUTTON.Click);
INVOKE METHOD(#TEXT_MANAGER.Add) TEXT(#std_Text);
ENDROUTINE;
;
* ===================================================================;
* Handle Update Button Usage;
* ===================================================================;
;
EVTROUTINE HANDLING(#UPDATE_BUTTON.Click);
INVOKE METHOD(#TEXT_MANAGER.Update) TEXT(#std_Text) ENTRYNUMBER(#Text_List.CurrentItem.Entry);
ENDROUTINE;
;
* ===================================================================;
* Handle Text Manager indicating a new text string has been added;
* ===================================================================;
;
EVTROUTINE HANDLING(#TEXT_MANAGER.TextAdded) TEXT(#Text) ENTRYNUMBER(#Entry);
DEFINE FIELD(#Save_Text) REFFLD(#Std_Text);
CHANGE FIELD(#Save_Text) TO(#Std_Text);
CHANGE FIELD(#Std_Text) TO(#Text.value);
ADD_ENTRY TO_LIST(#text_List);
SET COM(#Text_List.CurrentItem) ENSUREVISIBLE(True);
CHANGE FIELD(#Std_Text) TO(#Save_Text);
ENDROUTINE;
;
* ===================================================================;
* Handle Text Manager indicating a text string has been updated;
* ===================================================================;
;
EVTROUTINE HANDLING(#TEXT_MANAGER.TextChanged) TEXT(#Text) ENTRYNUMBER(#EntryNumber);
CHANGE FIELD(#Save_Text) TO(#Std_Text);
CHANGE FIELD(#Std_Num) TO(#EntryNumber.Value);
GET_ENTRY NUMBER(#Std_Num) FROM_LIST(#Text_List);
IF_STATUS IS(*okay);
CHANGE FIELD(#Std_Text) TO(#Text.value);
UPD_ENTRY IN_LIST(#text_List);
SET COM(#Text_List.CurrentItem) ENSUREVISIBLE(True);
ENDIF;
CHANGE FIELD(#Std_Text) TO(#Save_Text);
ENDROUTINE;
;
* ===================================================================;
* Handle Text List Item selection and Deselection;
* ===================================================================;
;
EVTROUTINE HANDLING(#TEXT_LIST.ItemGotSelection) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
SET COM(#Add_Button) BUTTONDEFAULT(False);
SET COM(#Update_Button) ENABLED(True) BUTTONDEFAULT(True);
ENDROUTINE;
;
EVTROUTINE HANDLING(#TEXT_LIST.ItemLostSelection) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
SET COM(#Update_Button) ENABLED(False) BUTTONDEFAULT(False);
SET COM(#Add_Button) BUTTONDEFAULT(True);
ENDROUTINE;
;
END_COM
* ===================================================================;
*;
* Component : S_201RSB;
* Type : Reusable Component;
* Ancestor : PRIM_PANL (Primitive Panel);
*;
* Description : Simple String editor - scope(*Shared) version;
*;
* Full Description: This reusable component is used to provide a very;
* simple editor of a list of strings. It is iedntical to S_201RSA;
* except for using option scope(*Shared) on one line .... which;
* radically alters its behavior;
*;
* ===================================================================;
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM DISPLAYPOSITION(1) HEIGHT(140) LEFT(0) TABPOSITION(1) TOP(0) WIDTH(377);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_1) CAPTION('Editor Number nnn') DISPLAYPOSITION(1) HEIGHT(137) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TABSTOP(False) TOP(0) WIDTH(374);
DEFINE_COM CLASS(#PRIM_LTVW) NAME(#TEXT_LIST) DISPLAYPOSITION(1) FULLROWSELECT(True) HEIGHT(89) LEFT(8) PARENT(#GPBX_1) SELECTIONSTYLE(Single) TABPOSITION(1) TOP(18) WIDTH(274);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_1) CAPTION('Current List of Text Strings') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#TEXT_LIST) SOURCE(#STD_TEXT) WIDTH(20) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#STD_TEXT.Visual) NAME(#STD_TEXT) DISPLAYPOSITION(2) HEIGHT(21) LEFT(8) MARGINLEFT(0) PARENT(#GPBX_1) TABPOSITION(2) TOP(107) WIDTH(274);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#ADD_BUTTON) BUTTONDEFAULT(True) CAPTION('&Add') DISPLAYPOSITION(3) LEFT(286) PARENT(#GPBX_1) TABPOSITION(3) TOP(19);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#UPDATE_BUTTON) CAPTION('&Update') DISPLAYPOSITION(4) ENABLED(False) LEFT(286) PARENT(#GPBX_1) TABPOSITION(4) TOP(48);
;
* Define the text string list manager --- Note: SCOPE(*SHARED);
;
DEFINE_COM CLASS(#S_201RSO) NAME(#TEXT_MANAGER) SCOPE(*Shared);
;
* Define the uCaption property that allows the user to set the caption;
;
DEFINE_PTY NAME(uCaption) SET(SetuCaption);
;
* ===================================================================;
* Handle Component Initialization;
* ===================================================================;
;
EVTROUTINE HANDLING(#COM_OWNER.Initialize) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
CLR_LIST NAMED(#Text_List);
ENDROUTINE;
;
* ===================================================================;
* Handle Setting of the Caption;
* ===================================================================;
;
PTYROUTINE NAME(SetuCaption);
DEFINE_MAP FOR(*Input) CLASS(#Std_Text) NAME(#Pty_001);
SET COM(#GpBX_1) CAPTION(#Pty_001);
ENDROUTINE;
;
* ===================================================================;
* Handle Add button usage;
* ===================================================================;
;
EVTROUTINE HANDLING(#ADD_BUTTON.Click);
INVOKE METHOD(#TEXT_MANAGER.Add) TEXT(#std_Text);
ENDROUTINE;
;
* ===================================================================;
* Handle Update Button Usage;
* ===================================================================;
;
EVTROUTINE HANDLING(#UPDATE_BUTTON.Click);
INVOKE METHOD(#TEXT_MANAGER.Update) TEXT(#std_Text) ENTRYNUMBER(#Text_List.CurrentItem.Entry);
ENDROUTINE;
;
* ===================================================================;
* Handle Text Manager indicating a new text string has been added;
* ===================================================================;
;
EVTROUTINE HANDLING(#TEXT_MANAGER.TextAdded) TEXT(#Text) ENTRYNUMBER(#Entry);
DEFINE FIELD(#Save_Text) REFFLD(#Std_Text);
CHANGE FIELD(#Save_Text) TO(#Std_Text);
CHANGE FIELD(#Std_Text) TO(#Text.value);
ADD_ENTRY TO_LIST(#text_List);
SET COM(#Text_List.CurrentItem) ENSUREVISIBLE(True);
CHANGE FIELD(#Std_Text) TO(#Save_Text);
ENDROUTINE;
;
* ===================================================================;
* Handle Text Manager indicating a text string has been updated;
* ===================================================================;
;
EVTROUTINE HANDLING(#TEXT_MANAGER.TextChanged) TEXT(#Text) ENTRYNUMBER(#EntryNumber);
CHANGE FIELD(#Save_Text) TO(#Std_Text);
CHANGE FIELD(#Std_Num) TO(#EntryNumber.Value);
GET_ENTRY NUMBER(#Std_Num) FROM_LIST(#Text_List);
IF_STATUS IS(*okay);
CHANGE FIELD(#Std_Text) TO(#Text.value);
UPD_ENTRY IN_LIST(#text_List);
SET COM(#Text_List.CurrentItem) ENSUREVISIBLE(True);
ENDIF;
CHANGE FIELD(#Std_Text) TO(#Save_Text);
ENDROUTINE;
;
* ===================================================================;
* Handle Text List Item selection and Deselection;
* ===================================================================;
;
EVTROUTINE HANDLING(#TEXT_LIST.ItemGotSelection) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
SET COM(#Add_Button) BUTTONDEFAULT(False);
SET COM(#Update_Button) ENABLED(True) BUTTONDEFAULT(True);
ENDROUTINE;
;
EVTROUTINE HANDLING(#TEXT_LIST.ItemLostSelection) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
SET COM(#Update_Button) ENABLED(False) BUTTONDEFAULT(False);
SET COM(#Add_Button) BUTTONDEFAULT(True);
ENDROUTINE;
;
END_COM