InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IGraphicsPort.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Jack Kirstein
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Purpose of interface
24 // IGraphicsPort is THE drawing API for Shuksan. It is a shell around
25 // the AGM API
26 //
27 // The methods behave exactly, or very much like the equivalent PostScript operators.
28 // See the PostScript language reference manual for complete documentation
29 //
30 // IMPORTANT: if you expect something to print, this is the ONLY interface you can use
31 // to do drawing
32 //
33 //========================================================================================
34 
35 #ifndef __IGRAPHICSPORT__
36 #define __IGRAPHICSPORT__
37 
38 #include "GraphicsID.h"
39 //#include "GRConversions.h"
40 #include "PMMatrix.h"
41 #include "PMReal.h"
42 #include "PMRect.h"
43 #include "GraphicTypes.h"
44 #include "BravoForwardDecl.h"
45 
46 class IFontInstance;
47 class IPMFont;
48 class IOPIInfo;
49 class IDrawMgr;
50 class PMRealGlyphPoint;
51 
52 struct OneOTFeature;
53 
54 #define __PORTSUPPORTSFIXED__ // The graphics port is moving from Fixed numbers to floats - this is here until we force it
55 
64 {
65  public:
66  enum AuxInfoObjectType
67  {
68  kNone,
69  kImage,
70  kTextFrame,
71  kImageStream, // tagging only (no data)
72  kText,
73  kColor,
74  kTextRun
75  };
76 
77  inline GPortAuxInfoParam(): fObjType( kNone ), fOPIInfo(nil), fTextStart(0), fTextSpan(0), fTint(0.0) {}
78  inline GPortAuxInfoParam( AuxInfoObjectType objType ) :
79  fObjType(objType), fOPIInfo(nil), fTextStart(0), fTextSpan(0), fTint(0.0) {}
80 
85  inline void SetObjectType(AuxInfoObjectType bObjType) {fObjType = bObjType;}
90  inline void GetObjectType(AuxInfoObjectType* bObjType) {*bObjType = fObjType;}
95  inline AuxInfoObjectType GetObjectType() { return fObjType ; }
96 
101  inline void SetOPIInfo(IOPIInfo* bOPIInfo) {fOPIInfo = bOPIInfo;}
106  inline void GetOPIInfo(IOPIInfo** bOPIInfo) {*bOPIInfo = fOPIInfo;}
111  inline IOPIInfo* GetOPIInfo() { return fOPIInfo ; }
112 
117  inline void SetObjectRef( const UIDRef& obj ) { fObjRef = obj ; }
122  inline const UIDRef& GetObjectRef() { return fObjRef ; }
123 
128  inline void SetTextStart( TextIndex start ) { fTextStart = start ; }
133  inline TextIndex GetTextStart() { return fTextStart ; }
134 
139  inline void SetTextSpan( int32 span ) { fTextSpan = span ; }
144  inline int32 GetTextSpan() { return fTextSpan ; }
145 
150  inline void SetTint( const PMReal& tint ) { fTint = tint ; }
155  inline const PMReal& GetTint() { return fTint ; }
156 
157  private:
158  AuxInfoObjectType fObjType;
159  IOPIInfo* fOPIInfo;
160  UIDRef fObjRef ;
161  TextIndex fTextStart ;
162  int32 fTextSpan ;
163  PMReal fTint ;
164 };
165 
175 class IGraphicsPort : public IPMUnknown
176 {
177  public:
178  enum { kDefaultIID = IID_IGRAPHICSPORT };
179 
180  // Call this to initialize or re-initialize the port
181  virtual void Setup() = 0;
182 
188  virtual void newpath() = 0;
198  virtual void moveto(const PMReal& x, const PMReal& y) = 0;
208  virtual void rmoveto(const PMReal& x, const PMReal& y) = 0;
218  virtual void lineto(const PMReal& x, const PMReal& y) = 0;
230  virtual void curveto(const PMReal& x1, const PMReal& y1, const PMReal& x2, const PMReal& y2, const PMReal& x3, const PMReal& y3) = 0;
241  virtual void curvetov(const PMReal& x2, const PMReal& y2, const PMReal& x3, const PMReal& y3) = 0;
250  virtual void closepath() = 0;
265  virtual void gsave() = 0;
273  virtual void grestore() = 0;
282  virtual void translate(const PMReal& x, const PMReal& y) = 0;
291  virtual void scale(const PMReal& x, const PMReal& y) = 0;
298  virtual void rotate(const PMReal& theta) = 0;
305  virtual void concat(const PMMatrix &m) = 0; //this is a PreConcat in PMMatrix terms
318  virtual void setlinewidth(const PMReal& width) = 0;
327  virtual void setdash(int32 numDash, float* dashArray, float offset) = 0;
328 
334  virtual void setblendingmode (PMBlendingMode pmBlendingMode) = 0;
335 
354  virtual void starttransparencygroup(const PMRect& bounds, AGMColorSpace *cs, bool16 isolationgroup = kTrue, bool16 knockoutgroup = kFalse) = 0;
359  virtual void endtransparencygroup() = 0;
360 
373  virtual void BeginGroup( const PMString name, const_AIMDictionaryContainer* attrib ) = 0;
374 
380  virtual void EndGroup( const PMString name ) = 0;
381 
388  virtual void setopacity (const PMReal& opacity, bool16 bIsAlphaShape) = 0; // from 0 to 1.0
389 
403  virtual void setlinecap(int32 type) = 0;
418  virtual void setlinejoin(int32 type) = 0;
419 
429  virtual void setmiterlimit(const PMReal& limit) = 0;
435  virtual void setstrokeadjust(bool16 strokeAdjust) = 0;
436  virtual void setgray(const PMReal& gray) = 0;
437  virtual void setrgbcolor(const PMReal& r, const PMReal& g, const PMReal& b) = 0;
438  virtual void setcmykcolor(const PMReal& c, const PMReal& m, const PMReal& y, const PMReal& k) = 0;
439  virtual void setlabcolor(const PMReal& l, const PMReal& a, const PMReal& b) = 0;
440  virtual void setcolorspace(AGMColorSpace* colorSpace) = 0;
441  virtual void setcolorvalues(const float* colorVals) = 0;
442 
443  virtual void setgradient(AGMGradient *agmGrad, const PMMatrix& grMatrix,
444  const PMReal &xOrig, const PMReal &yOrig,
445  const PMReal &len, const PMReal &ang,
446  const PMReal &hiliteLen, const PMReal &hiliteAng) = 0;
465  virtual void SetColorServer(AGMPaint* agmPaint, bool16 bIsAlphaShape, const PMMatrix& m) = 0;
491  virtual void SetAlphaServer(AGMPaint* agmPaint, bool16 bIsAlphaShape, const PMMatrix& m) = 0;
492 
496  virtual void setoverprint(bool32 overprint) = 0;
509  virtual void fill() = 0;
522  virtual void eofill() = 0;
535  virtual void stroke() = 0;
536  virtual void image(_t_AGMImageRecord* imageRec, const PMMatrix& imMatrix, int32 flags) = 0;
537  virtual void image(_t_AGMImageRecord* imageRec, AGMColorSpace* cs, const PMMatrix& m, int32 flags) = 0;
538  // This replaces old version which took an IagmServer_Image
539  virtual void image(AGMImage *image, const PMMatrix& imMatrix, int32 flags) = 0;
540 
541  // Use the following constants for show and xshow
542  typedef enum
543  {
544  kFillText = 1,
545  kStrokeText = 2,
546  kClipText = 4
547  } TextGraphicsFlags;
548 
549  virtual void show(const PMReal &x, const PMReal &y, uint32 numUTF16s, const textchar* text,
550  TextGraphicsFlags graphicsflags = kFillText,
551  bool16 verticalGlyphs = kFalse, bool16 wmodePositioning = kFalse) = 0;
552 #ifdef __PORTSUPPORTSFIXED__
553  virtual void xshow(const PMReal &x, const PMReal &y, uint32 numGlyphs, const int32 *glyphArray,
554  const Fixed* widths, const Fixed* yoffsets = nil,
555  TextGraphicsFlags graphicsflags = kFillText,
556  bool16 verticalGlyphs = kFalse, bool16 wmodePositioning = kFalse,
557  uint32 numChars = 0, const textchar* text = nil,
558  K2Vector<OneOTFeature>* otFeatureArray = nil) = 0;
559 #endif
560  virtual void xshow(const PMReal &x, const PMReal &y, uint32 numGlyphs, const int32 *glyphArray,
561  const float* widths, const float* yoffsets = nil,
562  TextGraphicsFlags graphicsflags = kFillText,
563  bool16 verticalGlyphs = kFalse, bool16 wmodePositioning = kFalse,
564  uint32 numChars = 0, const textchar* text = nil,
565  K2Vector<OneOTFeature>* otFeatureArray = nil) = 0;
566 
567  virtual void ctshow(IFontInstance *fontInstance,
568  PMRealGlyphPoint *glyphPoints, uint32 numGlyphPoints,
569  TextGraphicsFlags graphicsflags = kFillText,
570  bool16 verticalGlyphs = kFalse) = 0;
571 
572  // xshow() and ctshow() take the optional parameters of numChars and text. These
573  // are needed to include searchable text in Export PDF. They are ignored by most
574  // other implementations.
575  // verticalGlyphs = kTrue means to use the vertical variants even if the CMap is -H.
576  // verticalGlyphs = kFalse means to use the horizontal variants.
577  // wmodePositioning = kTrue means vertical text with the implication that the supplied character
578  //positions are based on PostScript's vertical WMode; that is, vertical text with origin at
579  //the top center of the glyph. Set this to kTrue if your text will be imaged vertically by
580  //AGM or PostScript AND if the text positioning was determined by something other than
581  //InDesign's composition engine. Examples of proper uses of wmodePosition = kTrue:
582  //Vertical text in the UI or a placed EPS.
583  // wmodePositioning = kFalse means that the supplied character positions are referred to the Roman
584  //baseline. Set wmodePositioning to kFalse if InDesign's text composition engine layed out your
585  //text, whether the text is intended to be vertical or horizontal.
586  virtual void selectfont(IPMFont *font, const PMMatrix& m) = 0;
587  virtual void selectfont(IPMFont *font, const PMReal& ptSize) = 0;
600  virtual void clip() = 0;
613  virtual void eoclip() = 0;
614  virtual void strokepath_clip() = 0;
615  virtual void rectclip(const PMReal& x, const PMReal& y, const PMReal& width, const PMReal& height) = 0;
616  virtual void rectclip(const PMRect &r) = 0;
617  virtual void rectfill(const PMReal& x, const PMReal& y, const PMReal& width, const PMReal& height) = 0;
618  virtual void rectfill(const PMRect &r) = 0;
619  virtual void rectstroke(const PMReal& x, const PMReal& y, const PMReal& width, const PMReal& height) = 0;
620  virtual void rectstroke(const PMRect &r) = 0;
621  virtual void rectpath(const PMReal& x, const PMReal& y, const PMReal& width, const PMReal& height) = 0;
622  virtual void rectpath(const PMRect &r) = 0;
631  virtual void shadingfill(AGMPaint* paint) = 0;
632 
633  virtual void AddComment(int32 comment, void *commentData, int32 length) = 0;
634 
635  // Return a reference to the port's draw manager instance.
636  // Subclasses typically will have a draw manager concrete class as a data member, though details of
637  // its construction and deployment are up to the class.
638  virtual IDrawMgr *PortDrawMgr() = 0;
639 
640  // The following is only meant to pass auxiliary information, for a group of identical
641  // graphical entities. It has a paired methods, for Begin/End context.
642  // If a port does not support these methods, it should provide an empty stub.
643  // A client of a port could take advantage of these methods to pass additional information
644  // onto the port, where the port could simply punt the information, or use it to create
645  // a more advanced representations of the graphical objects.
646  virtual void BeginAuxInfoContext(GPortAuxInfoParam* auxInfoParam) = 0;
647  virtual void EndAuxInfoContext(GPortAuxInfoParam* auxInfoParam) = 0;
648 
649  // Show method to match AGM. This is used to include searchable text in Export PDF.
650  virtual void show( const CCTTextList& textList, int32 flags, const PMMatrix* matrix = 0 ) const = 0;
651 
658  typedef enum { kPerceptual, kSaturation, kRelative, kAbsolute } RenderingIntent;
659 
668  virtual void SetRenderingIntent(RenderingIntent intent) = 0;
669 
676  virtual void SetOverPrintMode(bool32 mode) = 0;
677 
687  virtual void FillPath(AGMPath *path) = 0;
688 
696  virtual void StrokePath(AGMPath *path) = 0;
697 
707  virtual void ClipPath(AGMPath *path) = 0;
708 };
709 
710 #endif