ELEMENT_STRING

Use ELEMENT_STRING to display text on a gauge. ELEMENT_STRING is particularly useful when you have a string that changes as the gauge is updated; the string can be automatically updated by setting up the MODULE_VAR elements and using callback functions. Using ELEMENT_STRING, you can specify the font name, weight, background and foreground colors of the text. You can also specify a highlight text color to use when the string is selected.

typedef struct ELEMENT_STRING

{

HEADER;

MODULE_VARsource_var[3];

FLOAT64save_var[3];

PMODULE_VAR_CB source_var_cb[3];

PFN_FLOAT64source_fn;

PCHARstring;

PCHARstring_old;

PIXPOINTimg_size;

PIMAGEstring_data;

PIMAGEsave_buffer;

COLORREFfg_color;

COLORREFbg_color;

COLORREFhilite_color;

HDChdc;

HFONThfont;

HFONThfont_old;

HBITMAPhbmp;

HBITMAPhbmp_old;

HBRUSHhbrush;

HBRUSHhbrush_old;

charfont_name[32];

longfont_weight;

UINT8font_charset;

UINT32draw_text_flags;

UINT16max_string_length;

UINT16char_width;

SINT16sel_str;

SINT16sel_end;

PSEQ_RECseq;

intsave_global_seq;

} ELEMENT_STRING, *PELEMENT_STRING, **PPELEMENT_STRING;

ELEMENT_STRING uses the following members:

Member Description
HEADER Discussed in detail in the topic Using Drawing Elements.
source_var[3] Token values to update the string. You must provide at least one callback function to update the string data member.
save_var[3] Used internally by the Panel system; do not use. Must be set to 0.
source_var_cb[3] Callback function used to update the display string. The callback function updates the string member variable. The string member variable is the character string data that's used to render this drawing element.
string Character string data to render the drawing element. Update this string to change the text displayed.
string_old Used internally by the Panel system: do not use. Must be set to 0.
img_size Width and height of the bounding rectangle area updated by the string. The font size used by ELEMENT_STRING is calculated using img_size and max_string_length. The optimal font size is also calculated using this information.
string_data Used internally by the Panel system; do not use. Must be set to 0.
save_buffer Used internally by the Panel system; do not use. Must be set to 0.
fg_color RGB text color.
bg_color RGB background color.
hilite_color RGB highlight color.
hdc Used internally by the Panel system; do not use. Must be set to 0.
hfont Used internally by the Panel system; do not use. Must be set to 0.
hfont_old Used internally by the Panel system; do not use. Must be set to 0.
hbmp Used internally by the Panel system; do not use. Must be set to 0.
hbmp_old Used internally by the Panel system; do not use. Must be set to 0.
hbrush Used internally by the Panel system; do not use. Must be set to 0.
hbrush_old Used internally by the Panel system; do not use. Must be set to 0.
font_name[32] Name of the font used to render the string.
font_weight Font weight used to create the Windows font used by the ELEMENT_STRING. A list of valid values can be found in the CreateFont Win32 API.
font_charset Character set used to create the Windows font used by the ELEMENT_STRING. A list of valid values can be found in the CreateFont Win32 API.
draw_text_flags Not supported at this time. Must be set to 0.
max_string_length Number of characters to use in the string. The font size used by the ELEMENT_STRING is calculated using img_size and max_string_length members of this structure. The optimal font size is calculated using this information.
char_width Used internally by the Panel system; do not use. Must be set to 0.
sel_str First character to select. Set both sel_str and sel_end to -1 to deselect a string.
sel_end Last character to select. Set both sel_str and sel_end to -1 to deselect a string.
seq Pointer to a SEQ_REC array structure. Can be NULL or a pointer to an array of SELECT states used to manage the highlighting of the string.
save_global_seq Used internally by the Panel system; do not use. Must be set to 0.

You can use the SEQ_REC table to automatically select a string on certain KEY_EVENTs. Flight Simulator 98 allows the user to select certain gauge elements by using different keyboard combinations. The SEQ_REC structure sets up the relationship between the current selection state and the characters that can be selected for that state. The following code example shows the SEQ_REC structure definition:

typedef struct SEQ_REC

{

int seq_id;

int sel_str;

int sel_end;

} SEQ_REC, *PSEQ_REC, **PPSEQ_REC;

SEQ_REQ uses the following members:

Member Description
seq_id Specifies the selection state.
sel_str Specifies the first character to select when the Flight Simulator 98 selection state is equal to the seq_id state.
sel_end Specifies the last character to select.

To mark the end of the array you must add one blank record that sets seq_id, sel_str, and sel_end to SELECT_NONE, 0, and 0, respectively. The following code example shows a sample SEQ_REC definition:

SEQ_REC seq_com[]  =

{

{SELECT_COM_WHOLE, 0, 2},

{SELECT_COM_FRACTION, 4, 5},

{SELECT_NONE, 0, 0}

};

The following table includes the gauge selection states available in Flight Simulator 98.

SEQ Record ID Description
SELECT_NONE No selection
SELECT_1 Unused
SELECT_ZOOM Zoom
SELECT_MAGNETO Magneto
SELECT_COM_WHOLE Communication frequency, whole number
SELECT_COM_FRACTION Communication frequency, fractional number
SELECT_NAV1_WHOLE Navigation radio frequency #1, whole number
SELECT_NAV1_FRACTION Navigation radio frequency #1, fractional number
SELECT_NAV2_WHOLE Navigation radio frequency #2, whole number
SELECT_NAV2_FRACTION Navigation radio frequency #2, fractional number
SELECT_XPNDR_1000 Transponder frequency fourth digit
SELECT_XPNDR_0100 Transponder frequency third digit
SELECT_XPNDR_0010 Transponder frequency second digit
SELECT_XPNDR_0001 Transponder frequency first digit
SELECT_VOR1 Toggle to VOR1 selection
SELECT_VOR2 Toggle to VOR2 selection
SELECT_ENGINE Toggle engine selection
SELECT_DME1 Toggle to DME1 selection
SELECT_DME2 Toggle to DME2 selection
SELECT_ADF_100 ADF frequency third digit
SELECT_ADF_010 ADF frequency second digit
SELECT_ADF_001 ADF frequency first digit
SELECT_EGT_BUG EGT bug
SELECT_SIM_RATE Simulation rate
SELECT_CLOCK_HOURS Clock hours
SELECT_CLOCK_MINUTES Clock minutes
SELECT_CLOCK_SECONDS Clock seconds
SELECT_STANDBY_ COM_WHOLE Standby communication frequency, whole number. No standby frequencies are implemented.
SELECT_STANDBY_ COM_FRACTION Standby communication frequency, fractional number. No standby frequencies are implemented.
SELECT_STANDBY_ NAV_WHOLE Standby navigation radio frequency, whole number. No standby frequencies are implemented.
SELECT_STANDBY_NAV_ FRACTION Standby navigation radio frequency, fractional number. No standby frequencies are implemented.
SELECT_STANDBY_ ADF_100 Standby ADF frequency, third digit. No standby frequencies are implemented.
SELECT_STANDBY_ ADF_010 Standby ADF frequency, second digit. No standby frequencies are implemented.
SELECT_STANDBY_ ADF_001 Standby ADF frequency, first digit. No standby frequencies are implemented.