![]() |
![]() |
![]() |
![]() |
A function you must write to create an instance of a frugal resource editor
typedef ResPluginHandle_t ResPluginFrugalCreateF_t ( PhABHandle_t phab , const PhABResExportFrugal_t *exp, const ResPluginFormatData_t *format, int n_default, const void *default_value, PtWidget_t *parent, int n, const void *value )
This function is exported in the ResPluginFrugalEditor_t structure.
This function is called to create a new instance of the frugal resource editor.
The plugin should create any necessary widgets inside the container parent widget. The plugin must try to create its widget(s) with a transparent background, if possible, and it should anchor it's widgets or attach a resize callback to the parent in order to properly display itself when the width of the parent changes. The parent widget will have a non-transparent background.
If necessary, format information is passed by format when the plugin instance is created. The format data depends on the data type. For example, for the RES_DATATYPE_FLAG datatype, format provides the plugin with the list of possible flag values, the flag manifests, and the associated masks, if any.
This function should return a ResPluginHandle_t plugin handle, or NULL on error. If you return a non-NULL value, this value will be passed as the first argument to all your other functions.
This example create function for a frugal editor is from the complete plugin example at the end of this chapter.
static ResPluginHandle_t plugin_frugal_create
( PhABHandle_t phab , const PhABResExportFrugal_t *exp,
const ResPluginFormatData_t *format,
int n_default, const void *default_value,
PtWidget_t *parent,
int n, const void *value ) {
PtArg_t args[2];
PhRect_t offset = { { -1, -1 }, { -1, -1 } };
PluginFrugalInstance_t *instance;
instance = calloc( 1, sizeof( *instance ) );
if( !instance ) return NULL;
instance->n_default = n_default;
instance->default_value = default_value;
instance->n_master = n;
instance->value_master = value;
instance->phab = phab;
instance->exp = exp;
PtSetArg( &args[0], Pt_ARG_ANCHOR_OFFSETS, &offset, 0 );
PtSetArg( &args[1], Pt_ARG_TEXT_STRING, value, 0 );
instance->frugal = ApCreateWidget( db, "string_frugal", 0, 0, 2, args );
PtAddCallback( instance->frugal, Pt_CB_TEXT_CHANGED, plugin_frugal_changed, instance );
return ( ResPluginHandle_t ) instance;
}
QNX Neutrino
PhABResExportFrugal_t, ResPluginFrugalEditor_t, Resource datatypes.
![]() |
![]() |
![]() |
![]() |