Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

forms.c File Reference

Forms interface. More...

#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "buf.h"
#include "forms.h"

Include dependency graph for forms.c:

Include dependency graph

Go to the source code of this file.

Defines

#define LONGEST_KEY   256
 Longest field name supported.


Functions

void frm_clear (Form *frm)
 Clear the title and all fields from the form.

void frm_define_field (Form *frm, char *nm, char *val)
 Add a field, and set the value, tip and help text.

void frm_print (Form *frm)
 Print a form to stdout for debugging.

FormFieldfld_add (FormField *fld, char *nm)
 Add a new field with the given name.

int fld_count (FormField *fld)
 Get the number of form fields.

FormFieldfld_free (FormField *fld)
 Free the specified field and return NULL.

FormFieldfld_get (FormField *fld, int i)
 Get the 'i'th field in the list rooted at 'fld'.

char * fld_get_help (FormField *fld)
 Retrieve the help text for the subject field.

FieldRelevance fld_get_relevance (FormField *fld)
 Get the relevance of this field.

char * fld_get_tip (FormField *fld)
 Get the tip text for the specified field.

FieldType fld_get_type (FormField *fld)
 Get the field type.

char * fld_get_name (FormField *fld)
 Get the name of the specified field.

char * fld_get_value (FormField *fld)
 Get the value text from the field.

char * fld_get_value_by_name (FormField *fld, char *nm)
 Search the field list rooted at 'fld', and return the value of the field with the name 'nm'.

FormFieldfld_new (char *nm)
 Allocate a new field named 'nm'.

FormFieldfld_next (FormField *fld)
 Return the next field in the list after 'fld'.

void fld_set_type (FormField *fld, FieldType typ)
 Set the type of the field.

void fld_set_help (FormField *fld, char *hlp)
 Set the help text for the field.

void fld_set_relevance (FormField *fld, FieldRelevance r)
 Set the relevance of the field.

void fld_set_tip (FormField *fld, char *txt)
 Set the tip text for the field.

FormFieldfld_set_name (FormField *fld, char *nm)
 Set the name of the field.

void fld_set_value (FormField *fld, char *val)
 Set the value of the field.

char * fld_set_value_by_name (FormField *fld, char *nm, char *val)
 Search the field list rooted at 'fld', and set the value of the field(s) with the name 'nm' to 'val'.

FormFieldfrm_add_field (Form *frm, char *nm, char *val)
 Add a new field to the form.

Formfrm_clone (Form *frm)
 Clone an existing form.

void frm_copy (Form *dst, Form *src)
 Copies one form to another.

ABuffrm_check_fields (Form *frm)
 Creates a pane from a form.

void frm_clear_fields (Form *frm)
 Clears the values of all fields, but doesn't free them.

Formfrm_free (Form *f)
 Free the specified form.

FormFieldfrm_get_field (Form *frm, int n)
 Get the 'n'th field from the form.

FieldType frm_get_field_type (Form *frm, int n)
 Get the type of the 'n'th field from the form.

int frm_get_field_count (Form *frm)
 Get the number of fields in the form.

char * frm_get_field_name (Form *frm, int i)
 Get the name of the 'i'th field on the form.

FormFieldfld_get_last (FormField *fld)
 Find the last field in the list rooted at 'fld'.

char * frm_get_title (Form *frm)
 Get the form title.

char * frm_get_value (Form *frm, int i)
 Get the value of the 'i'th field on the form.

char * frm_get_value_by_name (Form *frm, char *nm)
 Get the value of the form field with the name 'nm'.

FormFieldfrm_last_field (Form *frm)
 Get the last field on the form.

int frm_load_file (Form *frm, char *fn)
 Load a Form file from disk.

int frm_match (Form *frm1, Form *frm2)
 Compare two forms to see if they are identical.

Formfrm_new (Form *frm)
 Allocate a new form.

int frm_save_file (Form *frm, char *fn)
 Save the Form to a file.

void frm_set_field_type (Form *frm, int id, int typ)
 Set the type of the 'i'th field on the form.

Formfrm_set_title (Form *f, char *ttl)
 Set the title of the form.

void frm_set_value_by_name (Form *frm, char *nm, char *val)
 Set the value of the form field(s) named 'nm'.


Detailed Description

Forms interface.

Author:
Lionel ULMER , Darryl Luff
Each form can have a title and a number of fields. Each field has a name and a value. This is used in GtkSQL as the interface for database drivers to popup login dialogs etc. The driver creates a Form object that defines the fileds for the login dialog. GtkSQL then turns this into a GTK dialog.
FormField's
The FormField type has built-in support for a linked list. Some field functions work on a single field, others work on a field list. All functions take a FormField pointer as the first parameter. The ones that work on a list normally take an integer index as a second parameter. This selects the index number in the list of the field you want to work on. So given a function like fld_xyz(FormField *fld, int n), the call frm_xyz(fld, 5) would operate on the sixth element of the field list based at 'fld'. The index number is zero-based, so '0' refers to the first field in the list, '1' to the second, etc.

Definition in file forms.c.


Function Documentation

void frm_clear Form   frm
 

Clear the title and all fields from the form.

Internal function.

Parameters:
frm  The form to operate on.

Definition at line 422 of file forms.c.

References Form::fld, fld_free(), and frm_set_title().

Referenced by frm_copy(), and frm_load_file().

Form* frm_clone Form   frm
 

Clone an existing form.

All fields and field values are copied to the new form.

Parameters:
frm  The form to clone.
Returns:
The newly allocated form. If any field cannot be copied, NULL is returned.

Definition at line 342 of file forms.c.

References frm_new().

void frm_copy Form   dst,
Form   src
 

Copies one form to another.

Parameters:
dst  The destination form.
src  The source form.

Definition at line 356 of file forms.c.

References fld_get_name(), fld_get_value_by_name(), frm_add_field(), frm_clear(), frm_get_field(), frm_get_field_count(), frm_get_title(), and frm_set_title().

Referenced by frm_new().

void frm_define_field Form   frm,
char *    nm,
char *    val
 

Add a field, and set the value, tip and help text.

Parameters:
frm  The form to operate on.
nm  The field name.
val  The field value, tip text(optional) and help text (optional). These are in the format: value[|hint[|help]].

Definition at line 739 of file forms.c.

References fld_set_help(), fld_set_tip(), and frm_add_field().

Referenced by frm_load_file().

int frm_load_file Form   frm,
char *    fn
 

Load a Form file from disk.

Parameters:
frm  The form to load to.
fn  Filename to load. If NULL, returns without doing anything, otherwise clears the current form fields and attempts to load the file. If there's an error, sets the "frm_error" field to an error string.
Returns:
Zero on success, non-zero on error.

Definition at line 552 of file forms.c.

References frm_clear(), frm_define_field(), FRM_ERROR, frm_print(), frm_set_value_by_name(), and LONGEST_KEY.

void frm_print Form   frm
 

Print a form to stdout for debugging.

Parameters:
frm  The form to print.

Definition at line 636 of file forms.c.

References Form::fld, fld_get_help(), fld_get_name(), fld_get_tip(), fld_get_value(), and frm_get_title().

Referenced by frm_load_file().


Generated on Sun May 9 19:19:22 2004 for GtkSQL by doxygen1.2.18