Code::Blocks  SVN r11506
cctreectrl.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  */
5 
6 #ifndef CCTREECTRL
7 #define CCTREECTRL
8 
9 #include <wx/treectrl.h>
10 
11 #include <queue>
12 
13 #include "parser/parser.h" // BrowserSortType
14 #include "parser/token.h" // TokenKind
15 
16 class wxPoint;
17 class wxSize;
18 class wxWindow;
19 
20 class Token;
21 
24 {
25  sfToken = 0x0001, // token node
26  sfRoot = 0x0002, // root node
27  sfGFuncs = 0x0004, // global funcs node
28  sfGVars = 0x0008, // global vars node
29  sfPreproc = 0x0010, // preprocessor symbols node
30  sfTypedef = 0x0020, // typedefs node
31  sfBase = 0x0040, // base classes node
32  sfDerived = 0x0080, // derived classes node
33  sfMacro = 0x0100 // global macro node
34 };
35 
38 {
39 public:
40  CCTreeCtrlData(SpecialFolder sf = sfToken, Token* token = 0,
41  short int kindMask = 0xffff, int parentIdx = -1);
42 
45 
49  short int m_KindMask;
50 
53 
56 
59 
64 
70 
73  unsigned long m_Ticket;
74 };
75 
77 {
78 public:
79  CCTreeCtrlExpandedItemData(const CCTreeCtrlData* data, const int level);
80 
81  int GetLevel() const { return m_Level; }
82  const CCTreeCtrlData& GetData() { return m_Data; }
83 private:
84  CCTreeCtrlData m_Data; // copy of tree item data
85  int m_Level; // nesting level in the tree
86 };
87 
88 typedef std::deque<CCTreeCtrlExpandedItemData> ExpandedItemVect;
89 typedef std::deque<CCTreeCtrlData> SelectedItemPath;
90 
91 class CCTreeCtrl : public wxTreeCtrl
92 {
93 public:
94  CCTreeCtrl();
95  CCTreeCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos,
96  const wxSize& size, long style);
97 
98  void SetCompareFunction(const BrowserSortType type);
99  void RemoveDoubles(const wxTreeItemId& parent);
100 
101 protected:
102  static int CBAlphabetCompare(CCTreeCtrlData* lhs, CCTreeCtrlData* rhs);
103  static int CBKindCompare (CCTreeCtrlData* lhs, CCTreeCtrlData* rhs);
104  static int CBScopeCompare (CCTreeCtrlData* lhs, CCTreeCtrlData* rhs);
105  static int CBLineCompare (CCTreeCtrlData* lhs, CCTreeCtrlData* rhs);
106  static int CBNoCompare (CCTreeCtrlData* lhs, CCTreeCtrlData* rhs);
107 
108  int OnCompareItems(const wxTreeItemId& item1, const wxTreeItemId& item2);
109  int (*Compare)(CCTreeCtrlData* lhs, CCTreeCtrlData* rhs);
110 
111  DECLARE_DYNAMIC_CLASS(CCTreeCtrl)
112 };
113 
114 #endif // CCTREECTRL
BrowserSortType
specify the sort order of the symbol tree nodes
Definition: parser_base.h:49
std::deque< CCTreeCtrlExpandedItemData > ExpandedItemVect
Definition: cctreectrl.h:88
CCTreeCtrlData(SpecialFolder sf=sfToken, Token *token=0, short int kindMask=0xffff, int parentIdx=-1)
Definition: cctreectrl.cpp:24
TokenKind m_TokenKind
a copy of Token::m_TokenKind
Definition: cctreectrl.h:58
SpecialFolder m_SpecialFolder
the node&#39;s kind, it could be "root", "normal token",
Definition: cctreectrl.h:52
wxString m_TokenName
short name of the Token, it is a copy of Token::m_Name
Definition: cctreectrl.h:63
int m_ParentIndex
the parent Token index it is a copy of Token::m_ParentIndex,
Definition: cctreectrl.h:69
a symbol found in the parsed files, it can be many kinds, such as a variable, a class and so on...
Definition: token.h:82
Token * m_Token
a pointer to the associated Token instance in the TokenTree
Definition: cctreectrl.h:44
short int m_KindMask
a copy of Token::m_KindMask
Definition: cctreectrl.h:49
unsigned long m_Ticket
the Token&#39;s ticket in a TokenTree This is actually a copy of Token::m_Ticket,
Definition: cctreectrl.h:73
CCTreeCtrlData m_Data
Definition: cctreectrl.h:84
int m_TokenIndex
a copy of Token::m_TokenIndex
Definition: cctreectrl.h:55
std::deque< CCTreeCtrlData > SelectedItemPath
Definition: cctreectrl.h:89
Actual data stored with each node in the symbol tree.
Definition: cctreectrl.h:37
const CCTreeCtrlData & GetData()
Definition: cctreectrl.h:82
SpecialFolder
Specify which kind of node it is.
Definition: cctreectrl.h:23
int wxWindowID
TokenKind
Definition: token.h:29