1 struct Navigator {
2 	virtual int GetCurrentLine() = 0;
3 
4 	struct NavLine : Moveable<NavLine> {
5 		bool           impl:1;
6 		int            file:31;
7 		int            line;
8 
9 		bool operator<(const NavLine& b) const;
10 	};
11 
12 	struct NavItem {
13 		String          nest;
14 		String          qitem;
15 		String          name;
16 		String          uname;
17 		String          natural;
18 		String          type;
19 		String          pname;
20 		String          ptype;
21 		String          tname;
22 		String          ctname;
23 		byte            access;
24 		byte            kind;
25 		int16           at;
26 		int             line;
27 		int             file;
28 		int             decl_line; // header position
29 		int             decl_file;
30 		bool            impl;
31 		bool            decl;
32 		int8            pass;
33 		Vector<NavLine> linefo;
34 
35 		void Set(const CppItem& m);
36 	};
37 
38 	enum KindEnum { KIND_LINE = 123, KIND_NEST, KIND_FILE, KIND_SRCFILE };
39 
40 	struct ScopeDisplay : Display {
41 		Navigator *navigator;
42 
43 		int DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
44 		virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
45 		virtual Size GetStdSize(const Value& q) const;
46 	};
47 
48 	struct LineDisplay : Display {
49 		int DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style, int x) const;
50 		virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
51 		virtual Size GetStdSize(const Value& q) const;
52 	};
53 
54 	struct NavigatorDisplay : Display {
55 		const Vector<NavItem *>& item;
56 
57 		int DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
58 		virtual void PaintBackground(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
59 		virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
60 		virtual Size GetStdSize(const Value& q) const;
61 
NavigatorDisplayNavigator::NavigatorDisplay62 		NavigatorDisplay(const Vector<NavItem *>& item) : item(item) {}
63 	};
64 
65 	Ide             *theide;
66 
67 	Array<NavItem>                             nitem;
68 	VectorMap<String, Vector<NavItem *> >      gitem;
69 	Vector<NavItem *>                          litem;
70 	Array<NavItem>                             nest_item;
71 	VectorMap<int, SortedVectorMap<int, int> > linefo;
72 	NavigatorDisplay navidisplay;
73 	bool             navigating;
74 	TimeCallback     search_trigger;
75 	bool             navigator_global;
76 	ToolButton       sortitems;
77 	bool             sorting;
78 	bool             dlgmode;
79 
80 	ArrayCtrl         scope;
81 	ArrayCtrl         list;
82 	ArrayCtrl         navlines;
83 	EditString        search;
84 
85 	ScopeDisplay      scope_display;
86 
87 	void TriggerSearch();
88 	void NavGroup(bool local);
89 	void Search();
90 	void Scope();
91 	void ListLineEnabled(int i, bool& b);
92 	void NaviSort();
93 
94 	Vector<NavLine> GetNavLines(const NavItem& m);
95 
96 	void           Navigate();
97 	void           ScopeDblClk();
98 	void           NavigatorClick();
99 	void           NavigatorEnter();
100 	void           SyncLines();
101 	void           SyncNavLines();
102 	void           GoToNavLine();
103 	void           SyncCursor();
104 
105 	static bool SortByLines(const NavItem *a, const NavItem *b);
106 	static bool SortByNames(const NavItem *a, const NavItem *b);
107 
108 	typedef Navigator CLASSNAME;
109 
110 	Navigator();
111 };
112 
113 struct AssistEditor : CodeEditor, Navigator {
114 	virtual bool Key(dword key, int count);
115 	virtual void LostFocus();
116 	virtual void MouseWheel(Point p, int zdelta, dword keyflags);
117 	virtual void LeftDown(Point p, dword keyflags);
118 	virtual void SelectionChanged();
119 	virtual void DirtyFrom(int line);
120 	virtual void State(int reason);
121 
122 	virtual int  GetCurrentLine();
123 
124 	struct IndexItem : Moveable<IndexItem> {
125 		String text;
126 		Color  ink;
127 		int    line;
128 	};
129 	bool           navigator;
130 	SplitterFrame  navigatorframe;
131 	StaticRect     navigatorpane;
132 	Splitter       navigator_splitter;
133 
134 	struct AssistItemConvert : Convert {
135 		AssistEditor *editor;
136 
137 		virtual Value Format(const Value& q) const;
138 	}
139 	assist_convert;
140 
141 	Splitter       popup;
142 	ArrayCtrl      assist;
143 	ArrayCtrl      type;
144 	Index<String>      assist_type;
145 	Array<CppItemInfo> assist_item;
146 	Vector<int>        assist_item_ndx;
147 	RichTextCtrl   annotation_popup;
148 
149 	int            assist_cursor;
150 	bool           auto_assist;
151 	bool           auto_check;
152 	bool           assist_active;
153 	bool           commentdp;
154 	bool           inbody;
155 	bool           thisback, thisbackn;
156 	bool           include_assist;
157 	WString        cachedline;
158 	int            cachedpos;
159 	int            cachedln;
160 	bool           include_local;
161 	int            include_back;
162 	String         include_path;
163 	int            scan_counter;
164 
165 	RichTextCtrl   param_info;
166 	String         param_qtf;
167 	struct ParamInfo {
168 		int            line;
169 		int            pos;
170 		WString        test;
171 		CppItem        item;
172 		String         editfile;
173 
ParamInfoAssistEditor::ParamInfo174 		ParamInfo()    { line = -1; }
175 	};
176 	enum { PARAMN = 16 };
177 	ParamInfo param[PARAMN];
178 	int       parami;
179 
180 	String    current_type;
181 
182 	static Ptr<Ctrl> assist_ptr;
183 
184 	bool      navigator_right = true;
185 
186 
187 	void           PopUpAssist(bool auto_insert = false);
188 	void           CloseAssist();
189 	static bool    WheelHook(Ctrl *, bool inframe, int event, Point p, int zdelta, dword keyflags);
190 	void           Assist();
191 	bool           IncludeAssist();
192 	String         ReadIdBackPos(int& pos, bool include);
193 	String         ReadIdBack(int q, bool include = false, bool *destructor = NULL);
194 	void           SyncAssist();
195 	void           AssistInsert();
196 	bool           InCode();
197 
198 	void           SyncParamInfo();
199 	void           StartParamInfo(const CppItem& m, int pos);
200 
201 	void           Complete();
202 	void           Abbr();
203 
204 	void           Context(ParserContext& parser, int pos);
205 	void           ExpressionType(const String& type,
206 	                              const String& context_type,
207 	                              const String& usings,
208 	                              const Vector<String>& xp, int ii,
209 	                              Index<String>& typeset, bool variable,
210 	                              bool can_shortcut_operator, Index<String>& visited_bases,
211 	                              int lvl);
212 	void           ExpressionType(const String& type,
213 	                              const String& context_type,
214 	                              const String& usings,
215 	                              const Vector<String>& xp, int ii,
216 	                              Index<String>& typeset, bool variable, int lvl);
217 //	void           ExpressionType(const String& type, const Vector<String>& xp, int ii,
218 //	                              Index<String>& typeset);
219 	Index<String>  ExpressionType(const ParserContext& parser, const Vector<String>& xp);
220 
221 	Index<String>  EvaluateExpressionType(const ParserContext& parser, const Vector<String>& xp);
222 
223 	String         RemoveDefPar(const char *s);
224 	String         MakeDefinition(const String& cls, const String& _n);
225 	void           DCopy();
226 	void           Virtuals();
227 	void           Thisbacks();
228 	void           AssistItemAdd(const String& scope, const CppItem& m, int typei);
229 	void           GatherItems(const String& type, bool only_public, Index<String>& in_types,
230 	                           bool types);
231 	void           RemoveDuplicates();
232 
233 	void           SelParam();
234 	int            Ch(int q);
235 	int            ParsBack(int q);
236 	Vector<String> ReadBack(int q, const Index<String>& locals);
237 	void           SkipSpcBack(int& q);
238 	String         IdBack(int& qq);
239 	String         CompleteIdBack(int& q, const Index<String>& locals);
240 
241 	void           SwapSContext(ParserContext& p);
242 
243 	bool           GetAnnotationRefs(Vector<String>& tl, String& coderef, int q = -1);
244 	bool           GetAnnotationRef(String& t, String& coderef, int q = -1);
245 	void           SyncAnnotationPopup();
246 	void           EditAnnotation(bool fastedit);
247 	void           Annotate(const String& filename);
248 	void           OpenTopic(String topic, String create, bool before);
249 	void           NewTopic(String group, String coderef);
250 
251 	bool           Esc();
252 
IsNavigatorAssistEditor253 	bool           IsNavigator() const                             { return navigator; }
254 	void           Navigator(bool navigator);
255 	void           SyncNavigatorShow();
256 	void           SyncNavigator();
257 	void           SerializeNavigator(Stream& s);
258 	void           SyncNavigatorPlacement();
259 
260 	Event<int>     WhenFontScroll;
261 
262 	typedef AssistEditor CLASSNAME;
263 
264 	AssistEditor();
265 };
266