1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2012-2015, 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 #include <util/OpenHashTable.h> 12 13 #include "table/TreeTable.h" 14 15 #include "ExpressionInfo.h" 16 17 18 class ActionMenuItem; 19 class CpuState; 20 class SettingsMenu; 21 class StackFrame; 22 class Thread; 23 class Type; 24 class TypeComponentPath; 25 class ValueLocation; 26 class ValueNode; 27 class ValueNodeChild; 28 class ValueNodeContainer; 29 class ValueNodeManager; 30 class Value; 31 class Variable; 32 class VariableEditWindow; 33 class VariablesViewState; 34 class VariablesViewStateHistory; 35 36 37 class VariablesView : public BGroupView, private TreeTableListener, 38 private ExpressionInfo::Listener { 39 public: 40 class Listener; 41 42 public: 43 VariablesView(Listener* listener); 44 ~VariablesView(); 45 46 static VariablesView* Create(Listener* listener, 47 ValueNodeManager* manager); 48 // throws 49 50 void SetStackFrame(Thread* thread, 51 StackFrame* stackFrame); 52 53 virtual void MessageReceived(BMessage* message); 54 55 virtual void DetachedFromWindow(); 56 57 void LoadSettings(const BMessage& settings); 58 status_t SaveSettings(BMessage& settings); 59 60 void SetStackFrameClearPending(); 61 62 private: 63 // TreeTableListener 64 virtual void TreeTableNodeExpandedChanged(TreeTable* table, 65 const TreeTablePath& path, bool expanded); 66 virtual void TreeTableNodeInvoked(TreeTable* table, 67 const TreeTablePath& path); 68 virtual void TreeTableCellMouseDown(TreeTable* table, 69 const TreeTablePath& path, 70 int32 columnIndex, BPoint screenWhere, 71 uint32 buttons); 72 73 // ExpressionInfo::Listener 74 virtual void ExpressionEvaluated(ExpressionInfo* info, 75 status_t result, ExpressionResult* value); 76 77 private: 78 class ContainerListener; 79 class ExpressionVariableID; 80 class ModelNode; 81 class VariableValueColumn; 82 class VariableTableModel; 83 class ContextMenu; 84 class TableCellContextMenuTracker; 85 class VariablesExpressionInfo; 86 typedef BObjectList<ActionMenuItem> ContextActionList; 87 typedef BObjectList<ExpressionInfo> ExpressionInfoList; 88 typedef BObjectList<ValueNodeChild> ExpressionChildList; 89 90 struct FunctionKey; 91 struct ExpressionInfoEntry; 92 struct ExpressionInfoEntryHashDefinition; 93 94 typedef BOpenHashTable<ExpressionInfoEntryHashDefinition> 95 ExpressionInfoTable; 96 97 private: 98 void _Init(ValueNodeManager* manager); 99 100 void _RequestNodeValue(ModelNode* node); 101 status_t _GetContextActionsForNode(ModelNode* node, 102 ContextActionList*& _preActions, 103 ContextActionList*& _postActions); 104 status_t _AddContextAction(const char* action, 105 uint32 what, ContextActionList* actions, 106 BMessage*& _message); 107 void _FinishContextMenu(bool force); 108 void _SaveViewState(bool updateValues) const; 109 void _RestoreViewState(); 110 status_t _AddViewStateDescendentNodeInfos( 111 VariablesViewState* viewState, 112 void* parent, 113 TreeTablePath& path, 114 bool updateValues) const; 115 status_t _ApplyViewStateDescendentNodeInfos( 116 VariablesViewState* viewState, 117 void* parent, 118 TreeTablePath& path); 119 void _CopyVariableValueToClipboard(); 120 121 status_t _AddExpression(const char* expression, 122 bool persistentExpression, 123 ExpressionInfo*& _info); 124 void _RemoveExpression(ModelNode* node); 125 126 void _RestoreExpressionNodes(); 127 128 void _AddExpressionNode(ExpressionInfo* info, 129 status_t result, ExpressionResult* value); 130 131 void _HandleTypecastResult(status_t result, 132 ExpressionResult* value); 133 134 void _HandleEditVariableRequest(ModelNode* node, 135 Value* value); 136 137 status_t _GetTypeForTypeCode(int32 typeCode, 138 Type*& _resultType) const; 139 140 private: 141 Thread* fThread; 142 StackFrame* fStackFrame; 143 TreeTable* fVariableTable; 144 VariableTableModel* fVariableTableModel; 145 ContainerListener* fContainerListener; 146 VariablesViewState* fPreviousViewState; 147 VariablesViewStateHistory* fViewStateHistory; 148 ExpressionInfoTable* fExpressions; 149 ExpressionChildList fExpressionChildren; 150 TableCellContextMenuTracker* fTableCellContextMenuTracker; 151 VariablesExpressionInfo* fPendingTypecastInfo; 152 ExpressionInfo* fTemporaryExpression; 153 bool fFrameClearPending; 154 VariableEditWindow* fEditWindow; 155 Listener* fListener; 156 }; 157 158 159 class VariablesView::Listener { 160 public: 161 virtual ~Listener(); 162 163 virtual void ValueNodeValueRequested(CpuState* cpuState, 164 ValueNodeContainer* container, 165 ValueNode* valueNode) = 0; 166 167 virtual void ExpressionEvaluationRequested( 168 ExpressionInfo* info, 169 StackFrame* frame, 170 Thread* thread) = 0; 171 172 virtual void ValueNodeWriteRequested( 173 ValueNode* node, 174 CpuState* state, 175 Value* newValue) = 0; 176 177 }; 178 179 180 #endif // VARIABLES_VIEW_H 181