3.24 DM_FmtDefaultProc
This function takes on all tasks when processing an edittext, e.g. setting a format, the input control, the navigation, etc. as soon as a format is set for the editable text.
Usually, the Dialog Manager does then automatically call this default format function without involving the actual application.
If, however, the edittext has its own format function, Dialog Manager will call this application-specific function instead of the default format function. This function then has to perform the tasks demanded by Dialog Manager. To do so, it can call the function DM_FmtDefaultProc by various tasks, if these are not to be changed application-specifically.
DM_boolean DML_default DM_EXPORT DM_FmtDefaultProc
(
DM_FmtRequest *req,
DM_FmtFormat *fmt,
DM_FmtFormatDef **fmtDef,
DM_FmtContent *cont,
DM_FmtContentDef **contDef,
DM_FmtDisplay *dpy
)
Parameters
-> DM_FmtRequest *req
This parameter defines the demand for the formatting routine. To do so, a structure element is assigned to the task and - according to the task - a union is filled with the necessary data (e.g. with the new contents as string when setting a new contents).
<-> DM_FmtFormat *fmt
This structure includes description data about the format string which are needed independent of the format function and the chosen kind of format.
<-> DM_FmtFormatDef **fmtDef
With this parameter, a structure is transferred which includes the format-specific data for a format string. If a foreign format function is to use the default format, it has to provide an entry for this in its private data and pass it on there.
<-> DM_FmtContent *cont
This structure includes description data about the contents string to be formatted which are needed independent of the format function and the chosen kind of format
<-> DM_FmtContentDef **contDef
With this parameter, a structure is passed on which includes the format-specific data for a contents string. If a foreign format function is to fall back to the default formats, it has to provide an entry for this in its private data and pass it there.
<-> DM_FmtDisplay *dpy
This structure includes description data about the display string to be formatted which are needed independently of the format function and the chosen kind of format.
Example
Realization of a format function which, itself, assumes only few tasks. The function makes it possible for the user to input a date.
/*
** The number to be inputted depends on the cursor position
** so that a valid date results.
*/
char GetMax __1(
(DM_FmtDisplay far *, dpy))
{
char max;
switch (dpy->curpos)
{
case 0:
max = '3';
break;
case 1:
if (dpy->string[0] == '3')
max = '1';
else
max = '9';
break;
case 3:
max = '1';
break;
case 4:
if (dpy->string[3] == '1')
max = '2';
else
max = '9';
break;
default:
max = '9';
break;
}
return (max);
}
/*
** actual format function
**
*/
DM_Boolean DML_c DM_CALLBACK My_Formatter __6(
(DM_FmtRequest far *, req),
(DM_FmtFormat far *, fmt),
(FPTR *, fmtPriv),
(DM_FmtContent far *, cont),
(FPTR *, contPriv),
(DM_FmtDisplay far *, dpy))
{
DM_Boolean retval;
switch (req->task)
{
/*
** The date shall be inputable only in the format
** dd.mm.yy. This function is realized only rudimentarily.
** BackSpace and DEL shall also be intercepted.
*/
case FMTK_modify:
{
char max = GetMax(dpy);
if ((!req->targs.modify.strlength
&& (dpy->curpos == dpy->length))
|| ((req->targs.modify.strlength == 1)
&& (req->targs.modify.string[0] >= '0')
&& (req->targs.modify.string[0] <= max)))
{
retval = DM_FmtDefaultProc(req, fmt,
(DM_FmtFormatDef **) (FPTR) fmtPriv, cont,
(DM_FmtContentDef **) (FPTR) contPriv, dpy);
}
else
retval = FALSE;
}
break;
default:
/*
** Calling the default format function
*/
retval = DM_FmtDefaultProc(req, fmt, (DM_FmtFormatDef **)
(FPTR) fmtPriv,cont,
(DM_FmtContentDef **) (FPTR) contPriv, dpy);
break;
}
return (retval);
}
See Also
Chapter “Structures and Definitions for the Formatting of Input” in manual “C Interface - Basics”
Resource format
Chapter “Format Function” in manual “Rule Language”