examples/ForumNokia/SMSExample/GUI/src/SMSExampleLogView.cpp

00001 /*
00002  * Copyright � 2008 Nokia Corporation.
00003  */
00004 
00005 // INCLUDES
00006 #include <aknviewappui.h>
00007 #include <aknconsts.h>
00008 #include <aknutils.h>  // AknLayoutUtils
00009 #include <smsexample.rsg>
00010 
00011 #include "SMSExampleRTEContainer.h"
00012 #include "SMSExampleLogView.h"
00013 #include "SmsExample.hrh"
00014 
00015 // ----------------------------------------------------------------------------
00016 // CLogView::NewL()
00017 //
00018 // Symbian OS 2 phase constructor.
00019 // ----------------------------------------------------------------------------
00020 CLogView* CLogView::NewL()
00021     {
00022     CLogView* self = CLogView::NewLC();
00023     CleanupStack::Pop(self);
00024     return self;
00025     }
00026 
00027 // ----------------------------------------------------------------------------
00028 // CLogView::NewLC()
00029 //
00030 // Symbian OS 2 phase constructor.
00031 // ----------------------------------------------------------------------------
00032 CLogView* CLogView::NewLC()
00033     {
00034     CLogView* self = new (ELeave) CLogView();
00035     CleanupStack::PushL(self);
00036     self->ConstructL();
00037     return self;
00038     }
00039 
00040 // ----------------------------------------------------------------------------
00041 // CLogView::CLogView()
00042 //
00043 // Default constructor
00044 // ----------------------------------------------------------------------------
00045 CLogView::CLogView()
00046     {
00047     }
00048 
00049 // ----------------------------------------------------------------------------
00050 // CLogView::~CLogView()
00051 //
00052 // Destructor
00053 // ----------------------------------------------------------------------------
00054 CLogView::~CLogView()
00055     {
00056     delete iContainer;
00057     iContainer = NULL;
00058     }
00059 
00060 // ----------------------------------------------------------------------------
00061 // CLogView::ConstructL()
00062 //
00063 // Symbian OS 2 phase constructor.
00064 // ----------------------------------------------------------------------------
00065 void CLogView::ConstructL()
00066     {
00067     BaseConstructL(R_RICHTEXTEDITOR_MULTIVIEWS_VIEW);
00068 
00069     TRect rect;
00070     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00071     iContainer = CSMSExampleRTEContainer::NewL(rect);
00072     iContainer->SetMopParent( this );
00073     }
00074 
00075 // ----------------------------------------------------------------------------
00076 // CLogView::Id() const
00077 //
00078 // Id of the view.
00079 // ----------------------------------------------------------------------------
00080 TUid CLogView::Id() const
00081     {
00082     return TUid::Uid(ELogViewId);
00083     }
00084 
00085 
00086 // ----------------------------------------------------------------------------
00087 // CLogView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
00088 //                                    TUid /*aCustomMessageId*/,
00089 //                                    const TDesC8& /*aCustomMessage*/)
00090 //
00091 // Activate this view (make it visible again).
00092 // ----------------------------------------------------------------------------
00093 void CLogView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
00094                                     TUid /*aCustomMessageId*/,
00095                                     const TDesC8& /*aCustomMessage*/)
00096     {
00097     AppUi()->AddToStackL(*this, iContainer);
00098     iContainer->MakeVisible(ETrue);
00099     }
00100 
00101 
00102 // ----------------------------------------------------------------------------
00103 // CLogView::DoDeactivate()
00104 //
00105 // DeActivate this view (Hide the view). Do not destroy it.
00106 // ----------------------------------------------------------------------------
00107 void CLogView::DoDeactivate()
00108     {
00109 
00110     if (iContainer)
00111         {
00112         iContainer->MakeVisible(EFalse);
00113         AppUi()->RemoveFromStack(iContainer);
00114 
00115         }
00116     }
00117 
00118 // ----------------------------------------------------------------------------
00119 // CLogView::LogEventBeginningL()
00120 //
00121 // Begin a log event.
00122 // ----------------------------------------------------------------------------
00123 void CLogView::LogEventBeginningL()
00124     {
00125     iContainer->DrawLineL();
00126     TBuf<KMaxTimeFormatSpec+KMaxTimeFormatSpec> time;
00127     TTime now;
00128     now.HomeTime(); // Current time
00129     now.FormatL(time,TTimeFormatSpec());
00130     iContainer->DrawTextL( time );
00131     }
00132 
00133 // ----------------------------------------------------------------------------
00134 // CLogView::DrawUnderlinedTextL( const TDesC& aText)
00135 //
00136 // Draw underlined text.
00137 // ----------------------------------------------------------------------------
00138 void CLogView::DrawUnderlinedTextL( const TDesC& aText)
00139     {
00140     iContainer->DrawUnderlinedTextL(aText);
00141     }
00142 
00143 // ----------------------------------------------------------------------------
00144 // CLogView::DrawTextWithoutCarriageL( const TDesC& aText )
00145 //
00146 // Draw text without carriage.
00147 // ----------------------------------------------------------------------------
00148 void CLogView::DrawTextWithoutCarriageL( const TDesC& aText )
00149     {
00150     iContainer->DrawTextWithoutCarriageL(aText);
00151     }
00152 
00153 // ----------------------------------------------------------------------------
00154 // CLogView::HandleCommandL(TInt aCommand)
00155 //
00156 // Handle view commands. Forward command handling to AppUi
00157 // ----------------------------------------------------------------------------
00158 void CLogView::HandleCommandL(TInt aCommand)
00159     {
00160     AppUi()->HandleCommandL(aCommand);
00161     }
00162 
00163 // ----------------------------------------------------------------------------
00164 // CLogView::DrawTextL( const TDesC& aText )
00165 //
00166 // Draw into log.
00167 // ----------------------------------------------------------------------------
00168 void CLogView::DrawTextL( const TDesC& aText )
00169     {
00170     iContainer->DrawTextL( aText );
00171     }
00172 
00173 // ----------------------------------------------------------------------------
00174 // CLogView::AddCarriageReturnL()
00175 //
00176 // Add line break into log.
00177 // ----------------------------------------------------------------------------
00178 void CLogView::AddCarriageReturnL()
00179     {
00180     iContainer->AddCarriageReturnL();
00181     }
00182 
00183 void CLogView::SizeChanged()
00184   {
00185   if( iContainer )
00186     iContainer->SetRect( ClientRect() );
00187   }
00188 
00189 // End of File

Generated by  doxygen 1.6.2