Introduction to Maps

Maps are similar to Windows Dialogs, or HTML forms - they generally consist mainly of map fields, which can be used to edit or display data, and headings ("static" or "text" controls) that describe the map fields. Like dialogs and forms they may also contain "buttons" of various types, and images. Some types of maps may play a multi-media sound when they are displayed to alert the user to an error condition. Each control or field in a map has an associated field number. Field numbers are very important, as they are used for several different purposes:

Maps are much more general purpose than HTML forms or Windows dialogs - DP4 uses maps to display menus and popup windows (list boxes), and to format output to be written to files or printed. Maps are stored on a DP4 database, and maps for more than one language can be stored on the same database - allowing the same executable to be used for more than one language. Maps are keyed on the mapname, used to group a set of related maps together, the language code, and a map number. Programs usually refer to maps by their number within a mapset, though it is also possible to assign and use "handles" to allow multiple copies of the same map to be used simultanously. There is no built in facility to assign symbolic names to maps, though it is probably good practice to do this yourself, especially for maps that are used in several different source modules. Maps can also store context sensitive help for menus or dialogs. Maps are created using the Mapedit program. In 4.5xx it is also quite easy to create maps directly with a text editor - the best way to find out how to do this is to use MAPEDIT to print out a few maps in MAPPOST format.

C Functions

The two main functions for placing a map on screen are map_draw() and map_attach(). map_draw() tries to position maps in an empty part of the screen, usually underneath the last map. There are some rather complicated rules for how DP4 will clear or move other maps around to make room for a new map, depending on the flags passed to map_draw(), but usually you won't need to worry much about these.

You can attach one map to another with map_attach() to build up complex more displays.

To clear a map and all maps displayed after it, use map_clear_from().

map_clear_after() removes all the maps displayed after it, but not the map itself, and map_clear() (implemented as a macro based on map_change()) clears a map and its attached maps, but not other maps drawn after the map. You can also use map_change() to hide or reveal a map (amongst other things).

You can clear the whole screen with map_clear_all(), or by passing the CLEAR flag in the second parameter of map_draw(). You can use map_new_window() and map_old_window() to hide and restore all the maps on a screen. While the maps are hidden like this,

Data can be displayed in fields on the map using the show_x() functions, though usually you will only need to call this functions for "output only" fields.

Map Types

Maps are drawn on the screen are split into types, such as menu maps, data maps, remark maps, error maps, help maps and so on, several of which have their own function that can be used to display them: map_menu(), map_datamap(), and map_remark(). High level functions that display maps use one of these functions. This is intended to help you build a consistent interface, using uniformi colours and display positions: all the functions are supplied in source code form, allowing you to tailor the functions to meet your own needs, either by replacing them, or by setting the flags they use to display maps (in global variables menu_flags, data_flags, and rmk_flags

and controlling their positioning via map_new_position()