SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00008 // A logging window for the gui 00009 /****************************************************************************/ 00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00012 /****************************************************************************/ 00013 // 00014 // This file is part of SUMO. 00015 // SUMO is free software: you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation, either version 3 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <cassert> 00033 #include "GUIMessageWindow.h" 00034 00035 #ifdef CHECK_MEMORY_LEAKS 00036 #include <foreign/nvwa/debug_new.h> 00037 #endif // CHECK_MEMORY_LEAKS 00038 00039 00040 // =========================================================================== 00041 // method definitions 00042 // =========================================================================== 00043 GUIMessageWindow::GUIMessageWindow(FXComposite* parent) 00044 : FXText(parent, 0, 0, 0, 0, 0, 0, 50), 00045 myStyles(0) { 00046 setStyled(true); 00047 setEditable(false); 00048 myStyles = new FXHiliteStyle[4]; 00049 // set separator style 00050 myStyles[0].normalForeColor = FXRGB(0x00, 0x00, 0x88); 00051 myStyles[0].normalBackColor = FXRGB(0xff, 0xff, 0xff); 00052 myStyles[0].selectForeColor = FXRGB(0xff, 0xff, 0xff); 00053 myStyles[0].selectBackColor = FXRGB(0x00, 0x00, 0x88); 00054 myStyles[0].hiliteForeColor = FXRGB(0x00, 0x00, 0x88); 00055 myStyles[0].hiliteBackColor = FXRGB(0xff, 0xff, 0xff); 00056 myStyles[0].activeBackColor = FXRGB(0xff, 0xff, 0xff); 00057 myStyles[0].style = 0; 00058 // set message text style 00059 myStyles[1].normalForeColor = FXRGB(0x00, 0x88, 0x00); 00060 myStyles[1].normalBackColor = FXRGB(0xff, 0xff, 0xff); 00061 myStyles[1].selectForeColor = FXRGB(0xff, 0xff, 0xff); 00062 myStyles[1].selectBackColor = FXRGB(0x00, 0x88, 0x00); 00063 myStyles[1].hiliteForeColor = FXRGB(0x00, 0x88, 0x00); 00064 myStyles[1].hiliteBackColor = FXRGB(0xff, 0xff, 0xff); 00065 myStyles[1].activeBackColor = FXRGB(0xff, 0xff, 0xff); 00066 myStyles[1].style = 0; 00067 // set error text style 00068 myStyles[2].normalForeColor = FXRGB(0x88, 0x00, 0x00); 00069 myStyles[2].normalBackColor = FXRGB(0xff, 0xff, 0xff); 00070 myStyles[2].selectForeColor = FXRGB(0xff, 0xff, 0xff); 00071 myStyles[2].selectBackColor = FXRGB(0x88, 0x00, 0x00); 00072 myStyles[2].hiliteForeColor = FXRGB(0x88, 0x00, 0x00); 00073 myStyles[2].hiliteBackColor = FXRGB(0xff, 0xff, 0xff); 00074 myStyles[2].activeBackColor = FXRGB(0xff, 0xff, 0xff); 00075 myStyles[2].style = 0; 00076 // set warning text style 00077 myStyles[3].normalForeColor = FXRGB(0xe6, 0x98, 0x00); 00078 myStyles[3].normalBackColor = FXRGB(0xff, 0xff, 0xff); 00079 myStyles[3].selectForeColor = FXRGB(0xff, 0xff, 0xff); 00080 myStyles[3].selectBackColor = FXRGB(0xe6, 0x98, 0x00); 00081 myStyles[3].hiliteForeColor = FXRGB(0xe6, 0x98, 0x00); 00082 myStyles[3].hiliteBackColor = FXRGB(0xff, 0xff, 0xff); 00083 myStyles[3].activeBackColor = FXRGB(0xff, 0xff, 0xff); 00084 myStyles[3].style = 0; 00085 // 00086 setHiliteStyles(myStyles); 00087 } 00088 00089 00090 GUIMessageWindow::~GUIMessageWindow() { 00091 delete[] myStyles; 00092 } 00093 00094 00095 void 00096 GUIMessageWindow::appendText(GUIEventType eType, const std::string& msg) { 00097 if (!isEnabled()) { 00098 show(); 00099 } 00100 // build the styled message 00101 FXint style = 1; 00102 switch (eType) { 00103 case EVENT_ERROR_OCCURED: 00104 // color: red 00105 style = 2; 00106 break; 00107 case EVENT_WARNING_OCCURED: 00108 // color: yellow 00109 style = 3; 00110 break; 00111 case EVENT_MESSAGE_OCCURED: 00112 // color: green 00113 style = 1; 00114 break; 00115 default: 00116 assert(false); 00117 } 00118 // insert message to buffer 00119 FXText::appendStyledText(msg.c_str(), (FXint) msg.length(), style + 1, true); 00120 FXText::setCursorPos(getLength() - 1); 00121 FXText::setBottomLine(getLength() - 1); 00122 if (isEnabled()) { 00123 layout(); 00124 update(); 00125 } 00126 } 00127 00128 00129 void 00130 GUIMessageWindow::addSeparator() { 00131 std::string msg = "----------------------------------------------------------------------------------------\n"; 00132 FXText::appendStyledText(msg.c_str(), (FXint) msg.length(), 1, true); 00133 FXText::setCursorPos(getLength() - 1); 00134 FXText::setBottomLine(getLength() - 1); 00135 if (isEnabled()) { 00136 layout(); 00137 update(); 00138 } 00139 } 00140 00141 00142 void 00143 GUIMessageWindow::clear() { 00144 if (getLength() == 0) { 00145 return; 00146 } 00147 FXText::removeText(0, getLength() - 1, true); 00148 if (isEnabled()) { 00149 layout(); 00150 update(); 00151 } 00152 } 00153 00154 00155 00156 /****************************************************************************/ 00157