Gauge API


Overview

This is the reference sheet for gauge API contents.


Mixed Mode Sample

An example mixed mode gauge that uses gauges.h can be found in <Prepar3D SDK Path>\Panels and User Interface\Panels\Custom Nav Draw.


API Reference

Name Type Description
aircraft_varget Function Retrieves the value of an aircraft simulation variable.
check_named_variable Function Retrieves the ID number of a named local variable, if it exists.
drawing element manipulators Macros Collection of macros that can be used to manipulate a drawing element.
drawing element header Struct Header for drawing element structures.
drawing element structures structs Defines drawing element data.
DRAW FLAGS Enum Combine with | operator to adjust drawing elements.
element_list_erase Function Used before redrawing a gauge.
element_list_generate Function Regenerates a the effects mask and images for a gauge.
element_list_initialize Function Prepares a gauge before being redrawn.
element_list_install Function Used to install a gauge during initialization of a panel.
element_list_kill Function Used to remove a gauge completely, for example when changing user aircraft.
element_list_plot Function Redraws a gauge.
element_list_query Function Used to register the failure conditions for a gauge.
element_list_update Function Calculates new values for each gauge element.
element_use_color Function Selects the text color for string elements.
execute_calculator_code Function Evaluates a coded calculator string.
FAILURE ACTION Enum Gauge element reactions.
FAILURE KEY Enum Specifiy types of system failure.
FAILURE RECORD Struct Identify how gauges react when system fails.
format_calculator_string Function Evaluates a formatted calculator string.
gauge_calculator_code_precompile Function Compresses a calculator string into a more efficient internal format.
GAUGE HEADER FS700 Macro Creates the GAUGEHDR structure and an exported variable, gauge_header.
get_aircraft_var_enum Function Retrieves the enum value for a simulation variable, given the string name of that variable.
get_event_count Function Returns the number of event tokens. The event count can be used to iteratively call get_event_id_by_index to retrieve event id's.
get_event_description Function Returns the description for the given key event id as seen in the Control Settings user interface.
get_event_id_by_index Function Returns the event id for the associated event index. The event count can be obtained from the get_event_count function.
get_event_token_string Function Returns the token string for the given key event id.
get_gauge_flags Function Retrieves the flags set on a gauge.
get_name_of_named_variable Function Retrieves the name of a local variable, given an ID number.
get_named_variable_typed_value Function Retrieves the value of a named local variable, in the specified units.
get_named_variable_value Function Retrieves the value of a local variable, given and ID.
get_units_enum Function Retrieves the enum value for units, given the string name of the units.
IAircraftCCallback Class An abstract base class that can be overridden. Implementors should override the function CreateGaugeCCallback().
IFSXPanelCCallback Class
IGaugeCCallback Class An abstract base class that can be overridden. Implementors should override the function CreateGaugeCDrawable(SINT32 id, const IGaugeCDrawableCreateParameters* pParameters).
IGaugeCDrawable Class Handles drawing the parameters entered into IGaugeCDrawableCreateParameters.
IGaugeCDrawableCreateParameters Class Passes parameters into Prepar3D.
IGaugeCDrawableDrawParameters Class Gets the parameters passed into Prepar3D from the IGaugeCDrawableCreateParameters class.
initialize_var Function Initializes a token variable.
initialize_var_by_name Function Initializes a MODULE_VAR structure, given the name of a token variable.
IPanelCCallback Class An abstract base class that can be overridden. Implementors should override the functions CreateAircraftCallback(UINT32 ContainerId) as well as GetPropertyTable.
ISerializableGaugeCCallback Class
is_master Function Returns true if the aircraft is the master aircraft of a shared cockpit.
is_panel_window_visible_ident Function Returns true if the specified panel window is visible.
lookup_var Function Updates the contents of a token variable.
MAKE ICON Macro Creates Icon drawing element.
MAKE MOVING Macro Creates Moving drawing element.
MAKE NEEDLE Macro Creates Needle drawing element.
MAKE SLIDER Macro Creates Slider drawing element.
MAKE_SPRITE Macro Creates Sprite drawing element.
MAKE STATIC Macro Creates Static drawing element.
MAKE_STRING Macro Creates String drawing element.
MODULE VAR Struct Infomation on how to render element.
MOUSE BEGIN Macro Begins the definition of a rectangle.
MOUSE CHILD EVENT Macro Creates rectable within MOUSE_BEGIN rectangle.
MOUSE CHILD FUNCT Macro Creates rectable within MOUSE_BEGIN rectangle.
mouse_list_install Function Creates the mouse rectangles for a gauge.
mouse_list_register Function Registers the mouse windows.
mouse_list_unregister Function Unregisters the mouse windows.
MOUSE PARENT Macro Creates rectable within MOUSE_BEGIN rectangle. Includes MOUSE_PARENT_BEGIN and MOUSE_PARENT END.
MOUSE PARENT BEGIN Macro Creates rectable within MOUSE_BEGIN rectangle.
MOUSERECT Macro Retrieves the value of an aircraft simulation variable.
NONLINEARITY Struct Specifies non-linear behavior.
panel_get_aircraft_c_callback Function Retrieves a pointer to the aircraft callback function.
panel_get_registered_c_callback Function Retrieves a pointer to the registered callback function.
panel_register_c_callback Function Retrieves the resource string, given an ID.
panel_resource_string_get Function Retrieves the resource string, given an ID.
panel_window_close_ident Function Closes the specified panel window.
panel_window_open_ident Function Displays the specified panel window.
panel_window_toggle Function Toggles the visible state of a panel window.
panel_window_toggle_hud_color Function Changes the global HUD color to the next in the list.
panel_window_toggle_hud_units Function Toggles the HUD units between metric and imperial.
panel_window_toggle_menu_id Function Selects a menu item given an ID.
process_shared_event_out Function Sends data to the other aircraft, in a multiplayer shared cockpit scenario.
query_pdk Function Gets a pointer to the IPdk interface for querying additional SDK services.
radio_stack_autoclose Function Closes the radio stack, if it was opened with radio_stack_popup.
radio_stack_popup Function Displays the radio stack
register_key_event_handler Function Registers a key event callback function.
register_named_variable Function Registers a local variable name.
register_var_by_name Function Registers a variable from another gauge, for use by this gauge.
send_key_event Function Transmits a WM_COMMAND application event.
SEQ REC Struct Select a string automatically on certain KEY_EVENTs.
set_gauge_flags Function Used to specify the flags for a gauge.
set_named_variable_typed_value Function Specifies a local variable should be set to the given value with the given units.
set_named_variable_value Function Sets a local variable to a given value.
set_named_variable_value_sync Function Syncs a specified named variable from a shared cockpit.
set_named_variable_sync_enabled Function Enables a specified named variable to sync from a shared cockpit.
string element manipulators Macros Unregisters a named variable from another gauge, and frees up the memory used.
tooltip_units_getset Function Specifies or retrieves the tooltip units (metric or US).
trigger_key_event Function Initiates the action of a key event.
unregister_all_named_vars Function Unregisters all token variables, and frees up the memory used.
unregister_key_event_handler Function Unregisters the key event handler.
unregister_var_by_name Function Unregisters a named variable from another gauge, and frees up the memory used.
UNIVERSAL VAR Variable Token variable return.

aircraft_varget

The aircraft_varget function retrieves the value of an aircraft simulation variable.

Syntax

FLOAT64 aircraft_varget(
  ENUM  simvar,
  ENUM  units,
  SINT32  index );

Parameters

simvar
[in]  Specifies a simulation variable enum value. Use get_aircraft_var_enum to retrieve the enum value from a string.
 
units
[in]  Specifies the units enum value the returned value should have. Use get_units_enum to retrieve the enum value from a string.
index
[in]  Specifies an index number, which is required for some engine and communication data. Refer to the Simulation Variables document for details.

Return Values

The function returns the value in a FLOAT64. If the simulation variable is not found, zero will be returned.

Example

See Cabin_Comfort.cpp for an example of the use of this function, and refer to Creating a Gauge using XML and C++ for a description of this sample

Remarks

None.

See Also


check_named_variable

The check_named_variable function retrieves the ID number of a named local variable, if it exists.

Syntax

ID check_named_variable(
  PCSTRINGZ  name );

Parameters

name
[in]  Specifies the variable name.

Return Values

The function returns an ID number if the variables exists, or -1 if it does not.

Remarks

Local variable names are case-insensitive.

See Also


element_list_erase

The element_list_erase function is used before redrawing a gauge.

Syntax

void element_list_erase(
  PELEMENT_HEADER  element );

Parameters

element
[in]  A pointer to the element header.

Return Values

This function does not return a value.

Remarks

It is not necessary to call this function if the redrawing of the gauge is handled by element_list_plot.

See Also


element_list_generate

The element_list_generate function is regenerates a the effects mask and images for a gauge.

Syntax

void element_list_generate(
  PELEMENT_HEADER  element,
  GENERATE_PHASE  phase );

Parameters

element
[in]  A pointer to the element header.
 
phase
[in]  Unused, enter zero.

Return Values

This function does not return a value.

Remarks

See the remarks for element_list_plot.

See Also


element_list_initialize

The element_list_initialize function prepares a gauge before being redrawn.

Syntax

void element_list_initialize(
  PELEMENT_HEADER  element );

Parameters

element
[in]  A pointer to the element header.

Return Values

This function does not return a value.

Remarks

See the remarks for element_list_plot.

See Also


element_list_install

The element_list_install function is used to install a gauge during initialization of a panel.

Syntax

void element_list_install(
  PELEMENT_HEADER  element,
  PVOID  resource_file_handle );

Parameters

element
[in]  A pointer to the element header.
 
resource_file_handle
[in]  Specifies the resource file handle.

Return Values

This function does not return a value.

Remarks

Use this function before calling any of the other element_list functions. A gauge is defined by an element list, however the macros used to create gauges described in the tutorial mean that in many cases these functions do not need to be called directly.

See Also


element_list_kill

The element_list_kill function is used to remove a gauge completely, for example when changing user aircraft.

Syntax

void element_list_kill(
  PELEMENT_HEADER  element );

Parameters

element
[in]  A pointer to the element header.

Return Values

This function does not return a value.

Remarks

None.

See Also


element_list_plot

The element_list_plot function redraws a gauge.

Syntax

void element_list_plot(
  PELEMENT_HEADER  element );

Parameters

element
[in]  A pointer to the element header.

Return Values

This function does not return a value.

Remarks

Before calling this function, each and every time, call the following functions in this order:

  1. element_list_initialize
  2. element_list_update
  3. element_list_generate
  4. element_list_plot

See Also


element_list_query

The element_list_query function used to register the failure conditions for a gauge.

Syntax

void element_list_query(
  PELEMENT_HEADER  element );

Parameters

element
[in]  A pointer to the element header.

Return Values

This function does not return a value.

Remarks

Call this function once, after element_list_install.

See Also


element_list_update

The element_list_update function calculates new values for each gauge element.

Syntax

void element_list_update(
  PELEMENT_HEADER  element );

Parameters

element
[in]  A pointer to the element header.

Return Values

This function does not return a value.

Remarks

See the remarks for element_list_plot.

See Also


element_use_color

The element_use_color function selects the text color for string elements.

Syntax

void element_use_color(
  PELEMENT_HEADER  element,
  BOOL  override,
  UINT32  color );

Parameters

element
[in]  A pointer to the element header.
override
[in]  Specifies if a color selected by the user should be overridden..
color
[in]   RGB value for the color.

Return Values

This function does not return a value.

Remarks

None.

See Also


execute_calculator_code

The execute_calculator_code function evaluates a coded calculator string.

Syntax

BOOL execute_calculator_code(
  PCSTRINGZ  code,
  FLOAT64*  fvalue,
  SINT32*  ivalue,
  PCSTRINGZ*  svalue );

Parameters

code
[in]  Specifies the calculator code.
fvalue
[out]  Pointer to a float. Returns the result of the calculation, if it is a floating point value.
ivalue
[out]  Pointer to an integer. Returns the result of the calculation, if it is an integer value.
svalue
[out]  Pointer to a string. Returns the result of the calculation, if it is a string.

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Example

FLOAT64 att_pitch = 0;
FLOAT64 att_bank = 0;
execute_calculator_code ("(A:ATTITUDE INDICATOR PITCH DEGREES:2, degrees)", &att_pitch, NULL, NULL);
execute_calculator_code ("(A:ATTITUDE INDICATOR BANK DEGREES:2, degrees)", &att_bank, NULL, NULL);

Remarks

None.

See Also


format_calculator_string

The format_calculator_string function evaluates a formatted calculator string.

Syntax

BOOL format_calculator_string(
  PSTRINGZ  result,
  UINT32  resultsize,
  PCSTRINGZ  format );

Parameters

result
[out]  Returns the formatted string.
resultsize
[out]  Returns the length of the formatted string.
format
[in]  Specifies the calculator string to format.

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Remarks

None.

See Also


gauge_calculator_code_precompile

The gauge_calculator_code_precompile function compresses a calculator string into a more efficient internal format.

Syntax

BOOL gauge_calculator_code_precompile(
  PCSTRINGZ*  pCompiled,
  UINT32*  pCompiledSize,
  PCSTRINGZ  source );

Parameters

pCompiled
[out]  Pointer to a string, which will contain the compiled string if the function call is successful.
pCompiledSize
[out]  Pointer to an integer, which will contain the length of the compiled string if the function call is successful.
source
[in]  Specifies the source calculator string. Refer to the Creating XML Gauges document for details on format strings.

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Remark

A precompiled (compressed) calculator string can be used as input to the execute_calculator_code and format_calculator_string functions.

See Also


get_aircraft_var_enum

The get_aircraft_var_enum function retrieves the enum value for a simulation variable, given the string name of that variable.

Syntax

ENUM get_aircraft_var_enum(
  PCSTRINGZ  simvar );

Parameters

simvar
[in]  Specifies the simulation variable name.

Return Values

The function returns the ENUM value of the simulation variable, or SIMVAR_NONE (-1) if the variable name is not found.

Example

See Cabin_Comfort.cpp for an example of the use of this function, and refer to Creating a Gauge using XML and C++ for a description of this sample

Remarks

Use this function before calling aircraft_varget.

See Also


get_event_count

The get_event_count returns the number of event tokens. The event count can be used to iteratively call get_event_id_by_index to retrieve event id's.

Syntax

UINT32 get_event_count();

Parameters

This function takes no parameters.

Return Values

The number of event tokens.

Example

None.

Remarks

None.

See Also



get_event_description

The get_event_description function returns the description for the given key event id as seen in the Control Settings user interface.

Syntax

PCSTRINGZ get_event_description(
  ID32  event_id );

Parameters

event_id
[in]  The id of the key event.

Return Values

The function returns the description of the given key event id. The function returns NULL if the description or key event id is not found.

Example

None.

Remarks

None.

See Also



get_event_id_by_index

The get_event_id_by_index returns the event id for the associated event index. The event count can be obtained from the get_event_count function.

Syntax

ID32 get_event_id_by_index(
  UINT32  uIndex );

Parameters

uIndex
[in]  The index of the event id being requested.

Return Values

The event id for the associated index. Valid event id's are greater than zero.

Example

None.

Remarks

None.

See Also



get_event_token_string

The get_event_token_string function returns the token string for the given key event id.

Syntax

PCSTRINGZ get_event_token_string(
  ID32  event_id );

Parameters

event_id
[in]  The id of the key event.

Return Values

The function returns the token string of the given key event id. The function returns NULL if the key event id is not found.

Example

None.

Remarks

None.

See Also



get_gauge_flags

The get_gauge_flags function is used to retrieve the flags set on a gauge.

Syntax

FLAGS32 get_gauge_flags(
  PCSTRINGZ  name );

Parameters

name
[in]  Specifies the name of the gauge.

Return Values

The function returns a FLAGS32 value containing the flags that are set. See set_gauge_flags for a table of gauge flags.

Remarks

None.

See Also


get_name_of_named_variable

The get_name_of_named_variable function retrieves the name of a local variable, given an ID number.

Syntax

PCSTRINGZ get_name_of_named_variable(
  ID  id );

Parameters

id
[in]  Specifies the ID of the variable.

Return Values

The function returns the name in a PCSTRINGZ, or NULL if the name is not found.

Remarks

None.

See Also


get_named_variable_typed_value

The get_named_variable_typed_value function retrieves the value of a named local variable, in the specified units.

Syntax

FLOAT64 get_named_variable_typed_value(
  ID  id,
  ENUM  units );

Parameters

id
[in]  Specifies the ID of the variable.
units
[in]  Specifies the enum value of the units required. Use get_units_enum to retrieve the enum value from a string.

Return Values

The function returns the value in a FLOAT64. Zero is returned if the variable ID is not found.

Remarks

None.

See Also


get_named_variable_value

The get_named_variable_value function retrieves the value of a local variable, given an ID.

Syntax

FLOAT64 get_named_variable_value(
  ID  id );

Parameters

id
[in]  Specifies the ID of the variable.

Return Values

The function returns the value in a FLOAT64. Zero is returned if the variable ID is not found.

Remarks

None.

See Also


get_units_enum

The get_units_enum function retrieves the enum value for units, given the string name of the units.

Syntax

ENUM get_units_enum(
  PCSTRINGZ  unitname );

Parameters

unitname
[in]  Specifies the string name of the units.

Return Values

The function returns the ENUM. value for the units, or UNITS_UNKNOWN (-1) if the string name is not found.

Example

See Cabin_Comfort.cpp for an example of the use of this function, and refer to Creating a Gauge using XML and C++ for a description of this sample

Remarks

Use this function before calling aircraft_varget.

See Also


initialize_var

The initialize_var function initializes a token variable.

Syntax

void initialize_var(
  PMODULE_VAR  module_var );

Parameters

module_var
[in]  Specifies a pointer to a MODULE_VAR structure, containing the token variable to initialize.

Return Values

This function does not return a value.

Example

MODULE_VAR gs_var = {VOR1_GS_FLAG};
void install_routine(HINSTANCE resource_file_handle)
{
initialize_var(&gs_var);
'Include other initialization code.
}

Remarks

Before a token variable can be used, you must initialize it with a call to this function.

See Also


initialize_var_by_name

The initialize_var_by_name function initializes a MODULE_VAR structure, given the name of a token variable.

Syntax

void initialize_var_by_name(
  PMODULE_VAR  module_var,
  PSTRINGZ  name );

Parameters

module_var
[in]  Specifies the address of the MODULE_VAR structure that will receive information about the variable.
name
[in] Specifies the name of the variable (the same name used in register_var_by_name).

Return Values

This function does not return a value.

Example

MODULE_VAR var;
initialize_var_by_name (&var, GPS_INFO_PANEL_VARIABLE_NAME);

Also see SDK.FlightMap.cpp for an example of the use of this function.

Remarks

None.

See Also


is_master

The is_master function returns true if the aircraft is the master aircraft of a shared cockpit.

Syntax

BOOL is_master();

Parameters

This function takes no parameters.

Return Values

If the aircraft is the master aircraft, it returns a non-zero value. If it is not, it returns zero.

Remarks

This function is used in the multiplayer scenario of a shared cockpit. One aircraft is the master and one is not. There is a maximum of two users in this scenario.

See Also


is_panel_window_visible_ident

The is_panel_window_visible_ident function returns true if the specified panel window is visible.

Syntax

BOOL is_panel_window_visible_ident(
  UINT32  panel_id );

Parameters

panel_id
[in]  Specifies the identification number of the window to query. The identification number is specified in the Panel.cfg file in the [WindowXX] section by the variable ident.

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Remarks

None.

See Also


lookup_var

The lookup_var function updates the contents of a token variable.

Syntax

void lookup_var(
  PMODULE_VAR  module_var );

Parameters

module_var
[in]  Pointer to a MODULE_VAR structure, containing the token variable to update.

Return Values

This function does not return a value.

Example

MODULE_VAR gs_var = {VOR1_GS_FLAG};
Void update_routine()
{
  lookup_var(&gs_var);
  if(gs_var.var_value.n == 0)
  {
    HIDE_IMAGE((&gs_slider));
    HIDE_IMAGE((&gs_background));
  }
  else
  {
    SHOW_IMAGE((&gs_slider));
    SHOW_IMAGE((&gs_background));
  }
'Include other update code
}

Remarks

Before using the contents of a module variable, you must call the lookup_var function.

See Also


mouse_list_install

The mouse_list_install function creates the mouse rectangles for a gauge.

Syntax

void mouse_list_install(
  PMOUSERECT  rect,
  PGAUGEHDR  gauge_header,
  PPIXPOINT  size );

Parameters

rect
[in, out]  Specifies a pointer to a list of MOUSERECT structures. The first rectangle in the list is the main box. The rectangles are scaled according to the settings in the gauge_header. The last rectangle structure in the list should have the type MOUSE_RECT_EOL.
gauge_header
[in]  Specifies a pointer to a gauge_header structure (defined in gauges.h).
size
[in]  Specifies a pointer to a PIXPOINT structure, which contains an x and y value, defining the size of the rectangle.

Return Values

This function does not return a value.

Remarks

Call mouse_list_register after setting up the mouse rectangles with this function. Note that the mouse rectangle creation macros can be used instead of these low level function calls.

See Also


mouse_list_register

The mouse_list_register function registers the mouse windows.

Syntax

void mouse_list_register(
  PMOUSERECT  rect,
  PGAUGEHDR  gauge_header );

Parameters

rect
[in]  Specifies a pointer to a MOUSERECT structure.
gauge_header
[in]  Specifies a pointer to a gauge_header structure (defined in gauges.h).

Return Values

This function does not return a value.

Remarks

None.

See Also


mouse_list_unregister

The mouse_list_unregister function unregisters the mouse windows.

Syntax

void mouse_list_unregister(
  PMOUSERECT  rect,
  PGAUGEHDR  gauge_header );

Parameters

rect
[in]  Specifies a pointer to a MOUSERECT structure.
gauge_header
[in]  Specifies a pointer to a gauge_header structure (defined in gauges.h).

Return Values

This function does not return a value.

Remarks

None.

See Also


panel_get_aircraft_c_callback

The panel_get_aircraft_c_callback function retrieves a pointer to the aircraft callback function.

Syntax

IAircraftCCallback* panel_get_aircraft_c_callback(
  PCSTRINGZ  name );

Parameters

name
[in]  Specifies the name of the callback function.

Return Values

The function returns a pointer to the IAircraftCCallback function, or NULL if the name is not found.

Remarks

None.

See Also


panel_get_registered_c_callback

The panel_get_registered_c_callback function retrieves a pointer to the registered callback function.

Syntax

IPanelCCallback* panel_get_registered_c_callback(
  PCSTRINGZ  name );

Parameters

name
[in]  Specifies the name of the module, "CABIN" in the Cabin_Comfort.cpp example.

Return Values

The function returns a pointer to an IPanelCCallback function.

Remarks

None.

See Also


panel_register_c_callback

The panel_register_c_callback function specifies the registered callback function.

Syntax

BOOL panel_register_c_callback(
  PCSTRINGZ  name,
  IPanelCCallback*  pcallback );

Parameters

name
[in]  Specifies the name of the module, "CABIN" in the Cabin_Comfort.cpp example.
pcallback
[in]  Specifies a pointer to the IPanelCCallback function.

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Example

See Cabin_Comfort.cpp for an example of the use of this function, and refer to Creating a Gauge using XML and C++ for a description of this sample

Remarks

None.

See Also


panel_resource_string_get

The panel_resource_string_get function retrieves the resource string, given an ID.

Syntax

PCSTRINGZ panel_resource_string_get(
  ID32  id );

Parameters

id
[in]  Specifies the resource ID.

Return Values

The function returns the resource string in a PCSTRINGZ , or NULL if the ID is not found.

Remarks

None.

See Also


panel_window_close_ident

The panel_window_close_ident function closes the specified panel window.

Syntax

BOOL panel_window_close_ident(
  UINT32  panel_id );

Parameters

panel_id
[in]  Specifies the identification number of the window to close. The identification number is specified in the Panel.cfg file in the [WindowXX] section by the variable ident.

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Remarks

None.

See Also


panel_window_open_ident

The panel_window_open_ident function displays the specified panel window.

Syntax

BOOL panel_window_open_ident(
  UINT32  panel_id );

Parameters

panel_id
[in]  Specifies the identification number of the window to open. The identification number is specified in the Panel.cfg file in the [WindowXX] section by the variable ident.

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Remarks

None.

See Also


panel_window_toggle

The panel_window_toggle function toggles the visible state of a panel window.

Syntax

BOOL panel_window_toggle(
  UINT32  panel_id );

Parameters

panel_id
[in]  Specifies the identification number of the window to toggle. The identification number is specified in the Panel.cfg file in the [WindowXX] section by the variable ident.

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Example

BOOL window_open_cb(PPIXPOINT relative_point, FLAGS32 mouse_flags)
{
  return panel_window_toggle(50);
}

Remarks

None.

See Also


panel_window_toggle_hud_color

The panel_window_toggle_hud_color function changes the global HUD color to the next in the list.

Syntax

void panel_window_toggle_hud_color();

Parameters

This function takes no parameters.

Return Values

This function does not return a value.

Remarks

This function cycles through the range of HUD colors (green, dark green, blue, dark blue, red, dark red, black, white), setting the global HUD color to the next in the list..

See Also


panel_window_toggle_hud_units

The panel_window_toggle_hud_units function toggles the HUD units between metric and imperial.

Syntax

void panel_window_toggle_hud_units();

Parameters

This function takes no parameters.

Return Values

This function does not return a value.

Remarks

None.

See Also


panel_window_toggle_menu_id

The panel_window_toggle_menu_id function selects a menu item given an ID.

Syntax

BOOL panel_window_toggle_menu_id(
  ID32  menu_id );

Parameters

menu_id
[in]  Specifies the menu ID

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Example

panel_window_toggle_menu_id( IDM_MAIN_PANEL_OFF );

Remarks

This function does not "toggle", but rather "selects", but the name is left unchanged for backwards compatibility.

See Also


process_shared_event_out

The process_shared_event_out function sends data to the other aircraft, in a multiplayer shared cockpit scenario.

Syntax

BOOL process_shared_event_out(
  PGAUGEHDR  gauge_header,
  BYTE  *pBuf,
  UINT32  nSize
);

Parameters

gauge_header
[in]  Specifies the gauge header, which is used to identify the gauge that the event applies to.
pBuf
[in]  A pointer to an array of data.
nSize
[in]  The length of the data array, in bytes.

Return Values

If the function succeeds, it returns a non-zero value. If it fails, it returns zero.

Remarks

This function is used to send data from one aircraft to another in the shared cockpit scenario of multiplayer operations. Only two aircraft can share a cockpit, one is the master and the other is not. This function can be used to send data from either one to the other.

See Also


query_pdk

The query_pdk function gets an IPdk pointer which can be used to query additional SDK services.

Syntax

HRESULT query_pdk(REFIID riid, void** ppPdk);

Parameters

riid
[in]  Specifies IPdk interface ID requested. IID_IPdkV01 is the latest version.

ppPdk
[out]  Specifies the address of the IPdk pointer to be set.

Return Value

S_OK (0) if no errors and a valid IPdk pointer is set.

See Also


radio_stack_autoclose

The radio_stack_autoclose function closes the radio stack, if it was opened with radio_stack_popup.

Syntax

void radio_stack_autoclose();

Parameters

This function takes no parameters.

Return Values

This function does not return a value.

Remarks

None.

See Also


radio_stack_popup

The radio_stack_popup function displays the radio stack

Syntax

void radio_stack_popup();

Parameters

This function takes no parameters.

Return Values

This function does not return a value.

Remarks

This function has no effect if the radio stack is already displayed.

See Also


register_key_event_handler

The register_key_event_handler function registers a key event callback function.

Syntax

void register_key_event_handler(
  GAUGE_KEY_EVENT_HANDLER  handler,
  PVOID  userdata );

Parameters

handler
[in]  Specifies the handler function, which should match the following definition:
typedef void (*GAUGE_KEY_EVENT_HANDLER) (ID32 event, UINT32 evdata, PVOID userdata);
userdata
[in]  Specifies an optional value for use by the gauge developer. This value will be returned to the key event handler function, whenever it is called.

Return Values

This function does not return a value.

Example

This example shows how to receive custom numeric events from part animations (refer to the Creating a New Animation section of the Using Modeling Tools document).

Defined in gauges.h:

const int EVENT_BUTTON_PUSH = 0x11000; //THIRD_PARTY_EVENT_ID_MIN

Code in the gauge handler:

bool g_ButtonState = false;

//GAUGE_KEY_EVENT_HANDLER
void FSAPI EventHandler(ID32 event, UINT32 evdata, PVOID userdata)
{
     switch(event)
    {
         case EVENT_BUTTON_PUSH:
             g_ButtonState = !g_ButtonState;
             break;
         default:
             break;
     }
}

void FSAPI module_init(void)
{
     if (NULL != Panels)
     {
         ImportTable.PANELSentry.fnptr = (PPANELS)Panels;
             PanelCallbackInit();
     }
    register_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler, NULL);
}

Remarks

Custom Events

Third parties can use custom events with ID numbers in the following range to communicate between 3D virtual cockpits and 2D C++ gauges.

#define THIRD_PARTY_EVENT_ID_MIN 0x00011000
#define THIRD_PARTY_EVENT_ID_MAX 0x0001FFFF

Refer also the documentation on the function SimConnect_MapClientEventToSimEvent.

See Also


register_named_variable

The register_named_variable function registers a local variable name.

Syntax

ID register_named_variable(
  PCSTRINGZ  name );

Parameters

name
[in]  Specifies the variable name.

Return Values

The function returns an ID. If the named variable already exists, its existing ID will be returned. If it does not exist, a new registered variable is created.

Remarks

Local variable names are case-insensitive. The value of the variable is set to zero, and the units to UNITS_UNKNOWN, on creation.

See Also


register_var_by_name

The register_var_by_name function registers a variable from another gauge, for use by this gauge.

Syntax

void register_var_by_name(
  PVOID  var,
  VAR_TYPE  var_type,
  PSTRINGZ  name );

Parameters

var
[in]  Specifies the address of the variable.
var_type
[in]  Specifies the type of the variable, one of the following enum:

typedef enum VAR_TYPE {
    VAR_TYPE_NONE,
    TYPE_BOOL8,
    TYPE_UINT8,
    TYPE_SINT8,
    TYPE_FLAGS8,
    TYPE_ENUM8,
    TYPE_BOOL16,
    TYPE_ANGL16,
    TYPE_UINT16,
    TYPE_SINT16,
    TYPE_UIF16,
    TYPE_SIF16,
    TYPE_FLAGS16,
    TYPE_ENUM16,
    TYPE_BCD16,
    TYPE_BCO16,
    TYPE_VAR16,
    TYPE_BOOL32,
    TYPE_ANGL32,
    TYPE_UINT32,
    TYPE_SINT32,
    TYPE_UIF32,
    TYPE_SIF32,
    TYPE_FLAGS32,
    TYPE_ENUM32,
    TYPE_VAR32,
    TYPE_ANGL48,
    TYPE_SINT48,
    TYPE_UIF48,
    TYPE_SIF48,
    TYPE_UINT64,
    TYPE_SINT64,
    TYPE_SIF64,
    TYPE_FLOAT64,
    TYPE_BOOL,
    TYPE_FLAGS,
    TYPE_ENUM,
    TYPE_VOID,
    TYPE_PVOID,
    TYPE_PUINT32,
    TYPE_PSINT32,
    TYPE_PFLOAT64,
    VAR_TYPE_MAX
} VAR_TYPE;


name
[in]  Specifies the name of the variable. Specify a unique and descriptive name for the variable, such as "gaugename.variablename".

Return Values

This function does not return a value.

Example

static GPS_INFO gps_data;
static TVector<GPS_WP_INFO> *gps_wps;
static GPS_INFO gps_data_request;
static GPS_WP_INFO gps_wps_request[MAX_GPS_WAYPOINTS];

// In the gauge initialization code....

if (!gps_wps)
    gps_wps = new TVector<GPS_WP_INFO>;
init_gps_var (&gps_data, gps_wps->Address ());
init_gps_var (&gps_data_request, gps_wps_request);

register_var_by_name (&gps_data, TYPE_PVOID, GPS_INFO_PANEL_VARIABLE_NAME);
register_var_by_name (&gps_data_request, TYPE_PVOID, GPS_REQUEST_PANEL_VARIABLE_NAME);

// In the gauge closing code....

unregister_var_by_name (GPS_REQUEST_PANEL_VARIABLE_NAME);
unregister_var_by_name (GPS_INFO_PANEL_VARIABLE_NAME);
if (gps_wps) {
    delete gps_wps;
    gps_wps = NULL;
}

Remarks

You can use named variables to enable communication between two or more gauges. To establish communication between gauges, a "server" and "client" gauge needs to be defined. The terms "server" and "client" just distinguish between variable ownership and variable usage:

A single gauge can be both a server (by providing one or more variables) and a client (by accessing another gauge's variables) at the same time. Use the register_var_by_name, unregister_var_by_name, and initialize_var_by_name functions with named variables. The server gauge uses the register_var_by_name function to register a named variable with the panel system at startup, so create a callback for your gauge as part of the gauge_header structure. You can set this so it performs at startup, on shutdown, etc.

When using named variables, don't call the lookup_var function (as you would with the standard panel system variables). After initialize_var_by_name is called, the var_ptr field of the MODULE_VAR structure contains a pointer to the named variable. The panel system doesn't recognize named variables, per se, but the system does maintain the name to the pointer link for gauges to query. As a result, you can't use a named variable as a controlling variable for an ELEMENT structure directly. Instead, use a MODULE_VAR_NONE structure and provide a callback function that can query the variable's value using the var_ptr field of the MODULE_VAR structure.

Because named variables work via direct pointers between gauges, make sure that the server gauge is loaded before, or at the same time as, the client gauge. You can make sure this happens by either putting both gauges on the same panel window or by putting the server gauge on the main panel window. This ensures that the server gauge is loaded and the named variable is registered before the client gauge tries to connect to it. Alternatively, you can check the returned var_ptr for NULL and the returned var_type (both in the MODULE_VAR structure) for VAR_TYPE_NONE and execute (in the ELEMENT callback function) the initialize_var_by_name function until it returns valid information. (You can also call the initialize_var_by_name function every time you want to access the variable, but this approach is a little slower than caching the information once it's received.). The server gauge must keep checking the current value of the variable(s) it has made available, if the current state/value of that variable has any effect.

You can use named variables at any point in the simulation when you want to pass information between two or more gauges. Because named variables are shared by direct pointer access, you can also share out an entire data structure using one named variable, as long as the server and client gauges interpret the same data format.

You can place these gauges anywhere on a panel, as long as the server gauge is guaranteed to load before or at the same time as the client gauge.

See Also


send_key_event

The send_key_event function transmits a WM_COMMAND application event.

Syntax

void send_key_event(
  ID32  event_id,
  UINT32  value );

Parameters

event_id
[in]  Specifies a WM_COMMAND event ID.
value
[in]  Specifies a value to be transmitted along with the event ID. Can be set to zero.

Return Values

This function does not return a value.

Remarks

This function transmits a message with the following syntax:

PostMessage(hwndMain, WM_COMMAND, event_id, (LPARAM) value);

See Also


set_gauge_flags

The set_gauge_flags function is used to specify the flags for a gauge.

Syntax

void set_gauge_flags(
  PCSTRINGZ  name,
  FLAGS32  newflags );

Parameters

name
[in]  Specifies the name of the gauge.
newflags
[in]   One or more of the following flags:

Flag Value
GAUGE_FLAG_NORMAL 0
GAUGE_FLAG_HIDDEN 0x1
GAUGE_FLAG_BLINKING 0x2
GAUGE_FLAG_GRAYED 0x4
GAUGE_FLAG_HILIGHTED 0x8


Return Values

This function does not return a value.

Remarks

None.

See Also


set_named_variable_typed_value

The set_named_variable_typed_value function specifies a local variable should be set to the given value with the given units.

Syntax

void set_named_variable_typed_value(
  ID  id,
  FLOAT64  value,
  ENUM  units );

Parameters

id
[in]  Specifies the ID of the variable.
value
[in]  Specifies the value the variable should be set to.
units
[in]  Specifies the units of the value.

Return Values

This function does not return a value.

Remarks

None.

See Also


set_named_variable_value

The set_named_variable_value function sets a local variable to a given value.

Syntax

void set_named_variable_value(
  ID  id,
  FLOAT64  value );

Parameters

id
[in]  Specifies the ID of the variable.
value
[in]  Specifies the value the variable should be set to.

Return Values

This function does not return a value.

Remarks

None.

See Also


set_named_variable_value_sync

The set_named_variable_value_sync function syncs a specified named variable from a shared cockpit.

Syntax

void set_named_variable_value_sync(
  ID  id,
  FLOAT64  value );

Parameters

id
[in]  Specifies the ID of the variable.
value
[in]  Specifies the value the variable should be synced to.

Return Values

This function does not return a value.

Remarks

None.

See Also


set_named_variable_sync_enabled

The set_named_variable_sync_enabled function enables a specified named variable to sync from a shared cockpit.

Syntax

void set_named_variable_sync_enabled(
  ID  id,
  bool  bSync );

Parameters

id
[in]  Specifies the ID of the variable.
bSync
[in]  Specifies whether the variable should be synced from a shared cockpit.

Return Values

This function does not return a value.

Remarks

None.

See Also


tooltip_units_getset

The tooltip_units_getset function specifies or retrieves the tooltip units (metric or US).

Syntax

ENUM tooltip_units_getset(
  int  action,
  ENUM  type );

Parameters

action
[in]  Specifies the action. If this value is less than zero, the units are toggled (between metric and US imperial). If this value equals zero, the enum value for the units is returned. If this value is greater than zero, the units are set to the value of the type parameter.
type
[in]  The enum value to set the tooltip units to, one of:
enum TOOLTIP_UNITS_TYPE {
  TOOLTIP_UNITS_TYPE_DEFAULT,
  TOOLTIP_UNITS_TYPE_METRIC,
  TOOLTIP_UNITS_TYPE_US,
};

Return Values

The function returns one member of the TOOLTIP_UNITS_TYPE enumeration.

Remarks

None.

See Also


trigger_key_event

The trigger_key_event function initiates the action of a key event.

Syntax

ERR trigger_key_event(
  ID32  event_id,
  UINT32  value );

Parameters

event_id
[in]  Specifies the event ID. Refer to the list of key events in the EventIDs document, and the #define KEY_events in gauges.h.
value
[in]  Specifies an additional integer value. Set this to zero if it is not required.

Return Values

The function returns an ERR, which is usually ignored. If the event requested is not appropriate, it simply will not happen.

Example

static MODULE_VAR nav_light;
lookup_var( &nav_light);
trigger_key_event( KEY_TOGGLE_NAV_LIGHTS, 0 );

Also see the SDK.Fuel_Selector.cpp sample.

Remarks

None.

See Also


unregister_all_named_vars

The unregister_all_named_vars function unregisters all token variables, and frees up the memory used.

Syntax

void unregister_all_named_vars();

Parameters

This function takes no parameters.

Return Values

This function does not return a value.

Remarks

None.

See Also


unregister_key_event_handler

The unregister_key_event_handler function unregisters the key event handler.

Syntax

void unregister_key_event_handler(
  GAUGE_KEY_EVENT_HANDLER  handler,
  PVOID  userdata );

Parameters

handler
[in]  Specifies the handler function.
userdata
[in]  Specifies the user data value specified when creating the handler function.

Return Values

This function does not return a value.

Remarks

None.

See Also


unregister_var_by_name

The unregister_var_by_name function unregisters a named variable from another gauge, and frees up the memory used.

Syntax

void unregister_var_by_name(
  PSTRINGZ  name );

Parameters

name
[in]  Specifies the name of the variable.

Return Values

This function does not return a value.

Example

See register_var_by_name for an example of the use of this function.

Remarks

None.

See Also


GAUGE_HEADER_FS700

Syntax


#define GAUGE_HEADER_FS700(default_size_mm, gauge_name, element_list, pmouse_rect, pgauge_callback, user_data, parameters, usage)

Parameters

Member Description
default_size_mm
The default X axis size of the gauge in design units. This value is set as GAUGE_W in SDK.cpp.
gauge_name
The name of the gauge as defined in SDK.cpp as GAUGE_NAME.
element_list
A pointer to the first drawing element in the list of elements.
pmouse_rect
A pointer to the mouse rectangle drawn over the gauge.
pgauge_callback
A pointer to a function for the entire gauge. This will pass a message to the system. Use 0 if none.
user_data
A 32-bit space you can use for any data you want. Use 0 if none.
parameters
A field that contains a string. A pointer to this string is placed in the gauge header for use in the gauge callback function (or wherever might be appropriate). Use 0 if none.
usage Not used. Use 0.

Remarks

None.

See Also


FAILURE_RECORD

You'll use the FAILURE_RECORD structure to identify the systems that—should they fail—would need to be reflected by the gauge. The structure inside Gauges.h looks like this:

Syntax


typedef     struct      FAILURE_RECORD
{
      FAILURE_KEY       key;
      FAILURE_ACTION    action;
      PVOID             reserved;
}
FAILURE_RECORD, *PFAILURE_RECORD, **PPFAILURE_RECORD;

Remarks

None.

See Also


FAILURE_KEY

System failures are listed in the FAILURE_KEY enum values defined in gauges.h.

Syntax


typedef enum    FAILURE_KEY
{
        FAIL_NONE = 0,

        OLD_FAIL_SYSTEM_ELECTRICAL,         // obsolete: dont use it in new gauges; use FAIL_SYSTEM_ELECTRICAL_PANELS
        FAIL_SYSTEM_ENGINE,
        FAIL_SYSTEM_PITOT_STATIC,
        FAIL_SYSTEM_VACUUM,

        FAIL_GAUGE_ADF,
        FAIL_GAUGE_AIRSPEED,
        FAIL_GAUGE_ALTIMETER,
        FAIL_GAUGE_ATTITUDE,
        FAIL_GAUGE_COMMUNICATIONS,              // Used for COM1
        FAIL_GAUGE_FUEL_INDICATORS,
        FAIL_GAUGE_GYRO_HEADING,
        FAIL_GAUGE_MAGNETIC_COMPASS,
        OLD_FAIL_GAUGE_NAVIGATION,              // OBSOLETE: DON'T USE
        FAIL_GAUGE_NAVIGATION_VOR1,             // only vor1
        FAIL_GAUGE_NAVIGATION_VOR2,             // only vor2
        OLD_FAIL_GAUGE_NAVIGATION_BOTH,         // OBSOLETE: DON'T USE
        FAIL_GAUGE_TRANSPONDER,
        FAIL_GAUGE_TURN_COORDINATOR,
        FAIL_GAUGE_VERTICAL_SPEED,

        FAIL_SYSTEM_ELECTRICAL_PANELS,
        FAIL_SYSTEM_ELECTRICAL_AVIONICS,

        FAIL_GAUGE_COMMUNICATIONS_COM2,        // Used for COM2


        FAIL_KEY_MAX
}
FAILURE_KEY, *PFAILURE_KEY, **PPFAILURE_KEY;

Definitions

Enum values Description
FAIL_NONE Marks the end of a failure record.
OLD_FAIL_SYSTEM_
ELECTRICAL
Is obsolete. Don't use it in new gauges; use FAIL_SYSTEM_ELECTRICAL_PANELS instead.
FAIL_SYSTEM_ENGINE Specifies an engine system failure.
FAIL_SYSTEM_PITOT_STATIC Specifies a pitot-static system failure.
FAIL_SYSTEM_VACUUM Specifies a vacuum system failure.
FAIL_GAUGE_ADF Specifies an ADF gauge system failure.
FAIL_GAUGE_AIRSPEED Specifies an airspeed gauge system failure.
FAIL_GAUGE_ALTIMETER Specifies an altimeter gauge system failure.
FAIL_GAUGE_ATTITUDE Specifies an attitude gauge system failure.
FAIL_GAUGE_COMMUNICATIONS Specifies a COM1 communication gauge system failure.
FAIL_GAUGE_FUEL_INDICATORS Specifies a fuel indicators gauge system failure.
FAIL_GAUGE_GYRO_HEADING Specifies a gyro heading gauge system failure.
FAIL_GAUGE_MAGNETIC_COMPASS Specifies a magnetic compass gauge system failure.
FAIL_GAUGE_NAVIGATION_VOR1 Specifies a navigation VOR1 gauge system failure.
FAIL_GAUGE_NAVIGATION_VOR2 Specifies a navigation VOR2 gauge system failure.
FAIL_GAUGE_ TRANSPONDER Specifies a transponder gauge system failure.
FAIL_GAUGE_TURN_COORDINATOR Specifies a turn coordinator gauge system failure.
FAIL_GAUGE_VERTICAL_SPEED Specifies a vertical speed indicator gauge system failure.
FAIL_SYSTEM_ELECTRICAL_PANELS Specifies a failure of the electrical panel.
FAIL_SYSTEM_ELECTRICAL_AVIONICS Specifies a failure of the electrical avionics.
FAIL_GAUGE_COMMUNICATIONS_COM2 Specifies a COM2 communication gauge system failure.

Remarks

None.

See Also


FAILURE_ACTION

You can set up a gauge element to react to one or more of the system failures shown in the FAILURE_RECORD by using one of the defined FAILURE_ACTION enum values:

Syntax


typedef enum    FAILURE_ACTION
{
        FAIL_ACTION_NONE = 0,
        FAIL_ACTION_FREEZE,
        FAIL_ACTION_ZERO,
        FAIL_ACTION_NO_DRAW,
        FAIL_ACTION_COVER,

        FAIL_ACTION_MAX
}
FAILURE_ACTION, *PFAILURE_ACTION, **PPFAILURE_ACTION;

Definitions

Member Description
FAIL_ACTION_NONE = 0 Takes no action. This type of failure record is typically used as the background static image for covering a gauge.
FAIL_ACTION_FREEZE Freezes the gauge element at its last updated position. The element's MODULE_VAR variable(s) will not be updated.
(MODULE_VAR relates to the various gauge token variables accessible to the panel system from the simulation engine. See the section on Token Variables for more information.)
FAIL_ACTION_ZERO Sets the element MODULE_VAR variable(s) to 0.
FAIL_ACTION_NO_DRAW Erases the element and doesn't draw it again.

Remarks

None.

See Also


MOUSE_BEGIN

Syntax


#define MOUSE_BEGIN( name, helpid, x, y )

Parameters

Parameter Description
name Contains the name of the MOUSERECT you've assigned to the rectangle.
helpid Contains the Help ID of the ToolTip message you want to appear when a mouse cursor enters the rectangle. For foreign versions, the Help IDs point to localized strings. There is currently no way to add more ToolTip ID's.
x, y Specifies the upper-left corner of the rectangle. For MOUSE_BEGIN, this value will always be 0, 0.

Remarks

None.

See Also


MOUSE_PARENT and MOUSE_PARENT_BEGIN

Both the MOUSE_PARENT and the MOUSE_PARENT_BEGIN macros use the same parameters.

Syntax


#define MOUSE_PARENT_BEGIN( x, y, w, h, helpid )

#define MOUSE_PARENT( x, y, w, h, helpid )

Parameters

Parameter Description
x, y Specifies the X and Y position from the 0,0 position of the gauge.
w, h Specifies the width and height of the rectangle.
Help ID Specifies the Help ID of the ToolTip text to display for the rectangle. For foreign versions, the Help IDs point to localized strings. There is currently no way to add more ToolTip IDs.

Remarks

None.

See Also


MOUSE_CHILD_EVENT

Syntax


MOUSE_CHILD_EVENT(x, y, w, h, cursor, mouse_flags, event_id)

Parameters

Parameter Description
x, y Specifies the upper-left corner of the rectangle.
w, h Specifies the width and height of rectangle.
Cursor Specifies the cursor shown when the mouse is in the mouse rectangle. This parameter can be set to one of the following:
CURSOR_NONE
CURSOR_NORMAL
CURSOR_UPARROW
CURSOR_DOWNARROW
CURSOR_LEFTARROW
CURSOR_RIGHTARROW
CURSOR_HAND
CURSOR_CROSSHAIR
CURSOR_GRAB
mouse_flags Specifies under what conditions the event will be generated. It can be set to one of the following values:
MOUSE_NONE
MOUSE_RIGHTSINGLE
MOUSE_MIDDLESINGLE
MOUSE_LEFTSINGLE
MOUSE_RIGHTDOUBLE
MOUSE_MIDDLEDOUBLE
MOUSE_LEFTDOUBLE
MOUSE_RIGHTDRAG
MOUSE_MIDDLEDRAG
MOUSE_LEFTDRAG
MOUSE_MOVE
MOUSE_DOWN_REPEAT
MOUSE_RIGHTRELEASE
MOUSE_MIDDLERELEASE
MOUSE_LEFTRELEASE
MOUSE_WHEEL_FLIP (reverse direction of mouse wheel)
MOUSE_WHEEL_SKIP
MOUSE_WHEEL_UP
MOUSE_WHEEL_DOWN
MOUSE_MOVE_REPEAT
MOUSE_LEAVE
MOUSE_GETALL
MOUSE_LEFTALL (equivalent to MOUSE_LEFTSINGLE | MOUSE_LEFTDRAG | MOUSE_LEFT_RELEASE)
MOUSE_RIGHTALL (equivalent to MOUSE_RIGHTSINGLE | MOUSE_RIGHTDRAG | MOUSE_RIGHT_RELEASE)
MOUSE_MIDDLEALL (equivalent to MOUSE_MIDDLESINGLE | MOUSE_MIDDLEDRAG | MOUSE_MIDDLE_RELEASE)
MOUSE_WHEEL (equivalent to MOUSE_WHEEL_DOWN | MOUSE_WHEEL_UP )
event_id Specifies the simulation event to be sent by the mouse event. For a complete list of events, see the associated file EventIDs documentation.

Remarks

None.

See Also


MOUSE_CHILD_FUNCT

Syntax


MOUSE_CHILD_FUNCT(x, y, w, h, cursor, mouse_flags, function)

Parameters


Parameter Description
x, y Specifies the upper-left corner of the rectangle.
w, h Specifies the width and height of the rectangle.
cursor Specifies the type of cursor that is shown when the mouse is in the mouse rectangle.
mouse_flags Specifies under what mouse conditions the callback function will be executed.
function Specifies the callback function executed by the mouse event. You must define this function using mouse_child_funct.

Remarks

None.

See Also


MOUSERECT

The MOUSERECT structure defines a mouse rectangle, with associated cursor, help ID, and actions.

Syntax

typedef struct MOUSERECT{
  MOUSE_RECT_TYPE  rect_type;
  PIXBOX  relative_box;
  CURSOR_TYPE  cursor;
  ID  help_id;
  FLAGS  mouse_flags;
  ID  event_id;
  PMOUSE_FUNCTION  mouse_function;
  PVOID  api_data;
};

Members

rect_type
   Type of mouse rectangle, one of:

typedef enum
{
    MOUSE_RECT_EOL,
    MOUSE_RECT_PARENT,
    MOUSE_RECT_CHILD,
    MOUSE_RECT_END_PARENT,
    MOUSE_RECT_USER,



} MOUSE_RECT_TYPE;




relative_box
relative sense rectangle (relative to parameter to register function) .
cursor
Cursor to display when over this window.
help_id
Pop-up Help Id.
mouse_flags
One or more mouse flags.
event_id
Event to generate if mouse_flags conditions met.
mouse_function
Function to call if mouse_flags conditions met.
api_data
Unused.



Example

See SDK.Attitude.cpp for an example of the use of this structure.

Remarks

None.

See Also


UNIVERSAL_VAR Types

Each token variable returns a specific type of data. The following structure shows how the UNIVERSAL_VAR variable is defined and the types that could be returned:

Syntax


typedef union UNIVERSAL_VAR {
    FLOAT64 n; // any number.
    BOOL b; // any boolean
    ENUM e; // any enumerated value
    FLAGS f;// any flags field
    PVOID p;// any pointer
    VAR32 d;// any binary coded decimal
    VAR32 o;// any binary coded octal
} UNIVERSAL_VAR, *PUNIVERSAL_VAR, **PPUNIVERSAL_VAR;

Remarks

None.

See Also


MODULE_ VAR

Each drawing element structure has one or more MODULE_VAR members. You can initialize these members to one of the token variable values. Call the function element_install or element_list_install to initialize the MODULE_VAR element(s). The element_update or element_list_update function can be used to update the contents of the MODULE_VAR. The elements themselves use the MODULE_VAR information at render time to determine in what state they'll be rendered. Here's the structure from Gauges.h:

Syntax

typedef struct MODULE_VAR
{
    GAUGE_TOKEN id;
    PVOID var_ptr;
    VAR_TYPE var_type;
    UNIVERSAL_VAR var_value;
    UNIVERSAL_VAR var_old;
} MODULE_VAR, *PMODULE_VAR, **PPMODULE_VAR;

Details

Graphical elements can use the MODULE_VAR structure member to determine the state in which the element will be rendered. Sometimes, however, MODULE_VAR may not be a useful value. You can get around this problem by using callbacks. For each of the MODULE_VAR structures listed in the element structure, you can set an associated PMODULE_VAR_CB pointer. The pointer points to a callback function that you can use to set the variable to a useful value. The callback function is called by the panel system after the variable has been updated from the simulation state information. The callback function is generally used to normalize or scale the MODULE_VAR value into a valid range. You can also use the callback function to convert enumerated values, interpret a flag's variable, and so on. For example, the following code uses a callback routine to clip the airspeed to a useful range that can be used by the airspeed gauge. All elements use the same style callback routine in which the argument to the function acts as a pointer to that element.

Example


FLOAT64 convert_var_aspeed(PMODULE_VAR var)
{
    if (var->var_value.n > GAUGE_MAX_AIRSPEED)
    var->var_value.n = GAUGE_MAX_AIRSPEED;
    if (var->var_value.n < 60)
    var->var_value.n = 60;
    return var->var_value.n;
}

You can set any callback pointer to NULL so that no call will occur. Any assignments to the MODULE_VAR in a callback routine are discarded. The final value set in MODULE_VAR is the return value of the callback function.

Remarks

None.

See Also


Drawing Element Header

The first twelve data members are the same for all the drawing element structures. The data members are described in the following table.

Members

Member Description
element_type Specifies the element type. Set this member to be one of the following elements:
ELEMENT_TYPE_STATIC_IMAGE
ELEMENT_TYPE_NEEDLE
ELEMENT_TYPE_STRING
ELEMENT_TYPE_SLIDER
ELEMENT_TYPE_ICON
ELEMENT_TYPE_MOVING_IMAGE
ELEMENT_TYPE_SPRITE
resource_id Specifies the resource ID of an 8-bit or 24-bit bitmap resource. All element types, with the exception of ELEMENT_STRING (which ignores this value), use this value.
position Specifies the point that the drawing element pivots around. This value is used by ELEMENT_NEEDLE and ELEMENT_SPRITE and ignored by the other elements.
previous_position Specifies the previous position of the element relative to the gauge position. Used by the panel system. This value is ignored during initialization.
ofs Specifies an offset (pivot point) for an element to rotate around. This value is used by ELEMENT_NEEDLE and ELEMENT_SPRITE and ignored by the other elements.
gauge_header Points to the gauge header file.
previous_element Points to the previous element. This value is set by the panel system. This value is ignored during initialization.
next_element Points to a list of graphical elements. The elements are drawn after the current element. This value is used to determine the drawing order of all the elements in your gauge.
failure_systems Points to a FAILURE_RECORD list. This list defines how an element will react during simulated aircraft system failure.
image_flags Specifies how the element image will be rendered, with one or more DRAW_FLAGS.
aircraft_special_instrumentation Specifies the Aircraft Special Instrumentation flags.
reserved This value is reserved and must be set to 0.

Remarks

None.

See Also


MAKE_STATIC

The MAKE_STATIC macro draws the simplest type of graphical element. Use MAKE_STATIC to draw an image that never changes.

Syntax


#define     MAKE_STATIC(      NAME,                   \
                              RES_ID,                 \
                              NEXT_LIST,              \
                              FAILURE,                \
                              DRAW_FLAGS,             \
                              ASI_FLAGS,              \
                              POSITION_X, POSITION_Y )\

Parameters

Field Sample Code Description
NAME cs_background Contains the unique name you assign to the macro—this specific name applies to the static background image.
RES_ID BMP_CS_SMALL_BACKGROUND Contains the name of the resource file used by the macro as identified earlier by SDK.h.
NEXT_LIST &cs_sliders_list Sets the order in which parts of the gauge get drawn. The example identifies the sliders.
FAILURE NULL References a FAILURE_RECORD or NULL.
DRAW_FLAGS IMAGE_USE_TRANSPARENCY One or more DRAW_FLAGS.
ASI_FLAGS 0 Specifies the Aircraft Special Instrumentation flags.
POSITION_X, POSITION_Y 0,0 Specifies the X,Y coordinates, in display units relative to the background image (i.e., static image), at which to initially place the bitmap. Since this is the background image, always set the X,Y coordinates to 0,0.

Example

Here's the code fragment from Control_surfaces.cpp that uses MAKE_STATIC:


MAKE_STATIC
(
      cs_background,
      BMP_CS_SMALL_BACKGROUND,
      &cs_sliders_list,
      NULL,
      IMAGE_USE_TRANSPARENCY,
      0,
      0,0
)
PELEMENT_HEADER         cs_list     = &cs_background.header;

Remarks

None.

See Also


MAKE_NEEDLE

Use MAKE_NEEDLE to draw an image that pivots around a specific point in another image. MAKE_NEEDLE supports transparency and nonlinear gauges. For MAKE_NEEDLE, POS (position) is the center of rotation in the background image; OFS (offset) is the center of rotation in the needle image.

Syntax


#define     MAKE_NEEDLE(      NAME,                               \
                              RES_ID,                             \
                              NEXT_LIST,                          \
                              FAILURE,                            \
                              DRAW_FLAGS,                         \
                              ASI_FLAGS,                          \
                              BKND_POSITION_X, BKND_POSITION_Y,   \
                              NDL_POSITION_X, NDL_POSITION_Y,     \
                              SOURCE_VAR, CALLBACK,               \
                              NONLINEARITY_TABLE,                 \
                              MAX_DEG_PER_SEC )                   \

Parameters

Field Sample Code Description
NAME fuel_needle Contains the unique name you assign to the macro—this specific name applies to the static background image.
RES_ID BMP_FUEL_SMALL_NEEDLE Contains the name of the resource file used by the needle as identified earlier by SDK.h.
NEXT_LIST NULL Sets the order in which parts of the gauge get drawn.
FAILURE fuel_fail References a FAILURE_RECORD or NULL.
DRAW_FLAGS IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE One or more DRAW_FLAGS.
ASI_FLAGS 0 Specifies the Aircraft Special Instrumentation flags.
BKND_POSITION_X, BKND_POSITION_Y 150, 150 The X and Y coordinates on the background image around which the needle rotates.
NDL_POSITION_X, NDL_POSITION_Y 6, 12 The X and Y coordinates of the needle itself around which the needle revolves—the fix point of the needle. In general, bitmaps for needles should be drawn horizontally.
SOURCE_VAR FUEL_QUANTITY_
CENTER
Token Variable used to drive the needle. You can enter MODULE_VAR_NONE if you want to set your variable values.
CALLBACK fuel_needle_cb Callback function associated with the needle.
NONLINEARITY_
TABLE
fuel_nonlinearity Name of the non-linearity table used by the needle.
MAX_DEG_PER_SEC 6 Determines the refresh rate for the macro. Gauges are refreshed 18 times per second, so a value of 0 means update every cycle; a value of 6 means update every third of a second. You trade off gauge display quality versus frame rate—lower numbers give smoother display but worse frame rate.

Example

Here's the code fragment from SDK.fuel.cpp that uses this macro:


MAKE_NEEDLE
(
      fuel_needle,
      BMP_FUEL_SMALL_NEEDLE,
      NULL,
      fuel_fail,
      IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE,
      0,
      150, 150,
      6, 12,
      FUEL_QUANTITY_CENTER,fuel_needle_cb,
      fuel_nonlinearity,
      6
)

Remarks

None.

See Also


NONLINEARITY

In some cases, you might want a needle to move in a nonlinear manner. For example, an airspeed gauge sometimes shows a greater angle between 0 and 50 knots than the angle between 100 and 150 knots. You can specify this behavior by using a non-linearity table. A non-linearity table is an array of NONLINEARITY structures. Each element in the array represents a discrete point on a gauge where the value is known. For example, your gauge might show airspeed as values from 0 to 160 knots, with tick marks every 20 knots. You could create an entry for each tick, filling in the pt and value member variables of the NONLINEARITY structure.

Syntax


typedef struct NONLINEARITY
{
        PIXPOINT        pt;
        FLOAT64         value;
        FLOAT64         degrees;
}

Parameters

Member Description
pt Specifies the X, Y point in the background bitmap.
value Contains the readout of the gauge at that point.
degrees Used internally by the panel system: do not use. Must be set to 0.

Example

In SDK.Fuel.cpp, the linearity table deals with the fuel quantity, which ranges from 0 to 75. Here's the non-linearity table it uses:


NONLINEARITY  fuel_nonlinearity[] =
{
      {{30, 182}, 0, 0},
      {{119, 47}, 25, 0},
      {{246, 93}, 50, 0},
      {{241, 221}, 75, 0}
};

At runtime, the value of the needle is examined and the angle to be drawn is interpolated from the non-linearity table. Values are listed in the table as they appear on the gauge (clockwise around the face). If gauge values increase when rotating clockwise, values in the non-linearity table will start at the minimum and increase. If gauge values decrease when rotating clockwise, then values in the table will start with the maximum and decrease.

Remarks

None.

See Also


MAKE_STRING

Use MAKE_STRING to display text on a gauge. MAKE_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 MAKE_STRING, you can specify the font name, weight, and the background and foreground colors of the text. You can also specify a highlight text color to use when the string is selected.

Syntax


#define       MAKE_STRING(  NAME,                                          \
                                         NEXT_LIST,                        \
                                         FAILURE,                          \
                                         DRAW_FLAGS,                       \
                                         ASI_FLAGS,                        \
                                         POSITION_X, POSITION_Y,           \
                                         SIZE_X, SIZE_Y,                   \
                                         NUM_CHARS,                        \
                                         SOURCE_VAR_1,                     \
                                         SOURCE_VAR_2,                     \
                                         SOURCE_VAR_3,                     \
                                         FORECOLOR,                        \
                                         BACKCOLOR,                        \
                                         HILITECOLOR,                      \
                                         FONT_NAME,                        \
                                         FONT_WEIGHT,                      \
                                         FONT_CHARSET,                     \
                                         FONT_SIZE,                        \
                                         DRAW_TEXT_FLAGS,                  \
                                         HILITE_LIST,                      \
                                         CALLBACK)                         \

Parameters

Field Sample Code Description
NAME temperature_string Contains the unique name you assign to the macro—this specific name applies to the static background image.
RES_ID NULL Contains the name of the resource file used by the macro.
NEXT_LIST NULL Sets the order in which parts of the gauge are drawn.
FAILURE temperature_fail References a FAILURE_RECORD or NULL.
DRAW_FLAGS IMAGE_USE_ERASE | IMAGE_USE_BRIGHT One or more DRAW_FLAGS.
ASI_FLAGS 0 Specifies the Aircraft Special Instrumentation flags.
POSITION_X, POSITION_Y 28, 9 Specifies the X and Y coordinates on the background image where you want the text to display.
SIZE_X, SIZE_Y 60, 29 Defines the height and width of each character.
NUMCHARS 3 Specifies the number of characters to use in the string. The optimal font size is calculated using the information passed to the macro.
SOURCE_VAR_1 TOTAL_AIR_TEMP Contains the token variable used to update the string. The string can contain numbers, characters, or both. If you want to set your variable values, enter MODULE_VAR_NONE.
SOURCE_VAR_2 DISPLAY_UNITS Used to look up multiple token variables to update the string. (e.g., Hours, Minutes, Seconds). Sequence them inside the callback function.
SOURCE_VAR_3 MODULE_VAR_NONE Contains the token variable used to update the string.
FORECOLOR RGB(255,0,0), Defines the foreground (or daylight) color of the string display.
BACKCOLOR RGB(0,0,0), Defines the background color of the string display.
HILITECOLOR RGB(92,92,92), Defines the highlight color for the selected area.
FONT_NAME GAUGE_FONT_DEFAULT Contains the font name of the string. For more information, see "Defining the Font Type" below.
FONT_WEIGHT GAUGE_WEIGHT_DEFAULT Contains the font weight of the string. (The sample code sets the value of GAUGE_WEIGHT_DEFAULT to FW_NORMAL.)

Specifies the weight of the font in the range 0 through 1000. For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used.
The following values are defined for convenience.
Value Weight
FW_DONTCARE 0
FW_THIN 100
FW_EXTRALIGHT 200
FW_ULTRALIGHT 200
FW_LIGHT 300
FW_NORMAL 400
FW_REGULAR 400
FW_MEDIUM 500
FW_SEMIBOLD 600
FW_DEMIBOLD 600
FW_BOLD 700
FW_EXTRABOLD 800
FW_ULTRABOLD 800
FW_HEAVY 900
FW_BLACK 900
FONT_CHARSET GAUGE_CHARSET Specifies the font character set for the string. A list of valid values can be found in the CreateFont Win32 API.
FONT_SIZE 0 Specifies the font size for the string. A value of zero (0) means scale so that NUMCHARS capital W's fit into SIZE_X. A non-zero FONT_SIZE means fixed height.
DRAW_TEXT_
FLAGS
DT_CENTER | DT_VCENTER | DT_SINGLELINE Sets how to draw the text. There are three valid entries:
DT_CENTER
DT_VCENTER
DT_SINGLELINE
HILITE_LIST NULL Lists gauge selection states. (You can also find examples of gauge selection states in gauges.h)
CALLBACK temperature_string_cb Updates the 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.

Example

Here's the code fragment from SDK.Temperature.cpp that uses the MAKE_STRING macro:

MAKE_STRING
(
       temperature_string,
       NULL,
       temperature_fail,
       IMAGE_USE_ERASE | IMAGE_USE_BRIGHT,
       0,
       28, 9,
       60, 29,
       3,
       TOTAL_AIR_TEMP,
       DISPLAY_UNITS,
       MODULE_VAR_NONE,
       RGB(255,0,0),
       RGB(0,0,0),
       RGB(92,92,92),
       GAUGE_FONT_DEFAULT,
       GAUGE_WEIGHT_DEFAULT,
       GAUGE_CHARSET,
       0,
       DT_CENTER | DT_VCENTER | DT_SINGLELINE,
       NULL,
       temperature_string_cb
)

Remarks

Defining the Font Type

To define the font type you must place #define statements (after the initial #include) in your gauge code. For example, SDK.Temperature.cpp looks like this:


#define GAUGE_CHARSET               DEFAULT_CHARSET
#define GAUGE_FONT_DEFAULT          "Courier New"
#define GAUGE_WEIGHT_DEFAULT        FW_NORMAL

The first line in the code above is the default character set for English (UK and US). Most instruments are labeled in English. The second line defines the font set name. You want to define a font that will, with almost certainty, exist on your user's PC. Therefore, choose one of the following fonts: Courier New, Arial, Times New Roman, or Helvetica. The third line defines how the font will display. Here are the available options:


FW_THINFW_EXTRALIGHT
FW_LIGHT
FW_NORMAL
FW_MEDIUM
FW_SEMIBOLD
FW_BOLD
FW_EXTRABOLD
FW_HEAVY

See Also


SEQ_REC

You can use the SEQ_REC table to select a string automatically on certain KEY_EVENTs. The user can 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.

Syntax


typedef struct SEQ_REC
{
    int seq_id;
    int sel_str;
    int sel_end;
} SEQ_REC, *PSEQ_REC, **PPSEQ_REC;

Members

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

States

The following table shows the gauge selection states available.

SEQ Record ID Description
SELECT_NONE No selection
SELECT_1 Unused
SELECT_ZOOM Zoom
SELECT_MAGNETO Magneto
SELECT_COM_WHOLE COM1 communication frequency, whole number
SELECT_COM_FRACTION COM1 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_COM2_WHOLE COM2 communication frequency, whole number
SELECT_COM2_FRACTION COM2 communication frequency, fractional number
SELECT_ADF_TENTHS ADF tenths

Remarks

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}
};

See Also


MAKE_SLIDER

Use MAKE_SLIDER to move a drawing element around a gauge on the X and Y axes. You can use MAKE_SLIDER to move an image in only one direction as well. Just set the MODULE_VAR, for either X or Y, to MODULE_VAR_NONE.

Syntax


#define     MAKE_SLIDER(      NAME,                         \
                              RES_ID,                       \
                              NEXT_LIST,                    \
                              FAILURE,                      \
                              DRAW_FLAGS,                   \
                              ASI_FLAGS,                    \
                              POSITION_X, POSITION_Y,       \
                              SOURCE_VAR_X, CALLBACK_X, SCALE_X,  \
                              SOURCE_VAR_Y, CALLBACK_Y, SCALE_Y )

Parameters

Field Sample Code Description
NAME cs_slider_trim Contains the unique name you assign to the macro—this specific name applies to the trim slider. A gauge can have multiple sliders, but each one must have a unique name
RES_ID BMP_CS_SMALL_TRIM Contains the name of the resource file used by the slider as identified earlier by SDK.h.
NEXT_LIST NULL Sets the order in which parts of the gauge get drawn. Set to NULL as this is a simple gauge where the sliders do not overlap.
FAILURE 0 References a FAILURE_RECORD or NULL.
DRAW_FLAGS IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY One or more DRAW_FLAGS.
ASI_FLAGS 0 Specifies the Aircraft Special Instrumentation flags.
POSITION_X, POSITION_Y 20,44 Specifies the X,Y coordinates, in display units relative to the background image (i.e., static image), at which to initially place the slider bitmap.
SOURCE_VAR_X, CALLBACK_X, SCALE_X MODULE_VAR_NONE,
NULL,
0
Set the X or Y axis (you can move a slider on the X or Y axis).
SOURCE_VAR_X identifies the token variable the slider will use. Since Trim only goes up and down, there's no token variable so use MODULE_VAR_NONE.
CALLBACK_X identifies the modifying callback if any. None is needed so set to NULL.
SCALE_X sets the scaling value for the range of X-axis movement of the variable across the background image. Here it's 0. A slider moves from left to right unless this value is preceded by a minus (-) sign.
SOURCE_VAR_Y, CALLBACK_Y, SCALE_Y ELEVATOR_TRIM,
NULL,
-100
Set Y-axis values. Here the Trim slider does move on the Y-axis.
SOURCE_VAR_Y uses the ELEVATOR_TRIM token variable. See the discussion of token variables later in this section.
CALLBACK_Y identifies the modifying callback, which isn't used here.
SCALE_Y is the scaling value of the Y-axis movement of the slider across the background image. Divide the token variable value returned by the range of movement in pixels, and then multiply by the units of measure. A slider moves from left to right unless this value is preceded by a minus (-) sign.

Example

You'll need to fill this structure out with slider-specific information, such as the following from SDK.Control_Surfaces.cpp:


MAKE_SLIDER
(
      cs_slider_trim,
      BMP_CS_SMALL_TRIM,
      NULL,
      0,
      IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY,
      0,
      20,44,

      MODULE_VAR_NONE, NULL, 0,
      ELEVATOR_TRIM, NULL, -100
)

Remarks

None.

See Also


MAKE_MOVING

MAKE_MOVING, like MAKE_SLIDER, moves an image around on a gauge on the X and Y axes. The difference is that MAKE_MOVING specifies a mask, which does not move, and is used to hide parts of the image. The moving image moves in reference to where the mask is placed. Whiskey compasses are drawn using MAKE_MOVING.

Syntax


#define     MAKE_MOVING(            NAME,                  \
                                    RES_ID,                 \
                                    NEXT_LIST,              \
                                    FAILURE,                \
                                    DRAW_FLAGS,             \
                                    ASI_FLAGS,              \
                                    POSITION_X, POSITION_Y, \
                                    SOURCE_VAR_X, CALLBACK_X,     \
                                    MIN_X, MAX_X,                 \
                                    SOURCE_VAR_Y, CALLBACK_Y,     \
                                    MIN_Y, MAX_Y )

Parameters

Field Sample Code Description
NAME wiskey_moving_card Contains the unique name you assign to the macro.
RES_ID BMP_COMPASS_SMALL_CARD Contains the name of the resource file used by the gauge as identified earlier by SDK.h. This is the moving image.
NEXT_LIST NULL Sets the order in which parts of the gauge are drawn.
FAILURE wiskey_fail References a FAILURE_RECORD or NULL.
DRAW_FLAGS IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY One or more DRAW_FLAGS.
ASI_FLAGS 0 Specifies the Aircraft Special Instrumentation flags.
POSITION_X, POSITION_Y 20,44 Specifies the X,Y coordinates, in display units relative to the background image (i.e., static image), at which to initially place the mask.
SOURCE_VAR_X, CALLBACK_X WHISKEY_COMPASS_DEGREES, wiskey_moving_card_x_cb Specifies the token variable to use and a callback function to control the image in the X direction.
MIN_X, MAX_X 0,360 Specifies the minimum and maximum values expected from the callback for the X direction.
SOURCE_VAR_Y, CALLBACK_Y MODULE_VAR_NONE, wiskey_moving_card_y_cb Specifies the token variable to use and a callback function to control the image in the Y direction.
MIN_Y, MAX_Y 0,0 Specifies the minimum and maximum values expected from the callback for the Y direction.

Example

You'll need to fill this structure out with specific information, such as the following from SDK.Wiskey.cpp:


MAKE_MOVING
(
      wiskey_moving_card,
      BMP_COMPASS_SMALL_CARD,
      NULL,
      wiskey_fail,
      IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY,
      0,
      22,41,
      WHISKEY_COMPASS_DEGREES, wiskey_moving_card_x_cb,
      0, 360,
      MODULE_VAR_NONE, wiskey_moving_card_y_cb,
      0, 0
)

Remarks

When you specify a mask with MAKE_MOVING, you're actually specifying the area within which another part of the gauge can move and appear. Once that other part moves outside of that area (as defined by MIN_X, MAX_X, MIN_Y, and MAX_Y) it won't display. These fields identify the top left and bottom right corners of this area within the gauge background.

See Also


MAKE_ICON

Use MAKE_ICON to toggle between one of several images at a static location on a gauge. The RES_ID member of the structure specifies the first icon image. The panel system loads the first icon image using RES_ID. The panel system loads the next icon image by adding 1 to the RES_ID. It then adds 1 more to RES_ID and loads the next image, and so on. The panel system continues this process as many times as NUM_ICONS specifies. Icon images can be any size, although all images in the same MAKE_ICON have the same upper left location. If you specify IMAGE_USE_ERASE in the image flags for MAKE_ICON, the save buffer will only be as large as the first image. If source_var is set to -1, the icon image is automatically hidden.

Syntax


#define     MAKE_ICON(              NAME,            \
                                    RES_ID,          \
                                    NEXT_LIST,       \
                                    FAILURE,         \
                                    DRAW_FLAGS,      \
                                    ASI_FLAGS,       \
                                    POSITION_X, POSITION_Y,\
                                    SOURCE_VAR, CALLBACK,  \
                                    SWITCH_TYPE,     \
                                    NUM_ICONS,       \
                                    SCALE,           \
                                    OFFSET )         \

Parameters

Field Sample Code Description
NAME fuel_selector_icon Contains the unique name you assign to the macro.
RES_ID BMP_FUEL_SELECTOR_OFF Contains the name of the resource file used by the gauge as identified earlier by SDK.h.
NEXT_LIST NULL Sets the order in which parts of the gauge get drawn.
FAILURE NULL References a FAILURE_RECORD or NULL.
DRAW_FLAGS IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY One or more DRAW_FLAGS.
ASI_FLAGS 0 Specifies the Aircraft Special Instrumentation flags.
POSITION_X, POSITION_Y 0,0 Defines the upper-left X,Y coordinate in display units to initially place the image.
SOURCE_VAR, CALLBACK FUEL_TANK_SELECTOR, fuel_selector_icon_cb Specifies the token variable to use and a callback function to control the image in the X direction.
SWITCH_TYPE ICON_SWITCH_TYPE_SET_CUR_ICON The switch type of the icon. There are four types:
ICON_SWITCH_TYPE_SET_CUR_ICON: Simple on-off functions. The value is interpreted as an index to the current icon, where 0 is the first icon and the number of icons minus one is the last icon.
ICON_SWITCH_TYPE_SET_CUR_USING_RANGE: The value is subtracted from offset and divided by scale to get the current index. You can specify a range that is linearly interpolated into the valid range of icon index.
ICON_SWITCH_TYPE_STEP_TO: Steps through a series of icons—such as a key switch. This is the same as ICON_SWITCH_TYPE_SET_CUR_ICON except that it will step through (animate) each icon.
ICON_SWITCH_TYPE_STEP_TO_USING_RANGE: This is the same as ICON_SWITCH_TYPE_SET_CUR_USING_RANGE except that it will step through (animate) each icon.
NUM_ICONS 4 Specifies the number of icon bitmaps in the gauge.
SCALE 0 Specifies the scale of the icon. This value is only used if SWITCH_TYPE is: ICON_SWITCH_TYPE_SET_CUR_USING_RANGE or ICON_SWITCH_TYPE_STEP_TO_USING_RANGE.
OFFSET 0 Specifies the offset of the icon. This value is only used if switch type is: ICON_SWITCH_TYPE_SET_CUR_USING_RANGE or ICON_SWITCH_TYPE_STEP_TO_USING_RANGE

Example

You'll need to fill this structure out with specific information, such as the following from SDK.Fuel_Selector.cpp:


MAKE_ICON
(
      fuel_selector_icon,
      BMP_FUEL_SELECTOR_OFF,
      NULL,
      NULL,
      IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY,
      0,
      0,0,
      FUEL_TANK_SELECTOR,fuel_selector_icon_cb,
      ICON_SWITCH_TYPE_STEP_TO,
      4,
      0,
      0
)

Remarks

None.

See Also


MAKE_SPRITE

MAKE_SPRITE, like MAKE_MOVING_IMAGE, moves an element in X and Y directions and uses a mask to hide parts of the element. The difference is that MAKE_SPRITE can rotate an element around a pivot point. For MAKE_SPRITE, TEXTURE_CENTER_X and TEXTURE_CENTER_Y identify the center of the sprite—the center of the texture maps to this point. Textures used for ELEMENT_SPRITE must be 256 x 256. When the gauge is loaded, the RES_ID specifies the image to use for the texture. RES_ID + 1 specifies the mask image. The mask doesn't have to be a specific size. The mask is placed on the gauge using the position member. The texture slides and rotates underneath the mask. Element transformations occur in the following order:

Syntax


#define     MAKE_SPRITE(            NAME,      \
                                    RES_ID,    \
                                    NEXT_LIST,  \
                                    FAILURE,    \
                                    DRAW_FLAGS, \
                                    ASI_FLAGS,  \
                                    BKND_POSITION_X, BKND_POSITION_Y,   \
                                    TEXTURE_CENTER_X, TEXTURE_CENTER_Y, \
                                    TEXTURE_SCALE_X, TEXTURE_SCALE_Y,   \
                                    SOURCE_VAR_X, CALLBACK_X, SCALE_X,  \
                                    SOURCE_VAR_Y, CALLBACK_Y, SCALE_Y,  \
                                    SOURCE_VAR_0, CALLBACK_0, SCALE_0 ) \

Parameters

Field Sample Code Description
NAME attitude_sprite_outer Contains the unique name you assign to the macro.
RES_ID BMP_ATTITUDE_SMALL_CARD2 Contains the name of the resource file used by the sprite as identified earlier by SDK.h.
NEXT_LIST NULL Sets the order in which parts of the gauge get drawn.
FAILURE (PFAILURE_RECORD)&attitude_fail References a FAILURE_RECORD or NULL.
DRAW_FLAGS IMAGE_USE_TRANSPARENCY One or more DRAW_FLAGS.
ASI_FLAGS 0 Specifies the Aircraft Special Instrumentation flags.
BKND_POSITION_X, BKND_POSITION_Y 16, 13 Specifies the X and Y coordinates for the top left corner of the mask against the gauge background.
TEXTURE_CENTER_X, TEXTURE_CENTER_Y 137,134 Specifies the X and Y coordinates of the center of the bitmap that moves behind the mask.
TEXTURE_SCALE_X, TEXTURE_SCALE_Y 1.05, 1.05 Specifies the X and Y scaling factor for the sprite. X value can differ from Y value.
SOURCE_VAR_X, CALLBACK_X, SCALE_X MODULE_VAR_NONE, NULL, 0 Specifies the token variable to be read, callback function, and scaling factor for X direction (this value has no effect if equal to 1).
SOURCE_VAR_Y, CALLBACK_Y, SCALE_Y MODULE_VAR_NONE, NULL, 0 Specifies the token variable to be read, callback function, and scaling factor for Y direction (this value has no effect if equal to 1).
SOURCE_VAR_0, CALLBACK_0,
SCALE_0
ATTITUDE_INDICATOR_BANK_DEGREES, NULL, -1 Specifies the token variable to be read, callback function, and scaling factor for 0 direction (this value has no effect if equal to 1).

Example

You'll need to fill this structure out with specific information, such as the following from SDK.Attitude.cpp:


MAKE_SPRITE
(
      attitude_sprite_outer,
      BMP_ATTITUDE_SMALL_CARD2,
      NULL,
      (PFAILURE_RECORD)&attitude_fail,
      IMAGE_USE_TRANSPARENCY,
      0,
      16, 13,
      137,134,
      1.05, 1.05,
      MODULE_VAR_NONE, NULL, 0,
      MODULE_VAR_NONE, NULL, 0,
      ATTITUDE_INDICATOR_BANK_DEGREES, NULL, -1
)

Remarks

None.

See Also


Drawing Element

The following macros have been defined to manipulate drawing elements:

Syntax

#define GET_IMAGE_HIDDEN( element)      (element->image_flags & IMAGE_HIDDEN)
#define SHOW_IMAGE( element)            (element->image_flags &= ~IMAGE_HIDDEN)
#define HIDE_IMAGE( element)            (element->image_flags |= IMAGE_HIDDEN)
#define GET_IMAGE_HIDDEN_TREE( element) (element->image_flags & IMAGE_HIDDEN_TREE)
#define SHOW_IMAGE_TREE( element)       (element->image_flags &= ~IMAGE_HIDDEN_TREE)
#define HIDE_IMAGE_TREE( element)       (element->image_flags |= IMAGE_HIDDEN_TREE)
#define GET_USE_TRANSPARENCY( element)  (element->image_flags & IMAGE_USE_TRANSPARENCY)
#define GET_USE_ERASE( element)         (element->image_flags & IMAGE_USE_ERASE)
#define GET_USE_BRIGHT( element)        (element->image_flags & IMAGE_USE_BRIGHT)
#define GET_ERASE_ON_FAILURE( element)  (element->image_flags & IMAGE_ERASE_ON_FAILURE)

#define GET_ON_SCREEN( element)         (element->image_flags & IMAGE_ON_SCREEN)
#define SET_ON_SCREEN( element)         (element->image_flags |= IMAGE_ON_SCREEN)
#define SET_OFF_SCREEN( element)        (element->image_flags &= ~IMAGE_ON_SCREEN)

#define GET_FAILED( element)            (element->image_flags & GAUGE_FAILURE)
#define SET_GAUGE_FAILED( element)      (element->image_flags |= GAUGE_FAILURE)
#define SET_GAUGE_NOT_FAILED( element)  (element->image_flags &= ~GAUGE_FAILURE)

Remarks

None.

See Also


Drawing Element Structures

Each of the Gauge macros makes use of the drawing elements available. These drawing elements are part of the macro definition in Gauges.h. Here is each macro and its associated element.

Macro Drawing Element
MAKE_STATIC ELEMENT_STATIC_IMAGE
MAKE_NEEDLE ELEMENT_NEEDLE
MAKE_STRING ELEMENT_STRING
MAKE_SLIDER ELEMENT_SLIDER
MAKE_ICON ELEMENT_ICON
MAKE_MOVING ELEMENT_MOVING_IMAGE
MAKE_SPRITE ELEMENT_SPRITE

Shared Data Elements

Each macro has twelve shared data elements, which aren't included in the declaration of each structure. Instead, a #define HEADER is present that, when expanded, produces the twelve data members. The following code examples show the drawing element ELEMENT_NEEDLE before and after expansion. Before expansion:


typedef struct ELEMENT_NEEDLE
{
    HEADER;
    'Needle-specific data members
};

After expansion:


typedef struct ELEMENT_NEEDLE
{
    ELEMENT_TYPE_ENUM element_type;
    ID resource_id;
    PIXPOINT position;
    PIXPOINT previous_position;
    PIXPOINT ofs;
    PGAUGEHDR gauge_header;
    struct ELEMENT_HEADER previous_element;
    struct ELEMENT_HEADER next_element;
    PFAILURE_RECORD failure_systems;
    FLAGS image_flags;
    FLAGS aircraft_special_instrumentation;
    FLAGS reserved;
    'Needle-specific data members.
};

String Element

The following macros have been defined to manipulate string elements:

#define STR_UNSEL( ELEment)           (ELEMENT->sel_end = -1; ELEMENT->sel_str = -1;)
#define STR_SEL( ELEMENT, STR, END)   (ELEMENT->sel_end = END; ELEMENT->sel_str = STR;)
#define IS_STR_SEL( ELEment)          (ELEMENT->sel_end != -1 && ELEMENT->sel_str != -1)

Drawing Element Lists

In code, the drawing elements are organized (using the next_element data member) in a tree structure (the element list). This element list defines the drawing order of the gauge elements:

You don't need to set the previous_element pointer. This pointer is initialized by the panel system when the gauge is initialized.

Remarks

None.

See Also


DRAW_FLAGS

The DRAW_FLAGS field is a combination of one or more of the following flags (combine them using the | operator).

Flags


IMAGE_USE_TRANSPARENCY
This flag is used by C-style gauges for all element types; it has nothing to do with the transparency of a mask image used with an element. When black (pure black, or an RGB value of 0,0,0) is anywhere in a mask image, it is transparent, regardless of whether or not this image flag is set.
Renders the image using transparency. If this flag is set, RGB color (0,0,0) is treated as transparent in a 24-bit bitmap. Because non-transparent rendering is faster than transparent rendering, you can use this flag to enhance performance.
IMAGE_USE_ERASE Use the access buffer for resource. Note: there is a cost in memory and CPU usage.
Before the graphical element is rendered, a "snapshot" of the background is saved. As a result, the panel system can erase the element as needed by plotting the contents of the save buffer to the screen. You can use this flag to increase performance and save memory if an element never needs to be erased. Static images use this flag extensively.
IMAGE_USE_BRIGHT Use this to make the image appear lit at night.
Maps the element's image colors to the section of the palette that doesn't change during the transition from day to night. The image colors will not change.
IMAGE_CREATE_DIBSECTION Creates a new static image as a dibsection.
IMAGE_BILINEAR_GRAY  
IMAGE_BILINEAR_COLOR  
IMAGE_PRESERVE_COLOR_IN_HUD  
IMAGE_CONTAINS_NO_MASK  
IMAGE_BLT_MASK_ONLY  
IMAGE_CONTAINS_MASK Image contains mask bits.
IMAGE_USE_ALPHA Image contains alpha channel.
IMAGE_USE_LUMINOUS Image is bright when the interior light is on.
IMAGE_USE_LUMINOUS_PARTIAL  Parts of image are lit by interior light (alpha channel).
IMAGE_HIDDEN_TREE Do not show this image, and all images in the resource tree above it, until the gauge code specifically calls for it.
IMAGE_NO_STRETCH  
IMAGE_HUD_COLOR_MAP  
IMAGE_NO_TRANSLATION  
IMAGE_HIDDEN Do not show this image until the gauge code specifically calls for it. These change dynamically.
IMAGE_ON_SCREEN Status bit to say whether element is on the screen. You force a gauge to re-plot by setting it off-screen.

Remarks

Aircraft Special Instrumentation

These flags specify how the element will react in a special instrument situation. Currently this is used only with autopilot. This member can have the following values:

Flag Description
ASI_ALT_MANUALLY_TUNABLE Sets a global flag indicating that autopilot altitude hold is manually tunable. If this flag isn't set, turning on altitude hold maintains the current altitude instead of the currently set altitude.
ASI_HEADING_MANUALLY_TUNABLE Sets a global flag indicating that autopilot heading hold is manually tunable. If this flag isn't set, turning on heading hold would maintain the current heading instead of the currently set heading.

See Also