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.org/sumo
3 // Copyright (C) 2003-2020 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>
25 #include <fx.h>
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class GUIGlObject;
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
51 class GUIMessageWindow : public FXText {
52 public:
57  GUIMessageWindow(FXComposite* parent);
58 
61 
63  virtual void setCursorPos(FXint pos, FXbool notify = FALSE);
64 
73  void appendMsg(GUIEventType eType, const std::string& msg);
74 
76  void addSeparator();
77 
79  void clear();
80 
82  void registerMsgHandlers();
83 
85  void unregisterMsgHandlers();
86 
88  static void enableLocateLinks(const bool val) {
89  myLocateLinks = val;
90  }
91 
93  static bool locateLinksEnabled() {
94  return myLocateLinks;
95  }
96 
97 private:
99  class MsgOutputDevice : public OutputDevice {
100  public:
103  myMsgWindow(msgWindow),
104  myType(type) { }
105 
108 
109  protected:
111  std::ostream& getOStream() {
112  return myStream;
113  }
115  void postWriteHook() {
117  myStream.str("");
118  }
119 
120  private:
123 
125  std::ostringstream myStream;
126 
129  };
130 
132  const GUIGlObject* getActiveStringObject(const FXString& text, const FXint pos, const FXint lineS, const FXint lineE) const;
133 
134 private:
136  static bool myLocateLinks;
137 
139  FXHiliteStyle* myStyles;
140 
143 };
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.
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
void clear()
Clears the window.
GUIMessageWindow(FXComposite *parent)
Constructor.
static bool myLocateLinks
whether messages are linked to the GUI elements
FXHiliteStyle * myStyles
The text colors used.
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
static bool locateLinksEnabled()
ask whether locate links is enabled
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
OutputDevice * myWarningRetriever
OutputDevice * myMessageRetriever
OutputDevice * myDebugRetriever
~GUIMessageWindow()
Destructor.
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:60