58FXIMPLEMENT_ABSTRACT(
GUIMessageWindow, FXText, GUIMessageWindowMap, ARRAYNUMBER(GUIMessageWindowMap))
64 FXText(parent,
nullptr, 0, 0, 0, 0, 0, 50),
65 myMainWindow(mainWindow),
66 myErrorRetriever(
nullptr),
67 myMessageRetriever(
nullptr),
68 myWarningRetriever(
nullptr) {
74 setHiliteStyles(myStyles);
75 myTimeText =
TL(
" time");
102 const FXint idS =
MAX2(text.rfind(
" '", pos), text.rfind(
"='", pos));
103 const FXint idE = text.find(
"'", pos);
104 if (idS >= 0 && idE >= 0 && idS >= lineS && idE <= lineE) {
105 FXint typeS = text.rfind(
" ", idS - 1);
107 if (text.at(typeS + 1) ==
'(') {
110 type = std::string(text.mid(typeS + 1, idS - typeS - 1).lower().text());
115 id = std::string(text.mid(idS + 2, idE - idS - 2).text());
125 std::string id, type;
127 const std::string typedID = type +
":" + id;
138 std::string id, type;
140 const std::string typedID = type +
":" + id;
145 }
else if (type ==
"junction") {
156 const FXint end = text.find_first_of(
" ,", pos + 1);
159 time = text.mid(pos, end - pos).text();
161 time = text.mid(pos, text.length() - pos).text();
165 if (time.back() ==
'\n') {
171 if (time.back() ==
'.') {
178 if (time.front() ==
' ') {
179 time = time.substr(1);
193 FXText::setCursorPos(pos, notify);
196 if (viewIDs.empty()) {
200 const FXString text = getText();
202 if (glObj !=
nullptr) {
205 if (getApp()->getKeyState(KEY_Control_L)) {
209 const int lookback =
MIN2(pos, 20);
210 const int start =
MAX2(lineStart(pos), pos - lookback);
211 const FXString candidate = text.mid(start, lineEnd(pos) - start);
212 FXint timePos = candidate.find(
myTimeText.c_str());
215 if (pos >= 0 && pos > start + timePos) {
258 FXString text(msg.c_str());
260 FXint pos = text.find(
"'");
263 FXString insText = text.left(pos + 1);
264 FXText::appendStyledText(insText, style + 1);
265 text.erase(0, pos + 1);
266 pos = text.find(
"'");
267 insText = text.left(pos);
268 FXText::appendStyledText(insText, style + 4);
271 pos = text.find(
"'", pos + 1);
275 const int timeTerm = (int)
myTimeText.size() + 1;
281 FXString insText = text.left(pos + timeTerm);
282 FXText::appendStyledText(insText, style + 1);
283 text.erase(0, pos + timeTerm);
284 pos = text.find(
" ");
286 pos = text.rfind(
".");
288 insText = text.left(pos);
289 FXText::appendStyledText(insText, style + 4);
294 FXText::appendStyledText(text, style + 1,
true);
295 FXText::setCursorPos(getLength() - 1);
296 FXText::setBottomLine(getLength() - 1);
306 std::string msg = std::string(100,
'-') +
"\n";
307 FXText::appendStyledText(msg.c_str(), (FXint) msg.length(), 1,
true);
308 FXText::setCursorPos(getLength() - 1);
309 FXText::setBottomLine(getLength() - 1);
319 if (getLength() == 0) {
322 FXText::removeText(0, getLength(),
true);
354 FXEvent* e = (FXEvent*) ptr;
356 if (e->state & CONTROLMASK) {
357 return FXText::onKeyPress(o, sel, ptr);
365 FXText::onRightBtnRelease(o, sel, ptr);
369 FXEvent*
event = (FXEvent*)ptr;
374 FXMenuPane contextMenu(
this);
378 nullptr,
this, FXText::ID_SELECT_ALL);
379 if (getSelStartPos() >= getSelEndPos()) {
382 if (getLength() == 0) {
383 selAllCmd->disable();
385 new FXMenuSeparator(&contextMenu);
388 if (getLength() == 0) {
391 contextMenu.create();
392 contextMenu.popup(
nullptr, event->root_x, event->root_y);
393 getApp()->runModalWhileShown(&contextMenu);
407 sender->handle(
this, getLength() > 0 ? FXSEL(SEL_COMMAND, ID_ENABLE) : FXSEL(SEL_COMMAND, ID_DISABLE), ptr);
420 const FXColor white = FXRGB(0xff, 0xff, 0xff);
421 const FXColor blue = FXRGB(0x00, 0x00, 0x88);
422 const FXColor green = FXRGB(0x00, 0x88, 0x00);
423 const FXColor red = FXRGB(0x88, 0x00, 0x00);
424 const FXColor yellow = FXRGB(0xe6, 0x98, 0x00);
425 const FXColor fuchsia = FXRGB(0x88, 0x00, 0x88);
428 myStyles[0].normalBackColor = white;
429 myStyles[0].selectForeColor = white;
432 myStyles[0].hiliteBackColor = white;
433 myStyles[0].activeBackColor = white;
437 myStyles[1].normalForeColor = green;
438 myStyles[1].selectBackColor = green;
439 myStyles[1].hiliteForeColor = green;
441 myStyles[4].style = STYLE_UNDERLINE;
448 myStyles[5].style = STYLE_UNDERLINE;
451 myStyles[3].normalForeColor = yellow;
452 myStyles[3].selectBackColor = yellow;
453 myStyles[3].hiliteForeColor = yellow;
455 myStyles[6].style = STYLE_UNDERLINE;
458 myStyles[7].normalForeColor = fuchsia;
459 myStyles[7].selectBackColor = fuchsia;
460 myStyles[7].hiliteForeColor = fuchsia;
@ MID_CLEARMESSAGEWINDOW
Clear simulation output.
@ MESSAGE_OCCURRED
send when a message occurred
@ GLDEBUG_OCCURRED
send when a gldebug occurred
@ ERROR_OCCURRED
send when a error occurred
@ DEBUG_OCCURRED
send when a debug occurred
@ WARNING_OCCURRED
send when a warning occurred
GUISelectedStorage gSelected
A global holder of selected objects.
FXDEFMAP(GUIMessageWindow) GUIMessageWindowMap[]
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
constexpr SUMOTime TIME2STEPS(double x)
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
static FXMenuCommand * buildFXMenuCommandShortcut(FXComposite *p, const std::string &text, const std::string &shortcut, const std::string &info, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
void setView(GUIGlID id)
Centers the view onto the given artifact.
GUIGlID getGlID() const
Returns the numerical id of the object.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
virtual void addBreakpoint(SUMOTime)
add breakpoint to the application
GUIGlChildWindow * getViewByID(const std::string &id) const
get specific view by ID
std::vector< std::string > getViewIDs() const
get view IDs
A logging window for the gui.
GUIMainWindow * myMainWindow
main window
void addSeparator()
Adds a a separator to this log window.
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations.
void unregisterMsgHandlers()
unregister message handlers
static SUMOTime myBreakPointOffset
Offset when creating breakpoint by clicking on time links.
void clear()
Clears the window.
void fillStyles()
fill styles
static std::string myTimeText
The time text to look for.
static FXHiliteStyle * myStyles
The text colors used.
static bool myLocateLinks
whether messages are linked to the GUI elements
long onRightBtnRelease(FXObject *o, FXSelector sel, void *data)
handle right button release
long onUpdClear(FXObject *sender, FXSelector, void *data)
handle update of clear command
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
static FXHiliteStyle * getStyles()
The text colors used.
virtual void setCursorPos(FXint pos, FXbool notify=FALSE)
set cursor position over a certain line
SUMOTime getTimeString(const FXString &text, const FXint pos) const
get time string object
static std::map< std::string, std::string > myTypeStrings
The translated type strings text to look for.
OutputDevice * myWarningRetriever
OutputDevice * myMessageRetriever
static bool findObjectTypeID(const FXString &text, const FXint pos, const FXint lineS, const FXint lineE, std::string &id, std::string &type)
get active string object
~GUIMessageWindow()
Destructor.
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
long onCmdClear(FXObject *, FXSelector, void *)
handle clear command
const GUIGlObject * getActiveStringObject(const FXString &text, const FXint pos, const FXint lineS, const FXint lineE) const
bool hasActiveStringObject(const FXString &text, const FXint pos) const
void registerMsgHandlers()
register message handlers
void toggleSelection(GUIGlID id)
Toggles selection of an object.
virtual void addRetriever(OutputDevice *retriever)
Adds a further retriever to the instance responsible for a certain msg type.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
virtual void removeRetriever(OutputDevice *retriever)
Removes the retriever from the handler.
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.
static std::string to_lower_case(const std::string &str)
Transfers the content to lower case.