3 class WatchesView : Window
8 background = { 224, 224, 224 };
10 anchor = Anchor { left = 0, right = 0, bottom = 0 };
17 parent = this, hasHeader = true, hasVertScroll = true, alwaysEdit = true, collapseControl = true, resizable = true;
18 anchor = Anchor { left = 0, right = 0, top = 0, bottom = 0 };
19 background = viewsBackground;
20 foreground = viewsText;
21 selectionColor = selectionColor, selectionText = selectionText;
23 bool NotifyChanged(ListBox listBox, DataRow row)
25 char * expression = row.GetData(expressionField);
27 if(expression && expression[0])
29 TrimLSpaces(expression, expression);
30 TrimRSpaces(expression, expression);
33 if(expression && expression[0])
35 row.SetData(valueField, null);
36 if(row == listBox.lastRow)
38 DataRow newRow = listBox.AddRow();
39 newRow.SetData(expressionField, null);
40 newRow.SetData(valueField, null);
41 listBox.currentRow = newRow;
43 ide.debugger.ChangeWatch(row, expression);
47 ide.debugger.ChangeWatch(row, expression);
48 if(row != listBox.lastRow)
50 //Type type = (Type)row.GetData(typeField);
51 //if(type) FreeType(type);
52 listBox.DeleteRow(row);
55 row.SetData(valueField, null);
60 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
62 if((SmartKey)key == del)
64 listBox.StopEditing(true);
65 if(row && row != listBox.lastRow)
67 //Type type = (Type)row.GetData(typeField);
68 ide.debugger.ChangeWatch(row, null);
69 //if(type) FreeType(type);
70 listBox.DeleteRow(null);
76 DataField expressionField { "char *", true, width = 130, header = "Expression" };
77 DataField typeField { "Type", false, width = 180, header = "Type" };
78 //DataField addressField { "char *", true, width = 80, header = "Symbol Address" };
79 DataField valueField { class(WatchMultiLineString), true, width = 330, header = "Value" };
83 listBox.AddField(expressionField);
84 listBox.AddField(typeField);
85 listBox.AddField(valueField);
88 bool OnKeyDown(Key key, unichar ch)
92 case escape: ide.ShowCodeEditor(); break;
97 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
101 //listBox.SelectRow(listBox.firstRow);
102 ide.RepositionWindows(false);
107 bool OnClose(bool parentClosing)
111 ide.RepositionWindows(false);
112 return parentClosing;
121 void LoadFromWorkspace()
123 for(wh : ide.workspace.watches)
127 void AddWatch(Watch wh)
129 DataRow row = listBox.AddRowAfter(listBox.lastRow.previous);
135 void UpdateWatch(Watch wh)
139 DataRow row = wh.row;
142 row.SetData(expressionField, wh.expression);
143 row.SetData(typeField, wh.type);
144 //row.SetData(addressField, wh.address);
145 row.SetData(valueField, wh.value);
154 row = listBox.AddRow();
155 row.SetData(expressionField, null);
156 row.SetData(typeField, null);
157 row.SetData(valueField, null);
161 class WatchMultiLineString : String
163 Window OnEdit(DataBox dataBox, DataBox obsolete, int x, int y, int w, int h, void * userData)
165 if(this && strchr(this, '\n'))
167 // Don't show the editbox right away so that the text is highlighted by default
170 parent = dataBox, master = obsolete, visible = false,
171 borderStyle = contour,
173 hasHorzScroll = true, hasVertScroll = true,
174 modifyVirtualArea = false,
175 anchor = { 0, 0, 0, 0 };
176 //position = { x + dataBox.absPosition.x, y + dataBox.absPosition.y };
177 //size = { w, h * 4 };
180 bool OnKeyDown(Key key, unichar ch)
184 ((ListBox)master.master).currentField = ((ListBox)master.master).firstField;
187 return EditBox::OnKeyDown(key, ch);
190 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
192 if(active) SelectAll(); else Deselect();
193 return EditBox::OnActivate(active, previous, goOnWithActivation, direct);
196 void DataBox::NotifyUpdate(EditBox editBox)
202 dataBox.size = { w, h * 4 + 2 };
203 if(dataBox.size.h + dataBox.position.y > dataBox.parent.clientSize.h)
204 dataBox.position.y = dataBox.parent.clientSize.h - dataBox.size.h;
205 if(dataBox.size.w + dataBox.position.x > dataBox.parent.clientSize.w)
206 dataBox.position.x = dataBox.parent.clientSize.w - dataBox.size.w;
208 editBox.contents = this;
209 editBox.visible = true;
219 return String::OnEdit(dataBox, obsolete, x, y, w,h, userData);
222 bool OnSaveEdit(Window window, void * object)
224 bool changed = false;
225 EditBox editBox = (EditBox)window;
226 if(editBox.modifiedDocument)
235 for(line = editBox.firstLine; line; line = line.next)
236 size += line.count+1;
237 this = string = new char[size+1];
239 for(line = editBox.firstLine; line; line = line.next)
241 memcpy(string + size, line.text, line.count);
253 void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags)
258 char * string = this;
259 char actualString[8196];
261 for(c = 0; (ch = string[c]); c++)
263 if(ch == '\t') { actualString[len++] = '\\'; actualString[len++] = 't'; }
264 else if(ch == '\r') { actualString[len++] = '\\'; actualString[len++] = 'r'; }
265 else if(ch == '\n') { actualString[len++] = '\\'; actualString[len++] = 'n'; }
266 else actualString[len++] = ch;
268 actualString[len] = 0;
269 class(String)._vTbl[__ecereVMethodID_class_OnDisplay](class(String), actualString, surface, x, y, width, null, alignment, displayFlags);