00001 /* 00002 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are met: 00006 * 00007 * * Redistributions of source code must retain the above copyright notice, this 00008 * list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright notice, 00010 * this list of conditions and the following disclaimer in the documentation 00011 * and/or other materials provided with the distribution. 00012 * * Neither the name of Nokia Corporation nor the names of its contributors 00013 * may be used to endorse or promote products derived from this software 00014 * without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00017 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00020 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00021 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00022 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00023 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00024 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00025 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 * 00027 * Description: 00028 */ 00029 00030 // INCLUDES 00031 #include <aknviewappui.h> 00032 #include <aknconsts.h> 00033 #include <aknutils.h> // AknLayoutUtils 00034 #include <smsexample.rsg> 00035 00036 #include "SMSExampleRTEContainer.h" 00037 #include "SMSExampleLogView.h" 00038 #include "SmsExample.hrh" 00039 00040 // ---------------------------------------------------------------------------- 00041 // CLogView::NewL() 00042 // 00043 // Symbian OS 2 phase constructor. 00044 // ---------------------------------------------------------------------------- 00045 CLogView* CLogView::NewL() 00046 { 00047 CLogView* self = CLogView::NewLC(); 00048 CleanupStack::Pop(self); 00049 return self; 00050 } 00051 00052 // ---------------------------------------------------------------------------- 00053 // CLogView::NewLC() 00054 // 00055 // Symbian OS 2 phase constructor. 00056 // ---------------------------------------------------------------------------- 00057 CLogView* CLogView::NewLC() 00058 { 00059 CLogView* self = new (ELeave) CLogView(); 00060 CleanupStack::PushL(self); 00061 self->ConstructL(); 00062 return self; 00063 } 00064 00065 // ---------------------------------------------------------------------------- 00066 // CLogView::CLogView() 00067 // 00068 // Default constructor 00069 // ---------------------------------------------------------------------------- 00070 CLogView::CLogView() 00071 { 00072 } 00073 00074 // ---------------------------------------------------------------------------- 00075 // CLogView::~CLogView() 00076 // 00077 // Destructor 00078 // ---------------------------------------------------------------------------- 00079 CLogView::~CLogView() 00080 { 00081 delete iContainer; 00082 iContainer = NULL; 00083 } 00084 00085 // ---------------------------------------------------------------------------- 00086 // CLogView::ConstructL() 00087 // 00088 // Symbian OS 2 phase constructor. 00089 // ---------------------------------------------------------------------------- 00090 void CLogView::ConstructL() 00091 { 00092 BaseConstructL(R_RICHTEXTEDITOR_MULTIVIEWS_VIEW); 00093 00094 TRect rect; 00095 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); 00096 iContainer = CSMSExampleRTEContainer::NewL(rect); 00097 iContainer->SetMopParent( this ); 00098 } 00099 00100 // ---------------------------------------------------------------------------- 00101 // CLogView::Id() const 00102 // 00103 // Id of the view. 00104 // ---------------------------------------------------------------------------- 00105 TUid CLogView::Id() const 00106 { 00107 return TUid::Uid(ELogViewId); 00108 } 00109 00110 00111 // ---------------------------------------------------------------------------- 00112 // CLogView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, 00113 // TUid /*aCustomMessageId*/, 00114 // const TDesC8& /*aCustomMessage*/) 00115 // 00116 // Activate this view (make it visible again). 00117 // ---------------------------------------------------------------------------- 00118 void CLogView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, 00119 TUid /*aCustomMessageId*/, 00120 const TDesC8& /*aCustomMessage*/) 00121 { 00122 AppUi()->AddToStackL(*this, iContainer); 00123 iContainer->MakeVisible(ETrue); 00124 } 00125 00126 00127 // ---------------------------------------------------------------------------- 00128 // CLogView::DoDeactivate() 00129 // 00130 // DeActivate this view (Hide the view). Do not destroy it. 00131 // ---------------------------------------------------------------------------- 00132 void CLogView::DoDeactivate() 00133 { 00134 00135 if (iContainer) 00136 { 00137 iContainer->MakeVisible(EFalse); 00138 AppUi()->RemoveFromStack(iContainer); 00139 00140 } 00141 } 00142 00143 // ---------------------------------------------------------------------------- 00144 // CLogView::LogEventBeginningL() 00145 // 00146 // Begin a log event. 00147 // ---------------------------------------------------------------------------- 00148 void CLogView::LogEventBeginningL() 00149 { 00150 iContainer->DrawLineL(); 00151 TBuf<KMaxTimeFormatSpec+KMaxTimeFormatSpec> time; 00152 TTime now; 00153 now.HomeTime(); // Current time 00154 now.FormatL(time,TTimeFormatSpec()); 00155 iContainer->DrawTextL( time ); 00156 } 00157 00158 // ---------------------------------------------------------------------------- 00159 // CLogView::DrawUnderlinedTextL( const TDesC& aText) 00160 // 00161 // Draw underlined text. 00162 // ---------------------------------------------------------------------------- 00163 void CLogView::DrawUnderlinedTextL( const TDesC& aText) 00164 { 00165 iContainer->DrawUnderlinedTextL(aText); 00166 } 00167 00168 // ---------------------------------------------------------------------------- 00169 // CLogView::DrawTextWithoutCarriageL( const TDesC& aText ) 00170 // 00171 // Draw text without carriage. 00172 // ---------------------------------------------------------------------------- 00173 void CLogView::DrawTextWithoutCarriageL( const TDesC& aText ) 00174 { 00175 iContainer->DrawTextWithoutCarriageL(aText); 00176 } 00177 00178 // ---------------------------------------------------------------------------- 00179 // CLogView::HandleCommandL(TInt aCommand) 00180 // 00181 // Handle view commands. Forward command handling to AppUi 00182 // ---------------------------------------------------------------------------- 00183 void CLogView::HandleCommandL(TInt aCommand) 00184 { 00185 AppUi()->HandleCommandL(aCommand); 00186 } 00187 00188 // ---------------------------------------------------------------------------- 00189 // CLogView::DrawTextL( const TDesC& aText ) 00190 // 00191 // Draw into log. 00192 // ---------------------------------------------------------------------------- 00193 void CLogView::DrawTextL( const TDesC& aText ) 00194 { 00195 iContainer->DrawTextL( aText ); 00196 } 00197 00198 // ---------------------------------------------------------------------------- 00199 // CLogView::AddCarriageReturnL() 00200 // 00201 // Add line break into log. 00202 // ---------------------------------------------------------------------------- 00203 void CLogView::AddCarriageReturnL() 00204 { 00205 iContainer->AddCarriageReturnL(); 00206 } 00207 00208 void CLogView::SizeChanged() 00209 { 00210 if( iContainer ) 00211 iContainer->SetRect( ClientRect() ); 00212 } 00213 00214 // End of File