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