xytoxy(
xytoxy(
POINTRECTANGLE
,
FROMCOORDINATES
,
TOCOORDINATES
)

The xytoxy( function converts a point or rectangle from one co-ordinate system to another.

Parameters

This function has three parameters:

pointrectangle – the point (see point() or rectangle (see rectangle() you want to convert.

fromcoordinates – the current co-ordinate system for the point or rectangle in the first parameter. This may be screen relative, window relative, or form relative. See below for details.

tocoordinates – the new co-ordinate system for the point or rectangle. This may be screen relative, window relative, or form relative. See below for details.

Description

The xytoxy( function converts a point or rectangle from one co-ordinate system to another. The type of data returned depends on the type passed in: If you pass it a point, it returns a point, if you pass it a rectangle, it returns a rectangle.

Panorama has three different graphics co-ordinate systems - screen, window, and form.

Screen relative co-ordinates (sometimes also called global co-ordinates) are expressed relative to the top left corner of the main screen. In screen relative co-ordinates, the position 0,0 refers to the top left corner of the screen. To specify screen relative co-ordinates use `"Screen"`, `"screen"`, `"S"` or `"s"`.

Window relative co-ordinates are expressed relative to the top left corner of the current window. In window relative co-ordinates, the position 0,0 refers to the top left corner of the current window. If the window has scroll bars, window relative co-ordinates are not affected by scrolling. To specify window relative co-ordinates use `"Window"`, `"window"`, `"W"` or `"w"`.

Form relative co-ordinates are expressed relative to the top left corner of the current form. In form relative co-ordinates, the position 0,0 refers to the top left corner of the form. If the window has scroll bars, form relative co-ordinates are affected by scrolling – for example, 0,0 will refer to a position that is not visible if the form has been scrolled. To specify form relative co-ordinates use `"Form"`, `"form"`, `"F"` or `"f"`.

The info(“click”) function returns the screen relative co-ordinates of the last mouse click. This procedure will convert the mouse click point to form relative, then check to see if the mouse was clicked in the top inch of the form.

    local mousePoint
    mousePoint=xytoxy(info("click"),"s","f")
    if v(mousePoint)<=72
        message "You clicked in the top inch of the form"
    endif

Error Messages

xytoxy( function conversion error (unknown co-ordinate system). – This message indicates that Panorama doesn’t understand the conversion you asked it to do. For example, if you asked it to convert from “local” to “global” it would not know what you were asking. You’ll also see this error if you ask it to convert from a co-ordinate system to itself, for example “screen” to “screen”.

See Also

- adjustxy( -- adjusts the four corners of a rectangle. However, only corners that are inside a boundary are adjusted. Corners outside the boundary are left alone.
- bestfitrectangle -- fits a rectangle within a boundary rectangle, enlarging or reducing as necessary to produce the best fit without changing the proportions.
- bestfitrectangle( -- fits a rectangle within a boundary rectangle, enlarging or reducing as necessary to produce the best fit without changing the proportions.
- calcenclosingrectangle -- will calculate the rectangle surrounding all of the specified objects.
- getbutton -- retrieves the coordinates of the last button that was pressed (in global screen co-ordinates).
- getclick -- returns the location of the mouse in global coordinates (coordinates from the top left corner of the screen).
- getinternalbutton -- retrieves the coordinates of the last button that was pressed (in form relative coordinates).
- getlocalbutton -- retrieves the coordinates of the last button that was pressed (in window relative coordinates).
- getlocalclick -- returns the location of the most recent mouse click in local coordinates (coordinates from the top left corner of the current form).
- h( -- extracts the horizontal position from a point (see point(, Graphic Coordinates).
- info("availablescreenrectangle") -- returns a rectangle defining the edges of the main screen, after deducting for the space of the menu bar and dock (if visible).
- info("formxy") -- returns a point that indicates how much the current form is scrolled (if at all).
- info("screenrectangle") -- returns a rectangle defining the edges of the main screen.
- inrectangle( -- checks to see if a point is inside a rectangle.
- integralpoint( -- converts point coordinates to integers.
- integralrectangle( -- converts rectangle coordinates to integers.
- intersectionrectangle( -- creates a rectangle by combining two rectangles. The new rectangle is the area where the two rectangles overlap (if any).
- maprectangle( -- maps the position and size of a rectangle within a template rectangle into the same relative position and size within a goal rectangle.
- Modifiable Object Properties -- describes the properties of graphic objects that can be modified by a program (dimensions, color, font, title, etc.).
- moveobjects -- will move an object or group of objects up, down, left or right on the form.
- nsrect( -- defines a rectangle using the same parameter order as the Cocoa NSMakeRect( function.
- nsrectstr( -- converts a rectangle into text in the format x,y,width,height
- pinrectangle( -- pins a rectangle within the bounds of a larger rectangle.
- point( -- combines vertical and horizontal co-ordinates into a single binary value that describes the position of a point (see Graphic Coordinates).
- pointstr( -- converts a point value into text in the format v,h (for example 34,56).
- rbottom( -- extracts the position of the bottom edge of a rectangle (see rectangle(, Graphic Coordinates).
- rectangle( -- defines a rectangle from four dimensions.
- rectangleadjust( -- adjusts all four edges of a rectangle independently
- rectanglealign( -- aligns a small rectangle at one of nine positions within a larger rectangle.
- rectanglecenter( -- adjusts a rectangle so that it is centered inside of another rectangle.
- rectangleinset( -- insets a rectangle by a specified amount.
- rectangleoffset( -- offsets a rectangle to a new position.
- rectanglesize( -- defines a rectangle from its upper left hand corner and its height and width.
- rectanglesizestr( -- converts a rectangle into text in the format *top,left,height,width*.
- rectanglestr( -- converts a rectangle into text in the format *top,left,bottom,right*.
- rectangletweak( -- transforms a rectangle by changing its position and/or size.
- rheight( -- extracts the height of a rectangle (see rectangle(, Graphic Coordinates).
- rleft( -- extracts the position of the left edge of a rectangle (see rectangle(, Graphic Coordinates).
- rright( -- extracts the position of the right edge of a rectangle (see rectangle(, Graphic Coordinates).
- rtop( -- extracts the position of the top edge of a rectangle (see rectangle(, Graphic Coordinates).
- rwidth( -- extracts the width of a rectangle (see rectangle(, Graphic Coordinates).
- setrectangleheight( -- changes the height of a rectangle, leaving the width unchanged.
- setrectanglesize( -- changes the height and width of a rectangle, leaving the position of the top left hand corner unchanged.
- setrectanglewidth( -- changes the width of a rectangle, leaving the height unchanged.
- setrectedges -- changes the edges of the specified rectangle.
- unionrectangle( -- creates a rectangle by combining two rectangles. The new rectangle is large enough to exactly cover both of the input rectangles.
- v( -- returns the vertical position of a point (see point(, Graphic Coordinates).

History

Version | Status | Notes
10.0 | No Change | Carried over from Panorama 6.0