Table Editor Package
The package is available only in Visual Prolog Commercial Edition.
The package represents the table editor, which uses grid custom control.
1. Overview
Purpose
Table editor custom control is a screen object for browsing and editing information structured as a rectangular table. Table editor is based on a Grid custom control. In addition to the Grid functionality Table editor have many high level functions like internal data storage, sorting, filtering, undo-redo, etc.
Sorts of cell information and tools to edit cell contents.
Each Table editor cell may display integer, real, long or text information. Clicking a mouse button user may open one of the listed bellow controls inside the cell in order to edit it's contents:
* edit control,
* listbutton control,
* listedit control,
* any custom control,
* no control .
The application may decide which control to open in certain cell dynamically (during runtime).
Multiple instances
One or more instances of the Table editor custom control may be created inside one or more windows or dialogs at the same time. Each copy may have it's own properties like:
* general properties of the Table editor (TABLEEDIT_PROPERTIES),
* individual column properties (TABLEEDIT_COLUMNPROPERTIES)
* style, font, number of columns and rows and it's own application defined callback function (or they may share one callback function if desirable.
Interaction between the Table editor and the application
The Table editor custom control have internal storage for data to be displayed.
The Table editor has two modes:
* nobuffering - all data are passed to table editor during initialization and stored internally.
* buffering - table editor has the internal bufer with limited size and asks for next potion of data when necessary using special callback function. Using table editor in this mode is recommended for browsing of big databases which cannot be stored internally.
Table editor uses Callback function to notify the application about user actions inside the Table editor. It's the applications responsibility to provide suitable reactions to the user actions and events handling. If an event or user action is not handled by the application, then the Table editor control provides default handling.
Code structure
The source code consists of TABLEED.DOM (domains declaration), TABLEED.PRE (predicates declaration) and TABLEED.PRO (including also TABMAIN.PRO, TABLEED1.PRO, TABLEED2.PRO, TABLEED3.PRO, TABLEED4.PRO) (implementation). "TEMPLATE" directory contains TABLEED.DOM, TABLEED.PRE, TABLEED.PRO templates.
Multilanguage support
File TABLEED.CL contains 3 sets of string constants for menu:
* in English,
* in Danish,
* in Russian.
Application programmer must declare one of the constants below before including file TABLEED.CON in order to select one of the languages:
language_english = 1
or
language_danish = 1
or
language_russian = 1
If the support for any other language is desirable, open TABLEED.CON and add one more section with constants string.
Integration of the Table editor tool with the application by templates
For integration of the Table editor tool with the application programmer should follow next steps:
1. Copy TABLEED.DOM, TABLEED.PRE, TABLEED.PRO templates to application directory.
2. Replace all occurrences of "TABLEED_DIR" string in TABLEED.DOM, TABLEED.PRE, TABLEED.PRO templates with actual path to the TABLEED tool files.
3. Copy GRID custom control templates to application directory.
4. Replace all occurrences of "GRID_DIR" string in GRID templates with actual path to the GRID tool files.
5. Replace "PROJECT" string in TABLEED.PRO and GRID.PRO templates with actual name of the project.
6. Include GRID.DOM and TABLEED.DOM into the <PROJECT>.INC.
7. Include TABLEED.PRE into the project modules operating with Table editor.
8. Declare one of the "language_xxx" constants in the <PROJECT>.INC.
9. Add GRID.PRO and TABLEED.PRO template files to the list of project
modules.
2. Using Table editor custom control in application
Integration of the Table editor custom control with the program
To use the Table editor custom control application programmer should follow next steps:
1. Register class for the Table editor custom controls on Task window e_Create
event:
task_win_eh(Win,e_Create(_),0):-
tb_project_toolbar_Create(Win),
tb_help_line_Create(Win),
msg_Create(100),
% REGISTER CLASS FOR THE TABLE EDITOR CUSTOM CONTROL
class_Create("tableed_class", tableed_class_handler),
!.
Destroy class on TaskWindow e_Destroy
event.
task_win_eh(_Win,e_Destroy(),0):-
% DESTROY CLASS FOR THE TABLE EDITOR CUSTOM CONTROL
class_Destroy("tableed_class"),fail.
2. Supply the class with the event handler. Normally class event handler looks like:
Nobuffering mode:
tableed_class_handler(Win,e_Create(_),0):-!, % CALL tableedit_Init ON
/*Put here predicates assigning*/ % E_CREATE EVENT
/* init arguments values */
/* TableProperties = ... */
/* ColumnProperties = ... */
/* InputData = ... */
tableedit_Init(Win,TableProperies,ColumnProperties,InputData).
tableed_class_handler(Win,EVENT,0):- % CALL tableedit_HandleEvent
tableedit_HandleEvent(Win,EVENT). % ON ANY OTHER EVENT
Buffering mode: PREDICATES
....
buffAnswerFunc : TABLEEDIT_ANSWERDATA_FUNC
....
CLAUSES
tableed_class_handler(Win,e_Create(_),0):-!, % CALL tableedit_Init ON
/*Put here predicates assigning*/ % E_CREATE EVENT
/* init arguments values */
/* TableProperties = [bufferingmode(buffering(buffAnswerFunc,BuffSize,Maxows)),...]*/
/* ColumnProperties = ... */
tableedit_Init(Win,TableProperies,ColumnProperties,[]).
tableed_class_handler(Win,EVENT,0):- % CALL tableedit_HandleEvent
tableedit_HandleEvent(Win,EVENT). % ON ANY OTHER EVENT
/* Data Request for table editor in buffering mode*/
buffAnswerFunc(_Win,FromRow,ToRow,Data):-
/* Put here predicate for get data from external database*/
getDataFromDatabase(FromRow,ToRow,Data),
!.
Note that data argument is empty for tableedit_Init predicate in buffering mode because special callback function is used here to retrieve data from database.
3. In order to create the Table editor custom control inside a window or inside a dialog, application programmer has 2 opportunities:
* Create the Table editor custom control using win_CreateDynControl VPI global predicate. Code fragment below creates top level window and Table editor custom control
inside. PREDICATES
test_window_eh : EHANDLER
. . . . . . . . . . .
CLAUSES
. . . . . . . . . . .
%--- Top level window create ---
Win = win_Create(w_TopLevel,RCT,"Table editor test",no_menu,ParentWin,
win_Flags,test_window_eh,0),
%--- Table editor custom control create on e_Create EVENT---
test_window_eh(Win,e_Create(_),0):-
RCT = win_GetClientRect(Win),
Wdef = wdef(wc_Custom,RCT,"",u_Pixels),
WinDefList = [customctl(Wdef,tableed_class,tableed_id,[])],
win_CreateDynControl(WinDefList,Win),!.
. . . . . . . . . . .
* Load a dialog containing Table editor custom control from the project resources using usual call to win_CreateResDialog. The dialog specified by idd_TableEditor_test_dialog resource identifier in the following example may contain one or more Grid custom
controls:
win_CreateResDialog(Parent,wd_Modal,idd_TableEditor_test_dialog,
dlg_TableEditor_test_eh,0),!.
General (table) properties of the Table editor custom control.
All table properties are optional which means that if certain property is not listed then Table editor uses default value.
Application programmer can use the following table properties:
raised(BOOLEAN) - defines table editor grid exterior (b_true - raised, b_false -
plain);
Default: b_true
defcellcolor(COLOR) - defines a default cells color (If most of cells have identical color, it is useful to set it to defcellcolor(...) property for faster redrawing);
Default: color_LtGray
backcolor(COLOR) - defines a default grid background color for the area not occupied with the cells;
Default: color_Gray
emptycolor(COLOR) - defines a default cell color for void values;
Default: color_LtGray
titlebackcolor(COLOR) - defines a background color for column title;
Default: color_LtGray
titleforecolor(COLOR) - defines a foreground color for column title;
Default: color_Black
rowselector(GRID_ROW_SELECTOR, - show or not row number in row selector field
- see GRID_ROW_SELECTOR domain in Grid
- documentation
INTEGER Width, - width of row selector field
BOOLEAN ActiveRowPointer); - show or not active row pointer
Default: grid_number,50,b_false
nonscrollcol(INTEGER) - number of non scrollable columns (beginning from the leftmost column);
Default: 0
sortedby(INTEGER Column) - default sorting by Column;
Default: 1
allmarker(BOOLEAN) - allmarker is allowed/forbidden;
Default: b_false
areamarker(TABLEEDIT_MARKERMODE Mode) - area marker
mode;
Mode: none - area marker is forbidden
singular - single cell marker only
singlearea - single area marker only
multi - multiple area marker is allowed
Default: singular
colmarker(TABLEEDIT_MARKERMODE) - column marker mode;
Default: none
rowmarker(TABLEEDIT_MARKERMODE) - row marker mode;
Default: singular
insert_rows(BOOLEAN) - row inserting by means of "Ins" hotkey and corresponding menu item is enabled/disabled;
Default: b_true
delete_rows(BOOLEAN) - delet rows is allowed/forbidden by "Del" key or from menu;
Default: b_true
filter(BOOLEAN Mode) - filtration by column is allowed/forbidden (set Mode as defaul for
each filter(..) column property),(this property is actual for initialization, when most part of column have the same filter(..) column propertis);
Default: b_true (for each column default is filter(b_true))
menu(MENU_ITEM_LIST) - custom right mouse menu items;
Default: []
readonly(BOOLEAN Mode) - allow/forbid to change value by editing,cut,paste operation (set Mode as defaul for each readonly(..) column
property),(this property is actual for initialization, when most part of column have the same readonly(..) column propertis);
Default: b_false
undo_redo(BOOLEAN) - undo,redo operations ara allowed/forbidden;
Default: b_true
paste(BOOLEAN) - paste operations are allowed/forbidden;
Default: b_true
cut(BOOLEAN) - cut operations are allowed/forbidden;
Default: b_true
headers(INTEGER NRows) - first NRows are headers (header row does not participate in sorting and filtration);
Default: 0 rows
footers(INTEGER NRows) - last NRows are fuuters (fuuter row does not participate in sorting and filtration);
Default: 0 rows
callback(TABLEEDIT_CALLBACK Callback) - external Callback;
Default: internal dummy callback
compare(TABLEEDIT_COMPARE) - external (user defined) compare function;
Default: internal compare function;
find(BOOLEAN) - find are allowed/forbidden;
Default: allowed - b_true;
bufferingmode(TABLEEDIT_BUFFERING)
Default: nobuffering;
The TABLEEDIT_BUFFERING domain is shown below:
TABLEEDIT_BUFFERING =
nobuffering;
buffering(TABLEEDIT_ANSWERDATA_FUNC,
INTEGER RowBuffSize,
INTEGER MaxRows)
The TABLEEDIT_ANSWERDATA_FUNC domain is shown below:
TABLEEDIT_ANSWERDATA_FUNC =
determ(WINDOW TableEditWindow,
INTEGER FromRow,
INTEGER ToRow,
TABLEEDIT_DATA Data) - (i,i,i,o)
Individual column properties of the Table editor custom control.
All properties are optional which means that if certain property is not listed then column uses default value.
Application programmer can use the following column properties:
title(STRING) - Column title;
Default: ""
width(INTEGER) - Column width;
Default: 100 pixels
backcolor(COLOR) - column cells background color;
Default: color_LtGray
forecolor(COLOR) - column cells foreground color;
Default: color_Black
alignment(GRID_HORALIGNMENT) - column cells alignment;
Default: grid_right_align
See GRID_HORALIGNMENT domain in Grid documentation
maxlength(UNSIGNED);
Default: 0x7FFF
readonly(BOOLEAN) - allow/forbid to change value by editing,cut,paste operation;
Default: b_false
filter(BOOLEAN) - filtration by column is allowed/forbidden
Default: b_true
filterlist(TABLEEDIT_ORFILTERLIST) - column filter list;
Default: [ ]
The TABLEEDIT_ORFILTERLIST domain is shown below:
TABLEEDIT_ORFILTERLIST = TABLEEDIT_ORFILTER*
TABLEEDIT_ORFILTER =
% INTEGER FILTERS % Row is VISIBLE if:
if_min(INTEGER Limit); % value >= Limit
if_max(INTEGER Limit); % value <= Limit
% value from Lim1 to Lim2
if_range(INTEGER Lim1,INTEGER Lim2);
% value is not equal to Fval
if_not(INTEGER Fval);
% LONG FILTERS
lf_min(LONG);
lf_max(LONG);
lf_range(LONG,LONG);
lf_not(LONG);
% REAL FILTERS
rf_min(REAL);
rf_max(REAL);
rf_range(REAL,REAL);
rf_not(REAL);
% STRING FILTERS
s_f(STRING Fval); % value is equal to Fval
s_f_not(STRING Fval); % value is not equal to Fval
% VOID FILTERS
fvoid; % value is void
fvoid_not % value is not void
resizable(BOOLEAN) - resize of column is allowed/forbidden;
Default: b_true
sortmode(TABLEEDIT_SORTMODE) - column sort mode;
Default: ascending([])
The TABLEEDIT_SORTMODE domain is shown below:
TABLEEDIT_SORTMODE =
% ILIST defines dependence of sorting on other columns
ascending(ILIST Columns); % ascending sort mode
descending(ILIST Columns); % descending sort mode
none % sorting is impossible
defaultvalue(TABLEEDIT_CELLDATA) - "insert row" operations are uses row with default cells data;
Default: void
validationrule(TABLEEDIT_RULELIST) - column validation ruls;
Default: [ ]
The TABLEEDIT_RULELIST domain is shown below:
TABLEEDIT_RULELIST = TABLEEDIT_RULE*
TABLEEDIT_RULE =
% Validation ruls for string data:
s_length(INTEGER Length); % Number of chars
s_min(INTEGER Min); % Number of chars: From ..
s_max(INTEGER Max); % Number of chars: .. To
s_upper; % Upper case convertion
s_lower; % Lower case convertion
% Validation ruls for integer data:
i_min(INTEGER Min); % Value from ..
i_max(INTEGER Max); % Value to ..
% Validation ruls for real data:
r_min(REAL Min); % Value from ..
r_max(REAL Max); % Value to ..
% Validation ruls for long data:
l_min(LONG Min); % Value from ..
l_max(LONG Max) % Value to ..
mandatory(BOOLEAN) - Mandatory rule: allow/forbid void values. The handling is made as well as validation rule.
Default: b_false
validationtext(STRING ValidationText) - Text for validation rule message.
Default: ""
Handling of validationtext(ValidationTex), validationrule(RuleList), and mandatory(...) properties:
For integer, real, long column types:
1) If ValidationText is not empty string ("") and the value does not satisfy to a validation rule (Min, Max) or mandatory rule or the value is not consistent with field type, then dialog with ValidationText appears, the field remains active with the illegal value entered by user. ValidationText may contain a special symbol
"%". When tool displays prompt dialog it replaces this special symbol with the value entered by user.
2) If ValidationText is empty string and the value does not satisfy to a validation rule or mandatory rule or the value is not consistent with field type, then value remains not changed. The message dialog not appears.
For string column types:
1) If ValidationText is not empty string ("") and the value does not satisfy to a validation rule (Min, Max, Length) or mandatory rule or the value is not consistent with field type, then dialog with ValidationText appears, the field remains active with the illegal value entered by user. ValidationText may contain a special symbol "%". When tool displays prompt dialog it replaces this special symbol with the value entered by user.
2) If ValidationText is empty string and the value does not satisfy to a validation rule
(Min, Max,Length,Upper,Lower), then message dialog not appears and value is corrected according to a validation rule:
[s_min(Min)]: the string is supplemented by blanks up to specified number of chars;
[s_max(Max)]: the string is limited by specified number of chars;
[s_length(Value)]: is processed as well as [s_min(Value),s_max(Value)];
3) Independent of ValidationText:
[s_upper]: upper case convertion;
[s_lower]: lower case convertion.
The message dialog not appears.
Mandatory rule is ignored if ValidationText = "" for string column types.
column_type(TABLEEDIT_TYPE) - column type.
The TABLEEDIT_TYPE domain is shown below:
TABLEEDIT_TYPE =
te_integer; % INTEGER column type
te_real; % REAL column type
te_long; % LONG column type
te_string % STRING column type
te_picture % Picture column type
If data type in column differs from a string type, it is necessary to specify a type of a column.
Default: te_string
control(TABLEEDIT_CONTROL_TYPE) - control type for grid_edit_cell(...) marker.
The TABLEEDIT_CONTROL_TYPE domain is shown below:
TABLEEDIT_CONTROL_TYPE =
edit; % edit control
listbutton(SLIST); % listbutton control
listedit(SLIST); % listedit control
% custom control
custom(STRING ClassName,CTL_FLAGS Ctl_Flags,
GRID_PUT_CUSTOM_DATA, GRID_GET_CUSTOM_DATA)
Default: edit control.
GRID_GET_CUSTOM_DATA = (WINDOW CustWin,STRING OutStr) determ
(i,o)
GRID_PUT_CUSTOM_DATA = (WINDOW CustWin,STRING OutStr) determ
(i,i)
See GRID_PUT_CUSTOM_DATA, GRID_GET_CUSTOM_DATA domains in Grid documentation.
Handling Table editor custom control callback function
Callback function notifies an application about user actions in the Table editor control. Application have an opportunity to allow the action (fail) or forbid it. Examples below show some common situations:
* Forbid the setting of the real value =2.2 into row 2 column 1: PREDICATES
tab_Callback : TABLEEDIT_CALLBACK
...
CLAUSES
...
tab_Callback(_TableEditorWin,Event):-
Event = modified(2,1,_,r(2.2)),!.
* Forbid the setting of the row marker into first row (the marker not to
appear):
...
tab_Callback(_TableEditorWin,Event):-
Event = action(row_marker_beg(1)),!.
* Forbid the setting of the row marker into first row (the marker will be seted and
cancelled):
...
tab_Callback(_TableEditorWin,Event):-
Event = marker(M,b_true),
M =grid_row_marker([gl(1,1)]),!.
Handling Table editor custom control callback function in buffering mode
Examples below show some common situations:
* Handle the setting of the value to external
database: /*
User is about to Change cell data by editing or "cut","paste" operation or application Change cell data by tableedit_SetData/6, tableedit_SetRowData/4,
tableedit_SetClipBoardData/6, tableedit_SetCellData/4
*/
tab_Callback(_TableEditorWin,Event):-
Event = modified(Row,Column,_OldValue,NewValue),!,
/* Put here predicate for set data to external database*/
setDataToDatabase(Row,Column,NewValue),
fail.
/*
The user inseted row by "Insert row" operation.
*/
tab_Callback(TableEditorWin,Event):-
Event = insert_row(Row,InsData),!,
/* Put here predicate for insert row to external database*/
insertRowToDatabase(Row,InsData),
/* Get old MaxRow from table editor*/
MaxRows = tableedit_MaxRows(TableEditorWin),
NewMaxRows = MaxRows + 1,
/* Set New MaxRow to table editor*/
tableedit_Buff_SetMaxRows(TableEditorWin,NewMaxRows),
fail.
/*
The user deleted row by "Delete row" operation.
*/
tab_Callback(_TableEditorWin,Event):-
Event = delete_row(Row,_DelData),!,
/* Put here predicate for delete row to external database*/
deleteRowFromDatabase(Row),
/* Get old MaxRow from table editor*/
MaxRows = tableedit_MaxRows(Win),
NewMaxRows = MaxRows - 1,
/* Set New MaxRow to table editor*/
tableedit_Buff_SetMaxRows(Win,NewMaxRows),
fail.
/*
For example, forbid choice of the "cut" operation from column 2.
*/
tab_Callback(_TableEditorWin,Event):-
Event = cut_beg(_FromRow,_ToRow,FromColumn,ToColumn),
Column = 2,
Column >= FromColumn, Column <= ToColumn,
!.
/*
User is coped, pasted or cuted data by "copy","pste","cut" operations.
For example, forbid the "copy","paste","cut" and notify, if row range is more than 300.
*/
tab_Callback(_TableEditorWin,Event):-
Event = copy(FromRow,ToRow,_FromColumn,_ToColumn),
RowLimit = 300,
ToRow - FromRow >= RowLimit,
dlg_Note("Area too large for copying"),
!.
tab_Callback(_TableEditorWin,Event):-
Event = paste(FromRow,ToRow,_FromColumn,_ToColumn),
RowLimit = 300,
ToRow - FromRow >= RowLimit,
dlg_Note("Area too large for pasting"),
!.
tab_Callback(_TableEditorWin,Event):-
Event = cut(FromRow,ToRow,_FromColumn,_ToColumn),
RowLimit = 300,
ToRow - FromRow >= RowLimit,
dlg_Note("Area too large for cuting"),
!.
/*
The user set filter by "Filter by selection","Filter excluding selection" or "Show all rows" operation.
*/
tab_Callback(_TableEditorWin,Event):-
Event = filter(Filterlist),!,
/* Put here predicate for handle filter for external database*/
handleFiltersForDatabase(Filterlist,NewMaxRows),
/*Set New MaxRow to table editor*/
tableedit_Buff_SetMaxRows(Win,NewMaxRows),
/* Reset Table editor data*/
tableedit_SetAllData(Win,[]),
fail.
/*
The user sorted data by "Sort ascending","Sort descending" operation.
*/
tab_Callback(_TableEditorWin,Event):-
Event = sort(Column,Sortmode),!,
/* Put here predicate for handle sorting for external database*/
handleSortForDatabase(Column,Sortmode),
/* Reset Table editor data*/
tableedit_SetAllData(Win,[]),
fail.
/*
The user change PictureNameId string, set picture for
PictureNameId.
*/
tab_Callback(_TableEditorWin,Event):-
Event = modified(Row,Column,_OldValue,NewValue),
% For example, column 4 is te_picture type
Column = 4,
NewValue = p(_,_,PictureNameId),
/* Put here predicate for get Picture by PictureNameId string*/
get_PictureByNameId(PictureNameId,Pic,Stretch),
NewValue1 = p(Pic,Stretch,PictureNameId),
/* Put here predicate for set data to external database*/
setDataToDatabase(Row,Column,NewValue1),!,
fail.
Callback messages.
marker(GRID_MARKER,BOOLEAN MarkUnMark) - informs an application that user is about to Set new marker and UnSet old marker.
See GRID_MARKER domain in Grid documentation or tableedit_GetMarker(...) global predicate below.
modified(INTEGER Row,INTEGER Column,
TABLEEDIT_CELLDATA OldValue, TABLEEDIT_CELLDATA NewValue) - informs an application that user is about to Change cell data by
* NOBUFFERING MODE: editing or "cut",
"paste", "undo", "redo" operation;
* BUFFERING MODE: editing or "cut", "paste" operation or tableedit_SetData/6, tableedit_SetRowData/4, tableedit_SetClipBoardData/6,
tableedit_SetCellData/4 global predicates;
copy_beg(INTEGER FromRow,INTEGER ToRow,INTEGER FromColumn,INTEGER ToColumn) - allowed/forbidden choice of "copy" operation.
find(STRING FindString, TABLEEDIT_DIRECTION FindDirection, INTEGER Column, TABLEEDIT_MATCH Match, BOOLEAN
CaseSensitive,BOOLEAN FindNext) - user choice of find operation.
* NOBUFFERING MODE: notice and
handling.
* BUFFERING MODE: only notice.
copy(INTEGER FromRow,INTEGER ToRow,INTEGER FromColumn,INTEGER ToColumn) - informs an application that user is about to coped data to clipboard by "copy" operation.
paste_beg(INTEGER FromRow,INTEGER ToRow,INTEGER FromColumn,INTEGER ToColumn) - allow / forbid choice of "paste" operation.
paste(INTEGER FromRow,INTEGER ToRow,INTEGER FromColumn,INTEGER ToColumn) - informs an application that user is about to pasted data from clipboard by "paste" operation.
cut_beg(INTEGER FromRow,INTEGER ToRow,INTEGER FromColumn,INTEGER ToColumn) - allow / forbid choice of "cut" operation.
cut(INTEGER FromRow,INTEGER ToRow,INTEGER FromColumn,INTEGER ToColumn) - informs an application that user is about to cuted data to clipboard by "cut" operation.
sort_beg(INTEGER Column) - allow / forbid choice of sorting operations - "Sort ascending" and "Sort descending".
sort(INTEGER Column,TABLEEDIT_SORTMODE SortMode) - The user has made sorting by Column according to SortMode.
* NOBUFFERING MODE: notice and handling.
* BUFFERING MODE: only notice.
filter_beg(TABLEEDIT_FILTERS FilterList) - allow / forbid choice of "Filter by selection", "Filter excluding selection" or "Show all rows" operations.
filter(TABLEEDIT_FILTERS FiltertList) - The user has made a filtration according to FiltertList.
* NOBUFFERING MODE: notice and handling.
* BUFFERING MODE: only notice.
The TABLEEDIT_FILTERS domain is shown below:
TABLEEDIT_FILTERS = TABLEEDIT_COLUMNFILTER*
TABLEEDIT_COLUMNFILTER = columnfilter(INTEGER Column,TABLEEDIT_ORFILTERLIST)
(TABLEEDIT_ORFILTERLIST domain is described above in chapter "Individual column properties of the Table editor custom control")
insert_row_beg(INTEGER Row,TABLEEDIT_COLUMNDATA RowData) - allow / forbid choice of "insert row" operation.
insert_row(INTEGER Row,TABLEEDIT_COLUMNDATA InsRow) - The user inset row by:
* NOBUFFERING MODE: "Insert row", "Undo" or "Redo" operation. Notice and handling.
* BUFFERING MODE: "Insert row" operation. Only notice.
delete_row_beg(GRID_LINELIST ListOfRowForDeleting) - allow / forbid choice of "delete row" operation.
See GRID_LINELIST domain in Grid documentation.
delete_row(INTEGER Row,TABLEEDIT_COLUMNDATA DelRow) - The user delete row by "Delete row", "Undo" or "Redo" operation.
* NOBUFFERING MODE: "Delete row", "Undo" or "Redo" operation. Notice and handling.
* BUFFERING MODE: "Delete row" operation. Only notice.
menu_beg(INTEGER Row,INTEGER Column)- forbidding context menu in Row and Column.
Menu(MENU_TAG Id, GRID_MARKER CurrentMarker) - The user has chosen menu item (one of given in menu(...) table property).
See GRID_MARKER domain in Grid documentation or tableedit_GetMarker(...) global predicate below.
action(TABACTION) - advanced messages.
The TABACTION domain is shown below:
TABACTION =
% Beginning of a row marking (the marker is not yet present)
row_marker_beg(INTEGER Row);
% Beginning of a column marking (the marker is not yet present)
col_marker_beg(INTEGER Column);
% Beginning of a area marking (the marker is not yet present)
area_marker_beg(INTEGER Row,INTEGER Column);
% Beginning of a all marking (the marker is not yet present)
all_marker_beg;
% Beginning of a edit marking (the marker is not yet present)
edit_cell_beg(INTEGER Row,INTEGER Column);
% Beginning of column resizeing (the resize marker is not yet present)
resize_column_beg(INTEGER Column);
% Column resizeing
resize_column(INTEGER Column,INTEGER Width);
hscroll_create;
vscroll_create;
hscroll_destroy;
vscroll_destroy
Handling Table editor custom control compare function
Application have an opportunity to use internal priorities of sorting or user defined (external) compare function. If compare(ExtCompareFunction) property is not defined then Table editor uses default internal function. If external function is defined but fails on certain call then Table editor also uses default internal function. Example below show how application programmer may use external compare function for correct sorting of the rows containing dates in one of the columns (for ex. in column 3). Predicate compareFunc fails for all other columns except column 3 - table editor uses default internal comparison for these
columns.
PREDICATES
compareFunc : TABLEEDIT_COMPARE
convertdata(TABLEEDIT_CELLDATA,STRING)
...
CLAUSES
...
compareFunc(_Win,Column,First,Second,equal):-
Column = 3,
convertdata(First,Str1),
convertdata(Second,Str2),
Str1 = Str2,!.
compareFunc(_Win,Column,First,Second,less):-
Column = 3,
convertdata(First,Str1),
convertdata(Second,Str2),
dt_minstr_to_offset(Str1,"%DD-%MD-%YS",Offset1),
dt_minstr_to_offset(Str2,"%DD-%MD-%YS",Offset2),
Offset1 < Offset2,!.
compareFunc(_,Column,_,_,more):-
Column = 3,!.
Compare function:
TABLEEDIT_COMPARE = (WINDOW TableEditWindow,
INTEGER Column,
TABLEEDIT_CELLDATA CellData1,
TABLEEDIT_CELLDATA CellData2,
TABLEEDIT_COMPARESTATUS Equal_More_Less) determ (i,i,i,i,o)
Examples
Next example shows initialisation of the Table editor with external callback function, consisting from three columns with data and titles.
The first column has a real type and "Real Data" title.
The second column has a string type and "String Data" title.
The third column has a string type, "Date" title and type of control is custom (in this case -
date custom control).
The other Table and Column properties have default values.
Nobuffering mode:
tableed_class_handler(TableEditorWindow,e_Create(_),0):-!,
...
tableedit_Init(TableEditorWindow,
[callback(tab_Callback)],
[
column([title("Real Data"), column_type(te_real),
column([title("String Data")]),
column([title("Date"), control(custom("date",[],date_put_string,date_get_string)),
alignment(grid_left_align)])
],
[
[r(1.0),s("1s"),sc("10-04-97",255)], %(255 - is red color)
[r(2.0),s("2s"),sc("11-04-97",255)],
[r(3.0),s("3s"),sc("12-04-97",255)],
[r(4.0),s("4s"),sc("13-04-97",255)],
[r(5.0),s("5s"),sc("14-04-97",255)],
[r(6.0),s("6s"),void],
[r(7.0),s("7s"),void]
]
),fail.
Buffering mode:
PREDICATES
....
buffAnswerFunc : TABLEEDIT_ANSWERDATA_FUNC
....
CLAUSES
tableed_class_handler(TableEditorWindow,e_Create(_),0):-!,
...
BuffSize = 30,
get_MaxRowsFromExternalDatabase(MaxRows),
...
tableedit_Init(TableEditorWindow,
[callback(tab_Callback), bufferingmode(buffering(buffAnswer,Buff,MaxRows))],
[
column([title("Real Data"), column_type(te_real),
column([title("String Data")]),
column([title("Date"), control(custom("date",[],date_put_string,date_get_string)),
alignment(grid_left_align)])
],
[]
),fail.
/* Data Request for table editor in buffering mode*/
buffAnswerFunc(_Win,FromRow,ToRow,Data):-
/* Get data from external database*/
getDataFromDatabase(FromRow,ToRow,Data),
!.