6 class ThreadsView : Window
9 borderStyle = sizableDeep;
10 background = { 224, 224, 224 };
16 anchor = Anchor { left = 0.8, right = 0, top = 0 };
20 FindDialog findDialog { master = this, editBox = editBox, isModal = true, autoCreate = false, text = "Find" };
22 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
23 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
24 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
25 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
27 virtual void OnSelectThread(int threadId);
28 virtual bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread);
32 return atoi(editBox.line.text);
35 int FindThreadId(int threadId)
39 for(line = editBox.firstLine, lineNumber = 1; line; line = line.next, lineNumber++)
41 int id = atoi(line.text);
42 if(id && id == threadId)
50 parent = this, freeCaret = true, autoEmpty = true, multiLine = true, readOnly = true;
51 hasVertScroll = true, hasHorzScroll = true, borderStyle = none;
52 anchor = { left = 20, right = 0, top = 0, bottom = 0 };
53 background = viewsBackground;
54 foreground = viewsText;
55 selectionColor = selectionColor, selectionText = selectionText;
57 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
59 int id = GetThreadId();
64 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
66 if((SmartKey)key == enter)
68 int id = GetThreadId();
75 void NotifyCaretMove(EditBox editBox, int line, int charPos)
80 editBox.GetSelPos(null, &y1, null, null, &y2, null, false);
81 moved = (y1 == editBox.numLines - 1 && y2 == y1) ? false : true;
85 void OnVScroll(ScrollBarAction action, int position, Key key)
87 int boxH = clientSize.h;
88 Box box = { 0,0, 19, boxH - 1 };
90 EditBox::OnVScroll(action, position, key);
95 Menu editMenu { menu, $"Edit", e };
100 editMenu, $"Copy", c, ctrlC;
101 bool NotifySelect(MenuItem selection, Modifiers mods)
107 MenuDivider { editMenu };
108 MenuItem { editMenu, $"Find Previous", e, Key { f3, shift = true }, NotifySelect = MenuEditFind, id = 0 };
109 MenuItem { editMenu, $"Find Next", n, f3, NotifySelect = MenuEditFind, id = 1 };
110 MenuItem { editMenu, $"Find", f, ctrlF, NotifySelect = MenuEditFind, id = 2 };
112 bool MenuEditFind(MenuItem selection, Modifiers mods)
114 int64 id = selection.id;
115 const char * searchString = findDialog.searchString;
116 if(id != 2 && searchString[0])
118 editBox.Find(searchString, findDialog.wholeWord, findDialog.matchCase, id != 0);
125 void Logf(const char * format, ...)
127 char string[MAX_F_STRING*10];
129 va_start(args, format);
130 vsnprintf(string, sizeof(string), format, args);
131 string[sizeof(string)-1] = 0;
136 void LogSprintf(const char * entry)
138 char string[MAX_F_STRING];
139 sprintf(string, entry);
142 void LogRaw(const char * entry)
146 void Log(const char * string)
155 editBox.GetSelPos(&line1, &y1, &x1, &line2, &y2, &x2, false);
156 scroll = editBox.scroll;
159 editBox.PutS(string);
160 editBox.Update(null);
163 editBox.scroll = scroll;
164 editBox.SetSelPos(line1, y1, x1, line2, y2, x2);
180 ide.RepositionWindows(false);
184 void OnRedraw(Surface surface)
187 int scrollY = editBox.scroll.y;
188 int boxH = clientSize.h;
190 int activeThread, hitThread, signalThread;
192 if(OnGetThreadsInfo(&activeThread, &hitThread, &signalThread))
195 BitmapResource bmpRes;
196 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
197 for(line = editBox.firstLine, lineNumber = 1; line; line = line.next, lineNumber++)
199 if(strlen(line.text))
201 int id = atoi(line.text);
202 bmpRes = (id == signalThread) ? bmpTopFrameError : bmpTopFrame;
203 if(id == activeThread)
205 DrawLineMarginIcon(surface,
206 (id == signalThread) ? bmpCursorError : bmpCursor,
207 lineNumber, lineH, scrollY, boxH);
209 else if(id == signalThread)
210 DrawLineMarginIcon(surface, bmpRes, lineNumber, lineH, scrollY, boxH);
213 if(editBox.horzScroll && editBox.horzScroll.visible)
215 surface.SetBackground(control);
216 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
221 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
226 lineY = (line - 1) * lineH;
227 if(lineY + lineH > scrollY && lineY + lineH < scrollY + boxH)
229 Bitmap bitmap = resource.bitmap;
231 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);