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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // A logging window for the gui
19 /****************************************************************************/
20 #ifndef GUIMessageWindow_h
21 #define GUIMessageWindow_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <fx.h>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class GUIGlObject;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
60 class GUIMessageWindow : public FXText {
61 public:
66  GUIMessageWindow(FXComposite* parent);
67 
68 
71 
72 
73  virtual void setCursorPos(FXint pos, FXbool notify = FALSE);
74 
75 
84  void appendMsg(GUIEventType eType, const std::string& msg);
85 
86 
88  void addSeparator();
89 
90 
92  void clear();
93 
95  void registerMsgHandlers();
96  void unregisterMsgHandlers();
97 
99  static void enableLocateLinks(const bool val) {
100  myLocateLinks = val;
101  }
102 
104  static bool locateLinksEnabled() {
105  return myLocateLinks;
106  }
107 
108 
109 private:
110  class MsgOutputDevice : public OutputDevice {
111  public:
113  myMsgWindow(msgWindow),
114  myType(type) { }
115 
117 
118  protected:
119  std::ostream& getOStream() {
120  return myStream;
121  }
122  void postWriteHook() {
124  myStream.str("");
125  }
126 
127  private:
129  std::ostringstream myStream;
131  };
132 
133  const GUIGlObject* getActiveStringObject(const FXString& text, const FXint pos, const FXint lineS, const FXint lineE) const;
134 
135 private:
136 
138  static bool myLocateLinks;
139 
141  FXHiliteStyle* myStyles;
142 
145 
146 
147 
148 };
149 
150 
151 #endif
152 
153 /****************************************************************************/
154 
std::ostream & getOStream()
Returns the associated ostream.
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
void registerMsgHandlers()
register and unregister message handlers
~GUIMessageWindow()
Destructor.
void addSeparator()
Adds a a separator to this log window.
void postWriteHook()
Called after every write access.
FXHiliteStyle * myStyles
The text colors used.
virtual void setCursorPos(FXint pos, FXbool notify=FALSE)
GUIMessageWindow(FXComposite *parent)
Constructor.
GUIEventType
Definition: GUIEvent.h:41
MsgOutputDevice(GUIMessageWindow *msgWindow, GUIEventType type)
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
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
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