GUIMessageWindow.cpp

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

Generated on Wed May 5 00:06:30 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6