GME  13
GMEApp.h
Go to the documentation of this file.
00001 // GMEApp.h : main header file for the GME application
00002 //
00003 
00004 #if !defined(AFX_GME_H__BD235B4A_BD3F_11D3_91E2_00104B98EAD9__INCLUDED_)
00005 #define AFX_GME_H__BD235B4A_BD3F_11D3_91E2_00104B98EAD9__INCLUDED_
00006 
00007 #if _MSC_VER > 1000
00008 #pragma once
00009 #endif // _MSC_VER > 1000
00010 
00011 #ifndef __AFXWIN_H__
00012         #error include 'stdafx.h' before including this file for PCH
00013 #endif
00014 
00015 #include "resource.h"       // main symbols
00016 #include <set>
00017 #include <map>
00018 #include "GMELib.h"
00019 
00020 #define ID_FILE_PLUGINMENU 40000
00021 
00022 
00023 #include "RecentConnStrList.h"
00024 
00026 // CGMEApp:
00027 // See GMEApp.cpp for the implementation of this class
00028 //
00029 
00030 extern LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
00031 extern HINSTANCE GotoURL(LPCTSTR url, int showcmd);
00032 
00033 
00034 struct IMgaProject;
00035 struct IMgaMetaProject;
00036 class CGuiMetaProject;
00037 class CGuiPreferenceManager;
00038 
00039 class CGMEApp : public CWinAppEx
00040 {
00041         friend class CGMEOLEApp;
00042 public:
00043         virtual BOOL PreTranslateMessage(MSG* pMsg);
00044         CGMEApp();
00045         virtual ~CGMEApp();
00046 
00047         CMultiDocTemplate* pDocTemplate;
00048         CComPtr<IMgaProject> mgaProject;
00049         CComPtr<IMgaClient> mgaClient;
00050         CComPtr<IMgaMetaProject> mgaMetaProject;
00051 //  dynamic menus
00052         CStringArray plugins, interpreters, addons;
00053     CStringArray pluginTooltips, interpreterTooltips, addonToolTips;
00054         bool dynmenus_need_refresh;
00055 
00056         // Application look
00057         UINT  m_nAppLook;
00058         CMFCToolBarImages m_userImages;
00059         CComPtr<IMgaComponentEx> mgaConstMgr;
00060         CGuiMetaProject *guiMetaProject;
00061         CString projectName;
00062         CString bitmapPath, projectDir, paradigmDir;
00063         bool    multipleView;
00064         bool    useAutoRouting;
00065         bool    labelAvoidance;
00066 
00067         HACCEL m_GMEView_hAccel;
00068         CRecentConnStrList m_RecentProjectList;
00069         bool bNoProtect;   // do not catch application errors
00070         inline bool isMultiUserProj() const { return proj_type_is_xmlbackend; }
00071         inline bool isMgaProj()       const { return proj_type_is_mga; }
00072         inline CString connString() const { return currentConnection; }
00073 
00074         void getMgaPaths(CString& filename, CString& dirname) {
00075                 ASSERT(isMgaProj());
00076                 ASSERT(mgaProject);
00077                 CString conn = connString();
00078                 const TCHAR* zsConn = conn;
00079                 zsConn += 4; // skip MGA=
00080                 GetFullPathName(zsConn, filename, dirname);
00081         }
00082 
00083         BOOL OpenCommandLineProject();
00084         BOOL ShowWelcomeWindow();
00085 
00086 private:
00087         virtual int Run();
00088         void EmergencySave();
00089         bool proj_type_is_mga;
00090         bool proj_type_is_xmlbackend;
00091         bool abort_on_close;
00092         CString currentConnection;
00093 
00094         bool autosaveEnabled;
00095         bool autosaveUseDir;
00096         CString autosaveDir;
00097         int  autosaveFreq;
00098         CString defZoomLev;
00099         bool mouseOverNotify;
00100         CString realFmtStr;
00101         bool maintainHistory;
00102 
00103         //
00104         // component filter related fields
00105         //
00106 
00107         // the state of component filtering (not preserved through GME sessions)
00108         bool m_compFilterOn;
00109 
00110         // will store those command ids, which are disabled by the user 
00111         // through the ActivateComponent
00112         typedef std::set<unsigned int> ONE_ID_LIST;
00113         ONE_ID_LIST m_vecDisabledPlugIns;
00114         ONE_ID_LIST m_vecDisabledComps;
00115 
00116         typedef std::set<CString> ONE_COMP_LIST;
00117         typedef std::map<CString, ONE_COMP_LIST > ONE_COMP_MAP;
00118         // map of kind as key, and components registered for it
00119         ONE_COMP_MAP m_compsOfKind;
00120 
00121         //
00122         // component filter related private methods
00123         //
00124         void ClearDisabledComps();
00125 
00126         // Updates the plugins and addons on the component toolbar
00127         void CGMEApp::UpdateComponentToolbar();
00128 
00129         //
00130         // component filter related public methods
00131         //
00132 public:
00133         // called from CGMEOLEApp:
00134         void SetCompFiltering( bool pOn);
00135         bool GetCompFiltering();
00136         void DisableComp(const CString& pCompToFind, bool pbHide);
00137         void DisableCompForKinds( const CString& pComp, const CString& pKindSeq);
00138         // called from CGMEView:
00139         void UpdateCompList4CurrentKind( const CString& kind);
00140 
00141         static const TCHAR * m_no_model_open_string;
00142 
00143         // called from CGMEOLEAPP:
00144         bool SetWorkingDirectory( LPCTSTR pPath);
00145 
00146 public:
00147         void ImportDroppedFile(const CString& fname);
00148         void RegisterDroppedFile( const CString& fname, bool userReg = true);
00149         bool SafeCloseProject();
00150         void CloseProject(bool updateStatusBar = true, bool force_abort=false);
00151         void OpenProject(const CString &conn);
00152         void Importxml(CString fullPath, CString fname, CString ftitle);
00153         void SaveProject(const CString &conn);
00154         void CreateProject(const CString &metaname, const CString &dataconn);
00155         void UpdateProjectName(bool retrievePath = false);
00156         void UpdateMainFrameTitle(const CString& projName, bool retrievePath = false);
00157         void AfterOpenOrCreateProject(const CString &conn);
00158         void UpdateComponentLists(bool restart_addons =  false);
00159         void UpdateDynMenus(CMenu *filemenu);
00160         void FindConstraintManager();
00161         void RunComponent(const CString &progid);
00162         void exit() { OnAppExit(); }
00163         void consoleMessage( const CString& p_msg, short type);
00164 
00165         void Autosave();
00166         CString getDefZoomLev() { return defZoomLev; }
00167         inline bool isMouseOverNotifyEnabled() { return mouseOverNotify; }
00168         inline bool isHistoryEnabled() { return maintainHistory; }
00169         inline CString getRealFmtStr() { return realFmtStr; }
00170 
00171         // Both empty: reset on close, only one empty: no change to that name.
00172         void ChangedProjectConnStrings();
00173         void GetSettings();
00174 
00175         void UpdateMainTitle(bool retrievePath = false);
00176         bool IsUndoPossible(void) const;
00177 
00178 // Overrides
00179         // ClassWizard generated virtual function overrides
00180         //{{AFX_VIRTUAL(CGMEApp)
00181         public:
00182         virtual BOOL InitInstance();
00183         virtual int ExitInstance();
00184         virtual void OnAppExit();
00185         virtual BOOL SaveAllModified();
00186         //}}AFX_VIRTUAL
00187 
00188         void OnUniquePrintSetup();
00189 // Implementation
00190                 // Server object for document creation
00191         //{{AFX_MSG(CGMEApp)
00192         afx_msg void OnAppAbout();
00193         afx_msg void OnFileOpen();
00194         afx_msg void OnFileNew();
00195         afx_msg void OnUpdateRecentProjectMenu(CCmdUI* pCmdUI);
00196         afx_msg BOOL OnOpenRecentProject(UINT nID);
00197         afx_msg void OnUpdateFileCloseproject(CCmdUI* pCmdUI);
00198         afx_msg void OnFileCloseproject();
00199         afx_msg void OnUpdateFileNew(CCmdUI* pCmdUI);
00200         afx_msg void OnUpdateFileOpen(CCmdUI* pCmdUI);
00201         afx_msg void OnEditUndo();
00202         afx_msg void OnEditRedo();
00203         afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);
00204         afx_msg void OnUpdateFileExportxml(CCmdUI* pCmdUI);
00205         afx_msg void OnFileExportxml();
00206         afx_msg void OnFileImportxml();
00207         afx_msg void OnUpdateEditProjectproperties(CCmdUI* pCmdUI);
00208         afx_msg void OnEditProjectproperties();
00209         afx_msg void OnFileSettings();
00210         afx_msg void OnFileClearLocks();
00211         afx_msg void OnEditClearUndo();
00212         afx_msg void OnUpdateEditClearUndo(CCmdUI* pCmdUI);
00213         afx_msg void OnHelpContents();
00214         afx_msg void OnFileCheckall();
00215         afx_msg void OnUpdateFileCheckall(CCmdUI* pCmdUI);
00216         afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
00217         afx_msg void OnUpdateFileSaveAs(CCmdUI* pCmdUI);
00218         afx_msg void OnFileSaveAs();
00219         afx_msg void OnFileSave();
00220         afx_msg void OnFileAbortProject();
00221         afx_msg void OnUpdateFileAbortProject(CCmdUI* pCmdUI);
00222         afx_msg void OnFileRegcomponents();
00223         afx_msg void OnFileRegparadigms();
00224         afx_msg void OnUpdateFileRegcomponents(CCmdUI* pCmdUI);
00225         afx_msg void OnUpdateFileXMLUpdate(CCmdUI* pCmdUI);
00226         afx_msg void OnFileXMLUpdate();
00227         afx_msg void OnRunPlugin(UINT nID);
00228         afx_msg void OnRunInterpreter(UINT nID);
00229         afx_msg void OnUpdateFilePluginX(CCmdUI* pCmdUI);
00230         afx_msg void OnUpdateFileInterpretX(CCmdUI* pCmdUI);
00231         afx_msg void OnFileDisplayConstraints();
00232         afx_msg void OnUpdateFileDisplayConstraints(CCmdUI* pCmdUI);
00233         afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
00234         afx_msg void OnFocusBrowser();
00235         afx_msg void OnFocusInspector();
00236         //}}AFX_MSG
00237         DECLARE_MESSAGE_MAP()
00238 };
00239 
00240 extern CGMEApp theApp;
00241 
00243 
00245 // CDLLInfoDlg dialog
00246 
00247 class CDLLInfoDlg : public CDialog
00248 {
00249 // Construction
00250 public:
00251         CDLLInfoDlg(CWnd* pParent = NULL);   // standard constructor
00252 
00253 // Dialog Data
00254         //{{AFX_DATA(CDLLInfoDlg)
00255         enum { IDD = IDD_DLL_DIALOG };
00256         CListCtrl       m_DLLList;
00257         //}}AFX_DATA
00258 
00259 
00260 // Overrides
00261         // ClassWizard generated virtual function overrides
00262         //{{AFX_VIRTUAL(CDLLInfoDlg)
00263         protected:
00264         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00265         //}}AFX_VIRTUAL
00266 
00267 // Implementation
00268 protected:
00269 
00270         // Generated message map functions
00271         //{{AFX_MSG(CDLLInfoDlg)
00272         virtual BOOL OnInitDialog();
00273         //}}AFX_MSG
00274         DECLARE_MESSAGE_MAP()
00275 };
00276 //{{AFX_INSERT_LOCATION}}
00277 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00278 
00279 #endif // !defined(AFX_GME_H__BD235B4A_BD3F_11D3_91E2_00104B98EAD9__INCLUDED_)