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

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