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/lib_ref/pt/ptfindchildclass.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/lib_ref/pt/ptfindchildclass.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/lib_ref/pt/ptfindchildclass.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/lib_ref/pt/ptfindchildclass.html on line 8

PtFindChildClass()

Find the first descendant that matches the specified class

Synopsis:

PtWidget_t *PtFindChildClass( 
                PtWidgetClassRef_t *class,
                PtWidget_t *widget );

Library:

ph

Description:

This function searches the widget family hierarchy of the given container, widget, for a descendant widget that matches the specified class.


Note: Some container widgets, including PtDivider, PtMenuBar, PtMultiText, and PtScrollArea redirect children to an alternate parent. For all container widgets, it's best to call PtValidParent() to determine the “real” parent of the children. For example, to find a PtButton in a PtScrollArea:
child = PtFindChildClass( PtButton,
          PtValidParent( my_scrollarea, PtButton ));

Returns:

A pointer to a PtWidget_t structure, or NULL if an error occurs.

Examples:

#include <stdlib.h>
#include <Pt.h>

int main()
{
    PtArg_t argt;
    PtWidget_t *window, *pane, *button;

    if (PtInit(NULL) == -1)
      exit(EXIT_FAILURE);

    // Create a window that contains a pane, which in turn
    // contains a button.

    if ((window = PtCreateWidget(PtWindow, Pt_NO_PARENT,
                                 0, NULL)) == NULL)
      PtExit(EXIT_FAILURE);

    PtSetArg( &argt, Pt_ARG_RESIZE_FLAGS, 
              Pt_TRUE, Pt_RESIZE_XY_ALWAYS );
    pane = PtCreateWidget( PtPane, Pt_DEFAULT_PARENT,
                           1, &argt );

    PtSetArg( &argt, Pt_ARG_TEXT_STRING, "Sample", 0 );
    PtCreateWidget( PtButton, Pt_DEFAULT_PARENT, 1, &argt );

    // The following call finds the button because PtButton
    // is a subclass of PtLabel.

    button = PtFindChildClassMember( PtLabel, pane ); 
    if (button != NULL) {
       printf ("The widget is a subclass of PtLabel.\n");
    } else {
       printf ("The widget isn't a subclass of PtLabel.\n");
    }
       
    // The following call does not find the button because
    // PtButton is not equivalent to the PtLabel class.

    button = PtFindChildClass( PtLabel, pane );
    if (button != NULL) {
       printf ("The widget is a PtLabel.\n");
    } else {
       printf ("The widget isn't a PtLabel.\n");
    }

    // The following call finds the button because PtButton
    // is in the class PtButton.

    button = PtFindChildClass( PtButton, pane );
    if (button != NULL) {
       printf ("The widget is a PtButton.\n");
    } else {
       printf ("The widget isn't a PtButton.\n");
    }
   
   return EXIT_SUCCESS;
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PtFindChildClassMember(), PtValidParent(), PtWidgetBrotherBehind(), PtWidgetBrotherInFront(), PtWidgetChildBack(), PtWidgetFamily(), PtWidgetParent()


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/lib_ref/pt/ptfindchildclass.html on line 183

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/lib_ref/pt/ptfindchildclass.html on line 183