Selector Library
[Reference documentation]

File and Font selectors support. More...

Functions

int mt_FselInput (APPvar *app, char *path, char *fname, char *ext, char *title, char *lpath, char *lext)
 Universal file selector.
int mt_FontSel (APPvar *app, char *title, char *example, int flags, int *id, int *size, char *name)
 Builtin WinDom font selector.

Detailed Description

File and Font selectors support.


Function Documentation

int mt_FontSel APPvar app,
char *  winname,
char *  example,
int  flags,
int *  fontid,
int *  fontsize,
char *  fontname
 

Builtin WinDom font selector.

Parameters:
app application descriptor,
winname window font selector title,
example text used to display the font or NULL,
flags a bit field, possible bit are :
  • VSTHEIGHT size in pixel unit (instead of point unit),
  • MONOSPACED display only non proportional fonts.
fontid identificator of the selected font,
fontsize size selected,
fontname font name filled in a 64-byte buffer,
Returns:
1 if the user selects a valid font , 0 otherwise.
mt_FontSel() calls the internal WinDom font selector. The selector is displayed in a modal window. The selector can be used even the system does not support multiple fonts, in this case only the size can be changed.

Before the call, the fontid and fontsize parameters can be filled with a default font-id and size. If a null value is used, default values are the system font and a size of 13 pixels. If the example parameter is NULL, a default text is used to display the fonts.

The window hosting fontselector catches the AP_TERM message : the function will terminate in the same manner than a user clic on the Cancel button and an AP_TERM message is emited again.

Usage of selector
  • a single clic : select a font and display it,
  • a double clic : select a font and return this selection, the selector is closed,
  • field 'size' : font size are updated in real time,
  • up and down keys : browse the list font,
  • return or enter keys : shortcut of OK button,
  • undo key : shortcut of Cancel button.

int mt_FselInput APPvar app,
char *  path,
char *  name,
char *  ext,
char *  title,
char *  lpath,
char *  lext
 

Universal file selector.

Parameters:
app application descriptor,
path directory where the file selector is opened, then the directory of the selected item,
name of a default file, then the name of the selected file,
ext file mask,
title selector title if selector supports it, otherwise, it will be ignored
lpath list of predefined directories if selector supports it or NULL,
lext list of predefined mask file if selector supports it or NULL,
Returns:
1 if an object has been sucessfully selected, 0 otherwise.
mt_FselInput() is a custom call of the GEM file selector. If an alternative file selector is available ('FSEL' cookie, Selectric, BoxKite 2, FLSX extensions), it will be used instead of the GEM standard file selector.

When the function returns, parameters path and name are filled in with the directory and the filename selected. Then mt_FselInput() can be used both as a file and as a directory selector. If the path parameter is an empty string, the current directory is used. If the ext parameter is an empty string, the default mask used by mt_FselInput() will be "*.*".

Parameter title sets fileselector title and can be used for any TOS version. If fileselelector does not support this feature, this parameter has no effect.

The lpath and lext parameters allow you to define a list of preset directories and file mask. There list are displayed inside the file selector if it is possible (that is the case with Selectrics, BoxKite 2 and the FLSX selectors). A list is a string whose each items are delimited by a ';' character, for example :

  "C:\\usr;C:\\usr\\bin"
  "*.c;*.h"

mt_FselInput() adds in the directories preset, the path of the user directory (if the $HOME environ variable is defined). The environ variables $FSELPATH and $FSELMASK are used to build a default list of directories and file mask. The additional lists given by lpath and lext are adding in these lists. Environ variables provide a way to configure globally all WinDom clients. In addition, it is possible, for the user, to configure a specific application : the windom.fsel.path and windom.fsel.mask variable in the configuration file define the list of directories and file mask. These values are adding to the lists displayed by the file selector.

If the system has a FSLX extension (see mt_appl_getinfo()), the file selector is displayed in a modal window. The windom.fsel.fslx variable from the WinDom configuration file set to FALSE forces mt_FselInput() to not use the FSLX extension.

Example
int CallFsel ( name) {
  static char path[255]=""; // First usage : current directory
  char fullname[255]="";
     
  if( FselInput( path, name, "Load a file", "", NULL, NULL)) {
    strpcy( completname, path);
    strcat( completname, name);
    strpcy( name, fullname); // return the full path
    return 1;
  } else 
    return 0;
}


Generated on Thu Jun 22 11:45:29 2006 for WinDom by  doxygen 1.4.6