00001
00002
00003 #include "AOLabTextFlashContainer.h"
00004 #include "ActiveTimer.h"
00005 #include <eiklabel.h>
00006
00007 _LIT(KHelloText, "Hello");
00008 _LIT(KWorldText, "World");
00009
00010 const TInt KTimeoutValue = 2000000;
00011
00012
00013
00014 CAOLabTextFlashContainer* CAOLabTextFlashContainer::NewL(const TRect& aRect)
00015 {
00016 CAOLabTextFlashContainer* self = new ( ELeave ) CAOLabTextFlashContainer();
00017 CleanupStack::PushL(self);
00018 self->ConstructL(aRect);
00019 CleanupStack::Pop(self);
00020
00021 return self;
00022 }
00023
00024
00025
00026 void CAOLabTextFlashContainer::ConstructL(const TRect& aRect)
00027 {
00028 CreateWindowL();
00029
00030 iTopLabel = new (ELeave) CEikLabel;
00031 iTopLabel->SetContainerWindowL(*this);
00032 iTopLabel->SetTextL(KHelloText);
00033
00034 iBottomLabel = new (ELeave) CEikLabel;
00035 iBottomLabel->SetContainerWindowL(*this);
00036 iBottomLabel->SetTextL(KWorldText);
00037
00038 iIsVisible = ETrue;
00039
00040 SetRect(aRect);
00041 ActivateL();
00042 }
00043
00044
00045
00046 CAOLabTextFlashContainer::~CAOLabTextFlashContainer()
00047 {
00048 delete iTopLabel;
00049 delete iBottomLabel;
00050 }
00051
00052
00053
00054 void CAOLabTextFlashContainer::SizeChanged()
00055 {
00056 iTopLabel->SetExtent( TPoint(0,0), TSize(Rect().Width(), Rect().Height()/2));
00057 iBottomLabel->SetExtent( TPoint(0,Rect().Height()/2), TSize(Rect().Width(),Rect().Height()/2));
00058 }
00059
00060
00061
00062 TInt CAOLabTextFlashContainer::CountComponentControls() const
00063 {
00064 return 2;
00065 }
00066
00067
00068
00069 CCoeControl* CAOLabTextFlashContainer::ComponentControl(TInt aIndex) const
00070 {
00071 switch ( aIndex )
00072 {
00073 case 0:
00074 return iTopLabel;
00075 case 1:
00076 return iBottomLabel;
00077 default:
00078 return NULL;
00079 }
00080 }
00081
00082
00083
00084 void CAOLabTextFlashContainer::Draw(const TRect& aRect) const
00085 {
00086 CWindowGc& gc = SystemGc();
00087
00088 gc.SetPenStyle(CGraphicsContext::ENullPen);
00089 gc.SetBrushColor(KRgbGray);
00090 gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00091 gc.DrawRect(aRect);
00092 }
00093
00094
00095
00096 void CAOLabTextFlashContainer::FlashingText()
00097 {
00098 iTopLabel->SetTextL(KHelloText);
00099 iBottomLabel->SetTextL(KWorldText);
00100 DrawNow();
00101
00102 if (!iIsFlashing)
00103 {
00104 iIsVisible = ETrue;
00105 iIsFlashing = ETrue;
00106 }
00107 }
00108
00109
00110
00111 void CAOLabTextFlashContainer::StopFlashing()
00112 {
00113 if (iIsFlashing)
00114 {
00115 iIsFlashing = EFalse;
00116 }
00117
00118 iTopLabel->MakeVisible(ETrue);
00119 iBottomLabel->MakeVisible(ETrue);
00120 }
00121
00122
00123
00124 void CAOLabTextFlashContainer::TimerComplete(TInt aError)
00125 {
00126 if (KErrNone == aError)
00127 {
00128 iIsVisible = !iIsVisible;
00129 }
00130 else
00131 {
00132 iIsVisible = ETrue;
00133 iIsFlashing = EFalse;
00134 }
00135
00136 iTopLabel->MakeVisible(iIsVisible);
00137 iBottomLabel->MakeVisible(iIsVisible);
00138 }
00139
00140