SIMPOL Documentation

Chapter 23. Using Data-Aware Forms in SIMPOL

This chapter will describe the general design of the dataform1 family of types, as well as some techniques for successful use of the set of types.

[Note]Note

This chapter will not make much sense unless you have already read and feel comfortable with the earlier chapters covering variables and grammar.

The Design of dataform1

The goal of the design of dataform1 was to create a set of wrapper types for the wxWidgets-based form controls in order to provide a multi-page, data-aware form system similar in scope to that provided by Superbase. To do this required managing quite a bit more information than is need to just provide the wxform family of types. To work effectively, the data-aware forms would need to keep track of the data sources used, the database tables used, the current master record for the form, and for efficiency of implementation also the bitmaps used (there is no point in loading a large logo bitmap used on every page once for each page, it is more efficient to load it once and use it on the various pages). Also, the data-aware form would be a container of pages, where each would contain a wxform object to actually host the controls. Also, each control would need to be enhanced to allow it to store the information necessary to connect it to a field in the database. To finish it off, the functions would need to exist to carry out the required actions: selecting records, reading data from the record and updating the various controls, reading data from the controls as they are updated by the user and writing that back to the record, locking in both single and multi-user modes, and numerous things that might not be obvious in the first instance.

There are several different kinds of data types used in the dataform1 family. One is the wrappers of the controls, another the wrappers for the graphics, and finally additional internal and exported types used for the actual implementation of the public interface. Let's have a look at them here, starting with the graphics.

Graphical Elements

The graphical elements in the dataform1 family are fairly thin wrappers around the wxformgraphic controls. What they add are the necessary components to link them together and additional information, such as the support for named colors (colors that are not fixed but that are based on the operating system settings for that user, and therefore use symbolic names such as "Button Face" or "Window Text".

  • dataform1graphicline

  • dataform1graphicrectangle

  • dataform1graphictriangle

  • dataform1graphicarc

  • dataform1graphicellipse

All of the data types named above have a common type tag, called dataform1graphic. All the graphical elements are located in a dring property (doubly-linked ring) called graphics. Both the dataform1 and the dataform1page have a property with this name. The form contains a ring of all graphics from all pages. The page ring contains the graphics from that page.

Form Controls

Unlike the graphical elements, the form controls often contain quite a few more properties and methods than the original wxformcontrol objects. This is because of the requirement to store information about their binding to a database field and table, the required display format, whether the control is part of a detail block (a set of controls displayed in rows where each row represents a record in a related database table), and if so in which row it is. Some controls require even more information. The dataform1list and dataform1combo controls allow quite a bit of flexibility in determining where the data comes from (including showing one value in the list but assigning another to the control). The dataform1datagrid type provides a grid that has columns associated with fields from a table, and it can be linked like a detail block to the master table of the form. Here is the list of form controls:

  • dataform1bitmap

  • dataform1bitmapbutton

  • dataform1button

  • dataform1combo

  • dataform1checkbox

  • dataform1datagrid

  • dataform1edittext

  • dataform1grid

  • dataform1option

  • dataform1list

  • dataform1scrollbar

  • dataform1text

The form control types are all type tagged dataform1control. They are located in a dring property (doubly-linked ring) called controls. Both the dataform1 and the dataform1page have a controls property. The form contains a ring of all controls from all pages. The page ring contains the controls from that page.

Utility Types

There are a number of important utility types that play various roles in making the whole package work. Here is a list of them:

  • dataform1bitmapsource

  • dataform1controlsource

  • dataform1datagridcolumn

  • dataform1datasource

  • dataform1detailblock

  • dataform1link

  • dataform1optiongroup

  • dataform1page

  • dataform1record

  • dataform1table

The dataform1bitmapsource type was created to store the original location of a bitmap that is loaded into a form. The reason for it is simple, without that information it would be impossible to save the form later and to know what value to store in the output file for the location of the image. For each image used on a form, a bitmap source object is created and is then associated with the resulting bitmap so that it can be found later.

The same is true of the dataform1controlsource type. This stores the actual field reference associated with the control, plus the dataform1table object, and optionally a display format. This information is necessary in order to read from and write to the database field and to correctly display and interpret the data in the control itself.

A dataform1datagridcolumn is similar in that it also stores information about its control source, it may also store a reference to a dataform1link object if the column is not from the master table of the grid.

The dataform1datasource stores information about the data source, either its file name and path, or its IP address and port number. It also contains a list of the database tables that are part of the data source.

One of the most complex objects is the dataform1detailblock, which is a special type of container that provides a replicated group of controls, in rows and columns, that can be linked to the master table of a form. It can work in two different ways: either as a block of rows of data (records) that are related to the master record of the form, or else as a completely independent block of data, the content of which is governed by a query. In both cases, the data is read only (from the user's perspective). There are features in the design that allow for retrieving the database record for a given row, for updating that record or even replacing it, and also for removing the row from the result set. It also contains methods for scrolling the block up or down, a page or a row at a time. The detail block is currently not optimized for reducing the records read, so if the link results in reading 100,000 records, then it will do so, delaying everything until it is done. As such, it is important to choose the links and data design wisely.

The dataform1link contains the information that links two tables together, and it also stores the record sets that are read as a result of using the link to read records.

The dataform1optiongroup acts as the management object for a group of dataform1option controls. In this special case, the data source is associated with the group object, and not with the controls. It also ensures that if one option button in the group is selected, that the others are deselected.

The dataform1record contains properties that assist it in knowing if the record has been changed, but not yet saved, and provides a place to define events such as onsaverecord or ondeleterecord.

Similarly, the dataform1table object stores information about the current state of the table, such as the current index, an array of field information including display formats, and events like onnewrecord, onsaverecord, and ondeleterecord.

The dataform1page is the container of all items specific to a single page of the form.