Reusable Part S_199RFC
* ===================================================================;
*;
* Component : S_199RFC;
* Type : Reusable Part;
* Ancestor : PRIM_FORM (Primitive Form);
*;
* Description : Reusable Pop Up Menu used in Form S_199FB;
*;
* Full Description: This reusable part will work with any grid in your application. No;
* changes to this reusable part are necessary for it to work with your grid(s). Changes;
* required to make it work with your grid(s) should be applied to your Form containing;
* your grid(s).;
*;
* Note that although there are three different grids in Form S_199FB, this single reusable;
* part will handle them all. To achieve that functionality, two keyed collections are;
* defined:;
*;
* 1) #COLUMNS collects components of type grid column (#PRIM_GDCL);
* 2) #POPUP_MITM collects components of type pop up menu item (#PRIM_MITM);
*;
* At execution time there will be as many instances of this reusable part running;
* as grids are in the Form, in this example three: one "listening" to the Department;
* grid, a second to the Section grid and a third one to the Employee grid. These;
* instances are created in the Method Routine Define_Grid by "attaching";
* the pop up menu to each of the grid.;
*;
* The details of each of the columns are stored in the #COLUMNS collection in the;
* method routine Define_Column.;
*;
* Additionally, some properties of the grid columns are saved in a flat file in your;
* temporary directory using the TRANSFORM_LIST bif. During the grid definition;
* the flat file is restored using the TRANSFORM_FILE bif so that the changes applied;
* by the user to the grids will be "remembered" the next time the Form is executed.;
* The properties stored in this particular case are: Width, Display Position, Sort Position,;
* and Sort Direction.;
*;
* 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(133) Left(0) Popupmenu(#POPUP) Tabposition(1) Top(0) Visible(False) Width(130);
;
Define_Com Class(#PRIM_PMNU) Name(#POPUP);
;
* Collection of grid columns to received from grid;
;
Define_Com Class(#PRIM_KCOL) Name(#COLUMNS) Collects(#PRIM_GDCL) Keyedby(#STD_NUM) Style(Collection);
;
* This collection is included for demonstration purposes only. It is just to show that;
* that it is possible to overwrite the caption of a column at runtime.;
;
Define_Com Class(#PRIM_KCOL) Name(#CAPTIONS) Collects(#STD_TEXTL) Keyedby(#STD_NUM);
;
* Collection of popup menu items;
;
Define_Com Class(#PRIM_KCOL) Name(#POPUP_MITM) Collects(#PRIM_MITM) Keyedby(#STD_NUM);
;
* PopUp Menu options;
;
Define_Com Class(#PRIM_MITM) Name(#MITM_LEFT) Caption('Left') Displayposition(1) Enabled(False) Parent(#POPUP) Visible(False);
Define_Com Class(#PRIM_MITM) Name(#MITM_RIGHT) Caption('Right') Displayposition(2) Enabled(False) Parent(#POPUP) Visible(False);
Define_Com Class(#PRIM_MITM) Name(#MITM_ASCENDING) Caption('Sort Ascending') Displayposition(3) Enabled(False) Parent(#POPUP) Visible(False);
Define_Com Class(#PRIM_MITM) Name(#MITM_DESCENDING) Caption('Sort Descending') Displayposition(4) Enabled(False) Parent(#POPUP) Visible(False);
;
* Temporary work and test fields;
;
Define_Com Class(#STD_NUM) Name(#COLUMN_COUNT);
Define_Com Class(#STD_NUM) Name(#HIGH_POS);
Define_Com Class(#STD_NUM) Name(#CURRENT_COLUMN);
Define_Com Class(#STD_NUM) Name(#COLUMN_INDEX);
Define Field(#T_Visible) Reffld(#Std_Bool);
Define Field(#T_Display) Reffld(#Std_Num);
Define Field(#T_Index) Reffld(#Std_Num);
;
* The grid details storage file name;
;
Define Field(#SAVE_FILE) Reffld(#SYSVAR$AV);
;
* Fields to store the column properties;
;
Define Field(#SAVE_RETC) Type(*CHAR) Length(2);
Define Field(#SAVE_NAME) Reffld(#STD_TEXTL) Desc('Saved Column Name');
Define Field(#SAVE_POS) Reffld(#STD_NUM) Desc('Saved Display Position');
Define Field(#SAVE_SPOS) Reffld(#STD_NUM) Desc('Saved Sort Position');
Define Field(#SAVE_WID) Reffld(#STD_NUM) Desc('Saved Column Width');
Define Field(#SAVE_SDIR) Type(*CHAR) Length(10) Desc('Saved Sort Direction');
;
Def_List Name(#SAVE_LIST) Fields(#SAVE_NAME #SAVE_SDIR #SAVE_POS #SAVE_SPOS #SAVE_WID) Type(*WORKING) Entrys(256);
;
* ===============================================================;
* Handle close of owner form.;
* When the user closes the form, loop through the collection of columns, add the;
* column properties to the working list and transform it into a flat file.;
* ===============================================================;
;
Evtroutine Handling(#Com_Owner.DestroyInstance) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Com_Sender(#column);
Define_Com Class(#PRIM_GDCL) Name(#UseColumn) Reference(*dynamic);
;
Clr_List Named(#Save_List);
;
Change Field(#Std_Num) To(#Column_Count.Value);
Begin_Loop Using(#T_Index) To(#Std_Num);
;
Set_Ref Com(#UseColumn) To(#Columns<#T_Index>);
;
Change Field(#SAVE_NAME) To('#UseColumn.Name');
Change Field(#SAVE_POS) To('#UseColumn.DisplayPosition');
Change Field(#SAVE_SPOS) To('#UseColumn.Sortposition');
Change Field(#SAVE_WID) To('#UseColumn.Width');
Change Field(#SAVE_SDIR) To('#UseColumn.sortdirection');
;
Add_Entry To_List(#Save_List);
End_Loop;
;
Use Builtin(TRANSFORM_LIST) With_Args(#SAVE_LIST #SAVE_FILE T) To_Get(#SAVE_RETC);
Endroutine;
;
* ===============================================================;
* Handle selection of column by clickin on its caption;
* ===============================================================;
;
Evtroutine Handling(#Columns<>.Click) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Com_Sender(#column);
;
Invoke Method(#Com_Owner.Build_PopUp) Column(#Column);
;
Endroutine;
;
* ===============================================================;
* Build the pop-up suitable for the indicated column;
* ===============================================================;
;
Mthroutine Name(Build_PopUp);
Define_Map For(*input) Class(#prim_gdcl) Name(#column) Pass(*by_reference);
;
Set Com(#High_Pos #Current_Column #Column_Index) Value(0);
;
;
If Cond('#Column.Visible *ne True');
;
Set Com(#MITM_left #MITM_Right #MITM_Ascending #MITM_Descending) Visible(False);
;
Else;
;
Set Com(#MITM_left #MITM_Right #MITM_Ascending #MITM_Descending) Visible(True);
;
Change Field(#Std_Num) To(#Column_Count.Value);
;
* Loop throught the column collection to determine:;
* 1) If the column that was clicked on is the one on the extreme rigth position;
* so that the Move Column to the right can option in the pop up must be disabled.;
* 2) The column that was clicked on.;
;
Begin_Loop Using(#T_Index) To(#Std_Num);
Set Com(#Column_Index) Value(#T_Index);
Change Field(#T_Visible) To(#Columns<#column_index>.Visible);
Change Field(#T_Display) To(#Columns<#column_index>.DisplayPosition);
If Cond('(#T_Visible = True) and (#T_Display > #High_Pos)');
Set Com(#High_Pos) Value(#T_Display);
Endif;
;
* Loop throught the column collection to determine which one was clicked on.;
If_Ref Com(#Columns<#colUmn_index>) Is(*EQUAL_TO #column);
Set Com(#Current_Column) Value(#column_index);
Endif;
End_Loop;
;
Change Field(#Std_TextL) To(#Captions<#Current_Column>.Value);
;
Use Builtin(Bconcat) With_Args('<--' #std_TextL) To_Get(#Sysvar$av);
If Cond('(#column.displayposition = 1) or (#high_pos < 2)');
* extreme left column, disable the move left option in the pop up;
Set Com(#MITM_left) Enabled(false) Caption(#sysVar$av);
Else;
Set Com(#MITM_left) Enabled(true) Caption(#sysVar$av);
Endif;
;
Use Builtin(Bconcat) With_Args('-->' #std_TextL) To_Get(#Sysvar$av);
If Cond('(#high_pos < 2) or (#high_pos = #column.displayposition)');
Set Com(#MITM_right) Enabled(false) Caption(#sysVar$av);
Else;
Set Com(#MITM_right) Enabled(true) Caption(#sysVar$av);
Endif;
;
Use Builtin(BCONCAT) With_Args('Sort by' #std_TextL '(Ascending)') To_Get(#SYSVAR$AV);
Set Com(#mitm_ascending) Caption(#SysVar$av);
;
Use Builtin(BCONCAT) With_Args('Sort by' #Std_TextL '(Descending)') To_Get(#SYSVAR$AV);
Set Com(#mitm_Descending) Caption(#SysVar$av);
;
If Cond('#High_Pos = 0');
Set Com(#MITM_descending #mitm_ascending) Enabled(false);
Else;
Set Com(#MITM_descending #mitm_ascending) Enabled(true);
Endif;
;
Endif;
;
Endroutine;
;
* ===============================================================;
* Handle request to make colum visible / invisible;
* ===============================================================;
;
Evtroutine Handling(#PopUp_Mitm<>.Click) Com_Sender(#popup_item);
Define_Com Class(#PRIM_GDCL) Name(#Column) Reference(*dynamic);
;
Set Com(#Current_Column) Value(#Popup_Item.Tag);
;
Set_Ref Com(#Column) To(#Columns<#Current_Column>);
;
If Cond('#Column.Visible = True');
Set Com(#Column) Visible(False);
Set Com(#PopUp_Item) Checked(False);
Else;
Set Com(#Column) Visible(True);
Set Com(#PopUp_Item) Checked(True);
Endif;
;
Invoke Method(#Com_Owner.Build_PopUp) Column(#Columns<#Current_Column.Value>);
;
Endroutine;
;
* ===============================================================;
* Sort column in descending order and set sort position to 1;
* ===============================================================;
;
Evtroutine Handling(#Mitm_descending.Click);
If Cond('#Current_Column.Value > 0');
Set Com(#Columns<#Current_Column.Value>) Sortdirection(descending) Sortposition(1);
Endif;
Endroutine;
;
*;
* ===============================================================;
* Sort column in ascending order and set sort position to 1;
* ===============================================================;
;
Evtroutine Handling(#Mitm_ascending.Click);
If Cond('#Current_Column.Value > 0');
Set Com(#Columns<#Current_Column.Value>) Sortdirection(ascending) Sortposition(1);
Endif;
Endroutine;
;
* ===============================================================;
* Move column to the left;
* ===============================================================;
;
Evtroutine Handling(#Mitm_Left.Click);
Define_Com Class(#PRIM_GDCL) Name(#Column) Reference(*dynamic);
;
If Cond('#Current_Column.Value > 0');
Set_Ref Com(#Column) To(#Columns<#Current_Column>);
Change Field(#Std_Num) To('#Column.DisplayPosition - 1');
If Cond('#Std_Num > 0');
Set Com(#Column) Displayposition(#Std_Num);
Invoke Method(#Com_Owner.Build_PopUp) Column(#Column);
Endif;
Endif;
;
Endroutine;
;
* ===============================================================;
* Move column to the right;
* ===============================================================;
;
Evtroutine Handling(#Mitm_Right.Click);
Define_Com Class(#PRIM_GDCL) Name(#Column) Reference(*dynamic);
;
If Cond('#Current_Column.Value > 0');
Set_Ref Com(#Column) To(#Columns<#Current_Column>);
Change Field(#Std_Num) To('#Column.DisplayPosition + 1');
If Cond('#Std_Num > 0');
Set Com(#Column) Displayposition(#Std_Num);
Invoke Method(#Com_Owner.Build_PopUp) Column(#Column);
Endif;
Endif;
;
Endroutine;
;
* ===============================================================;
* Handle definition of a column;
* ===============================================================;
;
Mthroutine Name(define_column);
Define_Map For(*input) Class(#prim_gdcl) Name(#column) Pass(*by_reference);
Define_Map For(*input) Class(#std_textl) Name(#UseCaption) Mandatory(' ');
Define_Com Class(#Std_TextL) Name(#Menu_Caption);
;
Change Field(#Std_Num) To('#Column_Count.Value + 1');
Set Com(#Column_Count) Value(#Std_Num);
Set_Ref Com(#Columns<#Column_Count>) To(#column);
;
* See if this column can be found in Save_List;
;
Change Field(#Std_TextL) To(#Column.Name);
Loc_Entry In_List(#save_List) Where('#Save_Name = #Std_TextL');
;
* If found, set the column up to have saved details, etc;
;
If_Status Is(*Okay);
Set Com(#Column) Width(#save_Wid) Sortposition(#save_spos) Sortdirection(#save_sdir) Displayposition(#save_Pos);
Endif;
;
* Decide on the caption to be used in the pop menu.;
;
If Cond('#UseCaption.Value = *Blanks');
If Cond('#Column.Caption = *blanks');
Change Field(#Std_TextL) To(#Column.Name);
Else;
Change Field(#Std_TextL) To(#Column.Caption);
Endif;
Else;
Change Field(#Std_TextL) To(#UseCaption.Value);
Endif;
;
Set Com(#Captions<#Column_Count>) Value(#Std_TextL);
;
* Set up the pop-up menu entry for the grid;
;
Set Com(#popup_Mitm<#Column_Count>) Parent(#Popup) Tag(#Column_Count) Caption(#Std_TextL) Checked(#column.visible) Displayposition(1) Visible(True) Enabled(true);
;
Endroutine;
;
* ===============================================================;
* Handle definition of a grid;
* ===============================================================;
;
Mthroutine Name(Define_Grid);
Define_Map For(*input) Class(#prim_form) Name(#Form) Pass(*by_reference);
Define_Map For(*input) Class(#prim_grid) Name(#Grid) Pass(*by_reference);
;
* Attach the pop-up menu to the grid;
;
Set Com(#Grid) Popupmenu(#popup);
;
* Create the name of the file that should store details. Note that the;
* name should be <form Name>_<Grid Name>.dat in the temporary directory;
;
Use Builtin(Tconcat) With_Args(*Temp_Dir #Form.Name '_' #Grid.Name '.dat') To_Get(#Save_FILE);
;
* Clear the save list and attempt to load it up with old saved details;
;
Clr_List Named(#Save_List);
;
Use Builtin(TRANSFORM_FILE) With_Args(#SAVE_LIST #SAVE_FILE T) To_Get(#SAVE_RETC);
Endroutine;
;
End_Com
* ===================================================================;
*;
* Component : S_199RFC;
* Type : Reusable Part;
* Ancestor : PRIM_FORM (Primitive Form);
*;
* Description : Reusable Pop Up Menu used in Form S_199FB;
*;
* Full Description: This reusable part will work with any grid in your application. No;
* changes to this reusable part are necessary for it to work with your grid(s). Changes;
* required to make it work with your grid(s) should be applied to your Form containing;
* your grid(s).;
*;
* Note that although there are three different grids in Form S_199FB, this single reusable;
* part will handle them all. To achieve that functionality, two keyed collections are;
* defined:;
*;
* 1) #COLUMNS collects components of type grid column (#PRIM_GDCL);
* 2) #POPUP_MITM collects components of type pop up menu item (#PRIM_MITM);
*;
* At execution time there will be as many instances of this reusable part running;
* as grids are in the Form, in this example three: one "listening" to the Department;
* grid, a second to the Section grid and a third one to the Employee grid. These;
* instances are created in the Method Routine Define_Grid by "attaching";
* the pop up menu to each of the grid.;
*;
* The details of each of the columns are stored in the #COLUMNS collection in the;
* method routine Define_Column.;
*;
* Additionally, some properties of the grid columns are saved in a flat file in your;
* temporary directory using the TRANSFORM_LIST bif. During the grid definition;
* the flat file is restored using the TRANSFORM_FILE bif so that the changes applied;
* by the user to the grids will be "remembered" the next time the Form is executed.;
* The properties stored in this particular case are: Width, Display Position, Sort Position,;
* and Sort Direction.;
*;
* 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(133) Left(0) Popupmenu(#POPUP) Tabposition(1) Top(0) Visible(False) Width(130);
;
Define_Com Class(#PRIM_PMNU) Name(#POPUP);
;
* Collection of grid columns to received from grid;
;
Define_Com Class(#PRIM_KCOL) Name(#COLUMNS) Collects(#PRIM_GDCL) Keyedby(#STD_NUM) Style(Collection);
;
* This collection is included for demonstration purposes only. It is just to show that;
* that it is possible to overwrite the caption of a column at runtime.;
;
Define_Com Class(#PRIM_KCOL) Name(#CAPTIONS) Collects(#STD_TEXTL) Keyedby(#STD_NUM);
;
* Collection of popup menu items;
;
Define_Com Class(#PRIM_KCOL) Name(#POPUP_MITM) Collects(#PRIM_MITM) Keyedby(#STD_NUM);
;
* PopUp Menu options;
;
Define_Com Class(#PRIM_MITM) Name(#MITM_LEFT) Caption('Left') Displayposition(1) Enabled(False) Parent(#POPUP) Visible(False);
Define_Com Class(#PRIM_MITM) Name(#MITM_RIGHT) Caption('Right') Displayposition(2) Enabled(False) Parent(#POPUP) Visible(False);
Define_Com Class(#PRIM_MITM) Name(#MITM_ASCENDING) Caption('Sort Ascending') Displayposition(3) Enabled(False) Parent(#POPUP) Visible(False);
Define_Com Class(#PRIM_MITM) Name(#MITM_DESCENDING) Caption('Sort Descending') Displayposition(4) Enabled(False) Parent(#POPUP) Visible(False);
;
* Temporary work and test fields;
;
Define_Com Class(#STD_NUM) Name(#COLUMN_COUNT);
Define_Com Class(#STD_NUM) Name(#HIGH_POS);
Define_Com Class(#STD_NUM) Name(#CURRENT_COLUMN);
Define_Com Class(#STD_NUM) Name(#COLUMN_INDEX);
Define Field(#T_Visible) Reffld(#Std_Bool);
Define Field(#T_Display) Reffld(#Std_Num);
Define Field(#T_Index) Reffld(#Std_Num);
;
* The grid details storage file name;
;
Define Field(#SAVE_FILE) Reffld(#SYSVAR$AV);
;
* Fields to store the column properties;
;
Define Field(#SAVE_RETC) Type(*CHAR) Length(2);
Define Field(#SAVE_NAME) Reffld(#STD_TEXTL) Desc('Saved Column Name');
Define Field(#SAVE_POS) Reffld(#STD_NUM) Desc('Saved Display Position');
Define Field(#SAVE_SPOS) Reffld(#STD_NUM) Desc('Saved Sort Position');
Define Field(#SAVE_WID) Reffld(#STD_NUM) Desc('Saved Column Width');
Define Field(#SAVE_SDIR) Type(*CHAR) Length(10) Desc('Saved Sort Direction');
;
Def_List Name(#SAVE_LIST) Fields(#SAVE_NAME #SAVE_SDIR #SAVE_POS #SAVE_SPOS #SAVE_WID) Type(*WORKING) Entrys(256);
;
* ===============================================================;
* Handle close of owner form.;
* When the user closes the form, loop through the collection of columns, add the;
* column properties to the working list and transform it into a flat file.;
* ===============================================================;
;
Evtroutine Handling(#Com_Owner.DestroyInstance) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Com_Sender(#column);
Define_Com Class(#PRIM_GDCL) Name(#UseColumn) Reference(*dynamic);
;
Clr_List Named(#Save_List);
;
Change Field(#Std_Num) To(#Column_Count.Value);
Begin_Loop Using(#T_Index) To(#Std_Num);
;
Set_Ref Com(#UseColumn) To(#Columns<#T_Index>);
;
Change Field(#SAVE_NAME) To('#UseColumn.Name');
Change Field(#SAVE_POS) To('#UseColumn.DisplayPosition');
Change Field(#SAVE_SPOS) To('#UseColumn.Sortposition');
Change Field(#SAVE_WID) To('#UseColumn.Width');
Change Field(#SAVE_SDIR) To('#UseColumn.sortdirection');
;
Add_Entry To_List(#Save_List);
End_Loop;
;
Use Builtin(TRANSFORM_LIST) With_Args(#SAVE_LIST #SAVE_FILE T) To_Get(#SAVE_RETC);
Endroutine;
;
* ===============================================================;
* Handle selection of column by clickin on its caption;
* ===============================================================;
;
Evtroutine Handling(#Columns<>.Click) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Com_Sender(#column);
;
Invoke Method(#Com_Owner.Build_PopUp) Column(#Column);
;
Endroutine;
;
* ===============================================================;
* Build the pop-up suitable for the indicated column;
* ===============================================================;
;
Mthroutine Name(Build_PopUp);
Define_Map For(*input) Class(#prim_gdcl) Name(#column) Pass(*by_reference);
;
Set Com(#High_Pos #Current_Column #Column_Index) Value(0);
;
;
If Cond('#Column.Visible *ne True');
;
Set Com(#MITM_left #MITM_Right #MITM_Ascending #MITM_Descending) Visible(False);
;
Else;
;
Set Com(#MITM_left #MITM_Right #MITM_Ascending #MITM_Descending) Visible(True);
;
Change Field(#Std_Num) To(#Column_Count.Value);
;
* Loop throught the column collection to determine:;
* 1) If the column that was clicked on is the one on the extreme rigth position;
* so that the Move Column to the right can option in the pop up must be disabled.;
* 2) The column that was clicked on.;
;
Begin_Loop Using(#T_Index) To(#Std_Num);
Set Com(#Column_Index) Value(#T_Index);
Change Field(#T_Visible) To(#Columns<#column_index>.Visible);
Change Field(#T_Display) To(#Columns<#column_index>.DisplayPosition);
If Cond('(#T_Visible = True) and (#T_Display > #High_Pos)');
Set Com(#High_Pos) Value(#T_Display);
Endif;
;
* Loop throught the column collection to determine which one was clicked on.;
If_Ref Com(#Columns<#colUmn_index>) Is(*EQUAL_TO #column);
Set Com(#Current_Column) Value(#column_index);
Endif;
End_Loop;
;
Change Field(#Std_TextL) To(#Captions<#Current_Column>.Value);
;
Use Builtin(Bconcat) With_Args('<--' #std_TextL) To_Get(#Sysvar$av);
If Cond('(#column.displayposition = 1) or (#high_pos < 2)');
* extreme left column, disable the move left option in the pop up;
Set Com(#MITM_left) Enabled(false) Caption(#sysVar$av);
Else;
Set Com(#MITM_left) Enabled(true) Caption(#sysVar$av);
Endif;
;
Use Builtin(Bconcat) With_Args('-->' #std_TextL) To_Get(#Sysvar$av);
If Cond('(#high_pos < 2) or (#high_pos = #column.displayposition)');
Set Com(#MITM_right) Enabled(false) Caption(#sysVar$av);
Else;
Set Com(#MITM_right) Enabled(true) Caption(#sysVar$av);
Endif;
;
Use Builtin(BCONCAT) With_Args('Sort by' #std_TextL '(Ascending)') To_Get(#SYSVAR$AV);
Set Com(#mitm_ascending) Caption(#SysVar$av);
;
Use Builtin(BCONCAT) With_Args('Sort by' #Std_TextL '(Descending)') To_Get(#SYSVAR$AV);
Set Com(#mitm_Descending) Caption(#SysVar$av);
;
If Cond('#High_Pos = 0');
Set Com(#MITM_descending #mitm_ascending) Enabled(false);
Else;
Set Com(#MITM_descending #mitm_ascending) Enabled(true);
Endif;
;
Endif;
;
Endroutine;
;
* ===============================================================;
* Handle request to make colum visible / invisible;
* ===============================================================;
;
Evtroutine Handling(#PopUp_Mitm<>.Click) Com_Sender(#popup_item);
Define_Com Class(#PRIM_GDCL) Name(#Column) Reference(*dynamic);
;
Set Com(#Current_Column) Value(#Popup_Item.Tag);
;
Set_Ref Com(#Column) To(#Columns<#Current_Column>);
;
If Cond('#Column.Visible = True');
Set Com(#Column) Visible(False);
Set Com(#PopUp_Item) Checked(False);
Else;
Set Com(#Column) Visible(True);
Set Com(#PopUp_Item) Checked(True);
Endif;
;
Invoke Method(#Com_Owner.Build_PopUp) Column(#Columns<#Current_Column.Value>);
;
Endroutine;
;
* ===============================================================;
* Sort column in descending order and set sort position to 1;
* ===============================================================;
;
Evtroutine Handling(#Mitm_descending.Click);
If Cond('#Current_Column.Value > 0');
Set Com(#Columns<#Current_Column.Value>) Sortdirection(descending) Sortposition(1);
Endif;
Endroutine;
;
*;
* ===============================================================;
* Sort column in ascending order and set sort position to 1;
* ===============================================================;
;
Evtroutine Handling(#Mitm_ascending.Click);
If Cond('#Current_Column.Value > 0');
Set Com(#Columns<#Current_Column.Value>) Sortdirection(ascending) Sortposition(1);
Endif;
Endroutine;
;
* ===============================================================;
* Move column to the left;
* ===============================================================;
;
Evtroutine Handling(#Mitm_Left.Click);
Define_Com Class(#PRIM_GDCL) Name(#Column) Reference(*dynamic);
;
If Cond('#Current_Column.Value > 0');
Set_Ref Com(#Column) To(#Columns<#Current_Column>);
Change Field(#Std_Num) To('#Column.DisplayPosition - 1');
If Cond('#Std_Num > 0');
Set Com(#Column) Displayposition(#Std_Num);
Invoke Method(#Com_Owner.Build_PopUp) Column(#Column);
Endif;
Endif;
;
Endroutine;
;
* ===============================================================;
* Move column to the right;
* ===============================================================;
;
Evtroutine Handling(#Mitm_Right.Click);
Define_Com Class(#PRIM_GDCL) Name(#Column) Reference(*dynamic);
;
If Cond('#Current_Column.Value > 0');
Set_Ref Com(#Column) To(#Columns<#Current_Column>);
Change Field(#Std_Num) To('#Column.DisplayPosition + 1');
If Cond('#Std_Num > 0');
Set Com(#Column) Displayposition(#Std_Num);
Invoke Method(#Com_Owner.Build_PopUp) Column(#Column);
Endif;
Endif;
;
Endroutine;
;
* ===============================================================;
* Handle definition of a column;
* ===============================================================;
;
Mthroutine Name(define_column);
Define_Map For(*input) Class(#prim_gdcl) Name(#column) Pass(*by_reference);
Define_Map For(*input) Class(#std_textl) Name(#UseCaption) Mandatory(' ');
Define_Com Class(#Std_TextL) Name(#Menu_Caption);
;
Change Field(#Std_Num) To('#Column_Count.Value + 1');
Set Com(#Column_Count) Value(#Std_Num);
Set_Ref Com(#Columns<#Column_Count>) To(#column);
;
* See if this column can be found in Save_List;
;
Change Field(#Std_TextL) To(#Column.Name);
Loc_Entry In_List(#save_List) Where('#Save_Name = #Std_TextL');
;
* If found, set the column up to have saved details, etc;
;
If_Status Is(*Okay);
Set Com(#Column) Width(#save_Wid) Sortposition(#save_spos) Sortdirection(#save_sdir) Displayposition(#save_Pos);
Endif;
;
* Decide on the caption to be used in the pop menu.;
;
If Cond('#UseCaption.Value = *Blanks');
If Cond('#Column.Caption = *blanks');
Change Field(#Std_TextL) To(#Column.Name);
Else;
Change Field(#Std_TextL) To(#Column.Caption);
Endif;
Else;
Change Field(#Std_TextL) To(#UseCaption.Value);
Endif;
;
Set Com(#Captions<#Column_Count>) Value(#Std_TextL);
;
* Set up the pop-up menu entry for the grid;
;
Set Com(#popup_Mitm<#Column_Count>) Parent(#Popup) Tag(#Column_Count) Caption(#Std_TextL) Checked(#column.visible) Displayposition(1) Visible(True) Enabled(true);
;
Endroutine;
;
* ===============================================================;
* Handle definition of a grid;
* ===============================================================;
;
Mthroutine Name(Define_Grid);
Define_Map For(*input) Class(#prim_form) Name(#Form) Pass(*by_reference);
Define_Map For(*input) Class(#prim_grid) Name(#Grid) Pass(*by_reference);
;
* Attach the pop-up menu to the grid;
;
Set Com(#Grid) Popupmenu(#popup);
;
* Create the name of the file that should store details. Note that the;
* name should be <form Name>_<Grid Name>.dat in the temporary directory;
;
Use Builtin(Tconcat) With_Args(*Temp_Dir #Form.Name '_' #Grid.Name '.dat') To_Get(#Save_FILE);
;
* Clear the save list and attempt to load it up with old saved details;
;
Clr_List Named(#Save_List);
;
Use Builtin(TRANSFORM_FILE) With_Args(#SAVE_LIST #SAVE_FILE T) To_Get(#SAVE_RETC);
Endroutine;
;
End_Com