root/trunk/MainFrm.h

Revision 5, 13.5 kB (checked in by qbert, 6 years ago)

Initial ( and last :( ) commit

Line 
1 // MainFrm.h : interface of the CMainFrame class
2 //
3 /////////////////////////////////////////////////////////////////////////////
4
5 #if !defined(AFX_MAINFRM_H__452DC860_01CF_40E7_9A8F_9B7B10747616__INCLUDED_)
6 #define AFX_MAINFRM_H__452DC860_01CF_40E7_9A8F_9B7B10747616__INCLUDED_
7
8 #if _MSC_VER > 1000
9 #pragma once
10 #endif // _MSC_VER > 1000
11
12 #include "OutputBarTab.h"
13 #include "TabDockWnd.h"
14 #include "FileComboBox.h"
15 #include "FindEdit.h"
16 #include "replaceEdit.h"
17 #include "ProjectFilesComboBox.h"
18 #include "AdvancedFindAndReplaceDlg.h"
19 #include "FileCodeComboBox.h"
20 #include "ConfigCombo.h"
21 #include "tagcombo.h"
22
23 class CMainFrame : public CXTMDIFrameWnd
24 {
25     DECLARE_DYNAMIC(CMainFrame)
26 public:
27     CMainFrame();
28
29     void CompileProject(ProjectSettings* p = NULL );
30     void CleanProject(ProjectSettings* p = NULL );
31   void ShowOutputWindow();
32     void BeginSimpleFind() ;
33   void FindSimpleString(const string& str);
34     void StartFindAtLastPos( ) ;
35     vector<string> GetAllNamedFiles(bool relative = false );
36
37    
38 // Attributes
39 public:
40
41 // Operations
42 public:
43
44 // Overrides
45     // ClassWizard generated virtual function overrides
46     //{{AFX_VIRTUAL(CMainFrame)
47     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
48     //}}AFX_VIRTUAL
49
50 // Implementation
51 public:
52     bool srandInit ;
53     virtual ~CMainFrame();
54 #ifdef _DEBUG
55     virtual void AssertValid() const;
56     virtual void Dump(CDumpContext& dc) const;
57 #endif
58
59 public:  // control bar embedded members
60     CFileTreeCtrl& GetFileTree()
61     {
62         return m_wndTabDockBar.m_wndTreeCtrl;
63     }
64
65     CCodeBrowsingTreeCtrl& GetCodeCtrl()
66     {
67         return m_wndTabDockBar.m_codeBrowser.m_tagTree;
68     }
69
70     string randomFile()
71     {
72         if ( !srandInit ) {
73             srand(time(0));
74             srandInit = true;
75         }
76         string alfa = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZX";
77         string ret = "";
78         for ( int i = 0 ; i < 15; i++ )
79         {
80             ret += alfa[rand() % 53];
81
82         }
83
84         string path = Globals::settings->baseSettings->GetCache("installPath") + "\\" + ret + "_random.d";
85        
86         return path;
87     }
88
89     string SaveTempFile(const string& buffer )
90     {
91
92         string path = randomFile();
93         ofstream out(path.c_str() );
94         out << buffer;
95         out.close();
96
97         return path;       
98
99     }
100     vector<ErrorPacket> CompileFile(const string & path );
101     void AddLogo();
102     void RemoveLogo();
103     //void StartProject(ProjectSettings* project);
104    
105     void DockControlBarLeftOf(CXTToolBar* Bar, CXTToolBar* LeftOf);
106
107     CElephantDoc* GetActiveDoc() {
108
109         CXTMDIChildWnd *pChild =
110             (CXTMDIChildWnd *) GetActiveFrame();
111         if (!pChild) return NULL;
112         CElephantDoc *pActiveDoc = (CElephantDoc*)pChild->GetActiveDocument(); 
113         if (!pActiveDoc) return NULL;
114         return pActiveDoc;
115        
116     }
117    
118     CElephantView* GetActiveView() {
119        
120         CXTMDIChildWnd *pChild =
121             (CXTMDIChildWnd *) GetActiveFrame();
122         if (!pChild) return NULL;
123         CElephantDoc *pActiveDoc = (CElephantDoc*)pChild->GetActiveDocument(); 
124         if (!pActiveDoc) return NULL;
125        
126         POSITION x = pActiveDoc->GetFirstViewPosition();
127         return (CElephantView*)pActiveDoc->GetNextView(x);
128        
129        
130     }
131
132     CScintillaCtrl& GetActiveCtrl()
133     {
134         if ( GetActiveView() ) return GetActiveView()->GetCtrl();
135     }
136
137     void GotoFileAndLineNumber(const string& path , int lineNumber , const string& error = "" );
138
139    
140
141     void ExecuteTool(int i );
142    
143     void SetStatusBarText(const string& text)
144     {
145         m_wndStatusBar.SetWindowText(text.c_str());
146     }
147
148     CScintillaCtrl& GetActiveToolOutput();
149    
150        
151     void UpdateProjectFileLists(ProjectSettings* project);
152     bool UpdateProjectNodeMenu( ProjectSettings* project);
153     bool UpdateRecentProjectsMenu() ;
154     bool UpdateToolsMenu();
155     bool UpdateConfigCombo();
156
157
158     void SaveAllNamedFiles()
159     {
160            
161         POSITION x = Globals::theApp.m_pDocTemplate->GetFirstDocPosition();     
162        
163         CElephantDoc* pDoc;
164         while (x) {
165             pDoc = (CElephantDoc*)Globals::theApp.m_pDocTemplate->GetNextDoc(x);   
166             CScintillaCtrl& rCtrl = pDoc->GetCtrl();
167    
168            
169    
170             CString path = pDoc->GetPathName() ;
171             if ( path != "" )
172             {
173                 if ( ! rCtrl.GetModify()  ) continue;
174            
175                 pDoc->OnFileSaveSavefile();
176            
177             }
178            
179         }
180
181    
182
183     }
184
185     vector<string> CloseAllNamedFiles()
186     {
187
188         vector<string > ret;
189         POSITION x = Globals::theApp.m_pDocTemplate->GetFirstDocPosition();     
190        
191         CElephantDoc* pDoc;
192         while (x) {
193             pDoc = (CElephantDoc*)Globals::theApp.m_pDocTemplate->GetNextDoc(x);   
194             CString path = pDoc->GetPathName() ;
195             if ( path != "" )
196             {
197                 ret.push_back(path.GetBuffer(0) );
198                 pDoc->OnFileSaveSavefile();
199                 pDoc->OnCloseDocument();
200             }
201            
202         }
203
204         return ret;
205
206     }
207     void ReloadNamedFile(CString& pathToReload);
208     void ReloadAllNamedFiles()
209     {
210
211
212         POSITION x = Globals::theApp.m_pDocTemplate->GetFirstDocPosition();     
213        
214         CElephantDoc* pDoc;
215         while (x) {
216             pDoc = (CElephantDoc*)Globals::theApp.m_pDocTemplate->GetNextDoc(x);   
217             CString path = pDoc->GetPathName() ;
218             if ( path != "" )
219             {
220                 POSITION vPos = pDoc->GetFirstViewPosition();
221                 CElephantView* view = (CElephantView* ) pDoc->GetNextView(vPos);
222                
223                 string file = ReadFile(path.GetBuffer(0));
224                 CScintillaCtrl& rCtrl = view->GetCtrl();
225                 rCtrl.SetText(file.c_str());
226                
227             }
228            
229         }
230        
231        
232
233
234     }
235     void ReopenFiles(const vector<string>& files)
236     {
237         for ( int i = 0 ; i < files.size(); i++ )
238         {
239             Globals::theApp.OpenFile(files[i]);
240         }
241                    
242        
243     }
244    
245     void  UpdateAllViews()
246     {
247         POSITION x = Globals::theApp.m_pDocTemplate->GetFirstDocPosition();     
248        
249         CElephantDoc* pDoc;
250         while (x) {
251             pDoc = (CElephantDoc*)Globals::theApp.m_pDocTemplate->GetNextDoc(x);   
252            
253        
254            
255             CElephantView* view;
256             POSITION vPos = pDoc->GetFirstViewPosition();
257             view = (CElephantView*) pDoc->GetNextView(vPos);
258             view->OnInitialUpdate();
259             pDoc->UpdateAllViews(0);           
260         }
261        
262        
263     }
264    
265     string GetSelectedRecentProject(int command) {
266        
267        
268         CString t;
269        
270         CMenu *mmenu = GetMenu();
271         int pos = FindMenuItem(mmenu, "&File");
272         if (pos == -1) {
273             return " [empty] ";
274         }
275        
276         // Remove "New" menu item from the File menu.
277         CMenu* submenu = mmenu->GetSubMenu(pos);
278         pos = FindMenuItem(submenu, "&Recent Projects");
279         if ( pos == -1 ) return " [empty] ";
280         CMenu* rpMenu = submenu->GetSubMenu(pos);
281         rpMenu->GetMenuString(command, t, MF_BYCOMMAND);
282        
283         return (LPCSTR)t;
284        
285        
286     }
287
288     string lastProjectExecutable;
289
290     void ActivateProjectNode(int i );
291    
292     afx_msg void OnProjectNodeSelected1();
293     afx_msg void OnProjectNodeSelected2();
294     afx_msg void OnProjectNodeSelected3();
295     afx_msg void OnProjectNodeSelected4();
296     afx_msg void OnProjectNodeSelected5();
297
298     afx_msg void OnRecentProjectSelected1();
299     afx_msg void OnRecentProjectSelected2();
300     afx_msg void OnRecentProjectSelected3();
301     afx_msg void OnRecentProjectSelected4();
302     afx_msg void OnRecentProjectSelected5();
303
304     afx_msg void OnTools1();
305     afx_msg void OnTools2();
306     afx_msg void OnTools3();
307     afx_msg void OnTools4();
308     afx_msg void OnTools5();
309     afx_msg void OnTools6();
310     afx_msg void OnTools7();
311     afx_msg void OnTools8();
312     afx_msg void OnTools9();
313    
314
315     int cRet, lRet;
316     CXTLogoPane      m_wndLogoPane;
317     //COutputBar     m_wndOutputBar;
318     COutputBarTab     m_wndOutputBar;
319     CTabDockWnd    m_wndTabDockBar;
320     CXTStatusBar     m_wndStatusBar;
321     CXTToolBar       m_wndToolBar;
322     CXTToolBar       m_wndCodeToolBar;
323     CXTToolBar       m_wndFileToolBar;
324     CXTToolBar       m_wndConfigToolbar;
325    
326     CProjectFilesComboBox m_fileComboBox;
327     CFileComboBox m_fileHistoryComboBox;
328     CConfigCombo m_configComboBox;
329    
330    
331     CFileCodeComboBox m_fileTagComboBox;
332     CTagCombo m_tagComboBox;
333     CXTToolBar       m_wndFindToolBar;
334     CFindEdit m_findEdit;
335     CReplaceEdit m_replaceEdit;
336     CXTMDIWndTab m_wndMDITabWindow;
337    
338     bool m_simpleFindNeedsBegin;
339     int m_simpleFindLastPos;
340     int m_gotoPos;
341     vector<int> m_gotoLines;
342     vector<string> m_gotoFiles;
343     int currentErrorNumber;
344
345     CImageList m_imageList;
346     CBitmap m_bitmap;
347    
348
349     CImageList m_imageList2;
350     CBitmap m_bitmap2;
351
352     CImageList m_comboImageList;
353     CBitmap m_comboBitmap;
354    
355    
356 // Generated message map functions
357 protected:
358     CXTWindowPos     m_wndPosition;
359
360 public:
361     // Overrode CWnd implementation to restore saved window position.
362     BOOL ShowWindowEx(int nCmdShow);
363 afx_msg void OnViewMinimizeview();
364 protected:
365     //{{AFX_MSG(CMainFrame)
366     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
367     afx_msg void OnClose();
368     afx_msg void OnSettingsSettings();
369     afx_msg void OnFileNewNewproject();
370     afx_msg void OnFileNewNewaddprojectwizard();
371     afx_msg void OnRegistersStoreinregister1();
372     afx_msg void OnRegistersStoreinregister2();
373     afx_msg void OnRegistersStoreinregister3();
374     afx_msg void OnRegistersStoreinregister4();
375     afx_msg void OnRegistersStoreinregister5();
376     afx_msg void OnSettingsProjectsettings();
377     afx_msg void OnToolsConfiguretools();   
378     afx_msg void OnRegistersMangeregisters();
379     afx_msg void OnEditQuickfindandreplace();
380     afx_msg void OnEditQuickfind();
381     afx_msg void OnEditFindandreplace();
382     afx_msg void OnFiletreeAddfolder();
383     afx_msg void OnFileSaveSaveproject();
384     afx_msg void OnFiletreeAddfile();
385     afx_msg void OnFiletreeInsertfile();
386     afx_msg void OnFiletreeRemoveFolder(); 
387     afx_msg void OnNavigationBackonepage();
388     afx_msg void OnNavigationForward();
389     afx_msg void OnNavigationFoldall();
390     afx_msg void OnNavigationExpandall();
391     afx_msg void OnNavigationIsolate();
392     afx_msg void OnNavigationGotoline();
393     afx_msg void OnNavigationCenterline();
394     afx_msg void OnNavigationMakelinetop();
395     afx_msg void OnRegistersPasteregister1();
396     afx_msg void OnRegistersPasteregister2();
397     afx_msg void OnRegistersPasteregister4();
398     afx_msg void OnRegistersPasteregister3();
399     afx_msg void OnRegistersPasteregister5();
400     afx_msg void OnNavigationExecgotofile();
401     afx_msg void OnNavigationExecgotofilesymbol();
402     afx_msg void OnNavigationExecgotofilehistory();
403     afx_msg void OnSettingsChangefont();
404     afx_msg void OnToolsStartrecordingmacro();
405     afx_msg void OnToolsStoprecordingmacro();
406     afx_msg void OnToolsExecutescriptormacro();
407     afx_msg void OnEditPaste();
408     afx_msg void OnEditUndox();
409     afx_msg void OnEditCopyx();
410     afx_msg void OnEditCutx();
411     afx_msg void OnFileNewNewfile();
412     afx_msg void OnFileNewNewfilefromtemplate();
413     afx_msg void OnFileSaveSaveall();
414     afx_msg void OnEditCommentselect();
415     afx_msg void OnEditUncommonselection();
416     afx_msg void OnFileListCtrlUndo();
417     afx_msg void OnGotoAdvancedFileAndReplace();
418     afx_msg void OnCompileCompileProject();
419     afx_msg void OnNavigationNexterror();
420     afx_msg void OnNavigationPreviouserror();
421     afx_msg void OnNavigationCompileroutput();
422     afx_msg void OnCompileCompileandrun();
423     afx_msg void OnCompileCompilefile();
424     afx_msg void OnCompileClean() ;
425     afx_msg void OnCompileCompilehelp();   
426     afx_msg void OnEditParserUpdateprojectparser();
427     afx_msg void OnViewShowhideoutputbar();
428     afx_msg void OnViewShowhideworkspace();
429     afx_msg void OnViewShowhidefiletoolbar();
430     afx_msg void OnViewShowhidecodetoolbar();
431     afx_msg void OnViewShowhidefindtoolbar();
432     afx_msg void OnViewShowhidestandardtoolbar();
433     afx_msg void OnViewShowhidestatusbar();
434     afx_msg void OnNavigationBuildreportoutput();
435     afx_msg void OnNavigationFindbaroutput();
436     afx_msg void OnViewMaximizeview(); 
437     afx_msg void OnCompileEvaluatebuffer();
438     afx_msg void OnDescentAutocompleteavailablelibraries();
439     afx_msg void OnDescentAutocompleteavailableimports();
440     afx_msg void OnDescentAutocompletecode();
441     afx_msg void OnViewShowhideconfigtoolbar();
442     afx_msg void OnHelpBuildhelp();
443     afx_msg void OnViewMakeworkspacelarger();
444     afx_msg void OnFileOpen();
445     afx_msg void OnNavigationLineup();
446     afx_msg void OnNavigationLinedown();
447     afx_msg void OnWindowCloseall();
448     afx_msg void OnFiletreeInsertaddonproject();
449     afx_msg void OnFiletreeRemoveaddonproject();
450     afx_msg void OnFiletreeActivateaddonproject();
451     afx_msg void OnFiletreeBuildselectedproject();
452     afx_msg void OnFileNewImportprojecttype();
453     afx_msg void OnAppExitRelay();
454     afx_msg void OnNavigationOpenmodule();
455     afx_msg void OnProjectUpdateprojectparser();   
456     afx_msg void OnNavigationFilebrowser();
457     afx_msg void OnNavigationSourcebrowser();
458     afx_msg void OnNavigationHistorybrowser();
459     afx_msg void OnNavigationSelecttoolbarSelectfiletoolbar();
460     afx_msg void OnNavigationSelecttoolbarSelectcodetoolbar();
461     afx_msg void OnNavigationSelecttoolbarSelectsettingstoolbar();
462     afx_msg void OnProjectSelectprojectnodeSelectnode1();
463     afx_msg void OnProjectSelectprojectnodeSelectnode2();
464     afx_msg void OnProjectSelectprojectnodeSelectnode3();
465     afx_msg void OnProjectSelectprojectnodeSelectnode4();
466     afx_msg void OnProjectSelectprojectnodeSelectnode5();
467     afx_msg void OnProjectSelectprojectnodeSelectnode6();
468     afx_msg void OnProjectSelectprojectnodeSelectnode7();
469     afx_msg void OnNavigationSelecttabLogbrowser();
470     afx_msg void OnNavigationSelectcomboboxSelectcodesymbol();
471     afx_msg void OnNavigationSelectcomboboxSelectprojectconfiguration();
472     afx_msg void OnFiletreeCleanselectedproject();
473     afx_msg void OnCompileCompilefileWithbuild();
474     //}}AFX_MSG
475    
476 public:
477     afx_msg void OnNavigationExecgotosymbol();
478     afx_msg void OnFiletreeRemovefile();
479     //find stuff
480     afx_msg void OnFindBarFind();
481     afx_msg void OnFindBarReplace();
482    
483     DECLARE_MESSAGE_MAP()
484 };
485 extern CFont *defaultFont;
486 extern CQuickFindAndReplaceDlg *quickFindAndReplaceDlg;
487 extern CAdvancedFindAndReplaceDlg *advancedFindAndReplaceDlg;
488
489
490 ///////////////////////////////////////////////////////////////////////////
491
492 //{{AFX_INSERT_LOCATION}}
493 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
494
495 #endif // !defined(AFX_MAINFRM_H__452DC860_01CF_40E7_9A8F_9B7B10747616__INCLUDED_)
Note: See TracBrowser for help on using the browser.