Ipelib

Lua bindings for Ipe

These are the Lua methods provided by the Ipe program itself. They are only available to Lua code running inside Ipe.

# Application user interface

The application user interface object provides the GUI for the Ipe program.

    -- model is a Lua table containing methods that will be called
    -- by the ui when events occur
    ui = AppUi(model)

    -- returns window id of window
    -- (to be used as parent for dialogs)
    id = ui:win()

    ui:close()         -- close window

    ui:setActionState(name, t) -- set whether action is checked
    t = ui:actionState(name)   -- is action checked?
    -- return info about action: id, and whether it's always on
    id, alwaysOn = actionInfo(name)

    ui:explain(text)     -- show message in status bar for a few seconds
    ui:setWindowTitle(caption)

    -- make a tool visible or invisible
    -- tool is one of "layers", "properties", "bookmarks", "notes"
    -- t is true or false
    ui:showTool(tool, t)

    ui:setNotes(n)       -- set string for Notes tool

    -- set contents of attribute selectors from style sheet
    ui:setupSymbolicNames(styleSheet)

    -- set attribute values displayed in user interface
    -- 'attributes' table see below
    ui:setAttributes(styleSheet, attributes)

    -- set layer list from page
    ui:setLayers(page, view)

    ui:setNumbers(?)
    ui:setBookmarks(?)

    -- page/view selector tool:
    -- select one page and return page number (or nil if canceled)
    pno = ui:selectPage(doc)
    -- select one view and return view number (or nil if canceled)
    vno = ui:selectPage(doc, page_no)

    ui:pageSorter(?)

    ui:setClipboard(text)     -- store text on system clipboard
    -- get text or bitmap property from system clipboard
    -- if t is false, only text is retrieved
    -- returns either a string or an image object.
    obj = ipeui.clipboard(t)

The following methods work on the canvas inside the UI:

    ui:setPage(page, pgno, view, styleSheet) -- set page shown on canvas
    ui:setSnap(snap)                    -- for 'snap' table see below
    ui:setFontPool(p)       -- an opaque object obtained from an ipe.Document

    -- 'pan' is a vector indicating the user coordinates at canvas center
    v = ui:pan()
    ui:setPan(v)

    zoom = ui:zoom()        -- a number
    ui:setZoom(zoom)

    v = ui:pos()            -- current mouse position, after snapping
    v = ui:unsnappedPos()   -- current mouse position, before snapping
    v = ui:simpleSnapPos()  -- same, but ignoring angular snap
    v = ui:globalPos()      -- mouse position on screen

    v = ui:canvasSize()     -- size of canvas in pixels

    ui:setNumbering(t)      -- true or false
    ui:setFifiVisible(t)    -- true or false
    ui:setSelectionVisible(t) -- true or false
    ui:setPretty(t)         -- true or false

    -- setCursor only implemented on Qt.
    -- Windows 8 switches to a dot cursor automatically when using the pen.
    ui:setCursor(name)         -- name in "standard", "hand", "cross"
    ui:setCursor(width, color) -- sets a colored dot cursor (on Qt)

    ui:update()             -- update canvas and tool
    ui:update(false)        -- update tool only
    ui:finishTool()

    ui:panTool()
    ui:selectTool()
    ui:transformTool()
    ui:shapeTool()