Filespec for layout files

A layout file consists of a header and a body. It is a binairy file that has the .cul extension.

Header
======
1) 4-byte general KFLOG file token: @KFL
#define KFLOG_FILE_MAGIC    0x404b464c

2) 1-byte filetype token: L
#define FILETYPE 0x4c

3) 1-byte version token
#define FILEVERSION 0x01

4) Name of layout (QString) in Cumulus ShortString format:
If isNull():
  0xffffffff (Q_UINT32)
Else:
  length (Q_UINT32)
  data in utf8

Example:

A fileheader for fileversion 1 and name "Default Cruising" (in hexidecimals)

40 4b 46 4c 4c 01 0f 44 65 66 61 75 6c 74 20 43
72 69 73 69 6e 67


Body
====
The body consists of a single elementtype definition. Because elements can be nested, a whole layout can be described this way. Layouts consisting of more than one element will start with a layout, type 01 or 02 for horizontal and vertical layouts respectively.
The datastructure for "normal" widgets is described in the section "General element description". Elements with a different datastructure are discussed first.

Each elementtype definition starts with an element ID. The list of available element ID's is defined in interfaceelements.h.


LayoutBoxes
===========
LayoutBoxes are the base-elements of the Layout we are describing. They come in two flavors: Horizontal (element ID 0x01) and Vertical (element ID 0x02). The rest is the same for them both.

The second byte (the element ID being the first) hold the number of elements in this layout. The third and next bytes define each element consecutively. The layout is filled top top bottom and left to right.


Lines
=====
Lines can be used to visually separate rows and boxes. A line in a vertical layout will automaticly be horizontal, and vise versa. A line has elementID 0x03. After the elementID, there is one byte reserved for flags (not used yet). This byte is set to 0, but other values are ignored.


Map
===
The map element has element ID 0x04. It is usually the main element in a layout, and it takes up all remaining space. The map can accomodate up to 9 other widgets. This can be used to draw, say, a windarrow on the map itself. For this purpose, the map is devided into a 3x3 grid, numbered as follows:
1 2 3
4 5 6
7 8 9
After the elementID, there is one byte reserved for flags (currently not used and set to 0), after which the elemenents for each of the 9 places in the grid are defined. A 0x00 is used for an empty box in the grid. All elements within the map are drawn with a transparent background. So, a map element without other elements would look like this:

04 00 00 00 00 00 00 00 00 00 00


Thermal center and thermal stats
================================
These elements don't exist yet, so they are not used.


General element description
===========================
Each element description starts with it's element ID. The next byte consists of flags (definition below). After the flags, there is one byte for the fontsize of the label and one for the fontsize of the value. A complete definition therefore consists of 4 bytes.

The flags are a bitwise OR of the following values, defined as:
0x01 display label
0x02 value is bold
0x04 reserved
0x08 reserved
0x10 reserved
0x20 reserved
0x40 reserved
0x80 reserved

Example:
0c 01 08 0c
This is a widget displaying the distance to the selected waypoint with a label, with a labelsize of 8pt and a value size of 12pt (not bold).


Example:

40 4b 46 4c 4c 01 0f 44 65 66 61 75 6c 74 20 43
header            name of layout
72 69 73 69 6e 67 02 03 01 04 15 01 06 0c 0e 01
                  vertical layout with 3 elements
                        horizontal layout with 4 elements
                              Heading     Bearing
06 0c 0d 01 06 0c 21 01 06 0c 03 00 04 00 00 3b
      Distance    Gnd Speed   Line  Map      Windarrow
00 00 00 00 00 00 00 00 00 00

This puts a layout on screen with one row of data (all with labels and in 6/12 fontsizes), then a line, and then beneath that the map. Beneath each line is indicated what starts where in the example file (only the hexadecimal lines are in the file).
