File indexing completed on 2024-04-28 11:39:20

0001 /*
0002     Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
0003                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
0004 
0005     This file is part of the KDE project
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #ifndef SVGPreserveAspectRatio_h
0024 #define SVGPreserveAspectRatio_h
0025 
0026 #if ENABLE(SVG)
0027 #include "PlatformString.h"
0028 #include "SVGNames.h"
0029 #include "Document.h"
0030 
0031 #include <wtf/RefCounted.h>
0032 
0033 //khtml
0034 #include <wtf/PassRefPtr.h>
0035 
0036 namespace WebCore
0037 {
0038 
0039 //class String;
0040 class AffineTransform;
0041 class SVGStyledElement;
0042 
0043 class SVGPreserveAspectRatio : public RefCounted<SVGPreserveAspectRatio>
0044 {
0045 public:
0046     static PassRefPtr<SVGPreserveAspectRatio> create()
0047     {
0048         return adoptRef(new SVGPreserveAspectRatio);
0049     }
0050 
0051     enum SVGPreserveAspectRatioType {
0052         SVG_PRESERVEASPECTRATIO_UNKNOWN     = 0,
0053         SVG_PRESERVEASPECTRATIO_NONE        = 1,
0054         SVG_PRESERVEASPECTRATIO_XMINYMIN    = 2,
0055         SVG_PRESERVEASPECTRATIO_XMIDYMIN    = 3,
0056         SVG_PRESERVEASPECTRATIO_XMAXYMIN    = 4,
0057         SVG_PRESERVEASPECTRATIO_XMINYMID    = 5,
0058         SVG_PRESERVEASPECTRATIO_XMIDYMID    = 6,
0059         SVG_PRESERVEASPECTRATIO_XMAXYMID    = 7,
0060         SVG_PRESERVEASPECTRATIO_XMINYMAX    = 8,
0061         SVG_PRESERVEASPECTRATIO_XMIDYMAX    = 9,
0062         SVG_PRESERVEASPECTRATIO_XMAXYMAX    = 10
0063     };
0064 
0065     enum SVGMeetOrSliceType {
0066         SVG_MEETORSLICE_UNKNOWN    = 0,
0067         SVG_MEETORSLICE_MEET       = 1,
0068         SVG_MEETORSLICE_SLICE      = 2
0069     };
0070 
0071     virtual ~SVGPreserveAspectRatio();
0072 
0073     void setAlign(unsigned short);
0074     unsigned short align() const;
0075 
0076     void setMeetOrSlice(unsigned short);
0077     unsigned short meetOrSlice() const;
0078 
0079     AffineTransform getCTM(double logicX, double logicY,
0080                            double logicWidth, double logicHeight,
0081                            double physX, double physY,
0082                            double physWidth, double physHeight);
0083 
0084     // Helper
0085     bool parsePreserveAspectRatio(const UChar *&currParam, const UChar *end, bool validate = true);
0086 
0087     const QualifiedName &associatedAttributeName() const
0088     {
0089         return SVGNames::preserveAspectRatioAttr;
0090     }
0091 
0092 private:
0093     SVGPreserveAspectRatio();
0094 
0095     unsigned short m_align;
0096     unsigned short m_meetOrSlice;
0097 };
0098 
0099 } // namespace WebCore
0100 
0101 #endif // ENABLE(SVG)
0102 #endif // SVGPreserveAspectRatio_h
0103