matte.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * \file matte.h <mi32/matte.h>
00004  * \brief Settings for group backgrounds
00005  *
00006  * \if NODOC
00007  * $Log: matte.h_v $
00008  * Revision 1.20  2004/03/05 15:24:16  dwilliss
00009  * Doh!  Save before checking in.
00010  *
00011  * Revision 1.19  2004/03/05 15:23:22  dwilliss
00012  * destructor needed to be virtual
00013  *
00014  * Revision 1.18  2004/02/12 22:00:21  dwilliss
00015  * deprecate old mgd
00016  *
00017  * Revision 1.17  2003/09/15 13:49:56  fileserver!dwilliss
00018  * Doxygen
00019  *
00020  * Revision 1.16  2001/12/28 21:34:16  mju
00021  * SerialWrite now const.
00022  *
00023  * Revision 1.15  2001/12/21 20:33:40  dwilliss
00024  * [ irrelevant due to deprecated stuff ]
00025  *
00026  * Revision 1.14  2001/11/12 15:35:57  scowan
00027  * Removed comma from end of enum.
00028  *
00029  * Revision 1.13  2001/10/12 22:46:41  dwilliss
00030  * *** empty log message ***
00031  *
00032  * Revision 1.12  2001/10/04 15:04:10  dwilliss
00033  * Added methods to get and set cartoscript member
00034  *
00035  * Revision 1.11  2001/10/03 16:46:22  dwilliss
00036  * New border type flag for cartoscript
00037  *
00038  * Revision 1.10  2001/10/03 16:40:59  dwilliss
00039  * Seems to be done for now.
00040  *
00041  * Revision 1.9  2001/10/02 19:35:38  dwilliss
00042  * Operator =
00043  *
00044  * Revision 1.8  2001/10/02 15:53:32  dwilliss
00045  * Added members to keep track of page color and cartoscript border
00046  *
00047  * Revision 1.7  2001/09/14 20:05:02  dwilliss
00048  * Seems mostly done.
00049  * New border styles defined
00050  *
00051  * Revision 1.6  2001/09/13 21:52:22  dwilliss
00052  * Fixed typo in method name
00053  *
00054  * Revision 1.5  2001/09/13 21:44:43  dwilliss
00055  * Control panel now returns a handle which you can use to change things
00056  * after the fact
00057  *
00058  * Revision 1.4  2001/09/13 19:07:14  dwilliss
00059  * Drawing functions now take a MapScale parameter
00060  *
00061  * Revision 1.3  2001/09/12 21:31:44  dwilliss
00062  * Added drop shadow blend member
00063  *
00064  * Revision 1.2  2001/09/12 21:08:28  dwilliss
00065  * Added SPREADMODE member
00066  *
00067  * Revision 1.1  2001/09/12 15:44:00  dwilliss
00068  * Initial revision
00069  *
00070  *
00071  * \endif
00072  ****************************************************************************/
00073 #ifndef INC_MI32_MATTE_H
00074 #define INC_MI32_MATTE_H
00075 
00076 #ifndef INC_MI32_COLOR_H
00077 #include <mi32/color.h>
00078 #endif
00079 
00080 #ifndef INC_MI32_SERIALIZ_H
00081 #include <mi32/serializ.h>
00082 #endif
00083 
00084 #ifndef INC_MI32_SCRNUNIT_H
00085 #include <mi32/scrnunit.h>
00086 #endif
00087 
00088 #ifndef INC_MI32_MCB_H
00089 #include <mi32/mcb.h>
00090 #endif
00091 
00092 #ifndef INC_MI32_MGD2_H
00093 #include <mi32/mgd2.h>
00094 #endif
00095 
00096 
00097 class MATTE;
00098 
00099 //! A MATTE_CONTROLPANEL is returned by MATTE::CreateControlPanel()
00100 //!
00101 //! It allows you to manipulate the control panel after it was created.
00102 //! You should never create one of these yourself.
00103 class MATTE_CONTROLPANEL {
00104    public:
00105 
00106       void AddChangeCallback (
00107          McbCallbackFunc func,
00108          void* cbdata
00109          ) {
00110          McbAddCallback(&m_cblist, func, cbdata, 1);
00111          return;
00112          }
00113 
00114       void RemoveChangeCallabck (
00115          McbCallbackFunc func,
00116          void* cbdata
00117          ) {
00118          McbRemoveCallback(&m_cblist, func, cbdata, 1);
00119          return;
00120          }
00121 
00122       virtual void ChangeMatte (
00123          MATTE& matte
00124          ) = 0;
00125 
00126    protected:
00127       MATTE* m_matte;
00128 
00129       MATTE_CONTROLPANEL (
00130          MATTE* matte
00131          ) :
00132          m_matte(matte)
00133          {
00134          }
00135 
00136       virtual ~MATTE_CONTROLPANEL () {}
00137       
00138       void CallChangeCallbacks (
00139          );
00140 
00141    private:
00142       #ifndef GENERATING_DOXYGEN_OUTPUT
00143       McbLIST m_cblist;
00144       friend class MATTE;
00145       #endif // GENERATING_DOXYGEN_OUTPUT
00146    };
00147 
00148 class MATTE : public SERIALIZABLE {
00149    public:
00150       
00151       enum DRAWFLAGS {
00152          DRAWFLAG_None = 0,
00153          DRAWFLAG_DrawInsideExtents = 0x00000001   
00154          };
00155 
00156       enum FILLMODE {
00157          FILLMODE_None = 0,
00158          FILLMODE_Solid = 1,
00159          FILLMODE_Gradient,
00160          FILLMODE_Radial
00161          };
00162    
00163       enum SPREADMODE {
00164          SPREADMODE_RGB = 0,
00165          SPREADMODE_HISCW,
00166          SPREADMODE_HISCCW,
00167          SPREADMODE_HBSCW,
00168          SPREADMODE_HBSCCW
00169          };
00170 
00171       enum BORDER {
00172          BORDER_None = 0,
00173          BORDER_Solid = 1,
00174          BORDER_Double = 2,
00175          BORDER_Inset = 3,
00176          BORDER_Outset = 4,
00177          BORDER_Groove = 5,
00178          BORDER_Ridge = 6,
00179          BORDER_EtchedIn = 7,
00180          BORDER_EtchedOut = 8,
00181          BORDER_Rounded = 9,
00182          BORDER_CartoScript = 10
00183          };
00184    
00185       //! Constructor
00186       MATTE();
00187 
00188       //! Copy Constructor
00189       MATTE(const MATTE&);
00190 
00191       //! Destructor
00192       virtual ~MATTE();
00193 
00194 
00195       // OPERATORS
00196       
00197       MATTE& operator= (
00198          const MATTE& rhs
00199          );
00200 
00201       //! virtual methods of SERIALIZABLE
00202       virtual ERRVALUE SerialRead (
00203          SERIALIZER& serializer
00204          );
00205 
00206       virtual ERRVALUE SerialWrite (
00207          SERIALIZER& serializer,
00208          const char* tagname
00209          ) const;
00210 
00211       //! Create a control panel page
00212       //!
00213       //! Returns a pointer to a controlpanel which you can use
00214       //! to add a changed callback.
00215       //!
00216       //! Returns a pointer to the control panel's private data.
00217       //! With this pointer, you can add a callback to be called when
00218       //! anything on the control panel is modified, and also change 
00219       //! the matte being edited.
00220       MATTE_CONTROLPANEL* CreateControlPanel (
00221          MDLGPARENT form      //!< Form to create the controls in.
00222          );
00223 
00224       //! Draw the background, border and dropshadow
00225       //! The rectangle should be in output device coordinates and NOT include
00226       //! the margins, border or drop shadow.  They will all extend out from
00227       //! this rectangle
00228       ERRVALUE Draw (
00229          MGD::CONTEXT& gc,
00230          const LRECT2D& rect,
00231          double MapScale = 1.0,
00232          DRAWFLAGS flags = DRAWFLAG_None
00233          );
00234 
00235       //! Fill in the background based on background settings
00236       //! The rectangle should be in output device coordinates and NOT include
00237       //! the margins, border or drop shadow.  They will all extend out from
00238       //! this rectangle
00239       ERRVALUE DrawBackground (
00240          MGD::CONTEXT& gc,
00241          const LRECT2D& rect,
00242          double MapScale = 1.0,
00243          DRAWFLAGS flags = DRAWFLAG_None
00244          );
00245 
00246       //! Draw in the border
00247       //! The rectangle should be in output device coordinates and NOT include
00248       //! the margins, border or drop shadow.  They will all extend out from
00249       //! this rectangle
00250       ERRVALUE DrawBorder (
00251          MGD::CONTEXT& gc,
00252          const LRECT2D& rect,
00253          double MapScale = 1.0,
00254          DRAWFLAGS flags = DRAWFLAG_None
00255          );
00256 
00257       //! Draw the drop shadow
00258       //! The rectangle should be in output device coordinates and NOT include
00259       //! the margins, border or drop shadow.  They will all extend out from
00260       //! this rectangle
00261       ERRVALUE DrawDropShadow (
00262          MGD::CONTEXT& gc,
00263          const LRECT2D& rect,
00264          double MapScale = 1.0,
00265          DRAWFLAGS flags = DRAWFLAG_None
00266          );
00267 
00268 
00269       // Get Methods
00270 
00271       //! Return the primary background fill color
00272       const COLOR& GetBackgroundColor (
00273          ) const {
00274          return m_BGColor1; 
00275          }
00276 
00277       //! Return the secondary background fill color (used for gradiant fills)
00278       const COLOR& GetBackgroundColor2 (
00279          ) const {
00280          return m_BGColor2; 
00281          }
00282 
00283       //! Return the background fill mode
00284       FILLMODE GetBackgroundFillMode (
00285          ) const {
00286          return m_BGFillMode; 
00287          }
00288 
00289       double GetBackgroundGradientAngle (
00290          ) const {
00291          return m_BGGradientAngle;
00292          }
00293 
00294       SPREADMODE GetBackgroundGradientSpreadMode (
00295          ) const {
00296          return m_BGSpreadMode;
00297          }
00298 
00299       const MISTRING& GetBorderCartoScript (
00300          ) const {
00301          return m_BorderCartoScript;
00302          }
00303 
00304       //! Get the color of the border
00305       const COLOR& GetBorderColor (
00306          ) const {
00307          return m_BorderColor; 
00308          }
00309 
00310       //! Get the size (in mm at output scale
00311       //!) of the border
00312       double GetBorderSize (
00313          ) const {
00314          return m_BorderSize; 
00315          }
00316 
00317       //! Get the border style
00318       BORDER GetBorderStyle (
00319          ) const {
00320          return m_BorderStyle; 
00321          }
00322       
00323       //! Get whether or not the drop shadow is drawing with a Gaussian blend.
00324       bool GetDropShadowBlend (
00325          ) const {
00326          return (m_DSBlend);
00327          }
00328       
00329       //! Get the color of the drop shadow
00330       const COLOR& GetDropShadowColor (
00331          ) const {
00332          return m_DSColor; 
00333          }
00334 
00335       //! Return the extents of the shadow and border (in mm at output scale
00336       //!)
00337       //! 
00338       //!   Computes how far outside any rectangle the drawing will extend.
00339       void GetExtraExtents (
00340          double& x1,
00341          double& y1,
00342          double& x2,
00343          double& y2
00344          ) const;
00345 
00346       //! Get the direction (in radians) of the drop shadow
00347       double GetDropShadowDirection (
00348          ) const {
00349          return m_DSDirection; 
00350          }
00351 
00352       //! Get the size (in mm at output scale) of the drop shadow
00353       double GetDropShadowSize (
00354          ) const {
00355          return m_DSSize; 
00356          }
00357       
00358       //! Return the bottom margin (in mm at output scale)
00359       double GetMarginBottom (
00360          ) const {
00361          return m_MarginBottom; 
00362          }
00363 
00364       //! Return the left margin (in mm at output scale)
00365       double GetMarginLeft (
00366          ) const {
00367          return m_MarginLeft; 
00368          }
00369 
00370       //! Return the right margin (in mm at output scale)
00371       double GetMarginRight (
00372          ) const {
00373          return m_MarginRight; 
00374          }
00375 
00376       //! Return the top margin (in mm at output scale)
00377       double GetMarginTop (
00378          ) const {
00379          return m_MarginTop; 
00380          }
00381       
00382       //! Return the units the user wants to see sizes in
00383       //! note that sizes are always stored in mm at output scale
00384       SCREENUNIT GetDisplayUnits (
00385          ) const {
00386          return m_SizeUnits; 
00387          }
00388 
00389       bool IsBorderRoundedRect (
00390          ) const {
00391          return m_BorderRoundRect; 
00392          }
00393 
00394       //! Determine if anything in the background or drop shadow will require
00395       //! it to make use of transparency effects in the display.  
00396       bool NeedsTransparency (
00397          ) const;
00398 
00399       // Set Methods
00400 
00401       //! Set the primary background fill color
00402       void SetBackgroundColor (
00403          const COLOR& color
00404          ) {
00405          m_BGColor1 = color; 
00406          }
00407 
00408       //! Set the secondary background fill color (used for gradiant fills)
00409       void SetBackgroundColor2 (
00410          const COLOR& color
00411          ) {
00412          m_BGColor2 = color; 
00413          }
00414 
00415       //! Set the background fill mode
00416       void SetBackgroundFillMode (
00417          FILLMODE mode
00418          ) {
00419          m_BGFillMode = mode; 
00420          }
00421 
00422       void SetBackgroundGradientAngle (
00423          double angle
00424          ) {
00425          m_BGGradientAngle = angle;
00426          }
00427 
00428       void SetBackgroundGradientSpreadMode (
00429          SPREADMODE mode
00430          ) {
00431          m_BGSpreadMode = mode;
00432          }
00433 
00434       void SetBorderCartoScript (
00435          const MISTRING& script
00436          ) {
00437          m_BorderCartoScript = script;
00438          }
00439       
00440       //! Get the color of the border
00441       void SetBorderColor (
00442          const COLOR& color
00443          ) {
00444          m_BorderColor = color; 
00445          }
00446 
00447       //! Set the border to be a rounded rectangle.
00448       //! If this is set, corners of the border will be rounded.  The radius
00449       //! of the rounding is equal to the margin distances.
00450       void SetBorderIsRoundedRect (
00451          bool bRound
00452          ) {
00453          m_BorderRoundRect = bRound; 
00454          }
00455 
00456       //! Get the size (in mm at output scale) of the border
00457       void SetBorderSize (
00458          double size
00459          ) {
00460          m_BorderSize = size; 
00461          }
00462 
00463       //! Get the border style
00464       void SetBorderStyle (
00465          BORDER style
00466          ) {
00467          m_BorderStyle = style; 
00468          }
00469 
00470       //! Set whether or not the drop shadow is drawing with a Gaussian blend.
00471       void SetDropShadowBlend (
00472          bool blend
00473          ) {
00474          m_DSBlend = blend;
00475          }
00476       
00477       //! Get the color of the drop shadow
00478       void SetDropShadowColor (
00479          const COLOR& color
00480          ) {
00481          m_DSColor = color; 
00482          }
00483 
00484       //! Get the direction (in radians) of the drop shadow
00485       void SetDropShadowDirection (
00486          double dir
00487          ) {
00488          m_DSDirection = dir; 
00489          }
00490 
00491       //! Get the size (in mm at output scale) of the drop shadow
00492       void SetDropShadowSize (
00493          double size
00494          ) {
00495          m_DSSize = size; 
00496          }
00497 
00498       //! Set the bottom margin (in mm at output scale)
00499       void SetMarginBottom (
00500          double dist
00501          ) {
00502          m_MarginBottom = dist; 
00503          }
00504       
00505       //! Set the left margin (in mm at output scale)
00506       void SetMarginLeft (
00507          double dist
00508          ) {
00509          m_MarginLeft = dist; 
00510          }
00511 
00512       //! Set the right margin (in mm at output scale)
00513       void SetMarginRight (
00514          double dist
00515          ) {
00516          m_MarginRight = dist; 
00517          }
00518 
00519       //! Set the top margin (in mm at output scale)
00520       void SetMarginTop (
00521          double dist
00522          ) {
00523          m_MarginTop = dist; 
00524          }
00525       
00526       //! Set the units the user wants to see sizes in
00527       //! note that sizes are always stored in mm at output scale
00528       void SetDisplayUnits (
00529          SCREENUNIT units
00530          ) {
00531          m_SizeUnits = units; 
00532          }
00533 
00534       // Runtime drawing settings
00535       
00536       //! Tell the matte that the background is a solid color.
00537       //! This is NOT the background you want the matte to draw.  This is to
00538       //! allow an optimization of transparency blending effects if it is known
00539       //! that we're blending over a white (or other solid color) background.
00540       void SetSolidBackground (
00541          const COLOR& color
00542          ) {
00543          m_bSolidBackground = true;
00544          m_PageColor = color;
00545          return;
00546          }
00547        
00548       //! Clears the effects of SetSolidBackground()
00549       void SetDirtyBackground (
00550          ) {
00551          m_bSolidBackground = false;
00552          return;
00553          }
00554 
00555       void SetMarginsInset (
00556          bool inset
00557          ) {
00558          m_bMarginsInset = inset;
00559          }
00560 
00561    private:
00562       #ifndef GENERATING_DOXYGEN_OUTPUT
00563       COLOR m_BGColor1;
00564       COLOR m_BGColor2;
00565       FILLMODE m_BGFillMode;
00566       double m_BGGradientAngle;
00567       SPREADMODE m_BGSpreadMode;
00568 
00569       double m_MarginLeft;
00570       double m_MarginRight;
00571       double m_MarginTop;
00572       double m_MarginBottom;
00573 
00574       SCREENUNIT m_SizeUnits; //!< Units user wants to edit sizes in (always stored in mm at output res)
00575 
00576       COLOR m_DSColor;        //!< Color of dropshadow
00577       double m_DSDirection;   //!< In raidans
00578       double m_DSSize;
00579       bool m_DSBlend;      //!< Do a Gaussian blur
00580 
00581       COLOR m_BorderColor;
00582       double m_BorderSize;
00583       BORDER m_BorderStyle;      
00584       bool m_BorderRoundRect;
00585       MISTRING m_BorderCartoScript;
00586 
00587       bool m_bMarginsInset;      
00588       COLOR m_PageColor;
00589       bool m_bSolidBackground;   //!< If true, can blend with m_PageColor instead
00590                                  //! of doing real transparency
00591       
00592       static const SERIALIZER::ITEMDEF* SerialGetItemDef (
00593          SERIALIZER& serializer
00594          );
00595 
00596       friend class MATTEPRIV;
00597       #endif // GENERATING_DOXYGEN_OUTPUT
00598    };
00599 
00600 
00601 
00602 #endif
00603 

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