From 1ecb018dd430a757f4d736984e124de4796b3c4c Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Fri, 9 Oct 2009 19:07:52 +0000 Subject: [PATCH] A start on documentation for SvgCanvas using NaturalDocs. You will need to download the NaturalDocs and put it in svg-edit/naturaldocs git-svn-id: http://svg-edit.googlecode.com/svn/trunk@788 eee81c28-f429-11dd-99c0-75d572ba1ddd --- Makefile | 5 ++++- editor/svgcanvas.js | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 901618b0..535fb06b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ NAME=svg-edit -VERSION=2.3 +VERSION=2.4 +MAKEDOCS=naturaldocs/NaturalDocs PACKAGE=$(NAME)-$(VERSION) YUI=build/yuicompressor.jar ZIP=zip @@ -7,6 +8,7 @@ ZIP=zip all: release firefox opera build/$(PACKAGE): + $(MAKEDOCS) -i editor/ -o html docs/ -p config/ mkdir -p build/$(PACKAGE) cp -r editor/* build/$(PACKAGE) -find build/$(PACKAGE) -name .svn -type d -exec rm -rf {} \; @@ -36,6 +38,7 @@ opera: build/$(PACKAGE) cd build/opera ; $(ZIP) ../$(PACKAGE).wgt -r * ; cd ../.. clean: + rm -rf docs/* rm -rf build/$(PACKAGE) rm -rf build/firefox rm -rf build/opera diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index d36bd553..96ee8737 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -2987,6 +2987,12 @@ function BatchCommand(text) { call("opened", str); }; + // Function: save + // Serializes the current drawing into SVG XML text and returns it to the 'saved' handler. + // This function also includes the XML prolog. + // + // Returns: + // Nothing this.save = function() { // remove the selected outline before serializing this.clearSelection(); @@ -3007,12 +3013,23 @@ function BatchCommand(text) { } }; + // Function: getSvgString + // Returns the current drawing as raw SVG XML text. + // + // Returns: + // The current drawing as raw SVG XML text. this.getSvgString = function() { return svgCanvasToString(); }; - // this function returns false if the set was unsuccessful, true otherwise - // TODO: after parsing in the new text, do we need to synchronize getId()? + // Function: setSvgString + // This function sets the current drawing as the input SVG XML. + // + // Parameters: + // xmlString - The SVG as XML text. + // + // Returns: + // This function returns false if the set was unsuccessful, true otherwise. this.setSvgString = function(xmlString) { try { // convert string into XML document @@ -3124,6 +3141,13 @@ function BatchCommand(text) { walkTree(current_layer, function(e){e.setAttribute("style","pointer-events:all");}); }; + // Function: createLayer + // This function clears the selection and then creates a new top-level layer in the drawing + // with the given name and sets the current layer to it. This function then calls the + // 'changed' handler. + // + // Parameters: + // name - The given name this.createLayer = function(name) { var batchCmd = new BatchCommand("Create Layer"); var new_layer = svgdoc.createElementNS(svgns, "g"); @@ -3139,6 +3163,9 @@ function BatchCommand(text) { call("changed", [new_layer]); }; + // Function: deleteCurrentLayer + // This function clears the selection and then deletes the current layer from the drawing. + // This function then calls the 'changed' handler. this.deleteCurrentLayer = function() { if (current_layer && all_layers.length > 1) { var batchCmd = new BatchCommand("Delete Layer"); @@ -3156,9 +3183,15 @@ function BatchCommand(text) { return false; }; + // Function: getNumLayers + // This function returns the number of layers in the current drawing. + // + // Returns: + // The number of layers in the current drawing. this.getNumLayers = function() { return all_layers.length; }; + this.getLayer = function(i) { if (i >= 0 && i < canvas.getNumLayers()) { return all_layers[i][0];