Eclipse SUMO - Simulation of Urban MObility
GUIMessageWindow.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2003-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
19 // A logging window for the gui
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include <string>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class GUIGlObject;
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
52 class GUIMessageWindow : public FXText {
53  FXDECLARE(GUIMessageWindow)
54 public:
59  GUIMessageWindow(FXComposite* parent, GUIMainWindow* mainWindow);
60 
63 
65  virtual void setCursorPos(FXint pos, FXbool notify = FALSE);
66 
75  void appendMsg(GUIEventType eType, const std::string& msg);
76 
78  void addSeparator();
79 
81  void clear();
82 
84  void registerMsgHandlers();
85 
87  void unregisterMsgHandlers();
88 
90  static void enableLocateLinks(const bool val) {
91  myLocateLinks = val;
92  }
93 
95  static bool locateLinksEnabled() {
96  return myLocateLinks;
97  }
98 
100  static void setBreakPointOffset(SUMOTime val) {
101  myBreakPointOffset = val;
102  }
103 
106  return myBreakPointOffset;
107  }
108 
110  long onKeyPress(FXObject* o, FXSelector sel, void* data);
111 
113  static FXHiliteStyle* getStyles();
114 
115 protected:
117  FOX_CONSTRUCTOR(GUIMessageWindow)
118 
119 private:
121  class MsgOutputDevice : public OutputDevice {
122 
123  public:
126  myMsgWindow(msgWindow),
127  myType(type) { }
128 
131 
132  protected:
134  std::ostream& getOStream() {
135  return myStream;
136  }
138  void postWriteHook() {
140  myStream.str("");
141  }
142 
143  private:
146 
148  std::ostringstream myStream;
149 
152  };
153 
155  const GUIGlObject* getActiveStringObject(const FXString& text, const FXint pos, const FXint lineS, const FXint lineE) const;
156 
158  SUMOTime getTimeString(const FXString& text, const FXint pos, const FXint lineS, const FXint lineE) const;
159 
161  void fillStyles();
162 
165 
167  static bool myLocateLinks;
168 
171 
173  static FXHiliteStyle* myStyles;
174 
177 };
long long int SUMOTime
Definition: GUI.h:35
GUIEventType
Definition: GUIEvent.h:32
std::ostream & getOStream()
get Output Stream
std::ostringstream myStream
output string stream
MsgOutputDevice(GUIMessageWindow *msgWindow, GUIEventType type)
constructor
GUIMessageWindow * myMsgWindow
pointer to message Windows
GUIEventType myType
type of event
A logging window for the gui.
GUIMainWindow * myMainWindow
main window
OutputDevice * myGLDebugRetriever
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
SUMOTime getTimeString(const FXString &text, const FXint pos, const FXint lineS, const FXint lineE) const
get time string object
static FXHiliteStyle * myStyles
The text colors used.
static bool myLocateLinks
whether messages are linked to the GUI elements
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
static bool locateLinksEnabled()
ask whether locate links is enabled
static FXHiliteStyle * getStyles()
The text colors used.
static void enableLocateLinks(const bool val)
switch locate links on and off
virtual void setCursorPos(FXint pos, FXbool notify=FALSE)
set cursor position over a certain line
GUIMessageWindow(FXComposite *parent, GUIMainWindow *mainWindow)
Constructor.
static void setBreakPointOffset(SUMOTime val)
switch locate links on and off
OutputDevice * myWarningRetriever
OutputDevice * myMessageRetriever
OutputDevice * myDebugRetriever
~GUIMessageWindow()
Destructor.
static SUMOTime getBreakPointOffset()
ask whether locate links is enabled
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
const GUIGlObject * getActiveStringObject(const FXString &text, const FXint pos, const FXint lineS, const FXint lineE) const
get active string object
void registerMsgHandlers()
register message handlers
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61