#include <window_displayer.h>
Inheritance diagram for NLMISC::CWindowDisplayer:
Nevrax France
Definition at line 48 of file window_displayer.h.
Public Member Functions | |
void | create (std::string titleBar="", bool iconified=false, sint x=-1, sint y=-1, sint w=-1, sint h=-1, sint hs=-1, sint fs=0, const std::string &fn="", bool ww=false, CLog *log=InfoLog) |
uint | createLabel (const char *value="?") |
CWindowDisplayer (const char *displayerName="") | |
void | display (const CLog::TDisplayInfo &args, const char *message) |
Display the string where it does. | |
virtual void | getWindowPos (uint32 &x, uint32 &y, uint32 &w, uint32 &h) |
void | setLabel (uint label, const std::string &value) |
virtual void | setTitleBar (const std::string &titleBar) |
bool | update () |
virtual | ~CWindowDisplayer () |
Static Public Member Functions | |
const char * | dateToComputerString (time_t date) |
Convert date to "784551148" string (time in second from 1975). | |
const char * | dateToHumanString (time_t date) |
Convert date to "2000/01/14 10:05:17" string. | |
const char * | dateToHumanString () |
Convert the current date to human string. | |
const char * | logTypeToString (CLog::TLogType logType, bool longFormat=false) |
Convert log type to string. | |
Data Fields | |
std::string | DisplayerName |
This is the idenfiant for a displayer, it is used to fond or remove a displayer. | |
Protected Member Functions | |
virtual void | display_main ()=0 |
virtual void | doDisplay (const CLog::TDisplayInfo &args, const char *message)=0 |
Method to implement in the deriver. | |
virtual void | doDisplay (const NLMISC::CLog::TDisplayInfo &args, const char *message) |
virtual void | open (std::string titleBar, bool iconified, sint x, sint y, sint w, sint h, sint hs, sint fs, const std::string &fn, bool ww, CLog *log)=0 |
Static Protected Member Functions | |
const char * | HeaderString () |
Protected Attributes | |
CSynchronized< std::list< std::pair< uint32, std::string > > > | _Buffer |
CSynchronized< std::vector< std::string > > | _CommandsToExecute |
bool | _Continue |
std::vector< std::string > | _History |
sint | _HistorySize |
bool | _Init |
sint | _InputEditHeight |
CSynchronized< std::vector< CLabelEntry > > | _Labels |
uint | _PosInHistory |
NLMISC::IThread * | _Thread |
sint | _ToolBarHeight |
CLog * | Log |
bool | needSlashR |
Friends | |
class | CUpdateThread |
|
Definition at line 52 of file window_displayer.h. References _CommandsToExecute, _Continue, _HistorySize, _InputEditHeight, _Labels, _PosInHistory, and _ToolBarHeight.
00052 : 00053 IDisplayer(displayerName), 00054 _Buffer("CWindowDisplayer::_Buffer"), _Labels("CWindowDisplayer::_Labels"), _CommandsToExecute("CWindowDisplayer::_CommandsToExecute"), 00055 _Continue(true), _PosInHistory(0), _Init(false), _HistorySize(0), _ToolBarHeight(22), _InputEditHeight(25), _Thread(0), Log(0) 00056 { } |
|
Definition at line 68 of file window_displayer.cpp. References _Continue, nlassert, and NLMISC::IThread::wait().
|
|
Definition at line 120 of file window_displayer.cpp. References CUpdateThread, nlassert, sint, NLMISC::IThread::start(), w, x, and y. Referenced by NLNET::IService::main().
|
|
Definition at line 96 of file window_displayer.cpp. References _Labels, uint, and value. Referenced by NLNET::IService::main().
00097 { 00098 int pos; 00099 { 00100 CSynchronized<std::vector<CLabelEntry> >::CAccessor access (&_Labels); 00101 access.value().push_back (CLabelEntry(value)); 00102 pos = access.value().size()-1; 00103 } 00104 return pos; 00105 } |
|
Convert date to "784551148" string (time in second from 1975).
Definition at line 103 of file displayer.cpp. References NLMISC::smprintf().
00104 { 00105 static char cstime[25]; 00106 smprintf (cstime, 25, "%ld", &date); 00107 return cstime; 00108 } |
|
Convert date to "2000/01/14 10:05:17" string.
Definition at line 92 of file displayer.cpp. References uint32.
00093 { 00094 static char cstime[25]; 00095 struct tm *tms = localtime(&date); 00096 if (tms) 00097 strftime (cstime, 25, "%Y/%m/%d %H:%M:%S", tms); 00098 else 00099 sprintf(cstime, "bad date %d", (uint32)date); 00100 return cstime; 00101 } |
|
Convert the current date to human string.
Definition at line 85 of file displayer.cpp. Referenced by NLNET::CNetDisplayer::doDisplay(), NLMISC::CMemDisplayer::doDisplay(), NLMISC::CMsgBoxDisplayer::doDisplay(), NLMISC::CFileDisplayer::doDisplay(), and NLMISC::IDisplayer::HeaderString().
00086 { 00087 time_t date; 00088 time (&date); 00089 return dateToHumanString (date); 00090 } |
|
Display the string where it does.
Definition at line 132 of file displayer.cpp. References NLMISC::IDisplayer::doDisplay().
|
|
Referenced by NLMISC::CUpdateThread::run(). |
|
Method to implement in the deriver.
Implemented in NLMISC::CStdDisplayer, NLMISC::CFileDisplayer, NLMISC::CMsgBoxDisplayer, NLMISC::CMemDisplayer, and NLMISC::CLightMemDisplayer. Referenced by NLMISC::IDisplayer::display(). |
|
Definition at line 130 of file window_displayer.cpp. References _HistorySize, NLMISC::CLog::TDisplayInfo::CallstackAndLog, NLMISC::CLog::TDisplayInfo::Filename, NLMISC::CLog::TDisplayInfo::Line, NLMISC::CLog::TDisplayInfo::LogType, NLMISC::IDisplayer::logTypeToString(), needSlashR, NLMISC::CLog::TDisplayInfo::ThreadId, NLMISC::toString(), uint, and uint32.
00131 { 00132 bool needSpace = false; 00133 //stringstream ss; 00134 string str; 00135 00136 uint32 color = 0xFF000000; 00137 00138 if (args.LogType != CLog::LOG_NO) 00139 { 00140 str += logTypeToString(args.LogType); 00141 if (args.LogType == CLog::LOG_ERROR || args.LogType == CLog::LOG_ASSERT) color = 0x00FF0000; 00142 else if (args.LogType == CLog::LOG_WARNING) color = 0x00800000; 00143 else if (args.LogType == CLog::LOG_DEBUG) color = 0x00808080; 00144 else color = 0; 00145 needSpace = true; 00146 } 00147 00148 // Write thread identifier 00149 if ( args.ThreadId != 0 ) 00150 { 00151 if (needSpace) { str += " "; needSpace = false; } 00152 str += NLMISC::toString("%4u", args.ThreadId); 00153 needSpace = true; 00154 } 00155 00156 if (args.Filename != NULL) 00157 { 00158 if (needSpace) { str += " "; needSpace = false; } 00159 str += NLMISC::toString("%20s", CFile::getFilename(args.Filename).c_str()); 00160 needSpace = true; 00161 } 00162 00163 if (args.Line != -1) 00164 { 00165 if (needSpace) { str += " "; needSpace = false; } 00166 str += NLMISC::toString("%4u", args.Line); 00167 //ss << setw(4) << args.Line; 00168 needSpace = true; 00169 } 00170 00171 if (needSpace) { str += ": "; needSpace = false; } 00172 00173 uint nbl = 1; 00174 00175 char *npos, *pos = const_cast<char *>(message); 00176 while ((npos = strchr (pos, '\n'))) 00177 { 00178 *npos = '\0'; 00179 str += pos; 00180 if (needSlashR) 00181 str += "\r"; 00182 str += "\n"; 00183 *npos = '\n'; 00184 pos = npos+1; 00185 nbl++; 00186 } 00187 str += pos; 00188 00189 pos = const_cast<char *>(args.CallstackAndLog.c_str()); 00190 while ((npos = strchr (pos, '\n'))) 00191 { 00192 *npos = '\0'; 00193 str += pos; 00194 if (needSlashR) 00195 str += "\r"; 00196 str += "\n"; 00197 *npos = '\n'; 00198 pos = npos+1; 00199 nbl++; 00200 } 00201 str += pos; 00202 00203 { 00204 CSynchronized<std::list<std::pair<uint32, std::string> > >::CAccessor access (&_Buffer); 00205 if (_HistorySize > 0 && access.value().size() >= (uint)_HistorySize) 00206 { 00207 access.value().erase (access.value().begin()); 00208 } 00209 access.value().push_back (make_pair (color, str)); 00210 } 00211 } |
|
Definition at line 75 of file window_displayer.h. References uint32, w, x, and y.
|
|
Definition at line 110 of file displayer.cpp. References NLMISC::IDisplayer::dateToHumanString(), and NLMISC::smprintf(). Referenced by NLMISC::CMemDisplayer::doDisplay(), and NLMISC::CFileDisplayer::doDisplay().
00111 { 00112 static char header[1024]; 00113 smprintf(header, 1024, "\nLog Starting [%s]\n", dateToHumanString()); 00114 return header; 00115 } |
|
Convert log type to string.
Definition at line 77 of file displayer.cpp. References NLMISC::LogTypeToString. Referenced by doDisplay(), NLNET::CNetDisplayer::doDisplay(), NLMISC::CMemDisplayer::doDisplay(), NLMISC::CMsgBoxDisplayer::doDisplay(), NLMISC::CFileDisplayer::doDisplay(), and NLMISC::CStdDisplayer::doDisplay().
00078 { 00079 if (logType < CLog::LOG_NO || logType > CLog::LOG_UNKNOWN) 00080 return "<NotDefined>"; 00081 00082 return LogTypeToString[longFormat?1:0][logType]; 00083 } |
|
Referenced by NLMISC::CUpdateThread::run(). |
|
Definition at line 107 of file window_displayer.cpp. References _Labels, nlassert, uint, and value. Referenced by NLNET::IService::main().
00108 { 00109 { 00110 CSynchronized<std::vector<CLabelEntry> >::CAccessor access (&_Labels); 00111 nlassert (label < access.value().size()); 00112 if (access.value()[label].Value != value) 00113 { 00114 access.value()[label].Value = value; 00115 access.value()[label].NeedUpdate = true; 00116 } 00117 } 00118 } |
|
Definition at line 73 of file window_displayer.h. Referenced by NLNET::IService::main().
00073 { } |
|
Definition at line 77 of file window_displayer.cpp. References _CommandsToExecute, _Continue, nlassert, and uint. Referenced by NLNET::IService::main().
00078 { 00079 vector<string> copy; 00080 { 00081 CSynchronized<std::vector<std::string> >::CAccessor access (&_CommandsToExecute); 00082 copy = access.value(); 00083 access.value().clear (); 00084 } 00085 00086 // execute all commands in the main thread 00087 for (uint i = 0; i < copy.size(); i++) 00088 { 00089 nlassert (Log != NULL); 00090 ICommand::execute (copy[i], *Log); 00091 } 00092 00093 return _Continue; 00094 } |
|
Definition at line 120 of file window_displayer.h. Referenced by create(). |
|
Definition at line 95 of file window_displayer.h. |
|
Definition at line 97 of file window_displayer.h. Referenced by CWindowDisplayer(), and update(). |
|
Definition at line 106 of file window_displayer.h. Referenced by CWindowDisplayer(), update(), and ~CWindowDisplayer(). |
|
Definition at line 108 of file window_displayer.h. |
|
Definition at line 111 of file window_displayer.h. Referenced by CWindowDisplayer(), and doDisplay(). |
|
Definition at line 110 of file window_displayer.h. |
|
Definition at line 113 of file window_displayer.h. Referenced by CWindowDisplayer(). |
|
Definition at line 96 of file window_displayer.h. Referenced by createLabel(), CWindowDisplayer(), and setLabel(). |
|
Definition at line 109 of file window_displayer.h. Referenced by CWindowDisplayer(). |
|
Definition at line 116 of file window_displayer.h. |
|
Definition at line 112 of file window_displayer.h. Referenced by CWindowDisplayer(). |
|
This is the idenfiant for a displayer, it is used to fond or remove a displayer.
Definition at line 63 of file displayer.h. Referenced by NLMISC::IDisplayer::IDisplayer(). |
|
Definition at line 118 of file window_displayer.h. |
|
Definition at line 83 of file window_displayer.h. Referenced by doDisplay(). |