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

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