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.sourceforge.net/
11 // Copyright (C) 2001-2012 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>
33 #include "GUIMessageWindow.h"
34 
35 #ifdef CHECK_MEMORY_LEAKS
36 #include <foreign/nvwa/debug_new.h>
37 #endif // CHECK_MEMORY_LEAKS
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
44  : FXText(parent, 0, 0, 0, 0, 0, 0, 50),
45  myStyles(0) {
46  setStyled(true);
47  setEditable(false);
48  myStyles = new FXHiliteStyle[4];
49  // set separator style
50  myStyles[0].normalForeColor = FXRGB(0x00, 0x00, 0x88);
51  myStyles[0].normalBackColor = FXRGB(0xff, 0xff, 0xff);
52  myStyles[0].selectForeColor = FXRGB(0xff, 0xff, 0xff);
53  myStyles[0].selectBackColor = FXRGB(0x00, 0x00, 0x88);
54  myStyles[0].hiliteForeColor = FXRGB(0x00, 0x00, 0x88);
55  myStyles[0].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
56  myStyles[0].activeBackColor = FXRGB(0xff, 0xff, 0xff);
57  myStyles[0].style = 0;
58  // set message text style
59  myStyles[1].normalForeColor = FXRGB(0x00, 0x88, 0x00);
60  myStyles[1].normalBackColor = FXRGB(0xff, 0xff, 0xff);
61  myStyles[1].selectForeColor = FXRGB(0xff, 0xff, 0xff);
62  myStyles[1].selectBackColor = FXRGB(0x00, 0x88, 0x00);
63  myStyles[1].hiliteForeColor = FXRGB(0x00, 0x88, 0x00);
64  myStyles[1].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
65  myStyles[1].activeBackColor = FXRGB(0xff, 0xff, 0xff);
66  myStyles[1].style = 0;
67  // set error text style
68  myStyles[2].normalForeColor = FXRGB(0x88, 0x00, 0x00);
69  myStyles[2].normalBackColor = FXRGB(0xff, 0xff, 0xff);
70  myStyles[2].selectForeColor = FXRGB(0xff, 0xff, 0xff);
71  myStyles[2].selectBackColor = FXRGB(0x88, 0x00, 0x00);
72  myStyles[2].hiliteForeColor = FXRGB(0x88, 0x00, 0x00);
73  myStyles[2].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
74  myStyles[2].activeBackColor = FXRGB(0xff, 0xff, 0xff);
75  myStyles[2].style = 0;
76  // set warning text style
77  myStyles[3].normalForeColor = FXRGB(0xe6, 0x98, 0x00);
78  myStyles[3].normalBackColor = FXRGB(0xff, 0xff, 0xff);
79  myStyles[3].selectForeColor = FXRGB(0xff, 0xff, 0xff);
80  myStyles[3].selectBackColor = FXRGB(0xe6, 0x98, 0x00);
81  myStyles[3].hiliteForeColor = FXRGB(0xe6, 0x98, 0x00);
82  myStyles[3].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
83  myStyles[3].activeBackColor = FXRGB(0xff, 0xff, 0xff);
84  myStyles[3].style = 0;
85  //
86  setHiliteStyles(myStyles);
87 }
88 
89 
91  delete[] myStyles;
92 }
93 
94 
95 void
96 GUIMessageWindow::appendText(GUIEventType eType, const std::string& msg) {
97  if (!isEnabled()) {
98  show();
99  }
100  // build the styled message
101  FXint style = 1;
102  switch (eType) {
103  case EVENT_ERROR_OCCURED:
104  // color: red
105  style = 2;
106  break;
108  // color: yellow
109  style = 3;
110  break;
112  // color: green
113  style = 1;
114  break;
115  default:
116  assert(false);
117  }
118  // insert message to buffer
119  FXText::appendStyledText(msg.c_str(), (FXint) msg.length(), style + 1, true);
120  FXText::setCursorPos(getLength() - 1);
121  FXText::setBottomLine(getLength() - 1);
122  if (isEnabled()) {
123  layout();
124  update();
125  }
126 }
127 
128 
129 void
131  std::string msg = "----------------------------------------------------------------------------------------\n";
132  FXText::appendStyledText(msg.c_str(), (FXint) msg.length(), 1, true);
133  FXText::setCursorPos(getLength() - 1);
134  FXText::setBottomLine(getLength() - 1);
135  if (isEnabled()) {
136  layout();
137  update();
138  }
139 }
140 
141 
142 void
144  if (getLength() == 0) {
145  return;
146  }
147  FXText::removeText(0, getLength() - 1, true);
148  if (isEnabled()) {
149  layout();
150  update();
151  }
152 }
153 
154 
155 
156 /****************************************************************************/
157