hiGetAbsWindowScreenBBox
hiGetAbsWindowScreenBBox(w_windowId[g_includeWMOffsets] ) =>l_bBox
Description
Returns the absolute screen coordinates of a window, assuming 0:0 is the lower-left corner of the screen.
Arguments
Value Returned
Examples
Returns the screen coordinates of window (2).
hiGetAbsWindowScreenBBox(window(2))
=> ((221 296) (1121 964))
The following sample creates a form that allows the user to change the title or size of a given window.
;;; retrieving the height of the bounding box
procedure( trGetBBoxHeight( bBox )
let( ( ll ur lly ury )
ll = lowerLeft( bBox )
lly = yCoord( ll )
ur = upperRight( bBox )
ury = yCoord( ur )
ury - lly
) ; let
) ; procedure
;;; retrieving the width of the bounding box procedure( trGetBBoxWidth( bBox ) let( ( ll ur llx urx )
ll = lowerLeft( bBox )
llx = xCoord( ll )
ur = upperRight( bBox )
urx = xCoord( ur )
urx - llx
) ; let
) ; procedure
;;; retrieving the window height procedure( trGetWindowHeight( wid ) trGetBBoxHeight(hiGetAbsWindowScreenBBox( wid ) )
) ; procedure
;;; retrieving the window width procedure( trGetWindowWidth( wid ) trGetBBoxWidth( hiGetAbsWindowScreenBBox( wid ) )
) ; procedure
;;; resizing the window to the given bounding box procedure( trResizeWindow( @key ( id hiGetCurrentWindow() ) ( height nil ) ( width nil ) ) let( ( bBox ll ur llx lly urx ury urNew )
bBox = hiGetAbsWindowScreenBBox( id )
ll = lowerLeft( bBox )
ur = upperRight( bBox )
llx = xCoord( ll )
lly = yCoord( ll )
urx = xCoord( ur )
ury = yCoord( ur )
unless( height height = ury - lly )
unless( width width = urx - llx )
urNew = llx + width : lly + height
hiResizeWindow( id list( ll urNew ) )
id
) ; let
) ; procedure
;;; creating a form that acts upon the window with the
;;; window id (wid)
procedure( trCreateWindowForm( wid )
let( ( nameField heightField widthField theFormSymbol theForm )
nameField =
hiCreateStringField(
?prompt "Name"
?name 'nameField
?value hiGetWindowName( wid )
?defValue hiGetWindowName( wid )
?callback "println( 'nameField )"
)
heightField =
hiCreateScaleField(
?prompt "Height"
?name 'heightField
?value trGetWindowHeight( wid )
?defValue trGetWindowHeight( wid )
?range list( 0 yCoord( hiGetMaxScreenCoords()))
?callback "println( 'heightField )"
)
widthField =
hiCreateScaleField(
?prompt "Width"
?name ’widthField
?value trGetWindowWidth( wid )
?defValue trGetWindowWidth( wid )
?range list( 0 xCoord( hiGetMaxScreenCoords()) )
?callback "println( 'widthField )"
)
;;; specifying a unique symbol to allow multiple
;;; instances of the form to be active at a single
;;; time
theFormSymbol = gensym( 'WindowForm )
;;; building the form’s data structure
theForm =
hiCreateAppForm(
?name theFormSymbol
?formTitle sprintf( nil "%L" wid )
?callback "trWindowFormCB( hiGetCurrentForm())"
?fields list( nameField heightField widthField)
?unmapAfterCB t
)
;;; associating the wid with the form via a user
;;; defined slot
theForm->wid = wid
theForm ;;; the return value
) ; let
) ; procedure
;;; The following callback for the form handles the ;;; renaming and resizing of the window. procedure( trWindowFormCB( theForm ) let( ( wid newName newHeight newWidth )
;;; picking up the current form values
wid = theForm->wid
;;; user specified slot linking the form to the window
newName = theForm->nameField->value
;;; accessing the current hightField
newHeight = theForm->heightField->value
;;; accessing the current widthField
newWidth = theForm->widthField->value
;;; setting the window name
hiSetWindowName( wid newName )
;;; resizing the window
trResizeWindow(
?id wid
?height newHeight
?width newWidth
) ; trResizeWindow
t ;;; the return value
) ; let
) ; procedure
To test your application using the CIW, type:
wf1 = trCreateWindowForm( window(1))
hiDisplayForm(wf1)
After the form is displayed, change the values of the Height and Width fields and type a new title for the CIW in the Name field. Select the Apply button to see the changes in the title and size of the CIW.
Related Topics
Return to top