CE_Screen_Output.cpp

Go to the documentation of this file.
00001 // CE_Screen_Output.cpp,v 1.4 2005/10/28 16:14:51 ossama Exp
00002 
00003 #include "ace/CE_Screen_Output.h"
00004 #if defined (ACE_HAS_WINCE)
00005 
00006 #include "ace/Log_Msg.h"
00007 
00008 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00009 
00010 ACE_CE_Screen_Output::ACE_CE_Screen_Output(HWND hEdit)
00011 : handler_(hEdit)
00012 , pFile_(0)
00013 {
00014 }
00015 
00016 ACE_CE_Screen_Output::ACE_CE_Screen_Output()
00017 : handler_(0)
00018 , pFile_(0)
00019 {
00020 }
00021 
00022 ACE_CE_Screen_Output::~ACE_CE_Screen_Output()
00023 {
00024     if (pFile_ != 0) {
00025         fclose(pFile_);
00026     }
00027 }
00028 
00029 void ACE_CE_Screen_Output::log(ACE_Log_Record &log_record)
00030 {
00031     ACE_TCHAR verbose_msg[ACE_Log_Record::MAXVERBOSELOGMSGLEN];
00032     int result = log_record.format_msg (ACE_LIB_TEXT("WindozeCE"),  // host name
00033                                         0,                          // verbose flag
00034                                         verbose_msg);
00035 
00036     if (result == 0)
00037     {
00038         verbose_msg[ ACE_OS::strlen(verbose_msg) - 1 ] = 0;  // CE does not like '\n' by itself.
00039         *this << verbose_msg << endl;
00040     }
00041 }
00042 
00043 void ACE_CE_Screen_Output::SetOutputWindow(HWND hEdit)
00044 {
00045     handler_ = hEdit;
00046 }
00047 
00048 void ACE_CE_Screen_Output::clear()
00049 {
00050     SetWindowText(handler_, 0);
00051 }
00052 
00053 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (ACE_TCHAR* output)
00054 {
00055     int length = GetWindowTextLength(handler_);
00056     SendMessage(handler_, EM_SETSEL, length, length);
00057     SendMessage(handler_, EM_REPLACESEL, 0, (LPARAM)output);
00058 
00059     if (pFile_ != 0)
00060     {
00061         fwprintf(pFile_, L"%s", output);
00062     }
00063 
00064     return *this;
00065 }
00066 
00067 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (const ACE_TCHAR* output)
00068 {
00069     ACE_TCHAR* buffer = ACE_OS::strdup(output);
00070     if (buffer != 0)
00071     {
00072         *this << buffer;
00073         delete buffer;
00074     }
00075     return *this;
00076 }
00077 
00078 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (ACE_ANTI_TCHAR* output)
00079 {
00080     *this << ACE_TEXT_CHAR_TO_TCHAR(output);
00081     return *this;
00082 }
00083 
00084 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (const ACE_ANTI_TCHAR* output)
00085 {
00086     *this << ACE_TEXT_CHAR_TO_TCHAR(output);
00087     return *this;
00088 }
00089 
00090 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (char output)
00091 {
00092     *this << (int)output;
00093     return *this;
00094 }
00095 
00096 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned char output)
00097 {
00098     *this << (int)output;
00099     return *this;
00100 }
00101 
00102 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned short output)
00103 {
00104     ACE_TCHAR buffer[20];
00105     wsprintf(buffer, ACE_LIB_TEXT("%u"), output);
00106     *this << buffer;
00107     return *this;
00108 }
00109 
00110 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (int output)
00111 {
00112     ACE_TCHAR buffer[20];
00113     wsprintf(buffer, ACE_LIB_TEXT("%d"), output);
00114     *this << buffer;
00115     return *this;
00116 }
00117 
00118 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned int output)
00119 {
00120     ACE_TCHAR buffer[20];
00121     wsprintf(buffer, ACE_LIB_TEXT("%du"), output);
00122     *this << buffer;
00123     return *this;
00124 }
00125 
00126 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (float output)
00127 {
00128     ACE_TCHAR buffer[20];
00129     swprintf(buffer, ACE_LIB_TEXT("%f"), output);
00130     *this << buffer;
00131     return *this;
00132 }
00133 
00134 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (long output)
00135 {
00136     ACE_TCHAR buffer[20];
00137     wsprintf(buffer, ACE_LIB_TEXT("%l"), output);
00138     *this << buffer;
00139     return *this;
00140 }
00141 
00142 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned long output)
00143 {
00144     ACE_TCHAR buffer[20];
00145     wsprintf(buffer, ACE_LIB_TEXT("%lu"), output);
00146     *this << buffer;
00147     return *this;
00148 }
00149 
00150 ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (FILE* pFile)
00151 {
00152     pFile_ = pFile;
00153     return *this;
00154 }
00155 
00156 ACE_END_VERSIONED_NAMESPACE_DECL
00157 
00158 #endif  // ACE_HAS_WINCE

Generated on Thu Nov 9 09:41:48 2006 for ACE by doxygen 1.3.6