elemstyl.h

Go to the documentation of this file.
00001 /**
00002  * \file mi32/elemstyl.h
00003  * \brief Definitions for element drawing styles
00004  *
00005  * \if NODOC
00006  * $Id: elemstyl.h_v 1.67 2005/10/25 20:33:27 scowan Exp $
00007  *
00008  * $Log: elemstyl.h_v $
00009  * Revision 1.67  2005/10/25 20:33:27  scowan
00010  * Added inline dtor for text style because vc++ could not create one.
00011  *
00012  * Revision 1.66  2005/03/31 16:57:10  fileserver!dwilliss
00013  * Rename one of our types to MIUNICODE because it conflicted with a Microsoft #define
00014  *
00015  * Revision 1.65  2005/02/14 21:39:10  mju
00016  * Change usesTransparency to use device instead of context.
00017  *
00018  * Revision 1.64  2004/11/17 15:25:37  dwilliss
00019  * Changed ParseTildeCodes' return value to return true if any code was
00020  * recgonized rather than if any was unrecgonized.  Nothing was using the
00021  * return value yet anyway.
00022  *
00023  * Revision 1.63  2004/10/14 16:58:03  dwilliss
00024  * Added a UsesAntialiasing to text style
00025  *
00026  * Revision 1.62  2004/09/03 16:02:27  scowan
00027  * Removed text font name typedef.
00028  *
00029  * Revision 1.61  2004/04/08 14:57:22  scowan
00030  * Prevent mem cmp on text style.
00031  *
00032  * Revision 1.60  2004/04/05 20:13:26  scowan
00033  * Do not allow memset on multi style struct.
00034  *
00035  * Revision 1.59  2004/04/01 00:03:43  dwilliss
00036  * TEXTSTYLE fontname is now an MISTRING
00037  *
00038  * Revision 1.58  2004/03/30 22:32:23  dwilliss
00039  * Text style now completely memcpy/memset/memcmp free.  We can change
00040  * :w
00041  *
00042  * Revision 1.57  2004/03/17 21:21:33  scowan
00043  * Added a font style flag for CRS inversion for label extents.
00044  *
00045  * Revision 1.56  2003/10/03 17:37:09  dwilliss
00046  * *** empty log message ***
00047  *
00048  * Revision 1.55  2003/10/01 22:15:52  dwilliss
00049  * doxygen
00050  *
00051  * Revision 1.54  2003/10/01 20:46:18  dwilliss
00052  * nc
00053  *
00054  * Revision 1.53  2003/09/22 19:23:44  dwilliss
00055  * Changed dft ctor of TEXTSTYLEDIFF to have nothing set insetad of everyting
00056  *
00057  * Revision 1.52  2003/09/22 16:13:07  dwilliss
00058  * Added a method to TEXTSTYLEDIFF to parse {~} codes.  It has the ability to
00059  * return unknown codes in an optional parameter
00060  *
00061  * Revision 1.51  2003/09/15 13:49:56  fileserver!dwilliss
00062  * Doxygen
00063  *
00064  * Revision 1.50  2003/09/12 19:25:11  scowan
00065  * Fixed line style assignment from poly style with str dup from null value.
00066  *
00067  * Revision 1.49  2003/09/08 20:33:55  dwilliss
00068  * Added doxygen tags for start/end of function groups
00069  *
00070  * Revision 1.48  2003/08/12 14:50:57  mju
00071  * In textstyle ctor default to scale to design.
00072  *
00073  * Revision 1.47  2003/06/30 16:46:27  mju
00074  * Fix UMR/FIM in pointstyle::copy when called by copy ctor (init Desc).
00075  * Do similar init and fix leaks in line/polystyle.
00076  *
00077  * Revision 1.46  2003/06/25 20:43:54  dwilliss
00078  * Fixed memory leak in POINTSTYLE::Copy()
00079  *
00080  * Revision 1.45  2003/06/18 22:55:37  dwilliss
00081  * *** empty log message ***
00082  *
00083  * Revision 1.44  2003/06/18 22:47:17  dwilliss
00084  * Never mind.  Was going to add a LABELSTYLE, but decided to create a new
00085  * lablstyl.h to avoid include file dependancy problem
00086  *
00087  * Revision 1.43  2003/06/04 22:46:13  scowan
00088  * Reordered code and added a poly style to line style operator.
00089  *
00090  * Revision 1.42  2003/03/13 18:15:29  mju
00091  * Add BuiltIn_Point_Last.
00092  *
00093  * Revision 1.41  2003/02/07 14:34:26  mju
00094  * Fix Mac warning.
00095  *
00096  * Revision 1.40  2003/01/21 14:58:44  mju
00097  * Add STYLEFLAG_ScaleIsPatternZoom.
00098  *
00099  * Revision 1.38  2002/10/17 21:22:02  dwilliss
00100  * TEXTSYTYLEDIFF: more methods and operators
00101  *
00102  * Revision 1.37  2002/10/11 22:39:58  dwilliss
00103  * Created TEXTSTYLEDIFF and keep that stuff out of the main TEXTSTYLE
00104  *
00105  * Revision 1.35  2002/10/11 21:47:32  dwilliss
00106  * Added some operators to TEXTSTYLE.
00107  *
00108  * Revision 1.33  2002/10/09 22:33:03  dwilliss
00109  * Gave POLYSTYLE an Angle member for rotation hatch patterns.  There was a
00110  *
00111  * Revision 1.32  2002/09/09 13:28:13  mju
00112  * Remove deprecated typedef.
00113  *
00114  * Revision 1.31  2002/08/28 13:04:41  mju
00115  * Don't put ';' after prevent_memfunc as causes annoying warning on Mac.
00116  *
00117  * Revision 1.30  2002/08/21 20:39:10  scowan
00118  * Deprecate old object name define.
00119  *
00120  * Revision 1.28  2002/06/10 19:15:45  dwilliss
00121  * Don't use MmFree here
00122  *
00123  * Revision 1.27  2002/06/10 17:50:30  dwilliss
00124  * Added Clear methods()
00125  *
00126  * Revision 1.24  2002/05/13 22:59:02  dwilliss
00127  * UsesTransparency now takes an optional MGD::CONTEXT.
00128  * Because this file is included before mgd2 (so CONTEXT can have members
00129  * of the structures we define), I had to move the implementation of
00130  * UsesTransparency.
00131  *
00132  * Revision 1.23  2002/04/22 17:00:02  dwilliss
00133  * Added a UsesTransparency() method to text.  Could add to others too but it
00134  * couldn't account for colors used by patterns/symbols since the STYLE
00135  * doesn't know what they are without reading them.
00136  *
00137  * Revision 1.22  2002/03/19 22:56:24  dwilliss
00138  * Changed default Enhanced width to 15% to be closer to old behaviour
00139  *
00140  * Revision 1.20  2002/03/08 18:13:39  dwilliss
00141  * Missed the UnderlineWidth setting
00142  *
00143  * Revision 1.19  2002/03/08 17:08:13  dwilliss
00144  * Fixed the memcpy overload to cope with amemcpy
00145  *
00146  * Revision 1.18  2002/03/08 16:53:13  dwilliss
00147  * Moved WidthUnits to keep from mis-aligning the struct
00148  *
00149  * Revision 1.17  2002/03/08 16:19:56  dwilliss
00150  * TEXTSTYLE now has copy ctor and assignment operators that cope with
00151  * mismatched sizes
00152  *
00153  * Revision 1.15  2002/03/07 23:47:02  dwilliss
00154  * Added a bunch of members to TEXTSTYLE
00155  *
00156  * Revision 1.14  2000/07/26 15:17:56  mju
00157  * Add equality/inequality operators.
00158  *
00159  * Revision 1.11  2000/05/25 14:31:24  mju
00160  * Include compat.h so works on Sun.
00161  *
00162  * Revision 1.10  2000/05/22 14:23:40  mju
00163  * Include std C headers needed so compiles in isolation.
00164  *
00165  * Revision 1.9  2000/05/10 16:37:30  mju
00166  * Deprecate TEXTSTYLEEXT typedef.
00167  *
00168  * Revision 1.7  1999/12/13 21:12:31  mju
00169  * Implement ctor, copy ctor, dtor, op= for ...STYLE structs.
00170  *
00171  * Revision 1.5  1999/05/13 14:34:41  dwilliss
00172  * Define STYLEFLAGMASK for text justification.
00173  *
00174  * Revision 1.3  1999/04/30  21:14:49  dwilliss
00175  * Added TEXTSTYLE flag for kerning
00176  *
00177  * Revision 1.1  1999/04/12  15:16:01  mju
00178  * Initial revision
00179  * \endif
00180 **/
00181 
00182 #ifndef  INC_MI32_ELEMSTYL_H
00183 #define  INC_MI32_ELEMSTYL_H
00184 
00185 #ifndef  INC_MI32_STDDEFNS_H
00186 #include <mi32/stddefns.h>
00187 #endif
00188 
00189 #ifndef  INC_MI32_COLOR_H
00190 #include <mi32/color.h>
00191 #endif
00192 
00193 #ifndef  INC_STRING_H
00194 #include <string.h>                    // Includes defn for memset()
00195 #define  INC_STRING_H
00196 #endif
00197 
00198 #ifndef  INC_STDLIB_H
00199 #include <stdlib.h>
00200 #define  INC_STDLIB_H
00201 #endif
00202 
00203 #ifndef  INC_MI32_COMPAT_H
00204 #include <mi32/compat.h>               // Need for strdup() on Sun
00205 #endif
00206 
00207 #ifndef  INC_MI32_FIXEDSTR_H
00208 #include <mi32/fixedstr.h>             // Need for TEXTSTYLE fontname
00209 #endif
00210 
00211 
00212 namespace MGD {
00213    class DEVICE;
00214    }
00215 
00216 #define  STYLEFLAG_Fill                   (0x00000001)
00217 #define  STYLEFLAG_ScaleToMap             (0x00000002)   //!< Sizes given are relativve to MapScale
00218 #define  STYLEFLAG_UseSymbol              (0x00000004)
00219 #define  STYLEFLAG_UseLinePatt            (0x00000008)
00220 #define  STYLEFLAG_UseBitmapPatt          (0x00000010)   //!< Use bitmap FILL pattern (use BorderBitmapPatt for lines)
00221 #define  STYLEFLAG_UseHatchPatt           (0x00000020)   //!< Use "hatch" fill pattern
00222 #define  STYLEFLAG_DrawPolyBorder         (0x00000040)   //!< Draw polygon borders
00223 #define  STYLEFLAG_BorderBitmapPatt       (0x00000080)   //!< Use bitmap pattern for polygon border
00224 #define  STYLEFLAG_LineJoinBevel          (0x00000100)   //!< Join lines beveled
00225 #define  STYLEFLAG_LineJoinMiter          (0x00000200)   //!< Join lines mitered
00226 #define  STYLEFLAG_LineJoinRound          (0x00000300)   //!< Join lines rounded
00227 #define  STYLEFLAG_PointSymbolBuiltIn     (0x00000400)   //!< Use built-in point symbol
00228 #define  STYLEFLAG_LinePatternBuiltIn     (0x00000400)   //!< Use built-in line pattern
00229 #define  STYLEFLAG_PolyFillPattBuiltIn    (0x00000400)   //!< Use built-in polygon fill pattern
00230 #define  STYLEFLAG_PolyBorderPattBuiltIn  (0x00000800)   //!< Use built-in polygon border pattern
00231 #define  STYLEFLAG_TextHTML               (0x00002000)   //!< Text is in HTML format
00232 #define  STYLEFLAG_TextJustifyLeft        (0x00000000)   //!< Justify left side of block
00233 #define  STYLEFLAG_TextJustifyRight       (0x00004000)   //!< Justify right side of block
00234 #define  STYLEFLAG_TextJustifyCenter      (0x00008000)   //!< Center lines within block
00235 #define  STYLEFLAG_TextJustifyBoth        (0x0000C000)   //!< Justify both left and right sides of block
00236 #define  STYLEFLAG_TextCenterVert         (0x00010000)   //!< Center text "vertically" along baseline
00237 #define  STYLEFLAG_TextAboveBaseline      (0x00020000)   //!< Text drawn completely "above" baseline
00238 #define  STYLEFLAG_TextBelowBaseline      (0x00040000)   //!< Text drawn completely "below" baseline
00239 #define  STYLEFLAG_TextMirrorHorz         (0x00080000)   //!< Mirror text in "horizontal" plane
00240 #define  STYLEFLAG_TextMirrorVert         (0x00100000)   //!< Mirror text in "vertical" plane
00241 #define  STYLEFLAG_TextOrientOutput       (0x00200000)   //!< Orient block relative to output rather than baseline
00242 #define  STYLEFLAG_TextUseStyleHeight     (0x00400000)   //!< Use height stored with style, otherwise use height stored with text
00243 #define  STYLEFLAG_UseLayoutScale         (0x00800000)   //!< Sizes relative to scale int LAYOUTPARMS
00244 #define  STYLEFLAG_PointDrawCircle        (0x01000000)   //!< Draw points as circles if no pattern is used
00245 #define  STYLEFLAG_CenterSymbol           (0x02000000)   //!< Center point symbol, ignoring its hot-spot
00246 #define  STYLEFLAG_PointNoSymbol          (0x04000000)   //!< Point has no symbol (probably just a label)
00247 #define  STYLEFLAG_BlockInsert            (0x08000000)   //!< Style block insert using insert style
00248 #define  STYLEFLAG_WordWrap               (0x10000000)   //!< Word-wrap text to style's block width
00249 #define  STYLEFLAG_ScaleIsPatternZoom     (0x20000000)   //!< Scale values are pattern zoom factor.
00250 
00251 #define  STYLEFLAGMASK_LineJoin           (0x00000300)
00252 #define  STYLEFLAGMASK_Patt            (STYLEFLAG_UseSymbol | STYLEFLAG_UseLinePatt | STYLEFLAG_UseBitmapPatt | STYLEFLAG_UseHatchPatt | STYLEFLAG_BorderBitmapPatt)
00253 #define  STYLEFLAGMASK_PattPlus        (STYLEFLAGMASK_Patt | STYLEFLAG_Fill | STYLEFLAG_PointDrawCircle | STYLEFLAG_DrawPolyBorder | STYLEFLAG_PointSymbolBuiltIn | STYLEFLAG_PolyBorderPattBuiltIn)
00254 #define  STYLEFLAGMASK_Scale           (STYLEFLAG_ScaleToMap | STYLEFLAG_UseLayoutScale)
00255 #define  STYLEFLAGMASK_Point           (STYLEFLAG_UseSymbol | STYLEFLAG_UseBitmapPatt | STYLEFLAG_Fill | STYLEFLAG_PointDrawCircle | STYLEFLAG_PointNoSymbol | STYLEFLAG_PointSymbolBuiltIn)
00256 #define  STYLEFLAGMASK_Line            (STYLEFLAG_UseLinePatt | STYLEFLAG_UseBitmapPatt)
00257 #define  STYLEFLAGMASK_PolyFill        (STYLEFLAG_UseBitmapPatt | STYLEFLAG_UseHatchPatt | STYLEFLAG_Fill)
00258 #define  STYLEFLAGMASK_PolyBord        (STYLEFLAG_UseLinePatt | STYLEFLAG_BorderBitmapPatt | STYLEFLAG_DrawPolyBorder)
00259 #define  STYLEFLAGMASK_Poly            (STYLEFLAGMASK_PolyFill | STYLEFLAGMASK_PolyBord)
00260 #define  STYLEFLAGMASK_TextVertAlign   (STYLEFLAG_TextAboveBaseline | STYLEFLAG_TextCenterVert | STYLEFLAG_TextBelowBaseline)
00261 #define  STYLEFLAGMASK_TextJustify     (STYLEFLAG_TextJustifyRight|STYLEFLAG_TextJustifyCenter)
00262 
00263 //! Old names
00264 #define  STYLEFLAG_TextJustifyMask     STYLEFLAGMASK_TextJustify
00265 #define  STYLEFLAG_LineJoinMask        STYLEFLAGMASK_LineJoin
00266 
00267 //----------------------------------------------------------------------------
00268 //!      Element drawing style definitions are for in-memory use only            
00269 //!      These structures are referenced by DLLs and must not shrink or have     
00270 //!      field positions or sizes changed                                        
00271 //----------------------------------------------------------------------------
00272 
00273 //! In-memory structure for point feature style.
00274 struct POINTSTYLE {  
00275    
00276    UINT32 StyleFlags;
00277    INT32 SymbolNum;
00278    double ScaleX;                      //!< X size of point (usually in millimeters) or pattern zoom factor
00279    double ScaleY;                      //!< Y size of point (usually in millimeters) or pattern zoom factor
00280    double Angle;                       //!< Symbol rotation angle in RADIANS
00281    COLOR DrawColor;
00282    double MapScale;
00283    UINT8 spare[4];
00284    char *Desc;                         //!< string from query, Symbol$ (freed in destructor)
00285 
00286    //! Default constructor.
00287    POINTSTYLE (                        
00288       ) {
00289       memset(static_cast<void*>(this),0,sizeof(*this));
00290       }
00291 
00292    //! Copy constructor.
00293    POINTSTYLE (                        
00294       const POINTSTYLE& rhs
00295       ): Desc(0) {
00296       Copy(rhs);
00297       }
00298 
00299    //! Destructor.
00300    ~POINTSTYLE (                       
00301       ) {
00302       if (Desc) free(Desc);
00303       }
00304 
00305    //! Assignment from POINTSTYLE.
00306    POINTSTYLE& operator= (             
00307       const POINTSTYLE& rhs
00308       ) {
00309       if (this != &rhs) {
00310          Copy(rhs);
00311          }
00312       return (*this);
00313       }
00314 
00315    //! Equality operator.
00316    bool operator== (
00317       const POINTSTYLE& rhs
00318       ) const {
00319       if (StyleFlags != rhs.StyleFlags || SymbolNum != rhs.SymbolNum || ScaleX != rhs.ScaleX || ScaleY != rhs.ScaleY || Angle != rhs.Angle || DrawColor != rhs.DrawColor || MapScale != rhs.MapScale) return (false);
00320       if (Desc == rhs.Desc) return (true);
00321       if (Desc == 0 || rhs.Desc == 0) return (false);
00322       return (!strcmp(Desc,rhs.Desc));
00323       }
00324 
00325    //! Inequality operator.
00326    bool operator!= (
00327       const POINTSTYLE& rhs
00328       ) const {
00329       return (!(*this == rhs));
00330       }
00331 
00332    //! Clear the structure
00333    void Clear (
00334       ) {
00335       if (Desc != 0) free(Desc);
00336       memset(static_cast<void*>(this), 0, sizeof(*this));
00337       }
00338 
00339    //! Helper method for copying.
00340    void Copy (                        
00341       const POINTSTYLE& rhs
00342       ) {
00343       if (Desc != 0) free(Desc);
00344       memcpy(static_cast<void*>(this), static_cast<const void*>(&rhs), sizeof(*this));
00345       Desc = 0;
00346       if (rhs.Desc) {
00347          Desc = strdup(rhs.Desc);
00348          }
00349       return;
00350       }
00351    
00352    //! Determine if the style uses transparency
00353    //! Note: if the style uses a point symbol, this method can't tell
00354    //! if that symbol will use transparency or not.
00355    bool UsesTransparency (
00356       ) const {
00357       if (DrawColor.GetTransparency() != 0) return (true);
00358       // XXX what about point symbols?
00359       return (false);
00360       }
00361    };
00362 
00363 //! In-memory structure for polygon feature style.
00364 struct POLYSTYLE {
00365       
00366    UINT32 StyleFlags;
00367    INT32 FillPatternNum;
00368    INT32 BorderPatternNum;
00369    double BorderScale;                 //!< Width of border (usually in millimeters) or pattern zoom factor
00370    double MapScale;
00371    COLOR BorderColor;
00372    COLOR FillColor;
00373    double Angle;                       //!< Rotation angle for hatch patterns (was spare[8])
00374    char *FillDesc;                     //!< string from query, Symbol$ (free when done)
00375    char *LineDesc;                     //!< string from query, Symbol$ (free when done)
00376 
00377    //! Default constructor.
00378    POLYSTYLE (                         
00379       ) { memset(static_cast<void*>(this),0,sizeof(*this)); }
00380 
00381    //! Copy constructor.
00382    POLYSTYLE (                         
00383       const POLYSTYLE& rhs
00384       ): FillDesc(0), LineDesc(0) { Copy(rhs); }
00385 
00386    //! Destructor.
00387    ~POLYSTYLE (                        
00388       ) { if (FillDesc) free(FillDesc); if (LineDesc) free(LineDesc); }
00389 
00390    //! Assignment from POLYSTYLE.
00391    POLYSTYLE& operator= (              
00392       const POLYSTYLE& rhs
00393       ) { if (this != &rhs) { Copy(rhs); } return (*this); }
00394 
00395    //! Equality operator.
00396    bool operator== (
00397       const POLYSTYLE& rhs
00398       ) const {
00399       if (StyleFlags != rhs.StyleFlags || FillPatternNum != rhs.FillPatternNum || BorderPatternNum != rhs.BorderPatternNum || BorderScale != rhs.BorderScale || MapScale != rhs.MapScale || BorderColor != rhs.BorderColor || FillColor != rhs.FillColor) return (false);
00400       if (FillDesc != rhs.FillDesc) {
00401          if (FillDesc == 0 || rhs.FillDesc == 0) return (false);
00402          if (strcmp(FillDesc,rhs.FillDesc) != 0) return (false);
00403          }
00404       if (LineDesc != rhs.LineDesc) {
00405          if (LineDesc == 0 || rhs.LineDesc == 0) return (false);
00406          if (strcmp(LineDesc,rhs.LineDesc) != 0) return (false);
00407          }
00408       return (true);
00409       }
00410 
00411    //! Inequality operator.
00412    bool operator!= (
00413       const POLYSTYLE& rhs
00414       ) const { return (!(*this == rhs)); }
00415 
00416    //! Clear the structure
00417    void Clear (
00418       ) {
00419       if (FillDesc != 0) free(FillDesc);
00420       if (LineDesc != 0) free(LineDesc);
00421       memset(static_cast<void*>(this), 0, sizeof(*this));
00422       }
00423 
00424    //! Helper method for copying.
00425    void Copy (                         
00426       const POLYSTYLE& rhs
00427       ) {
00428       if (FillDesc != 0) free(FillDesc);
00429       if (LineDesc != 0) free(LineDesc);
00430       memcpy(static_cast<void*>(this), static_cast<const void*>(&rhs), sizeof(*this));
00431       FillDesc = 0;
00432       LineDesc = 0;
00433       if (rhs.FillDesc) {
00434          FillDesc = strdup(rhs.FillDesc);
00435          }
00436       if (rhs.LineDesc) {
00437          LineDesc = strdup(rhs.LineDesc);
00438          }
00439       return;
00440       }
00441 
00442    //! Determine if the style uses transparency
00443    //! Note: if the style uses a fill pattern, this method can't tell
00444    //! if that pattern will use transparency or not.
00445    bool UsesTransparency (
00446       ) const {
00447       if ((StyleFlags & STYLEFLAG_Fill) && FillColor.GetTransparency() != 0) return (true);
00448       if ((StyleFlags & STYLEFLAG_DrawPolyBorder) && BorderColor.GetTransparency() != 0) return (true);
00449       return (false);
00450       }
00451    };
00452 
00453 //! In-memory structure for line feature style.
00454 struct LINESTYLE {      
00455 
00456    UINT32 StyleFlags;
00457    INT32 PatternNum;
00458    double Scale;                       //!< Width of line (usually in millimeters) or pattern zoom factor
00459    COLOR DrawColor;
00460    double MapScale;
00461    UINT8 spare[4];
00462    char *Desc;                         //!< string from query, Symbol$ (free when done)
00463 
00464    //! Default constructor
00465    LINESTYLE (                         
00466       ) { memset(static_cast<void*>(this),0,sizeof(*this)); }
00467 
00468    //! Copy constructor.
00469    LINESTYLE (                         
00470       const LINESTYLE& rhs
00471       ): Desc(0) { Copy(rhs); }
00472 
00473    //! Destructor.
00474    ~LINESTYLE (                        
00475       ) { if (Desc) free(Desc); }
00476 
00477    //! Assignment from LINESTYLE.
00478    LINESTYLE& operator= (              
00479       const LINESTYLE& rhs
00480       ) { if (this != &rhs) { Copy(rhs); } return (*this); }
00481 
00482    //! Assignment from POLYSTYLE.
00483    LINESTYLE& operator= (              
00484       const POLYSTYLE& rhs
00485       ) {
00486       Clear();
00487       StyleFlags = (rhs.StyleFlags & (STYLEFLAG_ScaleToMap | STYLEFLAG_UseLayoutScale | STYLEFLAG_UseLinePatt));
00488       if (rhs.StyleFlags & STYLEFLAG_BorderBitmapPatt) StyleFlags |= STYLEFLAG_UseBitmapPatt;
00489       PatternNum = rhs.BorderPatternNum;
00490       Scale = rhs.BorderScale;
00491       DrawColor = rhs.BorderColor;
00492       MapScale = rhs.MapScale;
00493       if (rhs.LineDesc != 0) Desc = strdup(rhs.LineDesc);
00494       return (*this);
00495       }
00496 
00497    //! Equality operator.
00498    bool operator== (
00499       const LINESTYLE& rhs
00500       ) const {
00501       if (StyleFlags != rhs.StyleFlags || PatternNum != rhs.PatternNum || Scale != rhs.Scale || DrawColor != rhs.DrawColor || MapScale != rhs.MapScale) return (false);
00502       if (Desc == rhs.Desc) return (true);
00503       if (Desc == 0 || rhs.Desc == 0) return (false);
00504       return (!strcmp(Desc,rhs.Desc));
00505       }
00506 
00507    //! Inequality operator.
00508    bool operator!= (
00509       const LINESTYLE& rhs
00510       ) const { return (!(*this == rhs)); }
00511 
00512    //! Clear the structure
00513    void Clear (
00514       ) {
00515       if (Desc != 0) free(Desc);
00516       memset(static_cast<void*>(this), 0, sizeof(*this));
00517       }
00518 
00519    //! Helper method for copying.
00520    void Copy (                         
00521       const LINESTYLE& rhs
00522       ) {
00523       if (Desc != 0) free(Desc);
00524       memcpy(static_cast<void*>(this), static_cast<const void*>(&rhs), sizeof(*this));
00525       Desc = 0;
00526       if (rhs.Desc) {
00527          Desc = strdup(rhs.Desc);
00528          }
00529       return;
00530       }
00531    
00532    //! Determine if the style uses transparency
00533    //! Note: if the style uses a line pattern, this method can't tell
00534    //! if that pattern will use transparency or not.
00535    bool UsesTransparency (
00536       ) const {
00537       if (DrawColor.GetTransparency() != 0) return (true);
00538       // XXX what about line patterns?
00539       return (false);
00540       }
00541    };
00542 
00543 
00544 #define  FONTSTYLE_Normal        (0x00000000)
00545 #define  FONTSTYLE_Bold          (0x00000001)
00546 #define  FONTSTYLE_Italic        (0x00000002)
00547 #define  FONTSTYLE_Shadow        (0x00000004)
00548 #define  FONTSTYLE_Enhanced      (0x00000008)
00549 #define  FONTSTYLE_Outline       (0x00000010)
00550 #define  FONTSTYLE_Underline     (0x00000020)
00551 #define  FONTSTYLE_Boxed         (0x00000040)
00552 #define  FONTSTYLE_InvertGlyph   (0x00000080)   //! Invert glyphs
00553 #define  FONTSTYLE_Smooth        (0x00000100)   //! Text Smoothing (FreeType only)
00554 #define  FONTSTYLE_RoundWidth    (0x00000200)   //! Round all glyph width up to integer pixels (HTML Widget needs.  Screws up scale if zoomed out)
00555 #define  FONTSTYLE_Kerning       (0x00000400)   //! Do kerning if the font supports it
00556 #define  FONTSTYLE_InvertCRS     (0x00000800)   //! Invert Coordinate Reference System for multi-line labels
00557 
00558 struct TEXTSTYLE {
00559    UINT32 StyleFlags;                  //!< STYLEFLAG_Xxxx
00560    INT32 FontNumber;
00561    COLOR FGColor;
00562    COLOR BGColor;
00563    FLOAT GlyphRotation;                //!< Rotation of each glyph individually
00564    FLOAT GlyphAspect;                  //!< Height to width aspect ratio
00565    FLOAT Shear;                        //!< Italics angle (ignored unless FONTSTYE_Italic is set)
00566    FLOAT Height;                       //!< Height of glyph in "HeightUnits"
00567    FLOAT LineSpace;                    //!< Line spacing in "SpaceUnits"
00568    UINT32 FontFlags;                   //!< FONTSTYLE_Xxxx or'ed together
00569    double MapScale;
00570    MISTRING fontname;               //!< font name (eg: "SYSTEM.OF")
00571    UINT16 HeightUnits;                 //!< Units for height (SCREENUNIT_...)
00572    UINT16 SpaceUnits;                  //!< Units for line spacing (SCREENUNIT_...)
00573    UINT16 Predefined;                  //!< Predefined label styles
00574    UINT16 StructSize;                  //!< Sizeof this structure.  If 0, we assume old size (128) that ended with this field.
00575    double Width;                       //!< Width of block (only if STYLEFLAG_TextHTML or STYLEFLAG_WordWrap)
00576    double StrokeWidth;                 //!< Stroke width in % of glyph height (1.0 = 100%)
00577    double EnhanceWidth;                //!< Enhanced width in % of glyph height (1.0 = 100%)
00578    double BoldnessWidth;               //!< Boldness width in % of glyph height (1.0 = 100%) Ignored unless FONTSTYLE_Bold is set
00579    double UnderlineWidth;              //!< Underline with in % of glyph height (1.0 = 100%)
00580    double UnderlineOffset;             //!< Underline Offset from baseline in % (1.0 = 100%)
00581    double ShadowOffset;                //!< Drop shadow offset in % (1.0 = 100%) Ignored unless FONTSTYLE_Shadow is set
00582    double ShadowAngle;                 //!< Drop shadow angle in radians
00583    double ClipWidth;                   //!< Clip extended area around text in TextAddToClip()
00584    bool ShadowRelative;                //!< true if shadow angle relative to baseline angle
00585    bool m_bInitialized;                //!< Set to true by constructor.  Used to verify that defaults are valid and not just memset to 0
00586    UINT16 WidthUnits;
00587 
00588    //! Default constructor.
00589    TEXTSTYLE (                         
00590       ) :
00591       StyleFlags(STYLEFLAG_UseLayoutScale),
00592       FontNumber(0),
00593       GlyphRotation(0.0F),
00594       Height(0.0F),
00595       LineSpace(0.0F),
00596       FontFlags(0),
00597       HeightUnits(0),
00598       SpaceUnits(0), 
00599       Predefined(0),
00600       StructSize(sizeof(TEXTSTYLE)),
00601       StrokeWidth(0.0),
00602       EnhanceWidth(0.15),     //!< 15%
00603       BoldnessWidth(0.03), //!< 3%
00604       UnderlineWidth(0.0),
00605       UnderlineOffset(0.0),
00606       ShadowOffset(0.1),      //!< 10%
00607       ShadowAngle(-PI/4.0),
00608       GlyphAspect(1.0),
00609       Shear(static_cast<float>(20.0 * DEGTORAD)),  //! Default shear for italic
00610       ClipWidth(0.2),
00611       MapScale(1.0),
00612       WidthUnits(0),
00613       Width(0.0),
00614       ShadowRelative(false),
00615       m_bInitialized(true)
00616       {
00617       }
00618 
00619    //! Copy constructor
00620    TEXTSTYLE(const TEXTSTYLE& rhs) {
00621       Copy(rhs);
00622       }
00623 
00624    //! Default destructor, because VC++ does not generate a default one
00625    ~TEXTSTYLE (
00626       ) {}
00627 
00628    //! Assignment from TEXTSTYLE.
00629    TEXTSTYLE& operator= (              
00630       const TEXTSTYLE& rhs
00631       ) {
00632       if (this != &rhs) {
00633          Copy(rhs);
00634          }
00635       return (*this);
00636       }
00637       
00638 
00639    //! Equality operator.
00640    bool operator== (
00641       const TEXTSTYLE& rhs
00642       ) const {
00643       return (StyleFlags == rhs.StyleFlags
00644            && FontNumber == rhs.FontNumber
00645            && FGColor == rhs.FGColor
00646            && BGColor == rhs.BGColor
00647            && GlyphRotation == rhs.GlyphRotation
00648            && GlyphAspect == rhs.GlyphAspect
00649            && Shear == rhs.Shear
00650            && Height == rhs.Height
00651            && LineSpace == rhs.LineSpace
00652            && FontFlags == rhs.FontFlags
00653            && MapScale == rhs.MapScale
00654            && fontname == rhs.fontname
00655            && HeightUnits == rhs.HeightUnits
00656            && SpaceUnits == rhs.SpaceUnits
00657            && Predefined == rhs.Predefined
00658            && Width == rhs.Width
00659            && StrokeWidth == rhs.StrokeWidth
00660            && EnhanceWidth == rhs.EnhanceWidth
00661            && BoldnessWidth == rhs.BoldnessWidth
00662            && UnderlineWidth == rhs.UnderlineWidth
00663            && UnderlineOffset == rhs.UnderlineOffset
00664            && ShadowOffset == rhs.ShadowOffset
00665            && ShadowAngle == rhs.ShadowAngle
00666            && ClipWidth == rhs.ClipWidth
00667            && ShadowRelative == rhs.ShadowRelative
00668            && WidthUnits == rhs.WidthUnits);
00669       }
00670 
00671    //! Inequality operator.   
00672    bool operator!= (
00673       const TEXTSTYLE& rhs
00674       ) const {
00675       return (!(*this == rhs));
00676       }
00677 
00678 
00679    //! Returns true if this text style will try to use transparency 
00680    //! If a DEVICE is given, this will return true if the text uses antialising
00681    //!  AND if the device is < 300dpi (not meaningful above 300dpi)
00682    bool UsesTransparency (
00683       const MGD::DEVICE *pDevice = 0
00684       ) const;
00685 
00686    //! Returns true if this text style will try to use transparency 
00687    bool UsesAntialiasing (
00688       ) const {
00689       return ((FontFlags & FONTSTYLE_Smooth) != 0);
00690       }
00691 
00692    private:
00693       #ifndef GENERATING_DOXYGEN_OUTPUT
00694 
00695       void Copy (
00696          const TEXTSTYLE& rhs
00697          ) {
00698          // This is less important now because patches can include an update of
00699          // everything, so if we change the size, we just have to recompile
00700          // the whole world.
00701          StructSize = sizeof(TEXTSTYLE);
00702          StyleFlags = rhs.StyleFlags;
00703          FontNumber = rhs.FontNumber;
00704          FGColor = rhs.FGColor;
00705          BGColor = rhs.BGColor;
00706          GlyphRotation = rhs.GlyphRotation;
00707          GlyphAspect = rhs.GlyphAspect;
00708          Shear = rhs.Shear;
00709          Height = rhs.Height;
00710          LineSpace = rhs.LineSpace;
00711          FontFlags = rhs.FontFlags;
00712          MapScale = rhs.MapScale;
00713          fontname = rhs.fontname;
00714          HeightUnits = rhs.HeightUnits;
00715          SpaceUnits = rhs.SpaceUnits;
00716          Predefined = rhs.Predefined;
00717          Width = rhs.Width;
00718          StrokeWidth = rhs.StrokeWidth;
00719          EnhanceWidth = rhs.EnhanceWidth;
00720          BoldnessWidth = rhs.BoldnessWidth;
00721          UnderlineWidth = rhs.UnderlineWidth;
00722          UnderlineOffset = rhs.UnderlineOffset;
00723          ShadowOffset = rhs.ShadowOffset;
00724          ShadowAngle = rhs.ShadowAngle;
00725          ClipWidth = rhs.ClipWidth;
00726          ShadowRelative = rhs.ShadowRelative;
00727          WidthUnits = rhs.WidthUnits;
00728          m_bInitialized = true;
00729          }
00730 
00731       #endif // GENERATING_DOXYGEN_OUTPUT
00732    };
00733 
00734 PREVENT_MEMFUNC(TEXTSTYLE);
00735    
00736 
00737 struct TEXTSTYLEDIFF : public TEXTSTYLE {
00738    enum MEMBERMASK {
00739       MEMBER_NONE =              0x00000000,
00740       MEMBER_StyleFlags =        0x00000001,
00741       MEMBER_FontNumber =        0x00000002,
00742       MEMBER_FGColor =           0x00000004,
00743       MEMBER_BGColor =           0x00000008,
00744       MEMBER_GlyphRotation =     0x00000010,
00745       MEMBER_GlyphAspect   =     0x00000020,
00746       MEMBER_Shear   =           0x00000040,
00747       MEMBER_Height  =           0x00000080,
00748       MEMBER_LineSpace =         0x00000100,
00749       MEMBER_FontFlags =         0x00000200,
00750       MEMBER_MapScale =          0x00000400,
00751       MEMBER_fontname =          0x00000800,
00752       MEMBER_HeightUnits =       0x00001000,
00753       MEMBER_SpaceUnits =        0x00002000,
00754       MEMBER_Predefined =        0x00004000,
00755       MEMBER_Width =             0x00008000,
00756       MEMBER_StrokeWidth =       0x00010000,
00757       MEMBER_EnhanceWidth =      0x00020000,
00758       MEMBER_BoldnessWidth =     0x00040000,
00759       MEMBER_UnderlineWidth =    0x00080000,
00760       MEMBER_UnderlineOffset =   0x00100000,
00761       MEMBER_ShadowOffset =      0x00200000,
00762       MEMBER_ShadowAngle =       0x00400000,
00763       MEMBER_ClipWidth =         0x00800000,
00764       MEMBER_ShadowRelative =    0x01000000,
00765       MEMBER_WidthUnits =        0x02000000,
00766       MEMBER_ALL =               0x03FFFFFF
00767       };
00768 
00769    UINT32 StyleFlagMask;               //!< Which StyleFlags bits are meaningful
00770    UINT32 FontFlagMask;                //!< Which FontFlags bits are meaningful
00771    MEMBERMASK MemberMask;              //!< Which members are meaningful
00772 
00773    TEXTSTYLEDIFF() :
00774       TEXTSTYLE(),
00775       StyleFlagMask(0),
00776       FontFlagMask(0),                 
00777       MemberMask(MEMBER_NONE)
00778       {
00779       }
00780 
00781    //! Initialize a TEXTSTYLEDIFF with the style changes described by the 
00782    //! {~} codes in a text string.
00783    TEXTSTYLEDIFF (
00784       const MIUNICODE*     
00785       );
00786 
00787    //! Copy constructor
00788    TEXTSTYLEDIFF (
00789       const TEXTSTYLE& rhs
00790       ) :
00791       TEXTSTYLE(rhs),
00792       StyleFlagMask(0xFFFFFFFF),
00793       FontFlagMask(0xFFFFFFFF),                 
00794       MemberMask(MEMBER_ALL)
00795       {
00796       }
00797 
00798    //! Augment from another TEXTSTYLE. 
00799    //! Only the members of the right hand side which are valid (according to
00800    //! MemberMask) will be copied to the left hand side.
00801    TEXTSTYLEDIFF& operator|= (               
00802       const TEXTSTYLEDIFF& rhs
00803       );
00804 
00805    //! Augment from {~} code(s)
00806    TEXTSTYLEDIFF& operator+= (               
00807       const MIUNICODE* code
00808       );
00809 
00810    //! Compute the similaraties between this TEXTSTYLE and another.
00811    //! The left hand side will only have the MemberMask bits set for the
00812    //! members which are the same between its previous state and the
00813    //! right hand side.  The MemberMask bits for the members which are 
00814    //! different are cleared.
00815    TEXTSTYLEDIFF& operator&= (               
00816       const TEXTSTYLEDIFF& rhs
00817       );
00818 
00819    //! Compute the difference between this TEXTSTYLE and another.
00820    //! The left hand side will only have the MemberMask bits set for the
00821    //! members which are different between its previous state and the
00822    //! right hand side.  The MemberMask bits for the members which are the
00823    //! same are cleared.
00824    TEXTSTYLEDIFF& operator^= (               
00825       const TEXTSTYLEDIFF& rhs
00826       );
00827 
00828 
00829    //! Generate a string of TILDE codes which describe the changes that this
00830    //! TEXTSTYLEDIFF represent
00831    void GetTildeCodes (
00832       MISTRING& str,
00833       bool bClearStringFirst = true    //!< Pass false to append to existing text
00834       ) const;
00835 
00836    //! Parse a series of {~} codes.
00837    //! @return true if any ~ code was recgonized.
00838    bool ParseTildeCodes (
00839       const MIUNICODE* commands, //!< {~} codes to parse
00840       MISTRING* unknowns = 0     //!< Any unrecgonized commands will be returned in this string, if provided.
00841       );
00842 
00843    };
00844 DEFINE_ENUM_OP_BITWISE(TEXTSTYLEDIFF::MEMBERMASK);
00845 
00846 struct MULTISTYLE {
00847    POINTSTYLE Point;
00848    LINESTYLE Line;
00849    POLYSTYLE Poly;
00850    TEXTSTYLE Text;
00851    };
00852 
00853 #ifndef GENERATING_DOXYGEN_OUTPUT
00854 //! Make sure nobody is memsetting a TEXTSTYLE to 0.
00855 //! The following memset is an overload specific to TEXTSTYLE.  Any attempt
00856 //! to call it will result in a compile error.
00857 PREVENT_MEMFUNC(TEXTSTYLE)
00858 PREVENT_MEMCMP(TEXTSTYLE)
00859 PREVENT_MEMFUNC(POINTSTYLE)
00860 PREVENT_MEMFUNC(LINESTYLE)
00861 PREVENT_MEMFUNC(POLYSTYLE)
00862 PREVENT_MEMFUNC(MULTISTYLE)
00863 #endif // GENERATING_DOXYGEN_OUTPUT
00864 
00865 #define  STYLE_BuiltIn_Point_None            0
00866 #define  STYLE_BuiltIn_Point_BoxOpen         1
00867 #define  STYLE_BuiltIn_Point_BoxFilled       2
00868 #define  STYLE_BuiltIn_Point_CircleOpen      3
00869 #define  STYLE_BuiltIn_Point_CircleFilled    4
00870 #define  STYLE_BuiltIn_Point_Crosshair       5     //!< Simple thin-line crosshair
00871 #define  STYLE_BuiltIn_Point_CrosshairHalo   6     //!< Crosshair with background halo
00872 #define  STYLE_BuiltIn_Point_Last            6
00873 
00874          //! Values for TEXTSTYLE.Predefined
00875 #define  TEXTSTYLEPREDEF_None             0
00876 #define  TEXTSTYLEPREDEF_NauticalDepth    1
00877 
00878 //----------------------------------------------------------------------------
00879 //!      Functions and macros                                                    
00880 //----------------------------------------------------------------------------
00881 
00882 //!:Associate with "Element Style Functions"
00883 //!\addtogroup ElementStyle Element Style Functions
00884 //!@{
00885 
00886 #if defined(__cplusplus)
00887 extern "C" {
00888 #endif
00889 
00890 //! Compute min/max of a symbol in its coordinate system.
00891 int MxGetSymbolMinMax (
00892    UINT8 *symbolbuf, 
00893    LRECTXY *minmax
00894    );
00895 
00896 //! Compute size of symbol in its coordinate system.
00897 int MxGetSymbolSize (
00898    UINT8 *symbolbuf
00899    );
00900 
00901 //!   Parse text string and build symbol description.
00902 int MxParseSymbol (
00903    const char* const istring, 
00904    UINT8 **bufp
00905    );
00906 
00907 //!   Convert symbol description to text string.
00908 char *MxSymbolToText (
00909    UINT8 *buf
00910    );
00911 
00912 //!   Compute extents for string as it would be drawn.
00913 int GetStringExtents (
00914    TEXTSTYLE *style, 
00915    DPOINT2D *basepts, 
00916    INT32 numbasepts, 
00917    UINT32 baseflags, 
00918    const MIUNICODE *string, 
00919    DRECT2D *extents
00920    );
00921 
00922 //!   Compute extents for string as it would be drawn.
00923 int GetStringExtentsJustify (
00924    TEXTSTYLE *style, 
00925    DPOINT2D *basepts, 
00926    INT32 numbasepts, 
00927    UINT32 baseflags, 
00928    const MIUNICODE *string, 
00929    DRECT2D *extents
00930    );
00931 
00932 #if defined(__cplusplus)
00933 }                       
00934 #endif
00935 
00936 //!@}
00937 
00938 #endif   // INC_MI32_ELEMSTYL_H

Generated on Wed May 31 15:26:50 2006 for TNTsdk by  doxygen 1.3.8-20040913