PhABResExportCommon_t.get_res()

A function exported by PhAB to get the resource structure for another datatype

Synopsis:

void get_res (
  ResDatatype_t type
  char *abstract_name_editor
  ResPluginFrugalEditor_t **pfrugal_editor,
  ResPluginFullEditor_t **pfull_editor
   )

Arguments:

type
The datatype for the resource editor that you want to obtain a handle for.
abstract_name_editor
The name of the resource editor you want to obtain a handle for. Use NULL to get the handle for the pre-defined editor. Otherwise, use a name for an editor defined in the palette files.
pfrugal_editor
This argument is filled in by the function with a pointer to a ResPluginFrugalEditor_t, which represents the frugal editor that matches the type and abstract_name_editor. Pass NULL in this parameter if you're not interested in obtaining this pointer.
pfull_editor
This argument is filled in by the function with a pointer to a ResPluginFullEditor_t, which represents the full editor that matches the type and abstract_name_editor. Pass NULL in this parameter if you're not interested in obtaining this pointer.

Description:

This function is exported from PhAB in the PhABResExportCommon_t structure.

This convenience function can be called from either the frugal or full editor to obtain the handle for the editor of another resource type. This allows one plugin to call another currently loaded resource editor plugin as a sub-editor. For example, a pixmap full editor needs to be able to edit the color of a pixel. To do this, you can use get_res() in the pixmap editor to create an instance of the full color editor.

Examples:

Here is a partial example of calling the color editor from a different editor plugin.

/* taken from the pixmap editor plugin */
/* here "instance" is an instance to the full resource pixmap editor */
/* get the predefined resource editor for "color" */

instance->exp->common.get_res( RES_DATATYPE_COLOR, NULL, NULL,
                              &instance->def_res_full_color );

/* did we obtain a valid pointer to the full resource editor for "color" ?
*/

if( instance->def_res_full_color ) {

      /* use the exported convenience functions that were passed for the pixmap
      plugin editor */
      instance->color_editor_exp = *instance->exp;

    /* defined our own apply and closing functions */
    instance->color_editor_exp.common.apply = color_res_apply;
    instance->color_editor_exp.closing = color_res_closing;
    instance->color_editor_handle = instance->def_res_full_color->create(
            (PhABHandle_t) instance, &instance->color_editor_exp, NULL, color, NULL,
            NULL, "the color editor", color, NULL );
}

static int color_res_apply( PhABHandle_t phab, int color, void *value ) {
    PluginFullInstance_t *instance = (PluginFullInstance_t *) phab;

  /* here "instance" is an instance to the full resource pixmap editor */
    .......
    return 1;
}

static int color_res_closing( PhABHandle_t phab ) {
    PluginFullInstance_t *instance = (PluginFullInstance_t *) phab;

    /* here "instance" is an instance to the full resource pixmap editor */
    instance->color_editor_handle = NULL;
    return 1;
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

create_window(), destroy(), get_area(), PhABResExportCommon_t, set_state(), to_front().