diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2005-07-13 17:40:46 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2005-07-13 17:40:46 +0000 |
commit | 6535f926382842de14a36f1354cb08c86cbab28c (patch) | |
tree | 50d98021e0e50a1539a7cc35594fc63c58ddc361 /cppe/demo/IceE/chat/LogI.cpp | |
parent | Don't copy the testCommon libs. (diff) | |
download | ice-6535f926382842de14a36f1354cb08c86cbab28c.tar.bz2 ice-6535f926382842de14a36f1354cb08c86cbab28c.tar.xz ice-6535f926382842de14a36f1354cb08c86cbab28c.zip |
Commited first stab at MFC chat demo
Diffstat (limited to 'cppe/demo/IceE/chat/LogI.cpp')
-rw-r--r-- | cppe/demo/IceE/chat/LogI.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/cppe/demo/IceE/chat/LogI.cpp b/cppe/demo/IceE/chat/LogI.cpp new file mode 100644 index 00000000000..705430ac49c --- /dev/null +++ b/cppe/demo/IceE/chat/LogI.cpp @@ -0,0 +1,86 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include "stdafx.h" +#include "LogI.h" + +using namespace std; + +LogI::LogI() : + _log(0) +{ +} + +void +LogI::print(const string& msg) +{ + string s = msg; + + string::size_type idx = 0; + while((idx = s.find("\n", idx)) != string::npos) + { + s.replace(idx, 1, "\r\n "); + idx += 3; + } + + message(s); +} + +void +LogI::trace(const string& category, const string& msg) +{ + string s = "[ " + category + ": " + msg + " ]"; + + string::size_type idx = 0; + while((idx = s.find("\n", idx)) != string::npos) + { + s.replace(idx, 1, "\r\n "); + idx += 3; + } + + message(s); +} + +void +LogI::warning(const string& msg) +{ + message("warning: " + msg); +} + +void +LogI::error(const string& msg) +{ + message("error: " + msg); +} + +void +LogI::message(const string& msg) +{ + string line = msg + "\r\n"; + if(_log) + { + _log->SetSel(-1, -1); + _log->ReplaceSel(CString(line.c_str())); + } + else + { + _buffer.append(line); + } +} + +void +LogI::setControl(CEdit* log) +{ + _log = log; + if(!_buffer.empty()) + { + _log->ReplaceSel(CString(_buffer.c_str())); + _buffer.clear(); + } +} |