root/trunk/FileCodeComboBox.cpp

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

Initial ( and last :( ) commit

Line 
1 // FileCodeComboBox.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "Elephant.h"
6 #include "FileCodeComboBox.h"
7 #include "parsingfunctions.h"
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CFileCodeComboBox
16
17 CFileCodeComboBox::CFileCodeComboBox()
18 {
19 }
20
21 CFileCodeComboBox::~CFileCodeComboBox()
22 {
23 }
24
25 void CFileCodeComboBox::AddSymbols(vector<SymbolListing*> & symbols )
26 {
27
28     ResetContent();
29     if ( symbols.size () )
30     {
31         for ( int i= 0 , j = 0; i < symbols.size(); i++)
32     {
33         if (  symbols[i]->name != "__anonymous")
34         {
35        
36         AddString(Globals::proxyParser->projectParser->display.parseSymbolForDisplay(symbols[i]->sym).c_str() );
37         SetItemImage(j,GetImageNumber(symbols[i]));
38         SetItemData(j++,(DWORD)symbols[i]->sym);
39         }
40     }
41     }
42     else
43     {
44         AddString("File Tags");
45         SetItemImage(0,0);
46     }
47     SetCurSel(0);
48    
49 }
50 BEGIN_MESSAGE_MAP(CFileCodeComboBox, CComboBoxSuper)
51     //{{AFX_MSG_MAP(CFileCodeComboBox)
52         // NOTE - the ClassWizard will add and remove mapping macros here.
53         ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
54     //}}AFX_MSG_MAP
55     ON_WM_KEYUP()
56 END_MESSAGE_MAP()
57
58 /////////////////////////////////////////////////////////////////////////////
59 // CFileCodeComboBox message handlers
60
61 void CFileCodeComboBox::OnSelchange()
62 {
63
64     int sel = GetCurSel();
65     if ( sel >= 0 )
66     {
67         CString str;
68         this->GetLBText(sel,str);
69         if ( str == "File Tags") return;
70         Dsymbol* sym = (Dsymbol*)GetItemData(sel);
71         if ( sym )
72         {
73            
74             CMainFrame* m = (CMainFrame*)Globals::theApp.m_pMainWnd;
75             CElephantView* view = m->GetActiveView();
76             if ( view )
77             {
78                 try {
79                
80                 int count = sym->isClassDeclaration() || sym->isStructDeclaration() ? 2 : 1;
81                 view->GotoAndCenter(sym->loc.linnum - count );
82
83                     string text = sym->toChars();
84                     text += " -> ";
85                     text += sym->loc.filename;
86                     text += " [ " + ITOA(sym->loc.linnum) + " ] ";
87
88                     m->SetStatusBarText(text.c_str());
89
90                 }
91
92                 catch ( ... ) { }
93             }
94
95         }
96     }
97
98    
99
100
101 }
Note: See TracBrowser for help on using the browser.