xref: /haiku/src/apps/debugger/user_interface/gui/expression_eval_window/ExpressionEvaluationWindow.h (revision 6e97df31a0a18dc0ca522a0b8b4aae250e102760)
1 /*
2  * Copyright 2014-2016, Rene Gollent, rene@gollent.com.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef EXPRESSION_EVALUATION_WINDOW_H
6 #define EXPRESSION_EVALUATION_WINDOW_H
7 
8 
9 #include <Window.h>
10 
11 #include "Team.h"
12 #include "VariablesView.h"
13 
14 
15 class BButton;
16 class BMenuField;
17 class BTextControl;
18 class StackFrame;
19 class Team;
20 class UserInterfaceListener;
21 class SourceLanguage;
22 
23 class ExpressionEvaluationWindow : public BWindow, private Team::Listener,
24 	private VariablesView::Listener {
25 public:
26 								ExpressionEvaluationWindow(
27 									BHandler* fCloseTarget,
28 									::Team* team,
29 									UserInterfaceListener* listener);
30 
31 								~ExpressionEvaluationWindow();
32 
33 	static	ExpressionEvaluationWindow* Create(BHandler* fCloseTarget,
34 									::Team* team,
35 									UserInterfaceListener* listener);
36 									// throws
37 
38 
39 	virtual	void				Show();
40 	virtual	bool				QuitRequested();
41 
42 	virtual	void				MessageReceived(BMessage* message);
43 
44 	// Team::Listener
45 	virtual	void				ThreadAdded(const Team::ThreadEvent& event);
46 	virtual	void				ThreadRemoved(const Team::ThreadEvent& event);
47 
48 	virtual	void				ThreadStateChanged(
49 									const Team::ThreadEvent& event);
50 	virtual	void				ThreadStackTraceChanged(
51 									const Team::ThreadEvent& event);
52 
53 	// VariablesView::Listener
54 	virtual	void				ValueNodeValueRequested(CpuState* cpuState,
55 									ValueNodeContainer* container,
56 									ValueNode* valueNode);
57 
58 	virtual	void				ExpressionEvaluationRequested(
59 									ExpressionInfo* info,
60 									StackFrame* frame,
61 									::Thread* thread);
62 
63 	virtual	void				ValueNodeWriteRequested(
64 									ValueNode* node,
65 									CpuState* state,
66 									Value* newValue);
67 
68 private:
69 			void	 			_Init();
70 
71 			void				_HandleThreadSelectionChanged(int32 threadID);
72 			void				_HandleFrameSelectionChanged(int32 index);
73 
74 			void				_HandleThreadAdded(int32 threadID);
75 			void				_HandleThreadRemoved(int32 threadID);
76 			void				_HandleThreadStateChanged(int32 threadID);
77 			void				_HandleThreadStackTraceChanged(int32 threadID);
78 
79 			void				_UpdateThreadList();
80 			void				_UpdateFrameList();
81 
82 			status_t			_CreateThreadMenuItem(::Thread* thread,
83 									BMenuItem*& _item) const;
84 
85 private:
86 			BTextControl*		fExpressionInput;
87 			BMenuField*			fThreadList;
88 			BMenuField*			fFrameList;
89 			VariablesView*		fVariablesView;
90 			BButton*			fCloseButton;
91 			BButton*			fEvaluateButton;
92 			BHandler*			fCloseTarget;
93 			SourceLanguage*		fCurrentLanguage;
94 			SourceLanguage*		fFallbackLanguage;
95 			::Team*				fTeam;
96 			::Thread*			fSelectedThread;
97 			StackFrame*			fSelectedFrame;
98 			UserInterfaceListener* fListener;
99 };
100 
101 #endif // EXPRESSION_EVALUATION_WINDOW_H
102