[Previous] [Contents] [Index] [Next]

PtClearWidget()

Destroy all widgets within a container

Synopsis:

int PtClearWidget(PtWidget_t *widget);

Description:

This function destroys all the widgets within the specified container-class widget. If the specified widget isn't a container, no action is taken.

Returns:

0
Successful completion.
-1
An error occurred (the widget wasn't a container).

Examples:

main()
{
    PtWidget_t *group, *window;
    PtArg_t argt;
    PtArg_t argts[3];
    PhPoint_t pos ={ 10,10 };

    PtInit( NULL );
    PtSetArg( &argt, Pt_ARG_POS, &pos, 0 );
    window = PtCreateWidget( PtWindow, parent, 1, &argt );

    PtSetArg( &argts[0], Pt_ARG_POS, &pos, 0 );
    PtSetArg( &argts[1], Pt_ARG_GROUP_ORIENTATION, 
              Pt_GROUP_VERTICAL, 0 );
    group = PtCreateWidget( PtGroup, window, 1, &argt );

    PtSetArg( &argt, Pt_ARG_TEXT_STRING, "Button", 0 );
    PtCreateWidget( PtButton, group, 1, &argt );

    //using same string as previous button...
    PtCreateWidget( PtButton, group, 1, &argt );

    PtCreateWidget( PtButton, group, 1, &argt );

    PtRealizeWidget( window );

    PtContainerHold( group );
    PtClearWidget( group );
    //destroys all widgets within the group, 
    //clearing it...

    //add new children to the group
    PtSetArg( &argt, Pt_ARG_TEXT_STRING,
              "New Button", 0 );
    PtRealizeWidget( PtCreateWidget( PtButton, group, 1,
                                     &argt ) );
    PtSetArg( &argt, Pt_ARG_TEXT_STRING,
              "New Button2", 0 );
    PtRealizeWidget( PtCreateWidget( PtButton, group, 1,
                     &argt ) );
    
    //force the group to re-align its children and resize.
    PtExtentWidget( group );
    
    PtContainerRelease( group );
    PtMainLoop();
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PtContainerHold(), PtContainerRelease(), PtDestroyWidget(), PtExtentWidget(), PtWidgetChildBack()


[Previous] [Contents] [Index] [Next]