Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

PtWidgetToBack()

Move a widget behind all its brothers

Synopsis:

int PtWidgetToBack( PtWidget_t *widget );

Library:

ph

Description:

This function moves the specified widget behind all its brothers (i.e. away from the user). All of widget's children are moved too. Any widgets damaged as a result of this operation are automatically repaired.


Note: This function doesn't work for PtWindow widgets -- their positions are controlled by the Window Manager. To move a window to the back of the workspace, use PtWindowToBack(), which is described in the Photon Widget Reference.

Returns:

0
Successful completion.
-1
An error occurred.

Examples:

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

int main ()
{
  PtWidget_t *window, *group, *child, *child2, *child3;
  PtArg_t  argt[5];
  char *name;

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

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

  group = PtCreateWidget( PtGroup, Pt_DEFAULT_PARENT, 0, NULL );

  // Create some buttons in the group.
  PtSetArg( &argt[0], Pt_ARG_TEXT_STRING, "Child 1", 0 );
  PtCreateWidget( PtButton, Pt_DEFAULT_PARENT, 1, argt );
  PtSetArg( &argt[0], Pt_ARG_TEXT_STRING, "Child 2", 0 );
  child2 = PtCreateWidget( PtButton, Pt_DEFAULT_PARENT, 1, argt );
  PtSetArg( &argt[0], Pt_ARG_TEXT_STRING, "Child 3", 0 );
  child3 = PtCreateWidget( PtButton, Pt_DEFAULT_PARENT, 1, argt );
  PtSetArg( &argt[0], Pt_ARG_TEXT_STRING, "Child 4", 0 );
  PtCreateWidget( PtButton, Pt_DEFAULT_PARENT, 1, argt );

  /* Traverse the group from back to front. */
  
  printf ("From back to front:\n");
  for (child = PtWidgetChildBack( group );
       child;
       child = PtWidgetBrotherInFront( child ))
  {
     PtGetResource ( child, Pt_ARG_TEXT_STRING, &name, 0);
     printf ("  %s\n", name);
  }
   
  /* Move Child 2 to the front, and Child 3 to the back. */
  
  PtWidgetToFront (child2);
  PtWidgetToBack (child3);
   
  /* Traverse the group from back to front. */
  
  printf ("From back to front:\n");
  for (child = PtWidgetChildBack( group );
       child;
       child = PtWidgetBrotherInFront( child ))
  {
     PtGetResource ( child, Pt_ARG_TEXT_STRING, &name, 0);
     printf ("  %s\n", name);
  }
   
  PtRealizeWidget (window);
  PtMainLoop();
  return EXIT_SUCCESS;
}

The above code produces this output:

From back to front:
  Child 1
  Child 2
  Child 3
  Child 4
From back to front:
  Child 3
  Child 1
  Child 4
  Child 2

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PtWidgetBrotherBehind(), PtWidgetBrotherInFront(), PtWidgetChildBack(), PtWidgetChildFront(), PtWidgetInsert(), PtWidgetParent(), PtWidgetToFront()

PtWindowToBack() PtWindowToFront() in the Photon Widget Reference.

"Ordering widgets" in the Managing Widgets in Application Code chapter of the Photon Programmer's Guide