/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2003-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GUIMessageWindow.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @date Tue, 25 Nov 200317///18// A logging window for the gui19/****************************************************************************/20#pragma once21#include <config.h>2223#include <string>24#include <utils/foxtools/fxheader.h>25#include <utils/gui/events/GUIEvent.h>26#include <utils/gui/windows/GUIMainWindow.h>27#include <utils/iodevices/OutputDevice.h>282930// ===========================================================================31// class declarations32// ===========================================================================33class GUIGlObject;343536// ===========================================================================37// class definitions38// ===========================================================================39/**40* @class GUIMessageWindow41* @brief A logging window for the gui42*43* This class displays messages incoming to the gui from either the load or44* the run thread.45*46* The text is colored in dependence to its type (messages: green, warnings: yellow,47* errors: red)48*49* Each time a new message is passed, the window is reopened.50*/51class GUIMessageWindow : public FXText {52FXDECLARE(GUIMessageWindow)53public:54/** @brief Constructor55*56* @param[in] parent The parent window57*/58GUIMessageWindow(FXComposite* parent, GUIMainWindow* mainWindow);5960/// @brief Destructor61~GUIMessageWindow();6263/// @brief set cursor position over a certain line64virtual void setCursorPos(FXint pos, FXbool notify = FALSE);6566/** @brief Adds new text to the window67*68* The type of the text is determined by the first parameter69*70* @param[in] eType The type of the event the message was generated by71* @param[in] msg The message72* @see GUIEventType73*/74void appendMsg(GUIEventType eType, const std::string& msg);7576/// @brief Adds a a separator to this log window77void addSeparator();7879/// @brief Clears the window80void clear();8182/// @brief register message handlers83void registerMsgHandlers();8485/// @brief unregister message handlers86void unregisterMsgHandlers();8788/// @brief switch locate links on and off89static void enableLocateLinks(const bool val) {90myLocateLinks = val;91}9293/// @brief ask whether locate links is enabled94static bool locateLinksEnabled() {95return myLocateLinks;96}9798/// @brief switch locate links on and off99static void setBreakPointOffset(SUMOTime val) {100myBreakPointOffset = val;101}102103/// @brief ask whether locate links is enabled104static SUMOTime getBreakPointOffset() {105return myBreakPointOffset;106}107108/// @brief handle keys109long onKeyPress(FXObject* o, FXSelector sel, void* data);110111/// @brief The text colors used112static FXHiliteStyle* getStyles();113114protected:115/// @brief FOX needs this116FOX_CONSTRUCTOR(GUIMessageWindow)117118private:119/// @brief class MsgOutputDevice120class MsgOutputDevice : public OutputDevice {121122public:123/// @brief constructor124MsgOutputDevice(GUIMessageWindow* msgWindow, GUIEventType type) :125myMsgWindow(msgWindow),126myType(type) { }127128/// @brief destructor129~MsgOutputDevice() { }130131protected:132/// @brief get Output Stream133std::ostream& getOStream() {134return myStream;135}136/// @brief write hook137void postWriteHook() {138myMsgWindow->appendMsg(myType, myStream.str());139myStream.str("");140}141142private:143/// @brief pointer to message Windows144GUIMessageWindow* myMsgWindow;145146/// @brief output string stream147std::ostringstream myStream;148149/// @brief type of event150GUIEventType myType;151};152153/// @brief get active string object154const GUIGlObject* getActiveStringObject(const FXString& text, const FXint pos, const FXint lineS, const FXint lineE) const;155156/// @brief get time string object157SUMOTime getTimeString(const FXString& text, const FXint pos) const;158159/// @brief fill styles160void fillStyles();161162/// @brief main window163GUIMainWindow* myMainWindow;164165/// @brief whether messages are linked to the GUI elements166static bool myLocateLinks;167168/// @brief Offset when creating breakpoint by clicking on time links169static SUMOTime myBreakPointOffset;170171/// @brief The text colors used172static FXHiliteStyle* myStyles;173174/// @brief The time text to look for175static std::string myTimeText;176177/// @brief The translated type strings text to look for178static std::map<std::string, std::string> myTypeStrings;179180/// @brief The instances of message retriever encapsulations181OutputDevice* myErrorRetriever, *myMessageRetriever, *myWarningRetriever;182};183184185