Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/wid_build/libs/ptcreatewidgetclass.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/wid_build/libs/ptcreatewidgetclass.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/wid_build/libs/ptcreatewidgetclass.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/wid_build/libs/ptcreatewidgetclass.html on line 8

PtCreateWidgetClass()

Create a widget class

Synopsis:

PtWidgetClass_t *PtCreateWidgetClass( 
                   PtWidgetClassRef_t *superclass_ref, 
                   unsigned int size, 
                   unsigned int num_args, 
                   PtArg_t const *args );

Arguments:

superclass_ref
The superclass for the new widget class.
size
The size of the new widget class. If this is 0, the size of the superclass is used; if nonzero, it must be at least the size of the superclass.
num_args
The number of entries in the arg array.
args
An array of class attributes and member functions to be applied when creating the new class.

Description:

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.

Returns:

A pointer to the newly created class:

base->superclass = superclass ? superclass->wclass:NULL;

Examples:

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

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PtArg_t in the Photon Library Reference


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/wid_build/libs/ptcreatewidgetclass.html on line 165

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/wid_build/libs/ptcreatewidgetclass.html on line 165