newformobject
newformobject
CLASS
,
PROPERTY
,
VALUE

The newformobject statement creates a new graphic object in a form.

Parameters

This statement has three parameters:

class – the type of object to create, for example `RectangleShapeObject`, `TextDisplayObject`, `PushButtonObject`, etc. (For a complete list of object types use the `objectinfo("classnames")` function, or see the Object Library in the bottom right of any graphics mode form window.) The newform statement is very forgiving about how you specify the class. The class name can be upper or lower case, spaces are ignored, and the name can be abbreviated as long as it is unambiguous. For example you could create a new web browser object by specifying `WebBrowserObject`, `Web Browser`, or just `web`. However, Panorama will not understand if you ask it to create a `text` object because that is ambigous – it could mean `TextLabelObject`, `TextDisplayObject`, `TextEditorObject`, or `TextListObject`.

property – The name of a property you want to specify for the new object. See Modifiable Object Properties for descriptions of the different properties that can be specified. You can specify multiple property/value pairs to set up your new object. It’s not necessary, however, to specify all properties for the new object – Panorama will fill in default values for any you leave off.

value – The value for the specified property. Note: Instead of specifying the property names and values as separate parameters, you can specify multiple properties with a dictionary. See the main text below for more information.

Description

This statement creates a new graphic object in a form. You can create any kind of object you want, with whatever custom properties are needed. Here is a simple example that creates a 50 points by 100 points blue rectangle 1 inch from the top left corner of the form:

    newformobject "Rectangle",
       "rectangle",rectanglesize(72, 72, 50, 100),
       "color",htmlrgb("0000FF")

This example creates a mailing label template.

    startgraphicschange "Create 5160 Mailing Label"
    local labelRect
    labelRect = rectanglesize(100, 100, 72, 72*2.75)
    newformobject "ReportTile","Tile","Data Tile","Rectangle", labelRect
    newformobject "TextDisplay",
        "Rectangle",rectangleinset(labelRect,6),
        "Formula",{Name+cr()+Address+cr()+City+", "+State+" "+Zip}

This more complex example creates two rows of objects starting in the upper left corner of the form. The first row displays the name of each field. The second row contains a text editor for each field. The fields are spaced 4 points apart horizontally, and the titles and editors are 2 points apart vertically. Each column is an inch wide. (Note: The startgraphicschange statement allows this procedure to be undo-able.)

    startgraphicschange "Create Row of Fields"
    local fieldrect
    fieldrect = rectanglesize(0, 0, 15, 72)
    looparray dbinfo("fields",""),cr(),dbfield
        newformobject "TextDisplay",
            "rectangle",fieldrect,
            "formula",quoted(dbfield),
            "font","Tahoma","textsize",12
        newformobject "TextEditor",
            "rectangle",rectangleoffset(fieldrect, rheight(fieldrect)+2, 0),
            "fieldname",dbfield,
            "font","Tahoma","textsize",12
        fieldrect = rectangleoffset(fieldrect, 0, rwidth(fieldrect)+4)
    endloop

This example uses native properties (see Modifiable Object Properties) to create a 15-point red star with a drop shadow.

    newformobject "star",
        "rectangle",rectanglesize(100, 100, 200, 200),
        "$PolygonCorners",15,
        "color",htmlrgb("FF0000"),
        "$DropShadow",1

You can also specify the options with a dictionary, like this:

    newformobject "star",initializedictionary(
        "rectangle",rectanglesize(100, 100, 200, 200),
        "$PolygonCorners",15,
        "color",htmlrgb("FF0000"),
        "$DropShadow",1)

The advantage of using a dictionary is that you can set it up once and use it over and over again, like this.

    local starOptions
    starOptions = initializedictionary(
        "$PolygonCorners",5,
        "color",htmlrgb("FF0000"))
    for n,0,5
        newformobject "star",changedictionaryvalues(starOptions,
            "rectangle",rectanglesize(20, 20+n*24, 18, 18),
            "$StarAngle",str(n*30)+"°")
    endloop

This example creates a row of red stars, each 1/3rd inch to the right and rotated 30 degrees.

See Also

- activeobjectaction -- allows a procedure to communicate with the object on the current form that is currently being edited (if any).
- changeobject -- modifies the properties of one object in a form.
- changeobjects -- modifies the properties of one or more objects in a form.
- cloneform -- copies all of the objects in a form (optionally, with modifications) into the active form.
- cloneobjects -- duplicates objects in a form (with modifications).
- closeactiveobject -- closes any object whose text is currently being edited.
- datamode -- switches a form from graphics mode into data mode.
- deleteselectedobjects -- deletes selected objects from a form.
- draggraybox -- facilitates dragging something around in a form window.
- dragtext -- starts drag-and-drop of text.
- formcleanview -- cleans up extraneous NSView objects in the current form.
- formxy -- programmatically scrolls a form to a new position.
- graphicsmode -- switches a form into graphics mode.
- info("activeobject") -- returns the name of the currently active text editor or word processor object (if any).
- info("activesuperobject") -- returns the name of the currently active text editor or word processor object, if any.
- info("click") -- returns the location of the last mouse click in screen relative coordinates.
- info("clickedobjectid") -- returns the object ID of the clicked object.
- info("focusobject") -- returns the name of the currently active text editor or word processor object, if any.
- info("focusobjectid") -- returns the object ID of the currently active text editor or word processor object, if any.
- info("scrollpoint") -- returns the distance the current form is scrolled horizontally and vertically.
- magicformwindow -- designates an open window as the temporary active window for the purposes of info( functions and graphic statements.
- magicwindow -- designates an open window as the temporary active window for the purposes of info( functions and graphic statements.
- magnification -- changes the magnification of a form.
- Modifiable Object Properties -- describes the properties of graphic objects that can be modified by a program (dimensions, color, font, title, etc.).
- object -- selects an object (based on the object name).
- objectaction -- allows a procedure to communicate with an object on the current form.
- objectid -- selects one graphic object in the current form based on an ID number.
- objectinfo( -- returns information about a graphic object: its location, size, color, font, etc.
- objectinfoarray( -- builds a text array of form object properties
- objectnumber -- identifies one graphic object from a set of selected graphic objects in the current form.
- openasyncprogresswindow -- opens a floating progress window for asynchronous operations (urltask(, timers).
- progressalert -- displays a progress alert if an operation is going to take a long time.
- progressbar -- updates a progress bar on the current form.
- selectallobjects -- selects all the graphic objects in the current form.
- selectnoobjects -- unselects all the graphic objects in the current form.
- selectobjects -- uses a formula to select one or more objects in the current form.
- startgraphicschange -- adds undo support to a procedure.
- textlisttableoptions -- sets up text list table options
- xytoxy( -- converts a point or rectangle from one co-ordinate system to another.

History

Version | Status | Notes
10.0 | New | This statement is new in this version.