SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIMessageWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A logging window for the gui
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2003-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
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 <cassert>
35 #include "GUIMessageWindow.h"
36 
37 #ifdef CHECK_MEMORY_LEAKS
38 #include <foreign/nvwa/debug_new.h>
39 #endif // CHECK_MEMORY_LEAKS
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
45 GUIMessageWindow::GUIMessageWindow(FXComposite* parent) :
46  FXText(parent, 0, 0, 0, 0, 0, 0, 50),
47  myStyles(0),
48  myErrorRetriever(0),
49  myMessageRetriever(0),
50  myWarningRetriever(0) {
51  setStyled(true);
52  setEditable(false);
53  myStyles = new FXHiliteStyle[4];
54  // set separator style
55  myStyles[0].normalForeColor = FXRGB(0x00, 0x00, 0x88);
56  myStyles[0].normalBackColor = FXRGB(0xff, 0xff, 0xff);
57  myStyles[0].selectForeColor = FXRGB(0xff, 0xff, 0xff);
58  myStyles[0].selectBackColor = FXRGB(0x00, 0x00, 0x88);
59  myStyles[0].hiliteForeColor = FXRGB(0x00, 0x00, 0x88);
60  myStyles[0].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
61  myStyles[0].activeBackColor = FXRGB(0xff, 0xff, 0xff);
62  myStyles[0].style = 0;
63  // set message text style
64  myStyles[1].normalForeColor = FXRGB(0x00, 0x88, 0x00);
65  myStyles[1].normalBackColor = FXRGB(0xff, 0xff, 0xff);
66  myStyles[1].selectForeColor = FXRGB(0xff, 0xff, 0xff);
67  myStyles[1].selectBackColor = FXRGB(0x00, 0x88, 0x00);
68  myStyles[1].hiliteForeColor = FXRGB(0x00, 0x88, 0x00);
69  myStyles[1].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
70  myStyles[1].activeBackColor = FXRGB(0xff, 0xff, 0xff);
71  myStyles[1].style = 0;
72  // set error text style
73  myStyles[2].normalForeColor = FXRGB(0x88, 0x00, 0x00);
74  myStyles[2].normalBackColor = FXRGB(0xff, 0xff, 0xff);
75  myStyles[2].selectForeColor = FXRGB(0xff, 0xff, 0xff);
76  myStyles[2].selectBackColor = FXRGB(0x88, 0x00, 0x00);
77  myStyles[2].hiliteForeColor = FXRGB(0x88, 0x00, 0x00);
78  myStyles[2].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
79  myStyles[2].activeBackColor = FXRGB(0xff, 0xff, 0xff);
80  myStyles[2].style = 0;
81  // set warning text style
82  myStyles[3].normalForeColor = FXRGB(0xe6, 0x98, 0x00);
83  myStyles[3].normalBackColor = FXRGB(0xff, 0xff, 0xff);
84  myStyles[3].selectForeColor = FXRGB(0xff, 0xff, 0xff);
85  myStyles[3].selectBackColor = FXRGB(0xe6, 0x98, 0x00);
86  myStyles[3].hiliteForeColor = FXRGB(0xe6, 0x98, 0x00);
87  myStyles[3].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
88  myStyles[3].activeBackColor = FXRGB(0xff, 0xff, 0xff);
89  myStyles[3].style = 0;
90  //
91  setHiliteStyles(myStyles);
92 }
93 
94 
96  delete[] myStyles;
97  delete myMessageRetriever;
98  delete myErrorRetriever;
99  delete myWarningRetriever;
100 }
101 
102 
103 void
104 GUIMessageWindow::appendText(GUIEventType eType, const std::string& msg) {
105  if (!isEnabled()) {
106  show();
107  }
108  // build the styled message
109  FXint style = 1;
110  switch (eType) {
111  case EVENT_ERROR_OCCURED:
112  // color: red
113  style = 2;
114  break;
116  // color: yellow
117  style = 3;
118  break;
120  // color: green
121  style = 1;
122  break;
123  default:
124  assert(false);
125  }
126  // insert message to buffer
127  FXText::appendStyledText(msg.c_str(), (FXint) msg.length(), style + 1, true);
128  FXText::setCursorPos(getLength() - 1);
129  FXText::setBottomLine(getLength() - 1);
130  if (isEnabled()) {
131  layout();
132  update();
133  }
134 }
135 
136 
137 void
139  std::string msg = "----------------------------------------------------------------------------------------\n";
140  FXText::appendStyledText(msg.c_str(), (FXint) msg.length(), 1, true);
141  FXText::setCursorPos(getLength() - 1);
142  FXText::setBottomLine(getLength() - 1);
143  if (isEnabled()) {
144  layout();
145  update();
146  }
147 }
148 
149 
150 void
152  if (getLength() == 0) {
153  return;
154  }
155  FXText::removeText(0, getLength() - 1, true);
156  if (isEnabled()) {
157  layout();
158  update();
159  }
160 }
161 
162 
163 void
165  if (myMessageRetriever == 0) {
166  // initialize only if registration is requested
170  }
174 }
175 
176 
177 void
182 }
183 
184 
185 /****************************************************************************/
186