00001 /* 00002 * Copyright © 2009 Nokia Corporation. 00003 */ 00004 00005 // INCLUDE FILES 00006 #include "BluetoothPMPExampleRTEContainer.h" 00007 #include "BluetoothPMPExampleRichtexteditorrte.h" 00008 00009 // ---------------------------------------------------------------------------- 00010 // CBluetoothPMPExampleRTEContainer::NewL(const TRect& aRect) 00011 // 00012 // Symbian OS 2 phase constructor. 00013 // ---------------------------------------------------------------------------- 00014 CBluetoothPMPExampleRTEContainer* CBluetoothPMPExampleRTEContainer::NewL(const TRect& aRect) 00015 { 00016 CBluetoothPMPExampleRTEContainer* self = CBluetoothPMPExampleRTEContainer::NewLC(aRect); 00017 CleanupStack::Pop(self); 00018 return self; 00019 } 00020 00021 // ---------------------------------------------------------------------------- 00022 // CBluetoothPMPExampleRTEContainer::NewLC(const TRect& aRect) 00023 // 00024 // Symbian OS 2 phase constructor. 00025 // ---------------------------------------------------------------------------- 00026 CBluetoothPMPExampleRTEContainer* CBluetoothPMPExampleRTEContainer::NewLC(const TRect& aRect) 00027 { 00028 CBluetoothPMPExampleRTEContainer* self = new (ELeave) CBluetoothPMPExampleRTEContainer; 00029 CleanupStack::PushL(self); 00030 self->ConstructL(aRect); 00031 return self; 00032 } 00033 00034 // --------------------------------------------------------- 00035 // CBluetoothPMPExampleRTEContainer::ConstructL(const TRect& aRect) 00036 // Symbian OS two phased constructor. 00037 // --------------------------------------------------------- 00038 // 00039 void CBluetoothPMPExampleRTEContainer::ConstructL(const TRect& aRect) 00040 { 00041 CreateWindowL(); 00042 00043 iRte = CRichTextEditorRTE::NewL(); 00044 iRte->SetContainerWindowL(*this); 00045 // Scroll bars 00046 iRte->CreateScrollBarFrameL()->SetScrollBarVisibilityL( 00047 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn); 00048 iRte->UpdateScrollBarsL(); 00049 00050 ActivateL(); 00051 00052 // Set the windows size 00053 // NOTE: To call this after ActivateL() is solution to get 00054 // scrollbarframe width in SizeChanged() method. 00055 SetRect(aRect); 00056 } 00057 00058 CBluetoothPMPExampleRTEContainer::~CBluetoothPMPExampleRTEContainer() 00059 { 00060 delete iRte; 00061 } 00062 00063 void CBluetoothPMPExampleRTEContainer::DrawUnderlinedTextL( const TDesC& aText ) 00064 { 00065 iRte->SetTextUnderlineOn(ETrue); 00066 DrawTextWithoutCarriageL(aText); 00067 iRte->SetTextUnderlineOn(EFalse); 00068 iRte->UpdateScrollBarsL(); 00069 } 00070 00071 void CBluetoothPMPExampleRTEContainer::DrawLineL() 00072 { 00073 iRte->DrawLineL(); 00074 iRte->UpdateScrollBarsL(); 00075 } 00076 00077 TInt CBluetoothPMPExampleRTEContainer::GetScrollbarWidth() const 00078 { 00079 TInt scrollbarWidth = iRte->ScrollBarFrame()-> 00080 ScrollBarBreadth(CEikScrollBar::EVertical); 00081 // If scrollbars are not drawn yet, the width remains zero. In this 00082 // case, an intentionally magical number is returned. 00083 if (scrollbarWidth == 0) 00084 { 00085 scrollbarWidth = 8; 00086 } 00087 00088 return scrollbarWidth; 00089 } 00090 00091 void CBluetoothPMPExampleRTEContainer::Draw( const TRect& /*aRect*/ ) const 00092 { 00093 CWindowGc& gc = SystemGc(); 00094 gc.Clear(); 00095 } 00096 00097 void CBluetoothPMPExampleRTEContainer::SizeChanged() 00098 { 00099 TRect rect = Rect(); 00100 TInt scrollbarWidth = GetScrollbarWidth(); 00101 iRte->SetExtent(TPoint(0, 0), 00102 TSize(rect.Width() - scrollbarWidth, rect.Height())); 00103 iRte->UpdateScrollBarsL(); 00104 } 00105 00106 void CBluetoothPMPExampleRTEContainer::DrawTextL( const TDesC& aText ) 00107 { 00108 iRte->AddTextL( aText ); 00109 iRte->UpdateScrollBarsL(); 00110 } 00111 00112 void CBluetoothPMPExampleRTEContainer::DrawTextWithoutCarriageL( const TDesC& aText ) 00113 { 00114 iRte->DrawTextWithoutCarriageL(aText); 00115 iRte->UpdateScrollBarsL(); 00116 } 00117 00118 void CBluetoothPMPExampleRTEContainer::AddCarriageReturnL() 00119 { 00120 iRte->AddCarriageReturnL(KCarriageReturnToEnd); 00121 iRte->UpdateScrollBarsL(); 00122 } 00123 00124 TInt CBluetoothPMPExampleRTEContainer::CountComponentControls() const 00125 { 00126 return 1; // return number of controls inside this container 00127 } 00128 00129 CCoeControl* CBluetoothPMPExampleRTEContainer::ComponentControl(TInt aIndex) const 00130 { 00131 switch ( aIndex ) 00132 { 00133 case 0: 00134 return iRte; 00135 default: 00136 return NULL; 00137 } 00138 } 00139 00140 TKeyResponse CBluetoothPMPExampleRTEContainer::OfferKeyEventL( 00141 const TKeyEvent& aKeyEvent,TEventCode aType) 00142 { 00143 if (iRte) 00144 return iRte->OfferKeyEventL(aKeyEvent, aType); 00145 else 00146 return CCoeControl::OfferKeyEventL(aKeyEvent, aType); 00147 } 00148 00149 void CBluetoothPMPExampleRTEContainer::ShowMessageL(const TDesC& aMsg) 00150 { 00151 DrawTextL(aMsg); 00152 } 00153 00154 void CBluetoothPMPExampleRTEContainer::ClearScreenL() 00155 { 00156 iRte->ClearScreenL(); 00157 iRte->UpdateScrollBarsL(); 00158 } 00159