xref: /haiku/src/apps/debugger/user_interface/gui/team_window/VariablesView.h (revision d06cbe081b7ea043aea2012359744091de6d604d)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2012-2014, Rene Gollent, rene@gollent.com.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef VARIABLES_VIEW_H
7 #define VARIABLES_VIEW_H
8 
9 
10 #include <GroupView.h>
11 
12 #include "table/TreeTable.h"
13 
14 
15 class ActionMenuItem;
16 class CpuState;
17 class SettingsMenu;
18 class StackFrame;
19 class Thread;
20 class Type;
21 class TypeComponentPath;
22 class ValueNode;
23 class ValueNodeContainer;
24 class Variable;
25 class VariablesViewState;
26 class VariablesViewStateHistory;
27 
28 
29 class VariablesView : public BGroupView, private TreeTableListener {
30 public:
31 	class Listener;
32 
33 public:
34 								VariablesView(Listener* listener);
35 								~VariablesView();
36 
37 	static	VariablesView*		Create(Listener* listener);
38 									// throws
39 
40 			void				SetStackFrame(Thread* thread,
41 									StackFrame* stackFrame);
42 
43 	virtual	void				MessageReceived(BMessage* message);
44 
45 	virtual	void				DetachedFromWindow();
46 
47 			void				LoadSettings(const BMessage& settings);
48 			status_t			SaveSettings(BMessage& settings);
49 
50 			void				SetStackFrameClearPending();
51 
52 private:
53 	// TreeTableListener
54 	virtual	void				TreeTableNodeExpandedChanged(TreeTable* table,
55 									const TreeTablePath& path, bool expanded);
56 
57 	virtual	void				TreeTableCellMouseDown(TreeTable* table,
58 									const TreeTablePath& path,
59 									int32 columnIndex, BPoint screenWhere,
60 									uint32 buttons);
61 
62 private:
63 			class ContainerListener;
64 			class ModelNode;
65 			class VariableValueColumn;
66 			class VariableTableModel;
67 			class ContextMenu;
68 			class TableCellContextMenuTracker;
69 			typedef BObjectList<ActionMenuItem> ContextActionList;
70 
71 private:
72 			void				_Init();
73 
74 			void				_RequestNodeValue(ModelNode* node);
75 			status_t			_GetContextActionsForNode(ModelNode* node,
76 									ContextActionList* actions);
77 			status_t			_AddContextAction(const char* action,
78 									uint32 what, ContextActionList* actions,
79 									BMessage*& _message);
80 			void				_FinishContextMenu(bool force);
81 			void				_SaveViewState() const;
82 			void				_RestoreViewState();
83 			status_t			_AddViewStateDescendentNodeInfos(
84 									VariablesViewState* viewState, void* parent,
85 									TreeTablePath& path) const;
86 			status_t			_ApplyViewStateDescendentNodeInfos(
87 									VariablesViewState* viewState, void* parent,
88 									TreeTablePath& path);
89 			void				_CopyVariableValueToClipboard();
90 
91 private:
92 			Thread*				fThread;
93 			StackFrame*			fStackFrame;
94 			TreeTable*			fVariableTable;
95 			VariableTableModel*	fVariableTableModel;
96 			ContainerListener*	fContainerListener;
97 			VariablesViewState*	fPreviousViewState;
98 			VariablesViewStateHistory* fViewStateHistory;
99 			TableCellContextMenuTracker* fTableCellContextMenuTracker;
100 			bool				fFrameClearPending;
101 			Listener*			fListener;
102 };
103 
104 
105 class VariablesView::Listener {
106 public:
107 	virtual						~Listener();
108 
109 	virtual	void				ValueNodeValueRequested(CpuState* cpuState,
110 									ValueNodeContainer* container,
111 									ValueNode* valueNode) = 0;
112 };
113 
114 
115 #endif	// VARIABLES_VIEW_H
116