root/trunk/CodeBrowsingTreeCtrl.cpp

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

Initial ( and last :( ) commit

Line 
1 // CodeBrowsingTreeCtrl.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "Elephant.h"
6 #include "CodeBrowsingTreeCtrl.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CCodeBrowsingTreeCtrl
16
17 CCodeBrowsingTreeCtrl::CCodeBrowsingTreeCtrl()
18 {
19 }
20
21 CCodeBrowsingTreeCtrl::~CCodeBrowsingTreeCtrl()
22 {
23 }
24
25
26 BEGIN_MESSAGE_MAP(CCodeBrowsingTreeCtrl, CTreeCtrl)
27     //{{AFX_MSG_MAP(CCodeBrowsingTreeCtrl)
28     ON_WM_LBUTTONDBLCLK()
29     ON_WM_RBUTTONDOWN()
30
31     //}}AFX_MSG_MAP
32     ON_WM_KEYUP()
33 END_MESSAGE_MAP()
34
35 /////////////////////////////////////////////////////////////////////////////
36 // CCodeBrowsingTreeCtrl message handlers
37
38 void CCodeBrowsingTreeCtrl::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
39 {
40
41     if ( nChar == VK_DELETE )
42     {
43
44
45       CMainFrame* mf = static_cast<CMainFrame*>(Globals::theApp.m_pMainWnd );
46       if ( mf ) mf->OnFiletreeRemovefile();
47     }
48
49     else if (nChar == VK_RETURN )
50     {
51
52         OnLButtonDblClk(0,CPoint(0,0 ) );
53
54
55
56     }
57     else    if ( nChar == VK_ESCAPE )
58     {
59
60         CMainFrame* m = (CMainFrame*)Globals::theApp.m_pMainWnd;
61         if ( m ){
62        
63         CElephantView* v = m->GetActiveView();
64         if ( v )
65         {
66             CScintillaCtrl& rCtrl = v->GetCtrl();
67             rCtrl.SetFocus();
68         }
69
70         return;
71         }
72        
73
74
75     }
76
77
78
79 }
80
81 void CCodeBrowsingTreeCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
82 {
83     HTREEITEM item = GetSelectedItem();
84
85     if ( item )
86     {
87         Dsymbol* sym = (Dsymbol*)GetItemData(item);
88         if ( sym ) {       
89            
90             if ( sym->isModule() )
91             {
92                 Module* m = (Module*)sym;
93                 Globals::theApp.OpenFile(m->srcfile->toChars(),0);
94
95             }
96             else if ( sym->loc.filename)
97             {               
98                 Globals::theApp.OpenFile(sym->loc.filename,sym->loc.linnum);
99             }
100             else
101             {
102                 //AfxMessageBox("no filename");
103                 Module* m = (Module*)sym->getModule();
104                 if ( m ) Globals::theApp.OpenFile(m->srcfile->toChars(),0);
105             }
106         }
107         else ; //  AfxMessageBox("nosym");
108     }
109    
110     CTreeCtrl::OnLButtonDblClk(nFlags, point);
111 }
112
113 //void CCodeBrowsingTreeCtrl::OnRButtonUp(UINT nFlags, CPoint point)
114 //{
115 //  LoadAndShowMenu(IDR_SOURCEBROWSER_MENU,point,this);
116 // 
117 //  CTreeCtrl::OnRButtonUp(nFlags, point);
118 //}
119
120 void CCodeBrowsingTreeCtrl::OnRButtonDown(UINT nFlags, CPoint point)
121 {
122     LoadAndShowMenu(IDR_SOURCEBROWSER_MENU,point,this);
123    
124     CTreeCtrl::OnRButtonDown(nFlags, point);
125 }
Note: See TracBrowser for help on using the browser.