shapes.inl
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:13k
- /*
- * shapes.inl
- *
- * Geometric shapes inline functions.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: shapes.inl,v $
- * Revision 1.6 1998/09/23 06:29:01 robertj
- * Added open source copyright license.
- *
- * Revision 1.5 1997/04/27 05:50:19 robertj
- * DLL support.
- *
- * Revision 1.4 1995/01/21 05:22:34 robertj
- * Documentation.
- *
- * Revision 1.3 1994/10/23 04:56:32 robertj
- * Changed PImage descendents to be pointers for polymorphism.
- *
- * Revision 1.2 1994/07/27 05:58:07 robertj
- * Synchronisation.
- *
- * Revision 1.1 1994/04/20 12:17:44 robertj
- * Initial revision
- *
- */
- //////////////////////////////////////////////////////////////////////////////
- // PShape
- PINLINE PShape::PShape(PORDINATE x, PORDINATE y)
- : position(x, y) { }
- PINLINE PShape::PShape(const PPoint & pt)
- : position(pt) { }
- PINLINE void PShape::SetPosition(PORDINATE x, PORDINATE y)
- { _SetPosition(PPoint(x, y)); }
- PINLINE void PShape::SetPosition(const PPoint & pt)
- { _SetPosition(pt); }
- PINLINE PPoint PShape::GetPosition() const
- { return position; }
- PINLINE void PShape::Offset(PORDINATE x, PORDINATE y)
- { Offset(PPoint(x, y)); }
- PINLINE void PShape::Offset(const PPoint & pt)
- { SetPosition(GetPosition() + pt); }
- PINLINE void PShape::SetDimensions(PDIMENSION width, PDIMENSION height)
- { _SetDimensions(PDim(width, height)); }
- PINLINE void PShape::SetDimensions(const PDim & dim)
- { _SetDimensions(dim); }
- PINLINE void PShape::Grow(PORDINATE x, PORDINATE y)
- { Grow(PPoint(x, y)); }
- PINLINE void PShape::Grow(const PPoint & pt)
- { SetDimensions(GetDimensions() + pt); }
-
- PINLINE PRect PShape::GetBounds() const
- { return PRect(GetPosition(), GetDimensions()); }
- //////////////////////////////////////////////////////////////////////////////
- // PLine
- PINLINE PLine::PLine(PORDINATE x1, PORDINATE y1, PORDINATE x2, PORDINATE y2)
- : PShape(x1, y1), otherEnd(x2, y2) { }
- PINLINE PLine::PLine(const PPoint & pt1, const PPoint & pt2)
- : PShape(pt1), otherEnd(pt2) { }
- //////////////////////////////////////////////////////////////////////////////
- // POrthoShape
- PINLINE POrthoShape::POrthoShape(PORDINATE x, PORDINATE y,
- PDIMENSION dx, PDIMENSION dy)
- : PShape(x, y), dimensions(dx, dy) { }
- PINLINE POrthoShape::POrthoShape(const PPoint & topLeft, const PDim & dim)
- : PShape(topLeft), dimensions(dim) { }
- PINLINE POrthoShape::POrthoShape(const PRect & rect)
- : PShape(rect.Origin()), dimensions(rect.Dimensions()) { }
- //////////////////////////////////////////////////////////////////////////////
- // PRectangle
- PINLINE PRectangle::PRectangle(PORDINATE x, PORDINATE y,
- PDIMENSION dx, PDIMENSION dy)
- : POrthoShape(x, y, dx, dy) { }
- PINLINE PRectangle::PRectangle(const PPoint & topLeft, const PPoint & botRight)
- : POrthoShape(topLeft, botRight) { }
- PINLINE PRectangle::PRectangle(const PPoint & topLeft, const PDim & dim)
- : POrthoShape(topLeft, dim) { }
- PINLINE PRectangle::PRectangle(const PRect & rect)
- : POrthoShape(rect) { }
- //////////////////////////////////////////////////////////////////////////////
- // PRoundedRectangle
- PINLINE PRoundedRectangle::PRoundedRectangle(PORDINATE x, PORDINATE y,
- PDIMENSION dx, PDIMENSION dy,
- PDIMENSION cornerWidth, PDIMENSION cornerHeight)
- : PRectangle(x, y, dx, dy), corner(cornerWidth, cornerHeight) { }
- PINLINE PRoundedRectangle::PRoundedRectangle(const PPoint & topLeft,
- const PPoint & botRight, PDIMENSION cornerWidth, PDIMENSION cornerHeight)
- : PRectangle(topLeft, botRight), corner(cornerWidth, cornerHeight) { }
- PINLINE PRoundedRectangle::PRoundedRectangle(const PPoint & topLeft,
- const PDim & dim, PDIMENSION cornerWidth, PDIMENSION cornerHeight)
- : PRectangle(topLeft, dim), corner(cornerWidth, cornerHeight) { }
- PINLINE PRoundedRectangle::PRoundedRectangle(const PRect & rect,
- PDIMENSION cornerWidth, PDIMENSION cornerHeight)
- : PRectangle(rect), corner(cornerWidth, cornerHeight) { }
- PINLINE void PRoundedRectangle::SetCornerWidth(PDIMENSION width)
- { corner.SetWidth(width); }
-
- PINLINE PDIMENSION PRoundedRectangle::GetCornerWidth()
- { return corner.Width(); }
-
- PINLINE void PRoundedRectangle::SetCornerHeight(PDIMENSION height)
- { corner.SetHeight(height); }
-
- PINLINE PDIMENSION PRoundedRectangle::GetCornerHeight()
- { return corner.Height(); }
- //////////////////////////////////////////////////////////////////////////////
- // PEllipse
- PINLINE PEllipse::PEllipse(PORDINATE x, PORDINATE y,
- PDIMENSION dx, PDIMENSION dy)
- : POrthoShape(x, y, dx, dy) { }
- PINLINE PEllipse::PEllipse(const PPoint & topLeft, const PPoint & botRight)
- : POrthoShape(topLeft, botRight) { }
- PINLINE PEllipse::PEllipse(const PPoint & topLeft, const PDim & dim)
- : POrthoShape(topLeft, dim) { }
- PINLINE PEllipse::PEllipse(const PRect & rect)
- : POrthoShape(rect) { }
- //////////////////////////////////////////////////////////////////////////////
- // PArc
- PINLINE PArc::PArc(PORDINATE x, PORDINATE y, PDIMENSION dx, PDIMENSION dy,
- PORDINATE start, PORDINATE end)
- : POrthoShape(x, y, dx, dy), startAngle(start), endAngle(end) { }
- PINLINE PArc::PArc(const PPoint & topLeft, const PPoint & botRight,
- PORDINATE start, PORDINATE end)
- : POrthoShape(topLeft, botRight), startAngle(start), endAngle(end) { }
- PINLINE PArc::PArc(const PPoint & topLeft, const PDim & dim,
- PORDINATE start, PORDINATE end)
- : POrthoShape(topLeft, dim), startAngle(start), endAngle(end) { }
- PINLINE PArc::PArc(const PRect & rect, PORDINATE start, PORDINATE end)
- : POrthoShape(rect), startAngle(start), endAngle(end) { }
- PINLINE void PArc::SetStartAngle(PORDINATE start)
- { startAngle = start; }
-
- PINLINE PORDINATE PArc::GetStartAngle()
- { return startAngle; }
-
- PINLINE void PArc::SetEndAngle(PORDINATE end)
- { endAngle = end; }
-
- PINLINE PORDINATE PArc::GetEndAngle()
- { return endAngle; }
- //////////////////////////////////////////////////////////////////////////////
- // PPie
- PINLINE PPie::PPie(PORDINATE x, PORDINATE y, PDIMENSION dx, PDIMENSION dy,
- PORDINATE start, PORDINATE end)
- : PArc(x, y, dx, dy, start, end) { }
- PINLINE PPie::PPie(const PPoint & topLeft, const PPoint & botRight,
- PORDINATE start, PORDINATE end)
- : PArc(topLeft, botRight, start, end) { }
- PINLINE PPie::PPie(const PPoint & topLeft, const PDim & dim,
- PORDINATE start, PORDINATE end)
- : PArc(topLeft, dim, start, end) { }
- PINLINE PPie::PPie(const PRect & rect, PORDINATE start, PORDINATE end)
- : PArc(rect, start, end) { }
- //////////////////////////////////////////////////////////////////////////////
- // PChord
- PINLINE PChord::PChord(PORDINATE x, PORDINATE y, PDIMENSION dx, PDIMENSION dy,
- PORDINATE start, PORDINATE end)
- : PArc(x, y, dx, dy, start, end) { }
- PINLINE PChord::PChord(const PPoint & topLeft, const PPoint & botRight,
- PORDINATE start, PORDINATE end)
- : PArc(topLeft, botRight, start, end) { }
- PINLINE PChord::PChord(const PPoint & topLeft, const PDim & dim,
- PORDINATE start, PORDINATE end)
- : PArc(topLeft, dim, start, end) { }
- PINLINE PChord::PChord(const PRect & rect, PORDINATE start, PORDINATE end)
- : PArc(rect, start, end) { }
- //////////////////////////////////////////////////////////////////////////////
- // PPixShape
- PINLINE void PPixShape::SetPixels(const PPixelImage & img)
- { pixels = img; }
- PINLINE PPixelImage PPixShape::GetPixels() const
- { return pixels; }
- //////////////////////////////////////////////////////////////////////////////
- // PPicShape
- PINLINE void PPicShape::SetPicture(const PPictImage & img)
- { picture = img; }
- PINLINE PPictImage PPicShape::GetPicture() const
- { return picture; }
- //////////////////////////////////////////////////////////////////////////////
- // PTextLines
- PINLINE PTextLines::PTextLines(PORDINATE x, PORDINATE y, const PString & str)
- : PShape(x, y), text(str) { }
- PINLINE PTextLines::PTextLines(const PPoint & pt, const PString & str)
- : PShape(pt), text(str) { }
- PINLINE PString PTextLines::GetText() const
- { return text; }
- //////////////////////////////////////////////////////////////////////////////
- // PTextBlock
- PINLINE PTextBlock::PTextBlock(PORDINATE x, PORDINATE y,
- const PString & text, PDIMENSION width)
- : PTextLines(x, y, text) { dimensions.SetWidth(width); }
- PINLINE PTextBlock::PTextBlock(const PPoint & pt,
- const PString & text, PDIMENSION width)
- : PTextLines(pt, text) { dimensions.SetWidth(width); }
- //////////////////////////////////////////////////////////////////////////////
- // PPolyShape
- PINLINE PPolyShape::PPolyShape(PORDINATE x, PORDINATE y)
- : PShape(x, y) { points.Append(PNEW PPoint(x, y)); }
- PINLINE PPolyShape::PPolyShape(const PPoint & pt)
- : PShape(pt) { points.Append(PNEW PPoint(pt)); }
- PINLINE PPolyShape::PPolyShape(const PPointArray & pts)
- : PShape(pts[0]), points(pts) { }
- PINLINE void PPolyShape::AddPoint(PORDINATE x, PORDINATE y)
- { points.Append(PNEW PPoint(x, y)); }
- PINLINE void PPolyShape::AddPoint(const PPoint & pt)
- { points.Append(PNEW PPoint(pt)); }
- PINLINE void PPolyShape::RemovePoint(PINDEX idx)
- { points.RemoveAt(idx); }
- PINLINE PPoint & PPolyShape::operator[](PINDEX idx) const
- { return points[idx]; }
- //////////////////////////////////////////////////////////////////////////////
- // PPolyLine
- PINLINE PPolyLine::PPolyLine(PORDINATE x, PORDINATE y)
- : PPolyShape(x, y) { }
- PINLINE PPolyLine::PPolyLine(const PPoint & pt)
- : PPolyShape(pt) { }
- PINLINE PPolyLine::PPolyLine(const PPointArray & pts)
- : PPolyShape(pts) { }
- PINLINE PPolyLine::PPolyLine(const PPoint * ptArray, PINDEX numPts)
- : PPolyShape(ptArray, numPts) { }
- //////////////////////////////////////////////////////////////////////////////
- // PPolygon
- PINLINE PPolygon::PPolygon(PORDINATE x, PORDINATE y)
- : PPolyShape(x, y) { }
- PINLINE PPolygon::PPolygon(const PPoint & pt)
- : PPolyShape(pt) { }
- PINLINE PPolygon::PPolygon(const PPointArray & pts)
- : PPolyShape(pts) { }
- PINLINE PPolygon::PPolygon(const PPoint * ptArray, PINDEX numPts)
- : PPolyShape(ptArray, numPts) { }
- //////////////////////////////////////////////////////////////////////////////
- // PCurve
- PINLINE PCurve::PCurve(PORDINATE x, PORDINATE y)
- : PPolyShape(x, y) { }
- PINLINE PCurve::PCurve(const PPoint & pt)
- : PPolyShape(pt) { }
- PINLINE PCurve::PCurve(const PPointArray & pts)
- : PPolyShape(pts) { }
- PINLINE PCurve::PCurve(const PPoint * ptArray, PINDEX numPts)
- : PPolyShape(ptArray, numPts) { }
- //////////////////////////////////////////////////////////////////////////////
- // PBezier
- PINLINE PBezier::PBezier(PORDINATE x, PORDINATE y)
- : PCurve(x, y) { }
- PINLINE PBezier::PBezier(const PPoint & pt)
- : PCurve(pt) { }
- PINLINE PBezier::PBezier(const PPointArray & pts)
- : PCurve(pts) { }
- PINLINE PBezier::PBezier(const PPoint * ptArray, PINDEX numPts)
- : PCurve(ptArray, numPts) { }
- //////////////////////////////////////////////////////////////////////////////
- // PBSpline
- PINLINE PBSpline::PBSpline(PORDINATE x, PORDINATE y)
- : PCurve(x, y) { }
- PINLINE PBSpline::PBSpline(const PPoint & pt)
- : PCurve(pt) { }
- PINLINE PBSpline::PBSpline(const PPointArray & pts)
- : PCurve(pts) { }
- PINLINE PBSpline::PBSpline(const PPoint * ptArray, PINDEX numPts)
- : PCurve(ptArray, numPts) { }
- //////////////////////////////////////////////////////////////////////////////
- // PCompositeShape
- PINLINE PDim PCompositeShape::GetDimensions() const
- { return dimensions; }
- PINLINE BOOL PCompositeShape::IsComposite() const
- { return TRUE; }
- PINLINE PShape & PCompositeShape::operator[](PINDEX i)
- { return shapes[i]; }
- // End Of File ///////////////////////////////////////////////////////////////