Developer API Documentation¶
This section contains documentation on Pencil’s internal API for Pencil’s developers.
CollectionManager¶
-
class
CollectionManager()¶ A namespace responsible for loading and unloading Stencil Collections.
Controller¶
The Controller() is responsible for managing the Document &
its Pages. It is usually accesed via the global Pencil object.
- class
Controller(win)¶
Arguments:
- win – The window the controller should manipulate.
Controller.mainView¶The Element containing the application’s main display window.
The Controller object contains methods for creating new Documents/Pages, saving/loading Documents & moving/removing/duplicating Pages.
Pencil¶
Initializes a global Pencil namespace & sets up event listeners on boot.
-
class
Pencil()¶ The Pencil namespace contains attributes linked to the application’s Controller, Rasterizer, etc. as well as various helper functions.
-
Pencil.controller¶ A
Controller()initialized from the XUL window.
-
Pencil.getDocumentExporterById(id)¶ Arguments: - id – The id of a DocumentExporter.
Returns: The requested DocumentExporter or
nullif a matching DocumentExporter cannot be found.
-
Pencil.setPainterCommandChecked(id)¶ Arguments: - v – boolean; currently only as false; determines state of the format painter function.
Returns: undefined
Side Effect: If passed value v is false, it deactivates the format painter tool (used for copying formats of stencils on canvas) Side Effect: If passed value v is false, it removes the painter class from all canvas (“pages” in the GUI) if passed value v is false.
Called on click on stencils on canvas or if the toolbarFormatPainterCommand button is clicked.
-
Pencil.setupCommands()¶ Activates & deactivates commands via the
Pencil._enableCommand()function along with the ids of the<command>XUL Elements frommainWindow.xul.Called e.g. if an element is selected in order to provide applicable commands.
Whether a command is activated or deactivated depends on the state of the application(if a document has been created, if there is an active
canvaselement, etc.) and the active element (e.g. a selected stencil)
-
Pencil._enableCommand(name, condition)¶ Arguments: - name (string) – An
idof a<command>XUL Element. - condition (boolean) – Determines whether the command is activated
or deactivated. A value of
trueactivates the command.
- name (string) – An
-