00001 /******************************************************************************, 00002 * 00003 * \file mi32/mgd2.h 00004 * \brief MicroImages Graphics Device 00005 * 00006 * \if NODOC 00007 * $Log: mgd2.h_v $ 00008 * Revision 1.93 2004/10/15 21:26:43 ldyas 00009 * added usesTransparency to textblock 00010 * 00011 * Revision 1.92 2004/10/14 22:04:20 ldyas 00012 * added is antialiased as member of textblock 00013 * 00014 * Revision 1.91 2004/09/20 20:56:55 dwilliss 00015 * added SetColor method that takes COLOR::NAME 00016 * 00017 * Revision 1.90 2004/08/19 17:58:26 dwilliss 00018 * Made some funcitons non-inline 00019 * 00020 * Revision 1.89 2004/07/20 22:22:09 dwilliss 00021 * *** empty log message *** 00022 * 00023 * Revision 1.88 2004/07/20 16:51:00 dwilliss 00024 * Gave the lable extents computing functions a parameter to allow them to 00025 * bypass the whole region creation if totally off screen. 00026 * 00027 * Revision 1.87 2004/07/20 16:41:27 dwilliss 00028 * Added methods to compute label extents region 00029 * 00030 * Revision 1.86 2004/06/18 19:45:44 ldyas 00031 * added text get font by full name and family name. 00032 * 00033 * Revision 1.85 2004/05/25 19:26:58 dwilliss 00034 * Moved the enums to their own include file so that we could use them 00035 * elsewhere without having to include all of mgd2.h and all it pulls in. 00036 * 00037 * Revision 1.84 2004/05/25 19:05:43 dwilliss 00038 * fixed typo in template inline function 00039 * 00040 * Revision 1.83 2004/05/25 17:43:48 dwilliss 00041 * Added INTERFACETEXTSTYLE enum and parameters to InterfaceText functions 00042 * 00043 * Revision 1.82 2004/05/10 17:09:14 mju 00044 * Move PIXEL typedef to stddefns. 00045 * 00046 * Revision 1.81 2004/04/02 21:56:49 dwilliss 00047 * Added DrawLabel method that takes a TEXTBLOCK 00048 * 00049 * Revision 1.80 2004/04/01 00:04:44 dwilliss 00050 * text changes galore. 00051 * 00052 * Revision 1.79 2004/03/30 17:10:05 dwilliss 00053 * Added comments to an enum 00054 * 00055 * Revision 1.78 2004/03/05 21:20:57 mju 00056 * Change Draw...StyleSample to use enum flags. 00057 * 00058 * Revision 1.77 2004/03/05 18:40:11 dwilliss 00059 * Renamed a method 00060 * 00061 * Revision 1.76 2004/03/05 17:23:13 mju 00062 * No longer include legacy mgd hdr as want to fix stuff which uses it. 00063 * 00064 * Revision 1.75 2004/02/13 16:45:28 dwilliss 00065 * Changed to include mgd.h for deprecated builds AFTER everything else 00066 * 00067 * Revision 1.74 2004/02/13 15:31:31 dwilliss 00068 * include old mgd dot h unless NO_DEPRECATED is set 00069 * 00070 * Revision 1.73 2004/02/13 14:55:33 dwilliss 00071 * Changed reference to mgd dot h in comment to prevent grep from finding it. 00072 * 00073 * Revision 1.72 2004/02/12 21:45:28 dwilliss 00074 * GetImagePointer no longer protected. Need it to get rid of old deprecated 00075 * thing 00076 * 00077 * Revision 1.71 2004/02/12 21:08:56 dwilliss 00078 * Fixed stupid warning 00079 * 00080 * Revision 1.70 2004/01/12 20:46:36 dwilliss 00081 * Made the non-virtual Clear() method inline 00082 * 00083 * Revision 1.69 2004/01/12 20:44:54 dwilliss 00084 * Added Clear method to device 00085 * 00086 * Revision 1.68 2003/12/15 23:34:45 dwilliss 00087 * Diverging for 7.0 00088 * Made changes necessary for SML interface and graphical data tips 00089 * 00090 * Revision 1.67 2003/12/10 23:46:34 dwilliss 00091 * Keep track of virtual window in the base device class so low-level 00092 * implementations of fill span can cope with it. 00093 * 00094 * Revision 1.66 2003/12/10 17:47:25 dwilliss 00095 * Added private data 00096 * 00097 * Revision 1.65 2003/12/04 16:18:28 dwilliss 00098 * Make default implementation of v_InterfaceTextGetExtents() return 0s instead 00099 * of leaving return values as the random garbage they were passed in as 00100 * 00101 * Revision 1.64 2003/11/10 16:09:27 dwilliss 00102 * Added GetPixelColorNoICM and GetColorPixelNoICM 00103 * 00104 * Revision 1.63 2003/11/04 14:58:40 scowan 00105 * Removed groupkey deprecated get scalable font function. 00106 * 00107 * Revision 1.62 2003/11/04 13:25:04 mju 00108 * Remove ambiguity in dlgGetScalableFont. 00109 * 00110 * Revision 1.61 2003/11/03 20:40:26 scowan 00111 * Deprecate legacy get scalable font function. 00112 * Add new function with textid handling. 00113 * 00114 * Revision 1.60 2003/10/29 22:01:02 dwilliss 00115 * Context's method to check antialiasing no longer inline. Now also checks 00116 * to see if the device supports it 00117 * 00118 * Revision 1.59 2003/10/29 18:29:04 ldyas 00119 * *** empty log message *** 00120 * 00121 * Revision 1.58 2003/10/24 17:03:48 dwilliss 00122 * Added method to get/set thin line width hinting 00123 * 00124 * Revision 1.57 2003/10/22 21:20:42 ldyas 00125 * *** empty log message *** 00126 * 00127 * Revision 1.56 2003/10/10 22:44:48 dwilliss 00128 * Added Get/SetAntialiasing 00129 * 00130 * Revision 1.55 2003/10/08 17:46:35 ldyas 00131 * added anti-aliasing and filldevice 00132 * 00133 * Revision 1.54 2003/10/03 20:10:53 linux32build!build 00134 * Doxygen 00135 * 00136 * Revision 1.53 2003/10/01 22:16:22 dwilliss 00137 * Doxygen 00138 * 00139 * Revision 1.52 2003/09/29 22:58:22 dwilliss 00140 * Added a member to device 00141 * 00142 * Revision 1.51 2003/09/22 20:29:12 dwilliss 00143 * Got rid of an overload that wasn't used and didn't do anything useful 00144 * 00145 * Revision 1.50 2003/09/15 13:49:56 fileserver!dwilliss 00146 * Doxygen 00147 * 00148 * Revision 1.49 2003/09/09 22:11:21 scowan 00149 * nc. 00150 * 00151 * Revision 1.48 2003/09/09 17:56:22 scowan 00152 * Added more work buffers. 00153 * 00154 * Revision 1.47 2003/07/31 20:36:33 dwilliss 00155 * Made SetICMSourceProfile() non-inline. It just got a whole lot more 00156 * compilcated. 00157 * 00158 * Revision 1.46 2003/07/25 22:22:34 dwilliss 00159 * *** empty log message *** 00160 * 00161 * Revision 1.45 2003/07/03 17:52:14 dwilliss 00162 * *** empty log message *** 00163 * 00164 * Revision 1.44 2003/06/27 14:21:45 dwilliss 00165 * GetOutputScale modified to cope with this == NULL 00166 * 00167 * Revision 1.43 2003/06/24 16:11:20 dwilliss 00168 * Added a DrawLabel method 00169 * 00170 * Revision 1.42 2003/06/17 16:42:31 dwilliss 00171 * Made 3 methods of device non-inline. GetPixelSizeMM (2 flavors) and 00172 * CreateContext now cope with "this" being NULL. 00173 * 00174 * Revision 1.41 2003/06/16 22:58:58 dwilliss 00175 * *** empty log message *** 00176 * 00177 * Revision 1.40 2003/06/11 22:12:28 dwilliss 00178 * *** empty log message *** 00179 * 00180 * Revision 1.39 2003/06/11 22:08:06 dwilliss 00181 * The inline for DrawPoint was missing. 00182 * 00183 * Revision 1.38 2003/06/11 17:10:57 dwilliss 00184 * Virtual methods all renamed to start with v_ and made private (where 00185 * possible) or protected. 00186 * 00187 * Revision 1.37 2003/06/06 22:34:45 dwilliss 00188 * color management stuff 00189 * 00190 * Revision 1.36 2003/05/30 16:50:24 dwilliss 00191 * Added a new overload of a function 00192 * 00193 * Revision 1.35 2003/05/28 15:13:37 dwilliss 00194 * A bunch of ICM changes 00195 * 00196 * Revision 1.34 2003/05/23 22:41:59 dwilliss 00197 * Added methods to Clear ICM Profiles 00198 * 00199 * Revision 1.33 2003/05/21 22:30:56 dwilliss 00200 * Added ICM Profile support 00201 * 00202 * Revision 1.32 2003/01/23 15:03:13 scowan 00203 * Fixed inline calling errors for draw lines dashed. 00204 * 00205 * Revision 1.31 2003/01/20 16:45:53 mju 00206 * Fix parm names for draw/fillrectangle. 00207 * 00208 * Revision 1.30 2003/01/10 21:51:31 mju 00209 * Add comment. 00210 * 00211 * Revision 1.29 2003/01/10 21:24:30 mju 00212 * Add DrawLinesDashed versions using c-style array. 00213 * Make virtual DrawLinesDashed start with v_. 00214 * 00215 * Revision 1.28 2003/01/07 21:50:32 dwilliss 00216 * Added DrawArrow() method 00217 * 00218 * Revision 1.27 2003/01/02 20:28:49 dwilliss 00219 * Added new DrawRegion/DrawSubregion methods 00220 * 00221 * Revision 1.26 2002/11/21 23:01:36 dwilliss 00222 * Added new capabililty flag 00223 * 00224 * Revision 1.25 2002/11/15 16:25:10 dwilliss 00225 * The idea of a "work" context is gone. 00226 * 00227 * Revision 1.24 2002/11/13 23:37:02 dwilliss 00228 * Complex Clip Regions 00229 * Added DrawLines() method taking a POLYLINE 00230 * Added FillRegion() 00231 * Various private method changes necessary to fix hatch pattern filling to 00232 * use complex clip regions 00233 * 00234 * Revision 1.23 2002/10/30 21:54:22 scowan 00235 * Moved method to be private. 00236 * 00237 * Revision 1.22 2002/10/21 14:18:45 dwilliss 00238 * const issue 00239 * 00240 * Revision 1.21 2002/10/17 15:22:53 mju 00241 * COLORSPACE enum moved to mi32/colorspc.h and some items renamed. 00242 * 00243 * Revision 1.20 2002/10/03 22:05:52 dwilliss 00244 * Added InterfaceTextGetWidth(), Gave InterfaceTextDrawString() an optional 00245 * parameter for visual order drawing 00246 * 00247 * Revision 1.19 2002/10/02 22:39:29 dwilliss 00248 * Made GetImagePointer protected 00249 * 00250 * Revision 1.18 2002/10/02 20:28:44 dwilliss 00251 * Fixed a problem in SetFont. Wasn't keeping track of stuff right 00252 * 00253 * Revision 1.17 2002/09/09 17:00:42 mju 00254 * Allow mgd dot h so can compile stubs. 00255 * 00256 * Revision 1.16 2002/08/19 15:15:11 scowan 00257 * nc. 00258 * 00259 * Revision 1.15 2002/08/19 15:06:10 dwilliss 00260 * Change a cast to a const_cast for clarity 00261 * 00262 * Revision 1.14 2002/08/14 17:13:00 ldyas 00263 * *** empty log message *** 00264 * 00265 * Revision 1.13 2002/08/14 17:12:25 ldyas 00266 * Added IsEmbeddable for Fonts 00267 * 00268 * Revision 1.12 2002/08/13 16:15:47 vdronov 00269 * added m_IsPerspective and Calculate3dDepthFunction 00270 * 00271 * Revision 1.11 2002/08/01 16:09:39 dwilliss 00272 * *** empty log message *** 00273 * 00274 * Revision 1.10 2002/07/03 15:27:00 dwilliss 00275 * Added MGD::FONT::ReadTTF() as a static method 00276 * 00277 * Revision 1.9 2002/06/11 22:05:42 scowan 00278 * Added another friend. 00279 * 00280 * Revision 1.8 2002/06/10 16:18:59 mju 00281 * Add COLORLOCK class. 00282 * 00283 * Revision 1.7 2002/06/04 23:18:56 ldyas 00284 * Made SetColorIsPatternValue virtual 00285 * 00286 * Revision 1.4 2002/06/03 22:58:28 ldyas 00287 * Added SetColorIsPatternVariable and DrawLinesDashed 00288 * 00289 * RCS error forced me to delete the RCS file and start over 00290 * 00291 * Revision 1.1 2002/05/29 23:00:02 dwilliss 00292 * Initial revision 00293 * 00294 * Revision 1.62 2002/05/29 22:12:18 dwilliss 00295 * TextOpenFont now takes const filename 00296 * 00297 * Revision 1.61 2002/05/28 22:58:56 dwilliss 00298 * Expanded documentation in comments 00299 * 00300 * Revision 1.60 2002/05/21 22:51:14 dwilliss 00301 * Added TextBlockBegin/End methods 00302 * 00303 * Revision 1.59 2002/05/21 16:34:49 dwilliss 00304 * SetOutputScale is no longer inline. More complicated that just assignment 00305 * 00306 * Revision 1.58 2002/05/17 22:53:31 dwilliss 00307 * Added TextSpanBegin/End 00308 * 00309 * Revision 1.57 2002/05/13 22:53:35 dwilliss 00310 * Defined new "cabability" flag. 00311 * 00312 * Revision 1.56 2002/05/13 22:50:22 dwilliss 00313 * Made some text drawing methods virtual 00314 * 00315 * Revision 1.55 2002/04/23 16:46:29 dwilliss 00316 * Added more colorspaces for 32-bit cases 00317 * 00318 * Revision 1.54 2002/04/19 14:18:13 dwilliss 00319 * Inline method was missing return value 00320 * 00321 * Revision 1.53 2002/04/05 21:03:52 mju 00322 * Add Draw...StyleSample methods use RVC::STYLE. 00323 * 00324 * Revision 1.49 2002/03/14 23:30:36 dwilliss 00325 * TEXTBLOCKs now use Unicode text exclusively. 00326 * 00327 * Revision 1.48 2002/03/13 21:11:25 dwilliss 00328 * Changes necessary to implement full justified text 00329 * 00330 * Revision 1.47 2002/03/11 18:52:00 dwilliss 00331 * Added a GetTextStyle/SetTextStyle pair 00332 * 00333 * Revision 1.46 2002/03/08 15:39:26 dwilliss 00334 * MGD::TEXTBLOCKs can't be memset now. Use the constructor 00335 * 00336 * Revision 1.45 2002/03/08 15:28:54 dwilliss 00337 * TEXTBLOCK has constructor/destructor now 00338 * 00339 * Revision 1.44 2002/02/22 16:17:56 scowan 00340 * Added clip width. 00341 * 00342 * Revision 1.43 2002/02/21 23:59:24 scowan 00343 * Added clip width variable. 00344 * 00345 * Revision 1.42 2002/02/21 18:09:40 dwilliss 00346 * Changed the comments on CopyRect() to reflect reality 00347 * 00348 * Revision 1.41 2002/02/08 23:03:05 scowan 00349 * Changed text get area to text add to clip. 00350 * 00351 * Revision 1.40 2002/02/05 15:45:28 dwilliss 00352 * Changes to CONTEXT_AUTOPTR. Constructor is explicit, copy constructor and 00353 * assignment operator are declared but unimplemented to prevent use. 00354 * 00355 * Revision 1.39 2002/02/05 15:39:44 dwilliss 00356 * Added CONTEXT_AUTOPTR 00357 * 00358 * Revision 1.38 2002/01/30 23:44:57 scowan 00359 * Removed flag for using fill span. 00360 * 00361 * Revision 1.37 2002/01/29 23:58:11 scowan 00362 * Added clear clip mask method. 00363 * 00364 * Revision 1.36 2002/01/29 15:55:21 dwilliss 00365 * Added private method to device 00366 * 00367 * Revision 1.35 2002/01/28 21:35:31 scowan 00368 * Added virtual methods to deal with clipping masks. 00369 * 00370 * Revision 1.34 2002/01/25 23:34:09 scowan 00371 * Removed legacy clip mask structure. 00372 * 00373 * Revision 1.33 2002/01/25 16:04:56 mju 00374 * Add defaults for DlgGetScalableFont like old version had. 00375 * 00376 * Revision 1.32 2002/01/16 23:34:54 scowan 00377 * Added boldnesswidth to textsettings. 00378 * 00379 * Revision 1.31 2002/01/16 23:17:46 scowan 00380 * Changed methods and added methods. 00381 * 00382 * Revision 1.30 2002/01/09 20:20:11 dwilliss 00383 * Fixed problem with null device 00384 * 00385 * Revision 1.29 2002/01/09 20:07:05 dwilliss 00386 * Added Null Device 00387 * 00388 * Revision 1.28 2002/01/08 23:48:50 dwilliss 00389 * ImageBegin/ImageEnd/PutImageSpan now deal with any source colorspace 00390 * CopyRect uses above changes so it works too. 00391 * 00392 * Revision 1.27 2002/01/08 20:52:47 dwilliss 00393 * Added version of ImageBegin that takes a rectangle instead of x,y,h,w 00394 * 00395 * Revision 1.26 2002/01/08 20:39:53 dwilliss 00396 * TextSetHeight now allows you to specify units 00397 * 00398 * Revision 1.25 2002/01/08 19:50:10 dwilliss 00399 * CreateContext no longer pure virtual. 00400 * 00401 * Revision 1.24 2002/01/08 18:57:10 dwilliss 00402 * Reworkded to move all class members to base class 00403 * 00404 * Revision 1.23 2002/01/04 21:28:08 dwilliss 00405 * Define use new mgd flag 00406 * 00407 * Revision 1.22 2002/01/04 14:59:45 dwilliss 00408 * Allow use again 00409 * 00410 * Revision 1.21 2002/01/02 22:49:31 dwilliss 00411 * Everything compiles now 00412 * 00413 * Revision 1.20 2001/12/31 16:57:52 dwilliss 00414 * GetColorSpace no longer pure virtual 00415 * 00416 * Revision 1.16 2001/12/24 16:50:53 dwilliss 00417 * Added some methods that old MGD had. 00418 * 00419 * Revision 1.15 2001/12/24 16:22:47 dwilliss 00420 * Added NoMultiPointSpan setting method 00421 * 00422 * Revision 1.8 2001/07/27 22:09:34 dwilliss 00423 * Added capability flag for being able to use a mask in PutImageSpan 00424 * 00425 * Revision 1.7 2001/07/26 20:57:10 dwilliss 00426 * Update font stuff to use new freetype 00427 * 00428 * Revision 1.6 2001/07/13 15:29:47 dwilliss 00429 * Some more Mac compile issues 00430 * 00431 * Revision 1.5 2001/07/13 15:11:14 dwilliss 00432 * Fixed Mac compiler errors 00433 * 00434 * Revision 1.4 2001/07/12 14:05:03 dwilliss 00435 * gcc didn't like #error with no quotes even though should be ifdef'd out 00436 * 00437 * Revision 1.1 2001/07/11 17:33:41 dwilliss 00438 * Initial revision 00439 * \endif 00440 */ 00441 00442 #ifndef INC_MI32_MGD2_H 00443 #define INC_MI32_MGD2_H 00444 00445 #define USE_NEW_MGD 00446 00447 00448 #ifndef INC_MI32_STDDEFNS_H 00449 #include <mi32/stddefns.h> 00450 #endif 00451 00452 #ifndef INC_MI32_ELEMSTYL_H 00453 #include <mi32/elemstyl.h> 00454 #endif 00455 00456 #ifndef INC_MI32_MICON_H 00457 #include <mi32/micon.h> 00458 #endif 00459 00460 #ifndef INC_MI32_DISPINFO_H 00461 #include <mi32/dispinfo.h> 00462 #endif 00463 00464 #ifndef INC_MI32_COLORMAP_H 00465 #include <mi32/colormap.h> 00466 #endif 00467 00468 #ifndef INC_MI32_RECT_H 00469 #include <mi32/rect.h> 00470 #endif 00471 00472 #ifndef INC_MI32_POINT_H 00473 #include <mi32/point.h> 00474 #endif 00475 00476 #ifndef INC_MI32_SCRNUNIT_H 00477 #include <mi32/scrnunit.h> 00478 #endif 00479 00480 #ifndef INC_MI32_TEXTBASE_H 00481 #include <mi32/textbase.h> 00482 #endif 00483 00484 #ifndef INC_MI32_MILIST_H 00485 #include <mi32/milist.h> 00486 #endif 00487 00488 #ifndef INC_MI32_SIMPLEAR_H 00489 #include <mi32/simplear.h> 00490 #endif 00491 00492 #ifndef INC_MI32_COLOR_H 00493 #include <mi32/color.h> 00494 #endif 00495 00496 #ifndef INC_MI32_ERRCODES_H 00497 #include <mi32/errcodes.h> 00498 #endif 00499 00500 #ifndef INC_MI32_COLORSPC_H 00501 #include <mi32/colorspc.h> 00502 #endif 00503 00504 #ifndef INC_MI32_COLRCONV_H 00505 #include <mi32/colrconv.h> 00506 #endif 00507 #ifndef INC_MI32_COLRCONV_H 00508 #include <mi32/colrconv.h> 00509 #endif 00510 00511 #ifndef INC_MI32_POLYLINE_H 00512 #include <mi32/polyline.h> 00513 #endif 00514 00515 #ifndef INC_MI32_MG2CMS_H 00516 #include <mi32/mg2cms.h> 00517 #endif 00518 00519 #ifndef INC_MI32_TEXTID_H 00520 #include <mi32/textid.h> 00521 #endif 00522 00523 #ifndef INC_MI32_MG2ENUMS_H 00524 #include <mi32/mg2enums.h> 00525 #endif 00526 00527 00528 #ifndef GENERATING_DOXYGEN_OUTPUT 00529 struct HATCHCOMPONENT; 00530 class MISTRING; 00531 class REGION2D; 00532 class SUBREGION2D; 00533 class LABELSTYLE; 00534 struct FTFACE; 00535 struct HATCHCOMPONENT; 00536 struct McbAnyCallbackStruct; 00537 class SAVEFONTFLAGS; 00538 namespace RVC { 00539 class STYLE; 00540 } 00541 namespace { 00542 class LOCALOPENFONTS; // Located in mg2text.c 00543 } 00544 #endif // GENERATING_DOXYGEN_OUTPUT 00545 00546 namespace MGD { 00547 00548 00549 //! This struct should be moved to a private include file, but we might 00550 //! yet find a use for it. 00551 struct STRINGDATA { 00552 STRINGDATA() {} 00553 ~STRINGDATA() {} 00554 00555 SIMPLE_ARRAY<UINT16> m_gid; 00556 SIMPLE_ARRAY<FTFACE*> m_face; 00557 SIMPLE_ARRAY<UINT16> m_gflags; 00558 SIMPLE_ARRAY<DPOINT2D> m_pos; 00559 MISTRING m_str; //!< May be used by overloaded _DrawGlyph() call 00560 private: 00561 #ifndef GENERATING_DOXYGEN_OUTPUT 00562 STRINGDATA(const STRINGDATA&); 00563 #endif // GENERATING_DOXYGEN_OUTPUT 00564 }; 00565 00566 00567 //! Special characters in array of Glyph IDs (GID) returned from 00568 //! FONT.UCtoGID(). When rendering or computing string width, 00569 //! These shoul be passed through to let the rendering engine handle them 00570 //! XXX These should be private to mg2textt.c and mgdtext.c 00571 #define MgdTEXTGID_ChangeFace 0xFFFF 00572 #define MgdTEXTGID_LeftToRight 0xFFFE 00573 #define MgdTEXTGID_RightToLeft 0xFFFD 00574 #define MgdTEXTGID_NextGlyph0Width 0xFFFC 00575 #define MgdTEXTGID_FallbackFace 0xFFFB 00576 #define MgdTEXTGID_SpecialCodeMin 0xFFFB //!< For quicker comparison 00577 00578 #ifndef GENERATING_DOXYGEN_OUTPUT 00579 class CONTEXT; // Forward Declarations 00580 class DEVICE_MEM1; 00581 class DEVICE_MEM1_SPARSE; 00582 class DEVICE_MEM8G; 00583 #endif // GENERATING_DOXYGEN_OUTPUT 00584 00585 //! Information about single glyph in a font. 00586 struct GLYPHINFO { 00587 double lbearing; //!< Pixels between glyph origin and left edge 00588 double rbearing; //!< Pixels between glyph origin and right edge 00589 double rspacing; //!< Pixels between glyph origin and next character 00590 double ascent; //!< Pixels between glyph origin and top 00591 double descent; //!< Pixels between glyph origin and bottom 00592 }; 00593 00594 //! Font metrics. 00595 struct FONTINFO { 00596 double ascent; //!< Ascent above baseline in pixels 00597 double descent; //!< Descent below baseline in pixels 00598 double linespace; //!< Spacing between baselines 00599 UINT16 NumGlyphs; //!< Number of glyphs in font 00600 UINT16 InitChar; //!< Initial character having glyph defined 00601 UINT16 LastChar; //!< Last character having glyph defined 00602 UINT16 NullChar; //!< Character to user for undefined glyphs 00603 }; 00604 00605 //! Font definition and implementation. 00606 class FONT { 00607 public: 00608 00609 enum MODE { 00610 MODE_UNICODE, //!< Using Unicode 00611 MODE_RAWGID, //!< Glyph IDs instead of Unicode 00612 MODE_GID //!< Glyph IDs encoded by UCtoGID member function 00613 }; 00614 00615 enum FONTTYPE { 00616 FONTTYPE_OF, 00617 FONTTYPE_TTF 00618 }; 00619 00620 //! Read a TrueType font into memory. 00621 //! 00622 //! The "name" parameter is expected to be the filename, minus the path 00623 //! or extention. 00624 //! 00625 //! The FaceNum parameter is for TrueType Collections (ttc). A ttc file 00626 //! contains multiple ttfs 00627 //! Since TrueType fonts are embeded in resource files on the Macintosh 00628 //! (even in OS X), a simple "filename" isn't all that useful. This 00629 //! function handles reading the whole thing. 00630 static ERRVALUE ReadTTF ( 00631 const UNICODE* name, 00632 SIMPLE_ARRAY<UINT8>& data 00633 ); 00634 00635 FONT(); 00636 00637 virtual ~FONT(); 00638 00639 virtual int DrawGlyph ( 00640 MGD::CONTEXT* context, 00641 double dx, 00642 double dy, 00643 double baseangle, 00644 const UNICODE* ucstr, 00645 MGD::FONT::MODE mode 00646 ) = 0; 00647 00648 virtual int DrawGlyph ( 00649 MGD::CONTEXT* context, 00650 double dx, 00651 double dy, 00652 double baseangle, 00653 const STRINGDATA& string, 00654 int n 00655 ) = 0; 00656 00657 virtual double NextPosition ( 00658 MGD::CONTEXT* context, 00659 double* retx, 00660 double* rety, 00661 double baseangle, 00662 const STRINGDATA& string, 00663 int n, 00664 double SpaceExtra = 0.0, //!< Extra pixels per space to insert 00665 double GlyphExtra = 0.0 00666 ) = 0; 00667 00668 virtual int GetFontMetrics ( 00669 MGD::CONTEXT* context, 00670 MGD::FONTINFO& fontinfo 00671 ) = 0; 00672 00673 virtual int GetGlyphMetrics ( 00674 MGD::CONTEXT* context, 00675 UNICODE ch, 00676 MGD::GLYPHINFO& glyphinfo, 00677 MGD::FONT::MODE mode 00678 ) = 0; 00679 00680 virtual int GetGlyphExtents ( 00681 MGD::CONTEXT* context, 00682 const double& dx, 00683 const double& dy, 00684 const double& baseangle, 00685 UNICODE ch, 00686 DRECT2D& extents, 00687 MGD::FONT::MODE mode 00688 ) = 0; 00689 00690 virtual bool IsEmbeddable ( 00691 ) const = 0; 00692 00693 virtual int UCtoGID ( 00694 MGD::CONTEXT* context, 00695 const UNICODE* uc, 00696 MGD::STRINGDATA& strdata 00697 ) = 0; 00698 00699 const UNICODE* GetFontName ( 00700 ) const { 00701 return (m_fontname); 00702 } 00703 00704 00705 virtual MGD::FONT::FONTTYPE GetFontType ( 00706 ) const = 0; 00707 00708 //! Get the outline of a glyph. This only works for TrueType 00709 //! fonts, but the caller won't have access to the TrueType-derived 00710 //! MGD::FONT_TTF. So we make it virtual and let it return an 00711 //! error by default. We could easily implement it for OF fonts 00712 //! too if it was ever needed. 00713 virtual ERRVALUE GetGlyphOutline ( 00714 UINT16 GlyphIndex, 00715 INT32 *NumContours, 00716 LPOLYGON **Def, 00717 UINT32 FontFlags 00718 ) { 00719 return (EProgramError); 00720 } 00721 00722 UNICODE GetInitChar ( 00723 ) const { 00724 return (m_InitChar); 00725 } 00726 00727 UNICODE GetLastChar ( 00728 ) const { 00729 return (m_LastChar); 00730 } 00731 00732 UNICODE GetNULLChar ( 00733 ) const { 00734 return (m_NullChar); 00735 } 00736 00737 UNICODE GetNumGlyphs ( 00738 ) const { 00739 return (m_NumGlyphs); 00740 } 00741 00742 protected: 00743 UNICODE m_fontname[32]; 00744 UNICODE m_filename[FILENAME_MAX]; 00745 UINT16 m_NumGlyphs; //!< Number of glyphs in font 00746 UNICODE m_InitChar; //!< Initial character having glyph defined 00747 UNICODE m_LastChar; //!< Last character having glyph defined 00748 UNICODE m_NullChar; //!< Character to user for undefined glyphs 00749 }; 00750 00751 00752 struct TEXTSETTINGS : public TEXTSTYLE { //! Text drawing parameters 00753 PIXEL ForegroundPixel; 00754 PIXEL BackgroundPixel; 00755 PIXEL UnderlinePixel; 00756 00757 TEXTSETTINGS ( 00758 ) { 00759 Reset(); 00760 } 00761 00762 double GetBoldness ( 00763 ) const { 00764 return (BoldnessWidth); 00765 } 00766 00767 void Reset ( 00768 ); 00769 00770 }; 00771 00772 00773 //! Text block border settings. 00774 struct TEXTBLOCKBORDER { 00775 UINT16 Type; //!< Border type 00776 UINT16 WidthUnits; //!< Units for line width (SCREENUNIT_...) 00777 float Width; //!< Line or border width 00778 COLOR Color; //!< Line color 00779 00780 TEXTBLOCKBORDER() { 00781 memset(this, 0, sizeof(TEXTBLOCKBORDER)); 00782 } 00783 }; 00784 00785 //! Text block. 00786 struct TEXTBLOCK { 00787 const UNICODE *Text; //!< Encoded text string. Note, TEXTBLOCK does not actually own the text and will not free it. 00788 TEXTSTYLE Style; //!< Initial style 00789 DPOINT2D basepoint; //!< Base point in display coordinates 00790 double baseangle; //!< Rotation angle in radians 00791 TEXTBASEORIGIN baseorigin; //!< Origin of basepoint within block 00792 COLOR Background; //!< Background color 00793 COLOR ShadowTop; //!< "Top shadow" color, usually brighter than background 00794 COLOR ShadowBottom; //!< "Bottom shadow" color, usually darker than background 00795 TEXTBLOCKBORDER Frame; 00796 TEXTBLOCKBORDER LeftBorder; 00797 TEXTBLOCKBORDER RightBorder; 00798 TEXTBLOCKBORDER TopBorder; 00799 TEXTBLOCKBORDER BottomBorder; 00800 bool IsAntialiased; //!< set when SetUp is called 00801 bool UsesTransparency; //!< set when SetUp is called 00802 float MarginH; 00803 float MarginV; 00804 UINT16 MarginUnits; 00805 00806 //! Get the first line of the text block 00807 ERRVALUE GetFirstString ( 00808 MISTRING& string //!< String returned 00809 ); 00810 00811 TEXTBLOCK(); 00812 00813 ~TEXTBLOCK(); 00814 }; 00815 00816 00817 00818 //! \class DEVICE 00819 //! \brief Base class for all MGD::DEVICE derived classes 00820 //! 00821 //! @note The default constructor is protected, so you can't declare 00822 //! an MGD::DEVICE by itself. You must use one of the derived classes. 00823 class DEVICE { 00824 00825 public: 00826 00827 // Default constructor is protected. 00828 00829 //! Destructor 00830 virtual ~DEVICE ( 00831 ); 00832 00833 // (Note: copy constructor private and unimplemented. Can't copy one.) 00834 00835 00836 //! Returns true if the derived class is based on an implementation 00837 //! where fill spans are considered "bad". This is used by the 00838 //! implementation of text drawing functions to know if they should 00839 //! be drawn as fillspans of call FillPolygons 00840 bool AvoidFillSpans ( 00841 ) const { 00842 return (v_AvoidFillSpans()); 00843 } 00844 00845 //! Set the colormap for the display. Derived class should override this 00846 //! if it cares about colormaps. If not, the default version just ignores 00847 //! the caller. 00848 //! 00849 //! XXX Old version took a COLORMAPINFO which was passed to 00850 //! CompOptmFromColMap(). Has RedBits, GreenBits, BlueBits. 00851 //! What are these? 00852 ERRVALUE ChangeColorMap ( 00853 const SIMPLE_ARRAY<COLOR>& colors 00854 ) { 00855 return (v_ChangeColorMap(colors)); 00856 } 00857 00858 ERRVALUE Clear ( 00859 const COLOR& color 00860 ) { 00861 return (v_Clear(color)); 00862 } 00863 00864 //! Clear the ICM Profile of the destination device. 00865 void ClearICMDestProfile ( 00866 ) { 00867 m_DestProfile.Free(); 00868 } 00869 00870 //! Clear the ICM Profile of the proofing device 00871 void ClearICMProofProfile ( 00872 ); 00873 00874 //! Create a GC for drawing. 00875 //! 00876 //! Derived classes may override this and make it return anything 00877 //! derived from MGD::CONTEXT. MGD::CONTEXT's constructor is private, so 00878 //! this is the only way for calling code to create a GC. 00879 //! 00880 MGD::CONTEXT* CreateContext ( 00881 ); 00882 00883 //! If the display is going to support 3D, then it should allocate its depth 00884 //! buffer here. If overriding this, also be sure to override 00885 //! Is3DInitialized() so that it will return true if DepthInit3D() has been 00886 //! called and override CanDo3D() to return true. 00887 //! 00888 //! This implementation allocates an in-memory buffer if the device 00889 //! size is <= 1024 x 1024. If it's bigger, it allocates a temporary 00890 //! raster to hold the data. 00891 //! 00892 //! 3D implementation code can call GetDepthBuffer() to get the depth 00893 //! buffer for a given span of data. 00894 ERRVALUE DepthInit3D ( 00895 ) { 00896 return (v_DepthInit3D()); 00897 } 00898 00899 //! Destroy a GC. 00900 //! 00901 //! Not strictly necessary, but it balances the CreateGC() method nicely. 00902 //! You can just "delete" an MGD::CONTEXT. 00903 // Would inline this, but the compiler complains that MGD::CONTEXT is incomplete 00904 // and won't let me "delete" one here. 00905 void DestroyContext ( 00906 MGD::CONTEXT* gc 00907 ); 00908 00909 //! Return true if DepthInit3D() has been called. 00910 //! Derived class should override this to return true if DepthInit3D has 00911 //! been called. 00912 bool Is3DInitialized ( 00913 ) const { 00914 return (m_zbuf != 0); 00915 } 00916 00917 //! Return true if the display is for an X drawable 00918 bool IsX11 ( 00919 ) const { 00920 return (v_IsX11()); 00921 } 00922 00923 //! Get the ColorMap for the device. Will return NULL 00924 //! if the device doesn't use one. 00925 const SIMPLE_ARRAY<COLOR>* GetColorMap ( 00926 ) const { 00927 return (&m_ColorMap); 00928 } 00929 00930 //! Get the ColorMapInfo structure for this device 00931 //! Will return NULL if the device doesn't have one. 00932 //! Will be depricated. Use GetColorMap() instead 00933 const COLMAPINFO* GetColorMapInfo ( 00934 ) { 00935 memset(&m_ColorMapInfo, 0, sizeof(COLMAPINFO)); 00936 m_ColorMapInfo.colmap = const_cast<COLOR*>((const COLOR*)GetColorMap()); 00937 m_ColorMapInfo.NumColors = GetColorMap()->GetNumItems(); 00938 //! The rest of the structure is never used any more 00939 return (&m_ColorMapInfo); 00940 } 00941 00942 //! Given a color, return the Pixel value that matches (or is as close 00943 //! possible) 00944 //! Does NOT take ICM into account. The one in context does. 00945 00946 #if !defined(NO_DEPRECATED) 00947 //! Deprecated because you should call the one in the context 00948 //! \deprecated Call the version in the context 00949 PIXEL GetColorPixel ( 00950 const COLOR& color 00951 ) { 00952 return (v_GetColorPixel(color)); 00953 } 00954 #endif 00955 00956 //! Return the "native" COLORSPACE used by the display 00957 //! Image operations using this colorspace will be more effeciant. 00958 //! Default implementation determines the colorspace from the 00959 //! DeviceInfo 00960 COLORSPACE GetColorSpace ( 00961 ) const { 00962 return (v_GetColorSpace()); 00963 } 00964 00965 //! return the depth at a given pixel location. 00966 //! This is GC-indapendant. 00967 float GetDepth3D ( 00968 INT32 x, 00969 INT32 y 00970 ) { 00971 return (v_GetDepth3D(x, y)); 00972 } 00973 00974 const DISPLAYINFO& GetDeviceInfo ( 00975 ) const { 00976 return m_devinfo; 00977 } 00978 00979 const LRECT2D& GetExtents ( 00980 ) const { 00981 return m_Extents; 00982 } 00983 00984 INT32 GetHeight ( 00985 ) const { 00986 return (GetExtents().GetHeight()); 00987 } 00988 00989 00990 int GetImageBytesPerPixel ( 00991 ) const { 00992 return m_ImageBytesPerPixel; 00993 } 00994 00995 //! Return a pointer to a piece of the image buffer. 00996 //! This only has to be implemented if HasCapability(CAPABILITY_GetImage) 00997 //! returns true. The CopyRect() routines use it to read the source image. 00998 //! Note that this may return a pointer directly into the screen buffer 00999 //! or a temporary buffer into which it has read the requested data. It's 01000 //! up to the implementation to decide how to handle this. 01001 UINT8* GetImagePointer ( 01002 INT32 x, 01003 INT32 y, 01004 INT32 len 01005 ) { 01006 return (v_GetImagePointer(x, y, len)); 01007 } 01008 01009 //! Return the number of bytes needed to hold one line of image data 01010 //! Should be overridden by derived class unless images are not possible 01011 //! (such as a pen plotter) 01012 INT32 GetLineBytes ( 01013 ) const { 01014 return (v_GetLineBytes()); 01015 } 01016 01017 //! Determine if full image lines are needed (no tiled output). 01018 bool GetNeedFullImageLine ( 01019 ) const { 01020 return (v_GetNeedFullImageLine()); 01021 } 01022 01023 //! Get the OPTMPARM structure for the device. Will return NULL 01024 //! if the device doesn't use one. 01025 const OPTMPARM* GetOptmParm ( 01026 ) const { 01027 return (&m_optmparm); 01028 } 01029 01030 #if !defined(NO_DEPRECATED) 01031 //! Given a pixel value, return the color it represents 01032 //! \deprecated Call the one in the context instead 01033 void GetPixelColor ( 01034 PIXEL pixel, 01035 COLOR& color 01036 ) const { 01037 v_GetPixelColor(pixel, color); 01038 } 01039 #endif 01040 01041 //! Return the pixel size in millimeters, assuming square pixels. 01042 //! This method will cope with "this" being NULL by returning the 01043 //! pixel size of a NULL device 01044 double GetPixelSizeMM ( 01045 ) const; 01046 01047 //! Return the pixel size in millimeters without assuming squareness 01048 //! This method will cope with "this" being NULL by returning the 01049 //! pixel size of a NULL device 01050 void GetPixelSizeMM ( 01051 double& xsize, 01052 double& ysize 01053 ) const; 01054 01055 //! Return the pixel size in DPI, assuming square pixels. 01056 double GetPixelSizeDPI ( 01057 ) const { 01058 return ((1000.0 / METERSTOINCHES) / GetPixelSizeMM()); 01059 } 01060 01061 //! Return the pixel size in DPI without assuming squareness 01062 void GetPixelSizeDPI ( 01063 double& xsize, 01064 double& ysize 01065 ) const { 01066 double x, y; 01067 GetPixelSizeMM(x, y); 01068 xsize = (1000.0 / METERSTOINCHES) / x; 01069 ysize = (1000.0 / METERSTOINCHES) / y; 01070 } 01071 01072 INT32 GetWidth ( 01073 ) const { 01074 return (GetExtents().GetWidth()); 01075 } 01076 01077 bool HasCapability ( 01078 MGD::CAPABILITY capability 01079 ) { 01080 return ((v_GetCapabilities() & capability) != 0); 01081 } 01082 01083 //! Scan the image for color usage. 01084 //! (may not need for all implementations?) 01085 ERRVALUE ScanColorUse ( 01086 HISTORGB& historgb 01087 ) { 01088 return (v_ScanColorUse(historgb)); 01089 } 01090 01091 const PROFILE& GetICMDestProfile ( 01092 ) const { 01093 return (m_DestProfile); 01094 } 01095 01096 PROFILE::INTENT GetICMIntent ( 01097 ) const { 01098 return m_ICMIntent; 01099 } 01100 01101 //! Set the ICM Profile of the destination device. 01102 void SetICMDestProfile ( 01103 const PROFILE& profile, 01104 PROFILE::INTENT intent = PROFILE::INTENT_Perceptual 01105 ); 01106 01107 //! Set the ICM Profile of the destination device. 01108 void SetICMDestProfile ( 01109 const PROFILEPARMS_PRINTER& profile 01110 ); 01111 01112 //! Set the ICM Profile of the destination device to the currently 01113 //! selected Screen profile (Selected in the TNTmips preferences) 01114 void SetICMDestProfileScreen ( 01115 ); 01116 01117 //! Set the ICM Profile of the proofing device 01118 //! If set, will cause images and colors to be mapped to the gamut of 01119 //! the proofing device (printer) before being mapped to the gamut of 01120 //! the Dest device. This way, the Dest device (screen) won't show any 01121 //! colors which the Proofing device (printer) is incapable of rendering. 01122 void SetICMProofProfile ( 01123 const PROFILEPARMS_PRINTER& profile 01124 ); 01125 01126 //! Set the pixel size in millimeters without assuming squareness 01127 void SetPixelSizeMM ( 01128 double xsize, 01129 double ysize 01130 ) { 01131 m_mmPerPixel.x = xsize; 01132 m_mmPerPixel.y = ysize; 01133 return; 01134 } 01135 01136 protected: 01137 01138 #ifndef GENERATING_DOXYGEN_OUTPUT 01139 LRECT2D m_Extents; //!< All implementations need this 01140 OPTMPARM m_optmparm; //!< move to derived class? GetColorPixel uses it 01141 PIXEL m_AllPlanesMask; 01142 int m_ImageBytesPerPixel; 01143 DPOINT2D m_mmPerPixel; 01144 SIMPLE_ARRAY<COLOR> m_ColorMap; 01145 COLMAPINFO m_ColorMapInfo; //!< Only for old code 01146 LPOINT2D m_TileSize; //!< Raster tile size hint (0's if tiles not helpful) 01147 LPOINT2D m_offset; // Only ever changed by DEVICE_RASTER, but we need 01148 LPOINT2D m_RealSize; // to account for them in low-level fillspan 01149 bool m_bHasVirtualWindow; 01150 #endif 01151 01152 01153 //! Constructor. 01154 //! 01155 //! Because we could get an error while allocating an MGD::DEVICE, 01156 //! and we don't deal with exception handling code, 01157 //! the constructor should only initialize the class members. 01158 //! Each derived class should have an Initialize() method to 01159 //! actually allocate memory. This would be a pure-virtual 01160 //! function, but the parameters necessary are likely to be 01161 //! implementation dependant. For example, the raster implementation 01162 //! would need to take an RVC::RASTER object or something. 01163 //! An X implementation would require a Drawable, etc... 01164 //! 01165 DEVICE(); 01166 01167 virtual ERRVALUE v_CopyColorMap ( 01168 SIMPLE_ARRAY<COLOR> colors 01169 ) { 01170 return (0); 01171 } 01172 01173 //! Fill a horizontal span. 01174 //! 01175 //! Many of the default method implementations call this to do all the work. 01176 //! Not all of them even need it., so not pure-virtual. 01177 //! Derived classes that implement this do not need to worry about 01178 //! clipping, as the default implementation in CONTEXT does 01179 //! clipping and then calls this version. 01180 //! 01181 //! If your implementation handles bitmap pattern fills in a way that's 01182 //! optimized for your dest device, you should return CAPABALITY_BitmapFill 01183 //! in GetCapabilities 01184 virtual ERRVALUE v_FillSpan ( 01185 MGD::CONTEXT* gc, 01186 INT32 x1, 01187 INT32 x2, 01188 INT32 y 01189 ) { 01190 return (0); 01191 } 01192 01193 // For internal use only. Calls v_FillSpan 01194 ERRVALUE FillSpanWithDepthTest ( 01195 MGD::CONTEXT* gc, 01196 INT32 x1, 01197 INT32 x2, 01198 INT32 y 01199 ); 01200 01201 PIXEL GetAllPlanesMask ( 01202 ) const { 01203 return (m_AllPlanesMask); 01204 } 01205 01206 //! Return a list of the capabilities of this device. 01207 //! Don't forget to OR in the capabilities of the base class in the derived class 01208 virtual CAPABILITY v_GetCapabilities ( 01209 ) const { 01210 return CAPABILITY_3D; 01211 } 01212 01213 //! Get a pointer to the depth buffer for a given location. 01214 //! Since this is protected, it's assumed that you've already 01215 //! validated the coordinates. If the depth buffer is all in memory, 01216 //! this returns a pointer into that buffer. If it's being spooled 01217 //! to a temporary file, it reads the requested part into a buffer 01218 //! and returns that buffer. In the temporary raster case, each call 01219 //! to GetDepthBuffer() reuses the same buffer. After modifying the 01220 //! depth buffer, you should call WriteDepthBuffer(). WriteDepthBuffer() 01221 //! does nothing unless the depth buffer is from a temporary raster, in 01222 //! which case it writes it back out. 01223 //! This function will return NULL if the depth buffer is not initialized 01224 //! or if reading from the temporary raster would cause an error. 01225 float* GetDepthBuffer ( 01226 INT32 x, 01227 INT32 y, 01228 INT32 len 01229 ); 01230 01231 01232 //! Same as GetImagePointer() but returns a const pointer. 01233 const UINT8* GetImagePointerConst ( 01234 INT32 x, 01235 INT32 y, 01236 INT32 len 01237 ) { 01238 return (v_GetImagePointer(x, y, len)); 01239 } 01240 01241 //! If GetImagePointer returns a pointer directly into the frame buffer, 01242 //! this function does not need to be overridden. 01243 //! If GetImagePointer has to actually read something (say via an X 01244 //! call to the display or reading out of a raster, then this version 01245 //! should just return a temporary buffer big enough to hold a single 01246 //! line. 01247 UINT8* GetImagePointerNoRead ( 01248 INT32 x, 01249 INT32 y, 01250 INT32 len 01251 ) { 01252 return (v_GetImagePointerNoRead(x, y, len)); 01253 } 01254 01255 //! Sets the bits, shift, and mask parameters of the DEVICEINFO 01256 //! Currently only handles 16 and 24 bit RGB and BGR cases 01257 void SetDeviceColorSpace ( 01258 COLORSPACE colorspace 01259 ); 01260 01261 //! To be called by Create() method to set stuff up. 01262 ERRVALUE SetDeviceInfo ( 01263 const DISPLAYINFO& dispinfo 01264 ); 01265 01266 //! Update the Depth Buffer. 01267 //! Does nothing unless the Depth Buffer is initialized and 01268 //! is using a raster for depth buffering. 01269 ERRVALUE WriteDepthBuffer ( 01270 INT32 x, 01271 INT32 y, 01272 INT32 len, 01273 const float* zbuf 01274 ); 01275 01276 //! Write an image buffer to the display 01277 //! If GetImagePointer reutrns a pointer directly into the frame buffer, 01278 //! this method can just return 0. If GetImagePointer has to actually 01279 //! read something, this method is used to write the result back out. 01280 //! Typically used when drawing to a raster 01281 ERRVALUE WriteImageBuffer ( 01282 INT32 x, 01283 INT32 y, 01284 INT32 len, 01285 UINT8* buf 01286 ) { 01287 return (v_WriteImageBuffer(x, y, len, buf)); 01288 } 01289 01290 01291 private: 01292 #ifndef GENERATING_DOXYGEN_OUTPUT 01293 //! Copy constructor private and unimplemented 01294 DEVICE(const DEVICE&); 01295 01296 01297 friend class CONTEXT; //!< Is allowed access to FillSpan() 01298 01299 01300 float* m_zbuf; 01301 int m_zrhandle; //!< Handle for Z buffer if it's a raster 01302 int m_zfhandle; //!< Handle for Z buffer if it's a raster 01303 DISPLAYINFO m_devinfo; //!< MUST call Set method to modify 01304 01305 PROFILE m_DestProfile; 01306 PROFILE::INTENT m_ICMIntent; 01307 PROFILEPARMS_PRINTER m_ProofProfileParms; 01308 01309 static void MCB_ScreenProfileChanged ( 01310 McbAnyCallbackStruct*, 01311 void* 01312 ); 01313 #endif // GENERATING_DOXYGEN_OUTPUT 01314 01315 virtual ERRVALUE v_Clear ( 01316 const COLOR& color 01317 ); 01318 01319 //! Given a color, return the Pixel value that matches (or is as close 01320 //! possible). This should NOT take ICM into account. The context will 01321 //! have already translated the color through the ICM transform (if any) 01322 //! before calling this function. 01323 //! This method is not const because some derived classes may update a 01324 //! color map or something in the process. 01325 virtual PIXEL v_GetColorPixel ( 01326 const COLOR& color 01327 ); 01328 01329 //! Return a pointer to a piece of the image buffer. 01330 //! This only has to be implemented if HasCapability(CAPABILITY_GetImage) 01331 //! returns true. The CopyRect() routines use it to read the source image. 01332 //! Note that this may return a pointer directly into the screen buffer 01333 //! or a temporary buffer into which it has read the requested data. It's 01334 //! up to the implementation to decide how to handle this. 01335 virtual UINT8* v_GetImagePointer ( 01336 INT32 x, 01337 INT32 y, 01338 INT32 len 01339 ) { 01340 return (0); 01341 } 01342 01343 //! If GetImagePointer returns a pointer directly into the frame buffer. 01344 //! this function does not need to be overridden. 01345 //! If GetImagePointer has to actually read something (say via an X 01346 //! call to the display or reading out of a raster, then this version 01347 //! should just return a temporary buffer big enough to hold a single 01348 //! line. 01349 virtual UINT8* v_GetImagePointerNoRead ( 01350 INT32 x, 01351 INT32 y, 01352 INT32 len 01353 ) { 01354 return (v_GetImagePointer(x, y, len)); 01355 } 01356 01357 //! Given a pixel value, return the color it represents. 01358 //! This should NOT take ICM into account. The context will translate 01359 //! the color back through the inverse ICM transform (if any) 01360 virtual void v_GetPixelColor ( 01361 PIXEL pixel, 01362 COLOR& color 01363 ) const; 01364 01365 //! Return true if the display is for an X drawable. 01366 virtual bool v_IsX11 ( 01367 ) const { 01368 return (false); 01369 } 01370 01371 //! Returns true if the derived class is based on an implementation 01372 //! where fill spans are considered "bad". This is used by the 01373 //! implementation of text drawing functions to know if they should 01374 //! be drawn as fillspans of call FillPolygons 01375 virtual bool v_AvoidFillSpans ( 01376 ) const { 01377 return (false); 01378 } 01379 01380 //! Determine if the device wants low-level drawing code to anti-alias 01381 //! using transparency. 01382 //! 01383 //! Binary devices should override this to return false. 01384 //! @return true if you want anti-aliased drawing, false if not. Default implementation returns true. 01385 virtual bool v_UseAntiAliasing ( 01386 ) const { 01387 return (true); 01388 } 01389 01390 //! Write an image buffer to the display. 01391 //! If GetImagePointer reutrns a pointer directly into the frame buffer, 01392 //! this method can just return 0. If GetImagePointer has to actually 01393 //! read something, this method is used to write the result back out. 01394 //! Typically used when drawing to a raster 01395 virtual ERRVALUE v_WriteImageBuffer ( 01396 INT32 x, 01397 INT32 y, 01398 INT32 len, 01399 UINT8* buf 01400 ) { 01401 return 0; 01402 } 01403 01404 //! Set the colormap for the display. Derived class should override this 01405 //! if it cares about colormaps. If not, the default version just ignores 01406 //! the caller. 01407 //! 01408 //! XXX Old version took a COLORMAPINFO which was passed to 01409 //! CompOptmFromColMap(). Has RedBits, GreenBits, BlueBits. 01410 //! What are these? 01411 virtual ERRVALUE v_ChangeColorMap ( 01412 const SIMPLE_ARRAY<COLOR>& colors 01413 ); 01414 01415 //! Create a GC for drawing. 01416 //! 01417 //! Derived classes may override this and make it return anything 01418 //! derived from MGD::CONTEXT. MGD::CONTEXT's constructor is private, so 01419 //! this is the only way for calling code to create a GC. 01420 //! 01421 virtual MGD::CONTEXT* v_CreateContext ( 01422 ); 01423 01424 //! If the display is going to support 3D, then it should allocate its depth 01425 //! buffer here. If overriding this, also be sure to override 01426 //! Is3DInitialized() so that it will return true if DepthInit3D() has been 01427 //! called and override CanDo3D() to return true. 01428 //! 01429 //! This implementation allocates an in-memory buffer if the device 01430 //! size is <= 1024 x 1024. If it's bigger, it allocates a temporary 01431 //! raster to hold the data. 01432 //! 01433 //! 3D implementation code can call GetDepthBuffer() to get the depth 01434 //! buffer for a given span of data. 01435 virtual ERRVALUE v_DepthInit3D ( 01436 ); 01437 01438 //! Return the "native" COLORSPACE used by the display. 01439 //! Image operations using this colorspace will be more effeciant. 01440 //! Default implementation determines the colorspace from the 01441 //! DeviceInfo 01442 virtual COLORSPACE v_GetColorSpace ( 01443 ) const; 01444 01445 //! return the depth at a given pixel location. 01446 //! This is GC-indapendant. 01447 virtual float v_GetDepth3D ( 01448 INT32 x, 01449 INT32 y 01450 ); 01451 01452 //! Return the number of bytes needed to hold one line of image data. 01453 //! Should be overridden by derived class unless images are not possible 01454 //! (such as a pen plotter) 01455 virtual INT32 v_GetLineBytes ( 01456 ) const { 01457 return (0); 01458 } 01459 01460 //! Determine if full image lines are needed (no tiled output). 01461 virtual bool v_GetNeedFullImageLine ( 01462 ) const { 01463 return (false); 01464 } 01465 01466 //! Scan the image for color usage. 01467 //! (may not need for all implementations?) 01468 virtual ERRVALUE v_ScanColorUse ( 01469 HISTORGB& historgb 01470 ) { 01471 return (0); 01472 } 01473 01474 }; 01475 01476 01477 // NOTE: Need methods on GC to get/set styles and other stuff that we used to store in the display 01478 // but was set by macros and inline functions. 01479 01480 //! \class CONTEXT 01481 //! \brief Base class for all your drawing needs. 01482 class CONTEXT { 01483 public: 01484 // Note, default Constructor is protected 01485 01486 //! Base class for private data. 01487 //! Basically just a class with a pure virtual destructor so that we 01488 //! can delete one without knowing what it is. Used for Get/SetPrivData 01489 class PRIVDATA { 01490 public: 01491 PRIVDATA() {} 01492 virtual ~PRIVDATA() {} 01493 }; 01494 01495 virtual ~CONTEXT(); 01496 01497 //! Allocate a private data index. 01498 //! This is uses as an argument to GetPrivData and SetPrivData 01499 static int AllocPrivDataIndex ( 01500 ); 01501 01502 //! Add to the clip mask drawing exclusion area using a rectangle. 01503 //! Areas OUTSIDE the rectangle will be clipped (i.e., they won't draw) 01504 //! The default method twiddles bits in a clip device which is used 01505 //! as a bitmask through which all FillSpans operate. 01506 //! ( Currently only used in autolabl.c, and only) 01507 //! Should be replaced by IntersectClipRegion() 01508 ERRVALUE AddExteriorToClip ( 01509 const LRECT2D& rect 01510 ); 01511 01512 //! Add to the clip mask drawing exclusion area using a DRECT2D. 01513 //! Areas added will NOT draw (i.e. they WILL be clipped). 01514 //! The default method clears bits in a clip device which is used 01515 //! as a bitmask through which all FillSpans operate. 01516 ERRVALUE AddToClip ( 01517 const DRECT2D& rect 01518 ); 01519 01520 //! Add to the clip mask drawing exclusion area using an LRECT2D. 01521 //! Areas added will NOT draw (i.e. they WILL be clipped). 01522 //! The default method clears bits in a clip device which is used 01523 //! as a bitmask through which all FillSpans operate. 01524 ERRVALUE AddToClip ( 01525 const LRECT2D& rect 01526 ); 01527 01528 //! Add to the clip mask drawing exclusion area using a POLYLINE. 01529 //! Areas added will NOT draw (i.e. they WILL be clipped). 01530 //! The default method clears bits in a clip device which is used 01531 //! as a bitmask through which all FillSpans operate. 01532 ERRVALUE AddToClip ( 01533 const POLYLINE& polyline 01534 ); 01535 01536 //! Add to the clip mask drawing exclusion area using a REGION2D. 01537 //! Areas added will NOT draw (i.e. they WILL be clipped). 01538 //! The default method clears bits in a clip device which is used 01539 //! as a bitmask through which all FillSpans operate. 01540 ERRVALUE AddToClip ( 01541 const REGION2D& region 01542 ); 01543 01544 //! Intersects the current clip region with a DRECT2D. 01545 //! The resulting region is made the new clip region. 01546 //! Only areas inside the clip region will be drawn. 01547 ERRVALUE IntersectClip ( 01548 const DRECT2D& rect 01549 ); 01550 01551 //! Intersects the current clip region with an LRECT2D. 01552 //! The resulting region is made the new clip region.