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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // A logging window for the gui
17 /****************************************************************************/
18 #ifndef GUIMessageWindow_h
19 #define GUIMessageWindow_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <fx.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class GUIGlObject;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
54 class GUIMessageWindow : public FXText {
55 public:
60  GUIMessageWindow(FXComposite* parent);
61 
64 
66  virtual void setCursorPos(FXint pos, FXbool notify = FALSE);
67 
76  void appendMsg(GUIEventType eType, const std::string& msg);
77 
79  void addSeparator();
80 
82  void clear();
83 
85  void registerMsgHandlers();
86 
88  void unregisterMsgHandlers();
89 
91  static void enableLocateLinks(const bool val) {
92  myLocateLinks = val;
93  }
94 
96  static bool locateLinksEnabled() {
97  return myLocateLinks;
98  }
99 
100 private:
102  class MsgOutputDevice : public OutputDevice {
103  public:
106  myMsgWindow(msgWindow),
107  myType(type) { }
108 
111 
112  protected:
114  std::ostream& getOStream() {
115  return myStream;
116  }
118  void postWriteHook() {
120  myStream.str("");
121  }
122 
123  private:
126 
128  std::ostringstream myStream;
129 
132  };
133 
135  const GUIGlObject* getActiveStringObject(const FXString& text, const FXint pos, const FXint lineS, const FXint lineE) const;
136 
137 private:
139  static bool myLocateLinks;
140 
142  FXHiliteStyle* myStyles;
143 
146 };
147 
148 
149 #endif
150 
151 /****************************************************************************/
152 
GUIEventType myType
type of event
std::ostringstream myStream
output string stream
std::ostream & getOStream()
get Output Stream
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
OutputDevice * myGLDebugRetriever
void registerMsgHandlers()
register message handlers
void unregisterMsgHandlers()
unregister message handlers
~GUIMessageWindow()
Destructor.
void addSeparator()
Adds a a separator to this log window.
OutputDevice * myDebugRetriever
FXHiliteStyle * myStyles
The text colors used.
virtual void setCursorPos(FXint pos, FXbool notify=FALSE)
set cursor position over a certain line
GUIMessageWindow(FXComposite *parent)
Constructor.
GUIEventType
Definition: GUIEvent.h:35
MsgOutputDevice(GUIMessageWindow *msgWindow, GUIEventType type)
constructor
OutputDevice * myMessageRetriever
static void enableLocateLinks(const bool val)
switch locate links on and off
static bool myLocateLinks
whether messages are linked to the GUI elements
const GUIGlObject * getActiveStringObject(const FXString &text, const FXint pos, const FXint lineS, const FXint lineE) const
get active string object
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
GUIMessageWindow * myMsgWindow
pointer to message Windows
void clear()
Clears the window.
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations.
static bool locateLinksEnabled()
ask whether locate links is enabled
A logging window for the gui.
OutputDevice * myWarningRetriever