#ifndef __SMIL_H__ #define __SMIL_H__ /** * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows * fairly closely the specifications in the various .idl files, copies of * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html * * Authors: * Bob Jamison * * Copyright (C) 2005-2008 Bob Jamison * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * =========================================================================== * NOTES * * This API and many of the comments come from this document: * http://www.w3.org/TR/smil-boston-dom * * ...which is a DRAFT. But it's the best we can find. Can someone * find a more finished, complete SMIL DOM document for us? Thanks. */ #include "dom.h" #include "views.h" #include "events.h" #include namespace org { namespace w3c { namespace dom { namespace smil { //Local definitions typedef dom::DOMString DOMString; typedef dom::Element Element; typedef dom::NodeList NodeList; typedef dom::Document Document; //forward declarations //SMIL (non-DOM) types class ElementExclusiveTimeContainer; class ElementLayout; class ElementParallelTimeContainer; class ElementSequentialTimeContainer; class ElementSyncBehavior; class ElementTargetAttributes; class ElementTest; class ElementTime; class ElementTimeContainer; class ElementTimeControl; class ElementTimeManipulation; class Time; class TimeEvent; class TimeList; //SMIL Elements class SMILAnimateColorElement; typedef Ptr SMILAnimateColorElementPtr; class SMILAnimateElement; typedef Ptr SMILAnimateElementPtr; class SMILAnimateMotionElement; typedef Ptr SMILAnimateMotionElementPtr; class SMILAnimation; typedef Ptr SMILAnimationPtr; class SMILDocument; typedef Ptr SMILDocumentPtr; class SMILElement; typedef Ptr SMILElementPtr; class SMILLayoutElement; typedef Ptr SMILLayoutElementPtr; class SMILMediaElement; typedef Ptr SMILMediaElementPtr; class SMILRefElement; typedef Ptr SMILRefElementPtr; class SMILRegionElement; typedef Ptr SMILRegionElementPtr; class SMILRegionInterface; typedef Ptr SMILRegionInterfacePtr; class SMILRootLayoutElement; typedef Ptr SMILRootLayoutElementPtr; class SMILSetElement; typedef Ptr SMILSetElementPtr; class SMILSwitchElement; typedef Ptr SMILSwitchElementPtr; class SMILTopLayoutElement; typedef Ptr SMILTopLayoutElementPtr; /*######################################################################### ########################################################################### ## D A T A T Y P E S ########################################################################### #########################################################################*/ /*######################################################################### ## ElementLayout #########################################################################*/ /** * This interface is used by SMIL elements root-layout, top-layout and region. */ class ElementLayout { public: /** * Return the title of an item implementing this interface */ virtual DOMString getTitle() { return title; } /** * Set the title of an item implementing this interface */ virtual void setTitle(const DOMString &val) throw(dom::DOMException) { title = val; } /** * Return the background color of an item implementing this interface */ virtual DOMString getBackgroundColor() { return backgroundColor; } /** * Set the background color of an item implementing this interface */ virtual void setBackgroundColor(const DOMString &val) throw(dom::DOMException) { backgroundColor = val; } /** * Return the height of an item implementing this interface */ virtual long getHeight() { return height; } /** * Set the height of an item implementing this interface */ virtual void setHeight(long val) throw(dom::DOMException) { height = val; } /** * Return the width of an item implementing this interface */ virtual long getWidth() { return width; } /** * Set the width of an item implementing this interface */ virtual void setWidth(long val) throw(dom::DOMException) { width = val; } //################## //# Non-API methods //################## /** * */ ElementLayout() {} /** * */ ElementLayout(const ElementLayout &other) { assign(other); } /** * */ ElementLayout &operator=(const ElementLayout &other) { assign(other); return *this; } /** * */ void assign(const ElementLayout &other) { title = other.title; backgroundColor = other.backgroundColor; height = other.height; width = other.width; } /** * */ virtual ~ElementLayout() {} protected: DOMString title; DOMString backgroundColor; long height; long width; }; /*######################################################################### ## SMILRegionInterface #########################################################################*/ /** * Declares rendering surface for an element. See the region attribute definition. */ class SMILRegionInterface { public: /** * Gets an associated region element */ virtual SMILRegionElementPtr getRegion() { return regionElement; } /** * Sets an associated region element */ virtual void setRegion(const SMILRegionElementPtr val) { regionElement = val; } //################## //# Non-API methods //################## /** * */ SMILRegionInterface() { } /** * */ SMILRegionInterface(const SMILRegionInterface &other) { regionElement = other.regionElement; } /** * */ SMILRegionInterface& operator=(const SMILRegionInterface &other) { regionElement = other.regionElement; return *this; } /** * */ virtual ~SMILRegionInterface() {} protected: SMILRegionElementPtr regionElement; }; /*######################################################################### ## Time #########################################################################*/ /** * The Time interface is a datatype that represents times within the timegraph. * A Time has a type, key values to describe the time, and a boolean to * indicate whether the values are currently unresolved. */ class Time { public: /** * A boolean indicating whether the current Time has been fully resolved to the * document schedule. Note that for this to be true, the current Time must be * defined (not indefinite), the syncbase and all Time's that the syncbase * depends on must be defined (not indefinite), and the begin Time of all * ascendent time containers of this element and all Time elements that this * depends upon must be defined (not indefinite). If this Time is based upon an * event, this Time will only be resolved once the specified event has happened, * subject to the constraints of the time container. Note that this may change * from true to false when the parent time container ends its simple duration * (including when it repeats or restarts). */ virtual bool getResolved() { return resolved; } /** * The clock value in seconds relative to the parent time container begin. This * indicates the resolved time relationship to the parent time container. This is * only valid if resolved is true. */ virtual double getResolvedOffset() { return resolvedOffset; } /** * An integer indicating the type of this time value. */ typedef enum { SMIL_TIME_INDEFINITE = 0, SMIL_TIME_OFFSET = 1, SMIL_TIME_SYNC_BASED = 2, SMIL_TIME_EVENT_BASED = 3, SMIL_TIME_WALLCLOCK = 4, SMIL_TIME_MEDIA_MARKER = 5 } TimeType; /** * A code representing the type of the underlying object, as defined above. */ virtual unsigned short getTimeType() { return timeType; } /** * The clock value in seconds relative to the syncbase or eventbase. * Default value is 0. */ virtual double getOffset() { return offset; } /** * Set the value above */ virtual void setOffset(double val) throw (dom::DOMException) { offset = val; } /** * Get the base element for a sync-based or event-based time. */ virtual ElementPtr getBaseElement() { return baseElement; } /** * Set the base element for a sync-based or event-based time. */ virtual void setBaseElement(const ElementPtr val) throw (dom::DOMException) { baseElement = val; } /** * If true, indicates that a sync-based time is relative to the begin of the * baseElement. If false, indicates that a sync-based time is relative to the * active end of the baseElement. */ virtual bool getBaseBegin() { return baseBegin; } /** * Set the value above. */ virtual void setBaseBegin(bool val) throw (dom::DOMException) { baseBegin = val; } /** * Get the name of the event for an event-based time. Default value is null. */ virtual DOMString getEvent() { return eventStr; } /** * Set the name of the event for an event-based time. Default value is null. */ virtual void setEvent(const DOMString &val) throw (dom::DOMException) { eventStr = val; } /** * Get the name of the marker from the media element, for media marker * times. Default value is null. */ virtual DOMString getMarker() { return marker; } /** * Set the name of the marker from the media element, for media marker * times. Default value is null. */ virtual void setMarker(const DOMString &val) throw (dom::DOMException) { marker = val; } //################## //# Non-API methods //################## /** * */ Time() { resolved = false; resolvedOffset = 0.0; timeType = SMIL_TIME_INDEFINITE; offset = 0.0; //baseElement = NULL; //not necessary baseBegin = false; eventStr = ""; marker = ""; } /** * */ Time(const Time &other) { assign(other); } /** * */ Time &operator=(const Time &other) { assign(other); return *this; } void assign(const Time &other) { resolved = other.resolved; resolvedOffset = other.resolvedOffset; timeType = other.timeType; offset = other.offset; baseElement = other.baseElement; baseBegin = other.baseBegin; eventStr = other.eventStr; marker = other.marker; } /** * */ virtual ~Time() {} protected: bool resolved; double resolvedOffset; unsigned short timeType; double offset; ElementPtr baseElement; bool baseBegin; DOMString eventStr; DOMString marker; }; /*######################################################################### ## TimeList #########################################################################*/ /** * The TimeList interface provides the abstraction of an ordered collection of * times, without defining or constraining how this collection is implemented. * * The items in the TimeList are accessible via an integral index, starting from 0. */ class TimeList { public: /** * Returns the indexth item in the collection. If index is greater than or equal * to the number of times in the list, this returns null. */ virtual Time item(unsigned long index) { if (index >=items.size()) { Time tim; return tim; } return items[index]; } /** * The number of times in the list. The range of valid child time * indices is 0 to length-1 inclusive. */ virtual unsigned long getLength() { return items.size(); } //################## //# Non-API methods //################## /** * */ TimeList() {} /** * */ TimeList(const TimeList &other) { items = other.items; } /** * */ TimeList &operator=(const TimeList &other) { items = other.items; return *this; } /** * */ virtual ~TimeList() {} protected: std::vector