Reusable Part VL_SAM064: Dynamic Radio Button Group
Name: VL_SAM064
Description: The following RDMLX reusable component is used to dynamically create a group of up to 100 radio buttons.
This reusable component is used by form VL_SAM065.
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM DISPLAYPOSITION(1) HEIGHT(94) LEFT(0) TABPOSITION(1) TOP(0) WIDTH(131);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GROUPBOX) CAPTION('Group') DISPLAYPOSITION(1) HEIGHT(89) HINTSHOW(False) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TABSTOP(False) TOP(0) WIDTH(129);
DEFINE_COM CLASS(#PRIM_KCOL) NAME(#RB) COLLECTS(#PRIM_RDBN) KEYEDBY(#STD_NUM);
DEFINE_COM CLASS(#PRIM_LABL) NAME(#TEXT) CAPTION('The radio buttons in this group box are determined at execution time') DISPLAYPOSITION(1) HEIGHT(57) LEFT(16) PARENT(#GROUPBOX) TABPOSITION(1) TABSTOP(False) TOP(20) VISIBLE(False) WIDTH(97);
;
Define_Pty CurrentCode get(*auto #CCode) Set(SetCode);
Define_Pty CurrentCaption get(*Auto #CCaption) ;
Define_Pty GroupCaption set(SetGrpCaption) ;
;
DEFINE_COM CLASS(#STD_CODEL) NAME(#CCODE) LENGTH(6);
DEFINE_COM CLASS(#STD_DESC) NAME(#CCAPTION) LENGTH(30);
* Define #CCode RefFld(#Std_CodeL) ;
* Define #CCaption RefFld(#Std_Desc) ;
;
Define_Evt CodeChanged;
Define_Map *input #Std_CodeL #NewCode ;
Define_Map *input #Std_Desc #NewCaption ;
;
Define #VCode RefFld(#Std_CodeL) ;
Define #VCaption RefFld(#Std_Desc);
Define #VCount Reffld(#Std_Num);
Define #GCount Reffld(#Std_Num);
Def_List #VList (#VCode #VCaption) Type(*Working) Entrys(100) Counter(#VCount) ;
;
Define #LoopCount RefFld(#Std_Num) ;
;
MthRoutine AddRadioButton;
Define_Map *input #Std_CodeL #UseCode ;
Define_Map *input #Std_Desc #UseCaption ;
Change #VCode #UseCode.Value;
Change #VCaption #UseCaption.Value;
Add_Entry #Vlist;
EndRoutine ;
;
PtyRoutine SetGrpCaption;
Define_Map *input #Std_Desc #PropGrp;
Set #GroupBox Caption(#PropGrp.Value);
EndRoutine ;
;
PtyRoutine GetCaption;
define_map *Output #Std_Desc #Prop3;
Set #Prop3 Value(#CCaption);
Endroutine ;
;
PtyRoutine GetCode;
define_map *Output #Std_CodeL #Prop2;
Set #Prop2 Value(#CCode);
Endroutine ;
;
PtyRoutine SetCode;
define_map *input #Std_CodeL #Prop1;
Change #CCode #Prop1.Value;
Execute DrawGroup;
Begin_Loop from(1) to(#VCount) Using(#LoopCount);
Get_Entry #LoopCount #Vlist ;
if '#VCode = #CCode';
Change #CCaption #VCaption;
Set #RB<#LoopCount> ButtonChecked(True);
Signal CodeChanged NewCode(#CCode) NewCaption(#CCaption);
Return ;
Endif ;
End_Loop ;
Abort 'Attempt to set code to a value which has not been previously defined' ;
Endroutine ;
;
Subroutine DrawGroup;
;
Define #RBHeight RefFld(#Std_Num) Default(20);
Define #RBWidth RefFld(#Std_Num) Default(115);
Define #RBLeft RefFld(#Std_Num) Default(8);
;
Define #RBIntTop RefFld(#Std_Num) Default(14);
Define #Top RefFld(#Std_Num) ;
Define #Height RefFld(#Std_Num) ;
;
if '#GCount < #VCount';
Change #Top #RBIntTop;
Begin_Loop from(1) to(#VCount) Using(#LoopCount);
Get_Entry #LoopCount #VList;
Set #RB<#LoopCount> Parent(#GroupBox) Top(#Top) Left(#RBLeft) Width(#RBWidth) Height(#RBHeight) Caption(#VCaption) ;
Invoke #RB<#LoopCount>.Realize;
Change #Top '#Top + #RBHeight' ;
End_Loop ;
Change #Height '(#VCount * #RBHeight) + #RBIntTop + 4';
Set #Com_Owner Height(#Height) ;
Set #GroupBox Height(#Height) ;
Change #GCount #VCount;
Endif ;
EndRoutine ;
;
EvtRoutine Handling(#RB<>.Click);
Begin_Loop from(1) to(#VCount) Using(#LoopCount);
if '#RB<#LoopCount>.ButtonChecked = True';
Get_Entry #LoopCount #Vlist ;
Change #CCode #VCode;
Change #CCaption #VCaption;
Signal CodeChanged NewCode(#CCode) NewCaption(#CCaption);
Return;
Endif ;
End_Loop ;
Abort 'Unable to determine which Radio button was clicked or no radio buttons in group' ;
EndRoutine ;
;
END_COM ;
Name: VL_SAM064
Description: The following RDMLX reusable component is used to dynamically create a group of up to 100 radio buttons.
This reusable component is used by form VL_SAM065.
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM DISPLAYPOSITION(1) HEIGHT(94) LEFT(0) TABPOSITION(1) TOP(0) WIDTH(131);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GROUPBOX) CAPTION('Group') DISPLAYPOSITION(1) HEIGHT(89) HINTSHOW(False) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TABSTOP(False) TOP(0) WIDTH(129);
DEFINE_COM CLASS(#PRIM_KCOL) NAME(#RB) COLLECTS(#PRIM_RDBN) KEYEDBY(#STD_NUM);
DEFINE_COM CLASS(#PRIM_LABL) NAME(#TEXT) CAPTION('The radio buttons in this group box are determined at execution time') DISPLAYPOSITION(1) HEIGHT(57) LEFT(16) PARENT(#GROUPBOX) TABPOSITION(1) TABSTOP(False) TOP(20) VISIBLE(False) WIDTH(97);
;
Define_Pty CurrentCode get(*auto #CCode) Set(SetCode);
Define_Pty CurrentCaption get(*Auto #CCaption) ;
Define_Pty GroupCaption set(SetGrpCaption) ;
;
DEFINE_COM CLASS(#STD_CODEL) NAME(#CCODE) LENGTH(6);
DEFINE_COM CLASS(#STD_DESC) NAME(#CCAPTION) LENGTH(30);
* Define #CCode RefFld(#Std_CodeL) ;
* Define #CCaption RefFld(#Std_Desc) ;
;
Define_Evt CodeChanged;
Define_Map *input #Std_CodeL #NewCode ;
Define_Map *input #Std_Desc #NewCaption ;
;
Define #VCode RefFld(#Std_CodeL) ;
Define #VCaption RefFld(#Std_Desc);
Define #VCount Reffld(#Std_Num);
Define #GCount Reffld(#Std_Num);
Def_List #VList (#VCode #VCaption) Type(*Working) Entrys(100) Counter(#VCount) ;
;
Define #LoopCount RefFld(#Std_Num) ;
;
MthRoutine AddRadioButton;
Define_Map *input #Std_CodeL #UseCode ;
Define_Map *input #Std_Desc #UseCaption ;
Change #VCode #UseCode.Value;
Change #VCaption #UseCaption.Value;
Add_Entry #Vlist;
EndRoutine ;
;
PtyRoutine SetGrpCaption;
Define_Map *input #Std_Desc #PropGrp;
Set #GroupBox Caption(#PropGrp.Value);
EndRoutine ;
;
PtyRoutine GetCaption;
define_map *Output #Std_Desc #Prop3;
Set #Prop3 Value(#CCaption);
Endroutine ;
;
PtyRoutine GetCode;
define_map *Output #Std_CodeL #Prop2;
Set #Prop2 Value(#CCode);
Endroutine ;
;
PtyRoutine SetCode;
define_map *input #Std_CodeL #Prop1;
Change #CCode #Prop1.Value;
Execute DrawGroup;
Begin_Loop from(1) to(#VCount) Using(#LoopCount);
Get_Entry #LoopCount #Vlist ;
if '#VCode = #CCode';
Change #CCaption #VCaption;
Set #RB<#LoopCount> ButtonChecked(True);
Signal CodeChanged NewCode(#CCode) NewCaption(#CCaption);
Return ;
Endif ;
End_Loop ;
Abort 'Attempt to set code to a value which has not been previously defined' ;
Endroutine ;
;
Subroutine DrawGroup;
;
Define #RBHeight RefFld(#Std_Num) Default(20);
Define #RBWidth RefFld(#Std_Num) Default(115);
Define #RBLeft RefFld(#Std_Num) Default(8);
;
Define #RBIntTop RefFld(#Std_Num) Default(14);
Define #Top RefFld(#Std_Num) ;
Define #Height RefFld(#Std_Num) ;
;
if '#GCount < #VCount';
Change #Top #RBIntTop;
Begin_Loop from(1) to(#VCount) Using(#LoopCount);
Get_Entry #LoopCount #VList;
Set #RB<#LoopCount> Parent(#GroupBox) Top(#Top) Left(#RBLeft) Width(#RBWidth) Height(#RBHeight) Caption(#VCaption) ;
Invoke #RB<#LoopCount>.Realize;
Change #Top '#Top + #RBHeight' ;
End_Loop ;
Change #Height '(#VCount * #RBHeight) + #RBIntTop + 4';
Set #Com_Owner Height(#Height) ;
Set #GroupBox Height(#Height) ;
Change #GCount #VCount;
Endif ;
EndRoutine ;
;
EvtRoutine Handling(#RB<>.Click);
Begin_Loop from(1) to(#VCount) Using(#LoopCount);
if '#RB<#LoopCount>.ButtonChecked = True';
Get_Entry #LoopCount #Vlist ;
Change #CCode #VCode;
Change #CCaption #VCaption;
Signal CodeChanged NewCode(#CCode) NewCaption(#CCaption);
Return;
Endif ;
End_Loop ;
Abort 'Unable to determine which Radio button was clicked or no radio buttons in group' ;
EndRoutine ;
;
END_COM ;