viewscript.h

Go to the documentation of this file.
00001 /**
00002  * \file gre/viewscript.h
00003  * \brief GRE::VIEWSCRIPT and related class definitions
00004  *
00005  * \if NODOC
00006  * $Id: viewscript.h_v 1.9 2003/11/10 18:44:03 mju Exp $
00007  *
00008  * $Log: viewscript.h_v $
00009  * Revision 1.9  2003/11/10 18:44:03  mju
00010  * Obtain filepath from viewable after edit script if is from viewable.
00011  *
00012  * Revision 1.8  2003/10/02 16:18:21  linux32build!build
00013  * Doxygen
00014  *
00015  * Revision 1.7  2003/09/23 13:05:34  mju
00016  * Fix compiler warnings.
00017  *
00018  * Revision 1.6  2003/09/15 13:48:59  fileserver!dwilliss
00019  * Doxygen
00020  *
00021  * Revision 1.5  2003/09/09 16:22:24  mju
00022  * Add SetFilePath method.
00023  *
00024  * Revision 1.4  2003/07/30 15:50:04  mju
00025  * Ignore forward decls.
00026  *
00027  * Revision 1.3  2003/06/30 20:08:39  mju
00028  * Now keeps script with macroscript context.
00029  *
00030  * Revision 1.2  2003/06/24 16:25:24  mju
00031  * Support saving scripts with viewable.
00032  *
00033  * Revision 1.1  2003/06/16 19:40:49  mju
00034  * Initial revision
00035  * \endif
00036 **/
00037 
00038 #ifndef  INC_GRE_VIEWSCRIPT_H
00039 #define  INC_GRE_VIEWSCRIPT_H
00040 
00041 #ifndef  INC_GRE_BASE_H
00042    #include <gre/base.h>
00043 #endif
00044 
00045 #ifndef  INC_MI32_FILEPATH_H
00046    #include <mi32/filepath.h>
00047 #endif
00048 
00049 #ifndef  INC_MI32_FIXEDSTR_H
00050    #include <mi32/fixedstr.h>
00051 #endif
00052 
00053 #ifndef  INC_MI32_MICON_H
00054    #include <mi32/micon.h>
00055 #endif
00056 
00057 #ifndef  INC_MI32_SERIALIZ_H
00058    #include <mi32/serializ.h>
00059 #endif
00060 
00061 #ifndef  INC_MI32_SIMPLEAR_H
00062    #include <mi32/simplear.h>
00063 #endif
00064 
00065 #if !defined(INC_MI32_XDEFNS_H) && defined(X_NATIVE)
00066    #include <mi32/xdefns.h>
00067 #endif
00068 
00069 #ifndef GENERATING_DOXYGEN_OUTPUT
00070 struct SMLCONTEXT;
00071 class SMLSYMBOL;
00072 #endif // GENERATING_DOXYGEN_OUTPUT
00073 
00074 #ifdef X_NATIVE
00075 namespace GRE {
00076 
00077 //===================================================================================================================
00078 
00079 class VIEWSCRIPT : public SERIALIZABLE {
00080    public:
00081 
00082       class CONTEXT;
00083 
00084       //! Default Constructor.
00085       VIEWSCRIPT ();
00086 
00087       //! Copy constructor.
00088       VIEWSCRIPT (
00089          const VIEWSCRIPT& rhs
00090          ): SERIALIZABLE(rhs) { Copy(rhs); }
00091 
00092       //! Destructor.
00093       virtual ~VIEWSCRIPT ();
00094 
00095       //! Assignment operator.
00096       VIEWSCRIPT& operator= (
00097          const VIEWSCRIPT& rhs
00098          ) { if (this != &rhs) { MiconDestroy(m_icon); Copy(rhs); } return (*this); }
00099 
00100       virtual void IniWrite (
00101          const char* IniGroup,
00102          const char* IniBaseName
00103          ) const;
00104 
00105       virtual int Load (
00106          const char* IniGroup = 0,
00107          const char* IniBaseName = 0
00108          );
00109 
00110       bool EditProperties (
00111          MDLGPARENT dlgparent,
00112          GRE_VIEWABLE *viewable,
00113          GRE_VIEW *view,
00114          bool CanChangeSet
00115          );
00116 
00117       //! @return TRUE if changed, FALSE if not, < 0 if error
00118       int EditScript (
00119          Widget pwidget,
00120          SMLCONTEXT* smlcontext
00121          );
00122 
00123       const FILEPATH& GetFilePath (
00124          ) const { return (m_filepath); }
00125 
00126       const MICON GetIcon (
00127          ) const {
00128          if (m_icon == 0) {
00129             MiconCreate(&m_icon,m_IconGroup,m_IconName,0,16,16,MICONFLAG_DefaultBackground);
00130             }
00131          return (m_icon);
00132          }
00133 
00134       const char* GetIconGroup (
00135          ) const { return (m_IconGroup); }
00136 
00137       const char* GetIconName (
00138          ) const { return (m_IconName); }
00139 
00140       const UNICODE* GetName (
00141          ) const { return (m_name); }
00142 
00143       const MISTRING& GetScriptString (
00144          ) const { return (m_scriptstr); }
00145 
00146       bool GetShowIcon (
00147          ) const { return (m_ShowIcon); }
00148 
00149       bool IsFromViewable (
00150          ) const { return (m_FromViewable); }
00151 
00152       ERRVALUE Load (
00153          const FILEPATH& filepath
00154          ) { m_filepath = filepath; return (Load()); }
00155 
00156       bool SelectIcon (
00157          MDLGPARENT dlgparent
00158          );
00159 
00160       void SetFilePath (
00161          const FILEPATH& filepath
00162          ) { m_filepath = filepath; }
00163 
00164       void SetFromViewable (
00165          bool FromViewable = true
00166          ) { m_FromViewable = FromViewable; }
00167 
00168       void SetName (
00169          const UNICODE *name
00170          ) { m_name = name; }
00171 
00172       void SetShowIcon (
00173          bool ShowIcon
00174          ) { m_ShowIcon = ShowIcon; }
00175 
00176    protected:
00177 
00178       //! Get serialization item definition table.
00179       static const SERIALIZER::ITEMDEF* SerialGetItemDef (
00180          );
00181 
00182    private:
00183       #ifndef GENERATING_DOXYGEN_OUTPUT
00184 
00185       FILEPATH m_filepath;
00186       INT32 m_inode;
00187       MISTRING m_scriptstr;
00188       FIXEDSTRING<64> m_name;
00189       char m_IconGroup[16];
00190       char m_IconName[16];
00191       mutable MICON m_icon;
00192       bool m_ShowIcon;
00193       bool m_FromViewable;
00194 
00195       void Copy (const VIEWSCRIPT& rhs);
00196 
00197       virtual bool v_EditProperties (
00198          MDLGPARENT dlgparent,
00199          GRE_VIEWABLE *viewable,
00200          GRE_VIEW *view,
00201          bool CanChangeSet
00202          ) = 0;
00203 
00204       #endif // GENERATING_DOXYGEN_OUTPUT
00205    };
00206 
00207 
00208 //===================================================================================================================
00209 
00210 class VIEWSCRIPT::CONTEXT {
00211    public:
00212 
00213       SMLCONTEXT* GetSMLContext (
00214          ) const { return (m_smlcontext); }
00215 
00216       ERRVALUE ParseScript (
00217          const VIEWSCRIPT& script
00218          );
00219 
00220    protected:
00221 
00222       CONTEXT (
00223          GRE_VIEWABLE *viewable,
00224          GRE_VIEW *view
00225          );
00226 
00227       ~CONTEXT ();
00228 
00229    private:
00230       #ifndef GENERATING_DOXYGEN_OUTPUT
00231       SMLCONTEXT *m_smlcontext;
00232 
00233       CONTEXT (const CONTEXT&);
00234       CONTEXT& operator= (const CONTEXT&);
00235 
00236       #endif // GENERATING_DOXYGEN_OUTPUT
00237    };
00238 
00239 
00240 //===================================================================================================================
00241 
00242 class MACROSCRIPT : public VIEWSCRIPT {
00243    public:
00244 
00245       enum BUTTONTYPE {
00246          BUTTONTYPE_Simple =  0,
00247          BUTTONTYPE_Menu =    1
00248          };
00249 
00250       class CONTEXT;
00251 
00252       //! Default constructor.
00253       MACROSCRIPT (
00254          ): m_ButtonType(BUTTONTYPE_Simple) { }
00255 
00256       //! Copy constructor.
00257       MACROSCRIPT (
00258          const MACROSCRIPT& rhs
00259          );
00260 
00261       //! Destructor.
00262       virtual ~MACROSCRIPT (
00263          );
00264 
00265       //! Assignment.
00266       MACROSCRIPT& operator= (
00267          const MACROSCRIPT& rhs
00268          );
00269 
00270       BUTTONTYPE GetButtonType (
00271          ) const { return (static_cast<BUTTONTYPE>(m_ButtonType)); }
00272 
00273       const MISTRINGLIST& GetMenuChoiceList (
00274          ) const { return (m_MenuChoiceList); }
00275 
00276       virtual void IniWrite (
00277          const char* IniGroup,
00278          const char* IniBaseName
00279          ) const;
00280 
00281       virtual int Load (
00282          const char* IniGroup = 0,
00283          const char* IniBaseName = 0
00284          );
00285 
00286       virtual ERRVALUE SerialRead (
00287          SERIALIZER& serializer
00288          );
00289 
00290       virtual ERRVALUE SerialWrite (
00291          SERIALIZER& serializer,
00292          const char *tagname = 0
00293          ) const;
00294 
00295       void SetButtonType (
00296          BUTTONTYPE ButtonType
00297          ) { m_ButtonType = static_cast<UINT8>(ButtonType); }
00298 
00299       void SetMenuChoices (
00300          const MISTRING& string
00301          );
00302 
00303    private:
00304       #ifndef GENERATING_DOXYGEN_OUTPUT
00305 
00306       UINT8 m_ButtonType;
00307       MISTRINGLIST m_MenuChoiceList;
00308 
00309       static ERRVALUE SerialCB_MenuChoice (SERIALIZER&, const SERIALIZER::ITEMDEF*, MACROSCRIPT *script, SERIALIZER::ITEMDEF::ACTION);
00310       static const SERIALIZER::ITEMDEF* SerialGetItemDef ();
00311 
00312       virtual bool v_EditProperties (
00313          MDLGPARENT dlgparent,
00314          GRE_VIEWABLE *viewable,
00315          GRE_VIEW *view,
00316          bool CanChangeSet
00317          );
00318 
00319       #endif // GENERATING_DOXYGEN_OUTPUT
00320    };
00321 typedef MILIST<MACROSCRIPT> MACROSCRIPTLIST;
00322 
00323 //! Dialog to edit list of MacroScripts for specified viewable and optional view.
00324 //! @return true if changed, false if not.
00325 bool DlgEditMacroScriptList (
00326    MDLGPARENT dlgparent,
00327    MACROSCRIPTLIST& ScriptList,
00328    GRE_VIEWABLE *viewable,
00329    GRE_VIEW *view = 0
00330    );
00331 
00332 
00333 //===================================================================================================================
00334 
00335 class MACROSCRIPT::CONTEXT : public VIEWSCRIPT::CONTEXT {
00336    public:
00337 
00338       //! Constructor.
00339       CONTEXT (
00340          GRE_VIEWABLE *viewable,
00341          GRE_VIEW *view,
00342          bool AddAllSymbols = false
00343          );
00344 
00345       //! Destructor.
00346       virtual ~CONTEXT ();
00347 
00348       bool AddCtrlToMenu (
00349          Widget MenuPane
00350          );
00351 
00352       bool AddCtrlToToolBar (
00353          Widget ToolBar
00354          );
00355 
00356       ERRVALUE Create (
00357          const MACROSCRIPT& script
00358          );
00359 
00360       const MISTRINGLIST& GetMenuChoiceList (
00361          ) const { return (m_script.GetMenuChoiceList()); }
00362 
00363       ERRVALUE Run (
00364          );
00365 
00366       ERRVALUE Run (
00367          const UNICODE* menuchoice
00368          );
00369 
00370    private:
00371       #ifndef GENERATING_DOXYGEN_OUTPUT
00372 
00373       MACROSCRIPT m_script;
00374       SMLSYMBOL *m_MenuChoiceSym;
00375 
00376       void GetMenuItems (SIMPLE_ARRAY<MENUITEM>& MenuItems) const;
00377 
00378       CONTEXT (const CONTEXT&);
00379       CONTEXT& operator= (const CONTEXT&);
00380       #endif // GENERATING_DOXYGEN_OUTPUT
00381    };
00382 
00383 //===================================================================================================================
00384 
00385 class TOOLSCRIPT : public VIEWSCRIPT {
00386    public:
00387 
00388       TOOLSCRIPT () { }
00389 
00390       TOOLSCRIPT (
00391          const TOOLSCRIPT& rhs
00392          ): VIEWSCRIPT(rhs) { }
00393 
00394       virtual ~TOOLSCRIPT (
00395          ) { }
00396 
00397       TOOLSCRIPT& operator= (
00398          const TOOLSCRIPT& rhs
00399          ) {
00400          if (this != &rhs) {
00401             static_cast<VIEWSCRIPT*>(this)->operator=(rhs);
00402             }
00403          return (*this);
00404          }
00405 
00406       virtual ERRVALUE SerialRead (
00407          SERIALIZER& serializer
00408          );
00409 
00410       virtual ERRVALUE SerialWrite (
00411          SERIALIZER& serializer,
00412          const char *tagname = 0
00413          ) const;
00414 
00415    private:
00416       #ifndef GENERATING_DOXYGEN_OUTPUT
00417 
00418       virtual bool v_EditProperties (
00419          MDLGPARENT dlgparent,
00420          GRE_VIEWABLE *viewable,
00421          GRE_VIEW *view,
00422          bool CanChangeSet
00423          );
00424 
00425       #endif // GENERATING_DOXYGEN_OUTPUT
00426    };
00427 typedef MILIST<TOOLSCRIPT> TOOLSCRIPTLIST;
00428 
00429 //! Dialog to edit list of ToolScripts for specified viewable and optional view.
00430 //! @return true if changed, false if not.
00431 bool DlgEditToolScriptList (
00432    MDLGPARENT dlgparent,
00433    TOOLSCRIPTLIST& ScriptList,
00434    GRE_VIEWABLE *viewable,
00435    GRE_VIEW *view = 0
00436    );
00437 
00438 
00439 }  // End namespace GRE
00440 #endif
00441 
00442 //===================================================================================================================
00443 
00444 #endif   // INC_GRE_VIEWSCRIPT_H

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