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