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 /****************************************************************************/
15 // A logging window for the gui
16 /****************************************************************************/
17 #ifndef GUIMessageWindow_h
18 #define GUIMessageWindow_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <string>
27 #include <fx.h>
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class GUIGlObject;
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
53 class GUIMessageWindow : public FXText {
54 public:
59  GUIMessageWindow(FXComposite* parent);
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 
99 private:
101  class MsgOutputDevice : public OutputDevice {
102  public:
105  myMsgWindow(msgWindow),
106  myType(type) { }
107 
110 
111  protected:
113  std::ostream& getOStream() {
114  return myStream;
115  }
117  void postWriteHook() {
119  myStream.str("");
120  }
121 
122  private:
125 
127  std::ostringstream myStream;
128 
131  };
132 
134  const GUIGlObject* getActiveStringObject(const FXString& text, const FXint pos, const FXint lineS, const FXint lineE) const;
135 
136 private:
138  static bool myLocateLinks;
139 
141  FXHiliteStyle* myStyles;
142 
145 };
146 
147 
148 #endif
149 
150 /****************************************************************************/
151 
GUIMessageWindow::MsgOutputDevice::MsgOutputDevice
MsgOutputDevice(GUIMessageWindow *msgWindow, GUIEventType type)
constructor
Definition: GUIMessageWindow.h:104
GUIMessageWindow::MsgOutputDevice::myType
GUIEventType myType
type of event
Definition: GUIMessageWindow.h:130
GUIMessageWindow::myMessageRetriever
OutputDevice * myMessageRetriever
Definition: GUIMessageWindow.h:144
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GUIMessageWindow
A logging window for the gui.
Definition: GUIMessageWindow.h:53
GUIMessageWindow::GUIMessageWindow
GUIMessageWindow(FXComposite *parent)
Constructor.
Definition: GUIMessageWindow.cpp:44
GUIMessageWindow::myWarningRetriever
OutputDevice * myWarningRetriever
Definition: GUIMessageWindow.h:144
GUIMessageWindow::MsgOutputDevice::~MsgOutputDevice
~MsgOutputDevice()
destructor
Definition: GUIMessageWindow.h:109
GUIMessageWindow::getActiveStringObject
const GUIGlObject * getActiveStringObject(const FXString &text, const FXint pos, const FXint lineS, const FXint lineE) const
get active string object
Definition: GUIMessageWindow.cpp:107
GUIEventType
GUIEventType
Definition: GUIEvent.h:34
GUIMessageWindow::myStyles
FXHiliteStyle * myStyles
The text colors used.
Definition: GUIMessageWindow.h:141
GUIMessageWindow::~GUIMessageWindow
~GUIMessageWindow()
Destructor.
Definition: GUIMessageWindow.cpp:98
GUIMessageWindow::unregisterMsgHandlers
void unregisterMsgHandlers()
unregister message handlers
Definition: GUIMessageWindow.cpp:261
GUIMessageWindow::addSeparator
void addSeparator()
Adds a a separator to this log window.
Definition: GUIMessageWindow.cpp:217
GUIMessageWindow::clear
void clear()
Clears the window.
Definition: GUIMessageWindow.cpp:230
GUIMessageWindow::myErrorRetriever
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations.
Definition: GUIMessageWindow.h:144
GUIMessageWindow::myLocateLinks
static bool myLocateLinks
whether messages are linked to the GUI elements
Definition: GUIMessageWindow.h:138
OutputDevice.h
GUIGlObject
Definition: GUIGlObject.h:65
GUIMessageWindow::MsgOutputDevice::myStream
std::ostringstream myStream
output string stream
Definition: GUIMessageWindow.h:127
GUIMessageWindow::locateLinksEnabled
static bool locateLinksEnabled()
ask whether locate links is enabled
Definition: GUIMessageWindow.h:95
GUIMessageWindow::appendMsg
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
Definition: GUIMessageWindow.cpp:157
GUIMessageWindow::MsgOutputDevice::postWriteHook
void postWriteHook()
write hook
Definition: GUIMessageWindow.h:117
GUIMessageWindow::enableLocateLinks
static void enableLocateLinks(const bool val)
switch locate links on and off
Definition: GUIMessageWindow.h:90
GUIMessageWindow::setCursorPos
virtual void setCursorPos(FXint pos, FXbool notify=FALSE)
set cursor position over a certain line
Definition: GUIMessageWindow.cpp:134
GUIEvent.h
GUIMessageWindow::MsgOutputDevice::getOStream
std::ostream & getOStream()
get Output Stream
Definition: GUIMessageWindow.h:113
GUIMessageWindow::myGLDebugRetriever
OutputDevice * myGLDebugRetriever
Definition: GUIMessageWindow.h:144
GUIMessageWindow::registerMsgHandlers
void registerMsgHandlers()
register message handlers
Definition: GUIMessageWindow.cpp:243
config.h
GUIMessageWindow::MsgOutputDevice::myMsgWindow
GUIMessageWindow * myMsgWindow
pointer to message Windows
Definition: GUIMessageWindow.h:124
GUIMessageWindow::myDebugRetriever
OutputDevice * myDebugRetriever
Definition: GUIMessageWindow.h:144
GUIMessageWindow::MsgOutputDevice
class MsgOutputDevice
Definition: GUIMessageWindow.h:101