]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - tools/src/tools/configtool/standalone/wxwin/configtooldoc.h
Initial revision
[karo-tx-redboot.git] / tools / src / tools / configtool / standalone / wxwin / configtooldoc.h
1 //####COPYRIGHTBEGIN####
2 //
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5 //
6 // This program is part of the eCos host tools.
7 //
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
11 // any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16 // more details.
17 //
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 //
22 // ----------------------------------------------------------------------------
23 //
24 //####COPYRIGHTEND####
25 // configtooldoc.h :
26 //
27 //===========================================================================
28 //#####DESCRIPTIONBEGIN####
29 //
30 // Author(s):   julians
31 // Contact(s):  julians
32 // Date:        2000/10/05
33 // Version:     $Id$
34 // Purpose:
35 // Description: Header file for ecConfigToolDoc
36 // Requires:
37 // Provides:
38 // See also:
39 // Known bugs:
40 // Usage:
41 //
42 //####DESCRIPTIONEND####
43 //
44 //===========================================================================
45
46 #ifndef _ECOS_CONFIGTOOLDOC_H_
47 #define _ECOS_CONFIGTOOLDOC_H_
48
49 #ifdef __GNUG__
50 #pragma interface "configtooldoc.h"
51 #endif
52
53 #include "cdl.hxx"
54
55 #include "configitem.h"
56
57 #if ecUSE_MLT
58 #include "memmap.h"
59 #endif
60
61 class ecConfigItem;
62
63 // Tell OnCreate to prompt for a repository instead of just loading it silently
64 #define ecDOC_PROMPT_FOR_REPOSITORY 8
65
66 /*
67  * ecConfigToolDoc
68  * Holds the saveable configtool information
69  */
70
71 class ecConfigToolDoc: public wxDocument
72 {
73     DECLARE_DYNAMIC_CLASS(ecConfigToolDoc)
74 public:
75     ecConfigToolDoc();
76     ~ecConfigToolDoc();
77
78 //// Overrides
79     virtual bool OnCreate(const wxString& path, long flags);
80     virtual bool OnOpenDocument(const wxString& filename);
81     virtual bool OnSaveDocument(const wxString& filename);
82     virtual bool OnNewDocument() { return TRUE; }
83     virtual bool OnCloseDocument() ;
84     virtual bool Save(); // Overridden only to correct bug in wxWindows, docview.cpp
85
86 //// Error and other handlers
87     static void CdlLoadErrorHandler(std::string message);
88     static void CdlLoadWarningHandler(std::string message);
89     static void CdlParseErrorHandler (std::string message);
90     static void CdlParseWarningHandler (std::string message);
91     static void CdlTransactionHandler (const CdlTransactionCallback & data);
92     static CdlInferenceCallbackResult CdlInferenceHandler (CdlTransaction data);
93     static CdlInferenceCallbackResult CdlGlobalInferenceHandler(CdlTransaction data);
94
95 //// Accessors
96     CdlPackagesDatabase GetCdlPkgData () { return m_CdlPkgData; }
97     CdlConfiguration GetCdlConfig () { return m_CdlConfig; }
98     CdlInterpreter GetCdlInterpreter() { return m_CdlInterp; }
99
100     // Absolute path name to root of respository - parent of PackagesDir below
101     void SetRepository(const wxString& pszRepository)  { m_strRepository = ecFileName(pszRepository); }
102     const ecFileName& GetRepository() const { return m_strRepository; }
103
104     wxString GetDefaultHardware () ;
105         const wxString& GetTemplateVersion() const { return m_templateVersion; }
106     wxString GetPackageName (const wxString & strAlias);
107
108     // Absolute path name to "packages" directory - i.e. the one under the repository
109     // named "packages" in a delivery or "ecc" in CVS:
110     const ecFileName& GetPackagesDir() const { return m_strPackagesDir; }   
111
112     const wxString& GetInstallTree() const { return m_strInstallTree; }
113     const wxString& GetBuildTree() const { return m_strBuildTree; }
114     void SetInstallTree(const wxString& str) { m_strInstallTree = str; }
115     void SetBuildTree(const wxString& str) { m_strBuildTree = str; }
116
117     wxList& GetItems() { return m_items; }
118     ecConfigItem* GetItem(size_t i) { return (ecConfigItem*) m_items[i]; }
119
120     CdlBuildInfo& GetBuildInfo() { return m_BuildInfo; }
121
122     ecConfigItem* GetFirstItem() { return (m_items.Number() == 0 ? (ecConfigItem*) NULL : (ecConfigItem*) m_items.First()->Data()); }
123
124     const wxString GetCurrentTargetPrefix();
125
126     const wxString HTMLHelpLinkFileName();
127
128     const ecFileName MLTDir ();
129     const ecFileName CurrentLinkerScript();
130     const wxString CurrentMemoryLayout ();
131
132     const ecFileName GetDocBase() const { return GetRepository() + wxT("doc"); }
133
134 //// Operations
135     bool OpenRepository(const wxString& pszRepository = wxEmptyString, bool bPromptInitially=FALSE) ;
136     bool OpenRepository (ecFileName& strNewRepository, CdlPackagesDatabase &NewCdlPkgData,CdlInterpreter &NewCdlInterp,CdlConfiguration &NewCdlConfig, wxString &strNewPackagesDir);
137     void CloseRepository() ;
138     // Find a valid repository given a directory name
139     bool FindRepository (ecFileName& repositoryIn, ecFileName& repositoryOut) const;
140     void EnableCallbacks (bool bEnable=TRUE);
141     void AddContents (const CdlContainer container, ecConfigItem *pParent);
142     void AddAllItems();
143     ecConfigItem* AddItem (const CdlUserVisible vitem, ecConfigItem * pParent);
144     void DeleteItems();
145
146     // Use the wxHtmlHelpController
147     bool ShowInternalHtmlHelp (const wxString& strURL);
148
149     // Use an external browser
150     bool ShowExternalHtmlHelp (const wxString& strURL);
151
152     bool ShowURL(const wxString& strURL);
153     // If prefix is TRUE, add file:// to beginning
154     bool QualifyDocURL(wxString &strURL, bool prefix = TRUE);
155     void CheckRadios();
156     bool GenerateHeaders();
157     bool ExportFile();
158     bool ImportFile();
159     void RunTests();
160
161     // A standalone method for generating a build tree without saving first
162     bool GenerateBuildTree();
163     // Can we generate the build tree yet?
164     bool CanGenerateBuildTree() ;
165
166     void SelectTemplate (const wxString& newTemplate, const wxString& newTemplateVersion);
167     void SelectHardware (const wxString& newTemplate);
168     void SelectPackages ();
169         void RegenerateData();
170     bool UpdateBuildInfo(bool bFirstTime=FALSE);
171     int GetTestExeNames (wxArrayString& arTestExes, wxArrayString& arMissing) ;
172     bool SaveMemoryMap();
173     bool CopyMLTFiles();
174     bool SwitchMemoryLayout (bool bNewTargetPlatform);
175     bool NewMemoryLayout (const wxString &strPrefix);
176
177         // Find the ecConfigItem referencing the given CdlValuable
178         ecConfigItem * Find (CdlValuable v);
179         ecConfigItem * Find(const wxString & strWhat, ecWhereType where = ecInMacro);
180
181     enum GlobalConflictOutcome {OK,Cancel,NotDone};
182     // Resolve conflicts
183     GlobalConflictOutcome ResolveGlobalConflicts(wxList *parConflictsOfInterest=NULL);
184     bool CheckConflictsBeforeSave();
185     void LogConflicts (const std::list<CdlConflict> & conflicts);
186     void UpdateFailingRuleCount();
187
188     bool SetValue(ecConfigItem &ti, long nValue, CdlTransaction transaction = NULL);
189     bool SetValue(ecConfigItem &ti, const wxString &strValue, CdlTransaction transaction = NULL);
190     bool SetValue (ecConfigItem &ti, double dValue, CdlTransaction transaction = NULL);
191     bool SetEnabled(ecConfigItem &ti, bool bEnabled, CdlTransaction transaction = NULL);
192
193     // Rebuild the .hhc, .hhp, .hhk files and reinitialize the help controller
194     bool RebuildHelpIndex(bool force = TRUE);
195
196 protected:
197     CdlPackagesDatabase m_CdlPkgData;
198     CdlInterpreter      m_CdlInterp;
199     CdlConfiguration    m_CdlConfig;
200     wxString            m_templateVersion;
201     ecFileName          m_strPackagesDir;
202     wxString            m_strCdlErrorMessage;
203     wxString            m_strMemoryLayoutFolder;
204     wxString            m_strLinkerScriptFolder;
205     ecFileName          m_strBuildTree;
206     ecFileName          m_strInstallTree;
207     wxList              m_items;
208     CdlBuildInfo                m_BuildInfo;
209
210     // This data supports communication of information to the failing rules dialog invoked by CdlGlobalInferenceHandler():
211     GlobalConflictOutcome m_ConflictsOutcome;
212     wxList              m_arConflictsOfInterest; // used by CRulesView::OnResolve (TODO change comment)
213
214 public:
215     ecFileName          m_strRepository;
216     bool                m_bRepositoryOpen;
217
218 #if ecUSE_MLT
219     mem_map             m_memoryMap;
220     wxString            m_strSelectedSection;
221     wxString            m_strSelectedRegion;
222 #endif
223 };
224
225
226 #endif
227         // _ECOS_CONFIGTOOLDOC_H_