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

Generated on Tue Dec 14 13:18:20 2004 for TNTsdk by  doxygen 1.3.8-20040913