LispWorks CAPI Reference Manual > 1 CAPI Reference Entries

NextPrevUpTopContentsIndex

set-object-automatic-resize

Function
Summary

Controls automatic resizing of objects on a pinboard.

Package

capi

Signature

set-object-automatic-resize object &key x-align y-align x-offset y-offset x-ratio y-ratio width-ratio height-ratio aspect-ratio aspect-ratio-y-weight pinboard

Arguments

object

A pinboard-object or a simple-pane.

x-align

nil , :left , :center or :right .

y-align

nil , :top , :center or :bottom .

x-offset

A real number, default value 0.

y-offset

A real number, default value 0.

x-ratio

A positive real number or nil .

y-ratio

A positive real number or nil .

width-ratio

A positive real number or nil .

height-ratio

A positive real number or nil .

aspect-ratio

A positive real number, t or nil .

aspect-ratio-y-weight

A real number, default value 0.5.

pinboard

A pinboard-layout, if supplied.

Description

The function set-object-automatic-resize arranges for object to be resized and/or re-positioned automatically when pinboard is resized, or removes such a setting.

The value of aspect-ratio can be t , which means use the current aspect ratio of object (that is, its height divided by its width).

object should be either a pinboard-object or a simple-pane which is (or will be) displayed in a pinboard-layout. This is, object will be added to the description of the pinboard layout by one of its :description initarg, (setf capi:layout-description) or manipulate-pinboard.

pinboard is the pinboard layout for object . If pinboard is already displayed with object in its description , the argument pinboard can be omitted.

When pinboard is resized, object is resized if either height-ratio or width-ratio are set.

The new width of object is calculated as follows:

The new height of object is calculated as follows:

If all of width-ratio , height-ratio and aspect-ratio are set, the new width and height of object are calculated as follows:

  1. Compute calculated-width as the width of pinboard multiplied by width-ratio , and calculated-height as the height of pinboard multiplied by height-ratio .
  2. Compute aspect-ratio-ratio as
(/ (/ calculated-height calculated-width ) aspect-ratio )
  1. Compute correction as
( expt aspect-ratio-ratio aspect-ratio-y-weight )
  1. Compute the new width as calculated-width multiplied by correction , and the new height as the new width multiplied by aspect-ratio .

The result is that if aspect-ratio-y-weight is 0, correction is 1 and height-ratio is effectively ignored, while if aspect-ratio-y-weight is 1, correction cancels the effect of width-ratio . With the default value of 0.5, the resulting position is in the (geometric) middle, and object takes a fixed fraction of the area of the pinboard.

After resizing (if needed), object is also positioned horizontally if x-align is non-nil, and vertically if y-align is non-nil.

The new x coordinate of object is calculated as follows:

The new y coordinate of object is calculated similarly, using y-ratio and y-offset , with an adjustment such that the top, center or bottom of object aligns with the new coordinate according to y-align .

If all of width-ratio , height-ratio , x-align and y-align are nil , automatic resizing/re-positioning of object is removed.

set-object-automatic-resize can be called before object is actually displayed, and its effect persists over calls adding and removing object to/from pinboard-layouts. If object is to be used in another pinboard layout, set-object-automatic-resize must be called to remove the automatic resizing from the first pinboard layout.

Example

Put an object of fixed size at the top right corner:

(set-object-automatic-resize object 
                             :x-ratio 1 :x-align :right)

Put an object in the bottom-right quadrant:

(set-object-automatic-resize 
 object
 :x-ratio 0.5 :y-ratio 0.5
 :width-ratio 0.5 :height-ratio 0.5)

Put an object with a fixed aspect ratio and object width linear with the width of the pinboard in the center:

(set-object-automatic-resize 
 object
 :x-align :center :y-align :center
 :x-ratio 0.5 :y-ratio 0.5
 :aspect-ratio 0.6 :width-ratio 0.1)
See also

manipulate-pinboard
pinboard-layout
pinboard-object
simple-pane


LispWorks CAPI Reference Manual - 21 Dec 2009

NextPrevUpTopContentsIndex