PtExtentWidget

PtExtentWidget — forces a widget to calculate its extent.

Syntax

PtExtentWidget (widget)

		

Arguments

widget

The widget that will calculate its extent.

Returns

t if successful.

Description

This function forces the widget to calculate its extent. When calculating its extent, a widget will resize itself to contain all of its children.

Example

This example, ex_PtExtentWidget.g, is included in the product distribution.

#!/usr/cogent/bin/phgamma

/*
This example draws many buttons on the screen.
The PtExtentWidget function is used to make sure
the window can hold all of the widgets.
*/

require_lisp("PhotonWidgets");
PtInit(nil);
win = new(PtWindow);
win.resize_flags = Pt_RESIZE_X_ALWAYS | Pt_RESIZE_Y_ALWAYS;
PtRealizeWidget(win);

but_array = make_array(0);
for(i=0;i<100;i++)
{
  but_array[i] = new(PtButton);
  but_array[i].text_string = "Button";
  but_array[i].SetPos((i * 10) % 640 , (i * 10) % 480);
  PtRealizeWidget(but_array[i]);
  PtExtentWidget(win);
  flush_events();
  nanosleep(0,50000000);
}

for(i=99;i>=0;i --)
{
  PtDestroyWidget(but_array[i]);
  PtExtentWidget(win);
  flush_events();
  nanosleep(0,50000000);
}
PtMainLoop();

See Also

In Photon documentation: PtDestroyWidget.