gre/lrlegnd2.h

Go to the documentation of this file.
00001 /**
00002  * \file lrlegnd2.h <gre/lrlegnd2.h>
00003  * \brief GRE_LAYER_LEGEND2 class definitions
00004  *
00005  * \if NODOC
00006  * $Id: lrlegnd2.h_v 1.3 2003/09/15 13:48:59 fileserver!dwilliss Exp $
00007  *
00008  * $Log: lrlegnd2.h_v $
00009  * Revision 1.3  2003/09/15 13:48:59  fileserver!dwilliss
00010  * Doxygen
00011  *
00012  * Revision 1.2  2003/07/30 15:23:21  mju
00013  * Ignore private sections.
00014  *
00015  * Revision 1.1  2002/09/20 17:37:36  mju
00016  * Initial revision
00017  *
00018  * \endif
00019 **/
00020 
00021 #ifndef  INC_GRE_LRLEGND2_H
00022 #define  INC_GRE_LRLEGND2_H
00023 
00024 #ifndef  INC_MI32_GRE_H
00025 #include <mi32/gre.h>
00026 #endif
00027 
00028 //===================================================================================================================
00029 
00030 class GRE_LAYER_LEGEND2 : public GRE_LAYER {
00031    public:
00032 
00033       //! Class used internally to keep track of which layers the legend refers to
00034       class LAYERREF  {
00035          public:
00036             UNICODE *m_name;  //!< Can't use MISTRING.  We MmAllocC() an array of LAYRREFs.
00037             //! Our DISPPARM's destructor worrys about freeing stuff.
00038             GRE_LAYER* m_layer;
00039             ELEMTYPE m_ElemType;
00040             UINT32 m_ID;
00041 
00042             LAYERREF (
00043                ) :
00044                m_name(0),
00045                m_layer(0),
00046                m_ID(0),
00047                m_ElemType(ELEMTYPE_Empty)
00048                {
00049                }
00050 
00051             LAYERREF (
00052                GRE_LAYER* lyr,
00053                ELEMTYPE et
00054                );
00055 
00056             LAYERREF(const LAYERREF& rhs) :
00057                m_ID(rhs.m_ID),
00058                m_layer(rhs.m_layer),
00059                m_ElemType(rhs.m_ElemType) 
00060                {
00061                   m_name = rhs.m_name ? ucstrdup(rhs.m_name) : 0;
00062                }
00063 
00064             ~LAYERREF() {
00065                MmFree(m_name);
00066                }
00067 
00068             LAYERREF& operator= (const LAYERREF& rhs) {
00069                if (this != &rhs) {
00070                   m_name = rhs.m_name ? ucstrdup(rhs.m_name) : 0;
00071                   m_ID = rhs.m_ID;
00072                   m_layer = rhs.m_layer;
00073                   m_ElemType = rhs.m_ElemType;
00074                   }
00075                return (*this);
00076                }
00077 
00078             //! Also sets m_name
00079             void SetLayer (
00080                GRE_LAYER* layer
00081                );
00082 
00083          };
00084          
00085       // GRE_LAYER_LEGEND2::DISPPARM
00086       class DISPPARM : public GRE_LAYER::DISPPARM {
00087          public:
00088 
00089             class DLG;
00090 
00091          /*=================This stuff must be saved/loaded by mdlegend.c=============*/
00092             GRAPHICLAYOUT m_grlayout;
00093             UINT32 m_NumLayers;
00094             LAYERREF* m_layers;
00095 
00096          /*=================This stuff is just internal=========================*/
00097 
00098             DISPPARM ();
00099             DISPPARM (const DISPPARM& rhs) {
00100                Copy(rhs);
00101                }
00102             ~DISPPARM () {
00103                Free();
00104                }
00105 
00106             DISPPARM& operator= (const DISPPARM& rhs) {
00107                if (this != &rhs) {
00108                   Free();
00109                   Copy(rhs);
00110                   }
00111                return (*this);
00112                }
00113 
00114             static void GRECB_LayerCallback (
00115                const GRE_CALLBACK_MSG* msg,
00116                void* cbdata
00117                );
00118 
00119             static int SerializerCB_GRLayout (
00120                SERIALIZER& serializer,
00121                const SERIALIZER::ITEMDEF *itemdef,
00122                void* cbdata,
00123                SERIALIZER::ITEMDEF::ACTION action
00124                );
00125 
00126 
00127             //! Returns index into m_layers array for given layer/elemtype
00128             //! Return -1 if not found, < -1 if error.
00129             INT32 GetLayerRefNum (
00130                GRE_LAYER* layer,
00131                ELEMTYPE ElemType,
00132                bool bAllocIfNotFound = false
00133                );
00134 
00135             void OnLayerChange (
00136                INT32 LayerRefNum,
00137                bool deleting
00138                );
00139 
00140             void OnLayoutLoaded (
00141                GRE_VIEWABLE* viewable
00142                );
00143 
00144          protected:
00145             virtual const SERIALIZER::ITEMDEF* SerialGetItemDef (SERIALIZER& serializer) const;
00146 
00147          private:
00148             #ifndef GENERATING_DOXYGEN_OUTPUT
00149             GRE_LAYER_LEGEND2* m_layer;      //!< Need it in a callback that only gets the DISPPARM
00150             void Copy (const DISPPARM&);
00151             void Free ();
00152             friend class GRE_LAYER_LEGEND2;
00153             #endif //!< GENERATING_DOXYGEN_OUTPUT
00154          };
00155 
00156       //! Callback for the "Add Legend" menu of GRE_LAYER_LEGEND.
00157    #ifndef WIN32_NATIVE
00158       static void CB_NewLegend2 (
00159          Widget w,
00160          void *vsubtype,
00161          void *
00162          );
00163    #endif
00164 
00165       //! Construct instance of this layer type
00166       static int Construct (
00167          GRE_GROUP *group,                      //!< Group to contain layer
00168          GRE_LAYER **retlayer,                  //!< Layer returned
00169          GRE_LAYER *reflayer,                   //!< Reference layer for insertion
00170          UINT32 flags                           //!< Creation flags
00171          );
00172 
00173       //! Register this layer type
00174       static void RegisterType (
00175          );
00176 
00177       //! Construct layer and insert into list
00178       explicit GRE_LAYER_LEGEND2 (
00179          GRE_GROUP *group,                      //!< Group to contain layer
00180          GRE_LAYER *reflayer = 0,               //!< Reference layer for insertion
00181          UINT32 flags = MDISPCREATE_InsertAfter //!< MDISPCREATE flags
00182          );
00183 
00184       virtual ~GRE_LAYER_LEGEND2 ();
00185 
00186       //! Retrieve layer-specific display parameters.
00187       const DISPPARM& GetDispParm (
00188          ) const { return (m_dispparm); }
00189 
00190       //! Return scale factor between legend's layout units and output "ground meters"
00191       double GetScaleFactor (
00192          ) const;
00193 
00194       //! Set layer-specific display parameters.
00195       //! This is the recommended method for changing how an existing layer is to be
00196       //! rendered.  Validation will be performed on the specified parameters and
00197       //! adjustments made to the layer's copy if necessary.  Use of this method
00198       //! usually result in a ChangeBegin / ChangeEnd message pair, and will also
00199       //! generate a ChangeObject message if the spatial object used in the layer
00200       //! is changed.
00201       ERRVALUE SetDispParm (
00202          const DISPPARM& dispparm               //!< Parameters to set
00203          );
00204 
00205       void SetLayout (
00206          const GRAPHICLAYOUT& grlayout
00207          );
00208 
00209    protected:
00210 
00211       DISPPARM m_dispparm;                      //!< Layer-specific display parameters
00212 
00213    private:
00214       #ifndef GENERATING_DOXYGEN_OUTPUT
00215 
00216    #ifndef WIN32_NATIVE
00217       static void CB_CreateDialog (Widget, void*, void*);
00218    #endif
00219 
00220       static void GRECB_LayoutLoaded (const GRE_CALLBACK_MSG* msg, void* cbdata);
00221 
00222       //! Overrides from GRE_LAYER.
00223    #if defined(X_NATIVE) || defined(WIN32_MFC)
00224       virtual int v_ControlPanel (MDLGPARENT dlgparent,UINT32 flags = 0);
00225    #endif
00226       virtual ERRVALUE v_Draw (GRE_LAYERDC& layerdc);
00227       virtual const char* v_SerialGetTagName () const;
00228       virtual void v_SetDftName (bool ReplaceExisting);
00229       virtual ERRVALUE v_TemplateRead (SERIALIZER& serializer);
00230       virtual int v_UpdateExtents (bool forceupdate);
00231       virtual bool v_UsesTransparency (const MGD::CONTEXT* gc = 0) const;
00232 
00233       friend class GRE_LAYER_LEGEND2::DISPPARM; //!< Need access to private static GRECB_LayoutLoaded()
00234 
00235       #endif //!< GENERATING_DOXYGEN_OUTPUT
00236    };
00237 
00238 //===================================================================================================================
00239 
00240 
00241 #endif   //!< INC_GRE_LRLEGND2_H

Generated on Thu Aug 12 06:18:25 2004 for TNTsdk by doxygen 1.3.4-20031026