Dialog Boxes

FUNCTIONS

  #define YES    1
  #define NO    -1
  #define CANCEL 0

  void  apperror(char *errstr);

  void  askok(char *info);
  int   askokcancel(char *question);
  int   askyesno(char *question);
  int   askyesnocancel(char *question);

  char *askstring(char *title, char *default_string);
  char *askfilename(char *title, char *default_name);
  char *askfilesave(char *title, char *default_name);

NOTES

The apperror function displays the string errstr in a modal message window before terminating the application using exitapp.

The askok function displays the info string in a modal window with an "OK" button which the user can select to dismiss the window.

The askokcancel function displays a modal window with a question, and returns YES if the user clicks the "OK" button, and CANCEL if the "Cancel" button is used to dismiss the window.

The askyesno function displays the question string in a modal window with two buttons, "Yes" and "No". The user may select either one to dismiss the window. If the user selects "Yes", the function returns YES; if the user selects "No" the function returns NO. The askyesnocancel function operates the same way except it has another button "Cancel" which, if selected, will cause the function to return CANCEL.

The askstring function displays the title string in a modal window which also has a text field into which the user can type a string. This static string is returned to the programmer by the function. The text field is initially loaded with the default_string. If the user selects the "Cancel" button in this window, the function will return NULL.

The askfilename function displays a modal window which can be used to select a file from the file system. The title string is displayed somewhere to indicate to the user what sort of file to select. The default_name string is loaded into the filename text field if this is available. The function returns the complete filename as a string, or NULL if the user cancels the operation.

The askfilesave function is similar to askfilename, except that it is used when saving a file, and the window will appear slightly different to reflect this fact.