Create a widget class
PtWidgetClass_t *PtCreateWidgetClass( PtWidgetClassRef_t *superclass_ref, unsigned int size, unsigned int num_args, PtArg_t const *args );
This function creates a new widget class based on superclass_ref. If the specified superclass hasn't yet been created, it's created now.
If the size parameter is zero, the new class is the same size as the specified superclass. Otherwise size bytes are allocated for the new class. The specified superclass is then copied into the newly allocated class (inheritance). The version, resources, num_resources, callbacks, dflts_f, connect_f, init_f, unrealize_f, and destroy_f members are cleared because they shouldn't be inherited.
A pointer to the newly created class:
base->superclass = superclass ? superclass->wclass:NULL;
This example is from the ShadowedBox sample widget.
// // ShadowedBox class-creation function // PtWidgetClass_t *PtCreateBasicClass( void ) { static const PtResourceRec_t resources[] = { { SBW_SHADOW_COLOR, Pt_CHANGE_REDRAW, 0, Pt_ARG_IS_NUMBER( ShadowedBoxWidget, shadow_color ) }, { SBW_SHADOW_OFFSET, Pt_CHANGE_REDRAW, 0, Pt_ARG_IS_NUMBER( ShadowedBoxWidget, shadow_offset ) } }; static const PtArg_t args[] = { { Pt_SET_VERSION, 110}, { Pt_SET_STATE_LEN, sizeof( ShadowedBoxWidget ) }, { Pt_SET_DFLTS_F, (long)shadowbox_dflts }, { Pt_SET_DRAW_F, (long)shadowedbox_draw }, { Pt_SET_FLAGS, 0, Pt_RECTANGULAR }, { Pt_SET_RESOURCES, (long) resources }, { Pt_SET_NUM_RESOURCES, sizeof( resources )/sizeof( resources[0] ) } }; return( ShadowedBox->wclass = PtCreateWidgetClass( PtBasic, 0, sizeof( args )/sizeof( args[0] ), args ) ); }
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PtArg_t in the Photon Library Reference