graphics.inl
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:15k
- /*
- * graphics.inl
- *
- * Graphics classes 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: graphics.inl,v $
- * Revision 1.22 1999/08/24 06:54:36 robertj
- * Cleaned up the smart pointer code (macros).
- *
- * Revision 1.21 1998/12/12 00:42:57 robertj
- * Added functions for user request on printing selection only.
- * Fixed transfer of start and end pages from PPrintDialog.
- *
- * Revision 1.20 1998/09/23 06:23:41 robertj
- * Added open source copyright license.
- *
- * Revision 1.19 1998/03/20 03:14:38 robertj
- * Added function to get physical bounds of canvas. Allows to scale drawing.
- *
- * Revision 1.18 1995/10/14 14:55:40 robertj
- * Changed return values to references for efficency.
- *
- * Revision 1.17 1995/01/27 11:09:25 robertj
- * "Commonised" DrawRect function.
- * Added pattern origin.
- * Added FillRect function.
- *
- * Revision 1.16 1995/01/21 05:13:54 robertj
- * Added origin changing function, simpler than setting rectangles.
- * Fixed rounding error for negative numbers in coordinate system conversions.
- *
- * Revision 1.15 1995/01/09 12:40:07 robertj
- * Rename of smart pointer macro.
- *
- * Revision 1.14 1995/01/06 10:43:47 robertj
- * Changed PRealFont usage from pointer to reference.
- *
- * Revision 1.13 1994/12/21 11:58:20 robertj
- * Documentation and variable normalisation.
- *
- * Revision 1.12 1994/12/12 10:13:01 robertj
- * Renamed PWrapper to PSmartPointer.
- * Added depth to PPixelBase and removed virtual function.
- *
- * Revision 1.11 1994/12/05 11:34:07 robertj
- * Major rewrite of images, pictures and pixmaps.
- * Renamed PPict, PPixels and PImage to make sure all uses are found.
- *
- * Revision 1.10 1994/10/23 04:43:17 robertj
- * PPixels split into subclasses for each pixel size.
- *
- * Revision 1.9 1994/07/27 05:58:07 robertj
- * Synchronisation.
- *
- * Revision 1.8 1994/07/25 03:30:41 robertj
- * Fixed comment leader.
- *
- * Revision 1.7 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.6 1994/04/20 12:17:44 robertj
- * assert stuff
- *
- * Revision 1.5 1994/03/07 07:45:40 robertj
- * Major upgrade
- *
- * Revision 1.4 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.3 1993/12/31 06:47:59 robertj
- * Made inlines optional for debugging purposes.
- *
- * Revision 1.2 1993/12/24 04:20:52 robertj
- * Mac CFront port.
- *
- * Revision 1.1 1993/12/04 05:24:25 robertj
- * Initial revision
- */
- ///////////////////////////////////////////////////////////////////////////////
- // PImage
- PINLINE PImage::PImage(PImageBase * obj)
- : PSmartPointer(obj) { }
- ///////////////////////////////////////////////////////////////////////////////
- // PPixels
- PINLINE PPixelImage::PPixelImage(PPixelBase * obj)
- : PImage(obj) { }
- PINLINE PPixelDataPtr PPixelBase::GetPixelDataPtr() const
- { return pixels; }
- PINLINE BOOL PPixelBase::IsFullColour() const
- { return GetDepth() >= 24; }
- PINLINE void PPixelBase::SetRaster(PORDINATE y,
- const PColourArray & raster, PDIMENSION width)
- { SetRaster(0, y, raster, width); }
-
- PINLINE void PPixelBase::SetRaster(PORDINATE x, PORDINATE y,
- const PColourArray & raster, PDIMENSION width)
- { SetRasterColours(x, y, raster, width); }
-
- PINLINE void PPixelBase::SetRaster(PORDINATE y,
- const PBYTEArray & raster, PDIMENSION width)
- { SetRaster(0, y, raster, width); }
-
- PINLINE void PPixelBase::SetRaster(PORDINATE y,
- const BYTE * raster, PDIMENSION width)
- { SetRaster(0, y, raster, width); }
-
- PINLINE void PPixelBase::SetRaster(PORDINATE x, PORDINATE y,
- const BYTE * raster, PDIMENSION width)
- { SetRasterValues(x, y, raster, width); }
-
- PINLINE void PPixelBase::GetRaster(PORDINATE y,
- PColourArray & raster, PDIMENSION width) const
- { GetRaster(0, y, raster, width); }
-
- PINLINE void PPixelBase::GetRaster(PORDINATE x, PORDINATE y,
- PColourArray & raster, PDIMENSION width) const
- { GetRasterColours(x, y, raster, width); }
-
- PINLINE void PPixelBase::GetRaster(PORDINATE y,
- PBYTEArray & raster, PDIMENSION width) const
- { GetRaster(0, y, raster, width); }
- PINLINE void PPixelBase::GetRaster(PORDINATE y,
- BYTE * raster, PDIMENSION width) const
- { GetRaster(0, y, raster, width); }
-
- PINLINE void PPixelBase::GetRaster(PORDINATE x, PORDINATE y,
- BYTE * raster, PDIMENSION width) const
- { GetRasterValues(x, y, raster, width); }
- PINLINE PPixelImage PPixelBase::ExtractPixels(const PRect & rect) const
- { return ExtractPixels(rect.X(), rect.Y(), rect.Width(), rect.Height()); }
-
- PINLINE const PRect & PPixelBase::GetDirtyArea() const
- { return dirtyArea; }
- PINLINE void PPixelBase::ClearDirtyArea()
- { dirtyArea = PRect(); }
- PINLINE PPixels1::PPixels1(PDIMENSION dx, PDIMENSION dy)
- : PPixelBase(dx, dy, 1) { }
- PINLINE PPixels2::PPixels2(PDIMENSION dx, PDIMENSION dy)
- : PPixelBase(dx, dy, 2) { }
- PINLINE PPixels4::PPixels4(PDIMENSION dx, PDIMENSION dy)
- : PPixelBase(dx, dy, 4) { }
- PINLINE PPixels8::PPixels8(PDIMENSION dx, PDIMENSION dy)
- : PPixelBase(dx, dy, 8) { }
- PINLINE PPixels24::PPixels24(PDIMENSION dx, PDIMENSION dy)
- : PPixelBase(dx, dy, 24) { }
- PINLINE PPixels32::PPixels32(PDIMENSION dx, PDIMENSION dy)
- : PPixelBase(dx, dy, 32) { }
- ///////////////////////////////////////////////////////////////////////////////
- // PPictImage
- PINLINE PPictImage::PPictImage(PPictBase * obj)
- : PImage(obj == NULL ? PNEW PPictBase : obj) { }
- PINLINE PPictImage::PPictImage(PRESOURCE_ID resID)
- : PImage(PNEW PPictBase(resID)) { }
-
- PINLINE PPictImage::PPictImage(PFile & dwg)
- : PImage(PNEW PPictBase(dwg)) { }
- //////////////////////////////////////////////////////////////////////////////
- // PCanvasState
- #if defined(_PCANVASSTATE)
- PINLINE PCanvasState::PenStyles PCanvasState::GetPenStyle() const
- { return penStyle; }
- PINLINE int PCanvasState::GetPenWidth() const
- { return penWidth; }
- PINLINE PCanvasState::DrawingModes PCanvasState::GetPenMode() const
- { return penMode; }
- PINLINE const PColour & PCanvasState::GetPenFgColour() const
- { return penFgColour; }
- PINLINE const PColour & PCanvasState::GetPenBkColour() const
- { return penBkColour; }
- PINLINE PPattern PCanvasState::GetFillPattern() const
- { return fillPattern; }
- PINLINE PPoint PCanvasState::GetPatternOrigin() const
- { return patternOrigin; }
- PINLINE PCanvasState::DrawingModes PCanvasState::GetFillMode() const
- { return fillMode; }
- PINLINE const PColour & PCanvasState::GetFillFgColour() const
- { return fillFgColour; }
- PINLINE const PColour & PCanvasState::GetFillBkColour() const
- { return fillBkColour; }
-
- PINLINE PFont PCanvasState::GetFont() const
- { return font; }
- PINLINE const PColour & PCanvasState::GetTextFgColour() const
- { return textFgColour; }
- PINLINE const PColour & PCanvasState::GetTextBkColour() const
- { return textBkColour; }
-
- PINLINE PPalette PCanvasState::GetPalette() const
- { return palette; }
- PINLINE PCanvasState::PolyFillMode PCanvasState::GetPolyFillMode() const
- { return polyFillMode; }
- PINLINE PRect PCanvasState::GetViewportRect() const
- { return viewport; }
- PINLINE PRect PCanvasState::GetMappingRect() const
- { return map; }
- PINLINE PPoint PCanvasState::GetOrigin() const
- { return map.Origin(); }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PCanvas
- #if defined(_PCANVAS)
- PINLINE void PCanvas::Save()
- { stack.Push(PNEW State(*this)); }
- PINLINE const PRealFont & PCanvas::GetFont() const
- { return realFont; }
- PINLINE void PCanvas::SetCurrentPosition(const PPoint & pos)
- { SetCurrentPosition(pos.X(), pos.Y()); }
- PINLINE void PCanvas::MoveCurrentPosition(const PPoint & pos)
- { MoveCurrentPosition(pos.X(), pos.Y()); }
- PINLINE void PCanvas::DrawLine(const PPoint & pt)
- { DrawLine(pt.X(), pt.Y()); }
- PINLINE void PCanvas::DrawLineRelative(const PPoint & pt)
- { DrawLineRelative(pt.X(), pt.Y()); }
- PINLINE void PCanvas::DrawLine(const PPoint & p1, const PPoint & p2)
- { DrawLine(p1.X(), p1.Y(), p2.X(), p2.Y()); }
- PINLINE void PCanvas::DrawRect(PORDINATE x,
- PORDINATE y, PDIMENSION dx, PDIMENSION dy)
- { _DrawRect(x, y, dx, dy); }
- PINLINE void PCanvas::DrawRect(const PPoint & topLeft, const PPoint & botRight)
- { DrawRect(PRect(topLeft, botRight)); }
- PINLINE void PCanvas::DrawRect(const PPoint & pt, const PDim & dim)
- { _DrawRect(pt.X(), pt.Y(), dim.Width(), dim.Height()); }
- PINLINE void PCanvas::DrawRect(const PRect & rect)
- { _DrawRect(rect.X(), rect.Y(), rect.Width(), rect.Height()); }
- PINLINE void PCanvas::FillRect(PORDINATE x,
- PORDINATE y, PDIMENSION dx, PDIMENSION dy)
- { _FillRect(x, y, dx, dy); }
- PINLINE void PCanvas::FillRect(const PPoint & topLeft, const PPoint & botRight)
- { FillRect(PRect(topLeft, botRight)); }
- PINLINE void PCanvas::FillRect(const PPoint & pt, const PDim & dim)
- { _FillRect(pt.X(), pt.Y(), dim.Width(), dim.Height()); }
- PINLINE void PCanvas::FillRect(const PRect & rect)
- { _FillRect(rect.X(), rect.Y(), rect.Width(), rect.Height()); }
- PINLINE void PCanvas::DrawImgIcon(const PPoint & pt, const PImgIcon & icn)
- { DrawImgIcon(pt.X(), pt.Y(), icn); }
- PINLINE void PCanvas::DrawIcon(const PPoint & pt, const PIcon & icn)
- { DrawIcon(pt.X(), pt.Y(), icn); }
- PINLINE void PCanvas::DrawPixels(const PPoint & pt, const PPixelImage & pix)
- { DrawPixels(pt.X(), pt.Y(), pix); }
- PINLINE void PCanvas::DrawPict(const PPoint & pt, const PPictImage & pic)
- { DrawPict(pt.X(), pt.Y(), pic); }
- PINLINE void PCanvas::DrawString(const PPoint & pt,
- const PString & str, int options)
- { DrawString(pt.X(), pt.Y(), str, options); }
- PINLINE PDim PCanvas::FromPixels(const PDim & dim) const
- { return PDim(FromPixelsDX(dim.Width()), FromPixelsDY(dim.Height())); }
- PINLINE PPoint PCanvas::FromPixels(const PPoint & p) const
- { return PPoint(FromPixelsX(p.X()), FromPixelsY(p.Y())); }
- PINLINE PRect PCanvas::FromPixels(const PRect & r) const
- { return PRect(FromPixels(r.Origin()), FromPixels(r.Corner())); }
- PINLINE PDim PCanvas::ToPixels(const PDim & dim) const
- { return PDim(ToPixelsDX(dim.Width()), ToPixelsDY(dim.Height())); }
- PINLINE PPoint PCanvas::ToPixels(const PPoint & p) const
- { return PPoint(ToPixelsX(p.X()), ToPixelsY(p.Y())); }
- PINLINE PRect PCanvas::ToPixels(const PRect & r) const
- { return PRect(ToPixels(r.Origin()), ToPixels(r.Corner())); }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PInteractorCanvas
- #ifdef _PINTERACTORCANVAS
- PINLINE PInteractor * PInteractorCanvas::GetInteractor() const
- { return interactor; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PMemoryCanvas
- #ifdef _PMEMORYCANVAS
- PINLINE PMemoryCanvas::PMemoryCanvas(const PImage & img)
- : image(img) { Construct(); }
- PINLINE PMemoryCanvas::~PMemoryCanvas()
- { }
- PINLINE const PImage PMemoryCanvas::GetImage()
- { return image; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PPrintCanvas
- #if defined(_PPRINTCANVAS)
- PINLINE PPrintCanvas::PPrintCanvas(const PString & job)
- : jobName(job) { Construct(); }
- PINLINE PPrintCanvas::PPrintCanvas(const PString & job,
- const PString & printer, const PString & device)
- : jobName(job), printInfo(printer, device) { Construct(); }
- PINLINE PPrintCanvas::PPrintCanvas(const PString &job, const PPrintInfo &info)
- : jobName(job), printInfo(info) { Construct(); }
- PINLINE const PPrintInfo & PPrintCanvas::GetPrintInfo() const
- { return printInfo; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PPrintInfo
- #ifdef _PPRINTINFO
- PINLINE PString PPrintInfo::GetPrinter() const
- { return printer; }
- PINLINE PString PPrintInfo::GetDevice() const
- { return device; }
- PINLINE void PPrintInfo::SetForm(Forms newForm)
- { form = newForm; }
- PINLINE PPrintInfo::Forms PPrintInfo::GetForm() const
- { return form; }
- PINLINE void PPrintInfo::SetPaperSize(const PDim & dim)
- { paperSize = dim; }
- PINLINE PDim PPrintInfo::GetPaperSize() const
- { return paperSize; }
- PINLINE PDim PPrintInfo::GetResolution() const
- { return resolution; }
- PINLINE void PPrintInfo::SetStartPage(unsigned page)
- { startPage = page; }
- PINLINE unsigned PPrintInfo::GetStartPage() const
- { return startPage; }
- PINLINE void PPrintInfo::SetEndPage(unsigned page)
- { endPage = page; }
- PINLINE unsigned PPrintInfo::GetEndPage() const
- { return endPage; }
- PINLINE void PPrintInfo::SetSelectionOnly(SelectionOnly selOnly)
- { selectionOnly = selOnly; }
- PINLINE PPrintInfo::SelectionOnly PPrintInfo::GetSelectionOnly() const
- { return selectionOnly; }
- PINLINE BOOL PPrintInfo::IsSelectionOnly() const
- { return selectionOnly == SelectionOnlyOn; }
- PINLINE void PPrintInfo::SetCopies(unsigned count)
- { copies = count; }
- PINLINE unsigned PPrintInfo::GetCopies() const
- { return copies; }
- PINLINE void PPrintInfo::SetPortrait(BOOL port)
- { orientation = port; }
- PINLINE void PPrintInfo::SetLandscape()
- { SetPortrait(FALSE); }
- PINLINE BOOL PPrintInfo::IsPortrait() const
- { return orientation; }
- PINLINE BOOL PPrintInfo::IsDraftQuality() const
- { return draftQuality; }
- #endif
- // End Of File ///////////////////////////////////////////////////////////////