Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

resize(3) [hpux man page]

resize()																  resize()

Name
  resize - RectObj class method called when a widget is resized.

Synopsis
  typedef void (*XtWidgetProc)(Widget);
	 Widget w;

Inputs
  w	    Specifies the widget that has been resized.

Description
  The  resize()  method is registered on the resize field of the RectObj or Core class part structure.	It is called when a widget is resized
  through a call to XtResizeWidget() or XtConfigureWidget(), and is responsible for doing any layout of children or recalculating any  cached
  values necessary for the widget to draw itself at its new size.

  The  resize() method is called whether or not the widget is realized.  The width, height, and border_width fields of the widget contain the
  new size of the widget.  Note that this method is not responsible for drawing the widget at its new size.  Unless the widget's  window  has
  bit gravity set (which is not the default) then when the window is resized, an Expose event will be generated, and the expose() method will
  be called by the Intrinsics.	If the resize() method does call the expose() method, then the widget will be redrawn twice.

  The widget must treat resize() as a command, not as a request.  A widget must neither change its own size from within the resize()  method,
  nor appeal the size change by calling XtMakeGeometryRequest() or XtMakeResizeRequest().

  Note	that  the  resize()  method  is  not  invoked by XtMakeResizeRequest() or XtMakeGeometryRequest(), but it may be called if the parent
  explicitly resizes the widget while granting the resize request.  Because the widget does not know whether its resize() method was  called,
  it  should  be prepared to perform the necessary layout or calculation after making a geometry request, and may choose to do this simply by
  calling its resize procedure directly.  Resize procedures should be written so that they can safely be called more than once in a row.

  The resize() method is not chained.  A widget class can inherit the resize() method of its superclass by specifying XtInheritResize in  the
  resize field of the RectObj or Core class part structure.  A widget that needs do no computation when resized can set this field to NULL.

Usage
  Very	simple	widgets may check their size and compute how to draw themselves every time their expose() procedure is called.	A widget that
  does this does not need a resize() method and can specify NULL.  Most widgets however, do some pre-computation so that they can more	effi-
  ciently redraw themselves.  The Xaw Label widget, for example, computes the starting position of the text it draws based on the size of the
  window, the size of the text, the margins, and the value of the XtNjustify resource.	This pre-computed value is  valid  until  the  window
  size, the label, the font, the margins, or the justification changes.  Label's resize() method calls an internal procedure to perform these
  calculations.  This procedure is also called from the set_values() method.

  Many composite widgets must recompute the layout of their children when they are resized.  This may involve moving or resizing the children
  widgets.   Composite widgets will often call an internal layout procedure from their resize() method, and will call the same procedure from
  their change_managed() method and perhaps also their geometry_manager() method.

Example
  The following procedures are the resize() methods of the Xaw Clock and Porthole widgets.  The first pre-computes a number of values used to
  draw	the  clock  at a given size, and the second ensures that the child of the Porthole is at least as large as the Porthole itself.  Note
  that the Clock resize() method is optimized only to do the resize calculations if the widget is realized.  In order to do this, though,  it
  must	call this procedure from its realize() method.	The Xaw Mailbox widget, which simply displays a pixmap, is so simple that it does not
  need a resize() method.  The Xaw Form and Box widgets are examples of composite widgets that must perform some sophisticated layout  compu-
  tations when they are resized.

     static void Resize (gw)
	 Widget gw;
     {
	 ClockWidget w = (ClockWidget) gw;
	 /* don't do this computation if window hasn't been realized yet. */
	 if (XtIsRealized(gw) && w->clock.analog) {
	     /* need signed value since Dimension is unsigned */
	     int radius = ((int) min(w->core.width, w->core.height) -
		  (int) (2 * w->clock.padding)) / 2;
	     w->clock.radius = (Dimension) max (radius, 1);

	     w->clock.second_hand_length =
		  (int)(SECOND_HAND_FRACT * w->clock.radius) / 100;
	     w->clock.minute_hand_length =
		  (int)(MINUTE_HAND_FRACT * w->clock.radius) / 100;
	     w->clock.hour_hand_length =
		  (int)(HOUR_HAND_FRACT * w->clock.radius) / 100;
	     w->clock.hand_width =
		  (int)(HAND_WIDTH_FRACT * w->clock.radius) / 100;
	     w->clock.second_hand_width =
		  (int)(SECOND_WIDTH_FRACT * w->clock.radius) / 100;

	     w->clock.centerX = w->core.width / 2;
	     w->clock.centerY = w->core.height / 2;
	 }
     }

     static void Resize (gw)
	 Widget gw;
     {
	 PortholeWidget pw = (PortholeWidget) gw;
	 Widget child = find_child (pw);

	 /*
	  * If we have a child, we need to make sure that it is
	  * at least as big as we are and in the right place.
	  */
	 if (child) {
	     Position x, y;
	     Dimension width, height;

	     layout_child (pw, child, NULL, &x, &y, &width, &height);
	     XtConfigureWidget (child, x, y, width, height, (Dimension) 0);
	 }

	 SendReport (pw, (unsigned int) (XawPRCanvasWidth XawPRCanvasHeight));
     }

See Also
  XtConfigureWidget(1), XtResizeWidget(1),
  Core(3).

Xt - Intrinsics Methods 														  resize()
Man Page