73 * |
82 * |
74 * - If previous screen ended with an image that fit there fully, |
83 * - If previous screen ended with an image that fit there fully, |
75 * next screen is started with next text line or image. |
84 * next screen is started with next text line or image. |
76 */ |
85 */ |
77 |
86 |
78 // constructors |
87 // ================= MEMBER FUNCTIONS ======================= |
79 |
88 |
80 CAboutContainer::CAboutContainer():iNumItem( 0 ) |
89 // ----------------------------------------------------------------------------- |
81 { |
90 // CAboutContainer::CAboutContainer() |
82 } |
91 // ----------------------------------------------------------------------------- |
83 |
92 CAboutContainer::CAboutContainer() |
|
93 { |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CAboutContainer::ConstructL() |
|
98 // ----------------------------------------------------------------------------- |
84 void CAboutContainer::ConstructL( const TRect& aRect ) |
99 void CAboutContainer::ConstructL( const TRect& aRect ) |
85 { |
100 { |
86 CreateWindowL(); |
101 CreateWindowL(); |
87 |
|
88 iScrollBarDragged = EFalse; |
102 iScrollBarDragged = EFalse; |
89 iBreakFlag = EFalse; |
103 iBreakFlag = EFalse; |
90 iIsSvg = EFalse; |
104 iSkinContext = NULL; |
91 iSkinContext = NULL; |
105 iText = NULL; |
92 iText = NULL; |
106 iImages = NULL; |
93 iImages = NULL; |
107 iScreenStarts = NULL; |
94 iScreenStarts = NULL; |
108 iSBFrame = NULL; |
95 iSBFrame = NULL; |
109 iHandleFlag = ETrue; |
96 CalculateL(aRect); |
110 iLoader = CAboutResourceLoader::NewL( iEikonEnv, this ); |
|
111 CalculateL( aRect ); |
97 ActivateL(); |
112 ActivateL(); |
98 } |
113 } |
99 |
114 |
100 // destructor |
115 // ----------------------------------------------------------------------------- |
101 |
116 // CAboutContainer::~CAboutContainer() |
|
117 // ----------------------------------------------------------------------------- |
102 CAboutContainer::~CAboutContainer() |
118 CAboutContainer::~CAboutContainer() |
103 { |
119 { |
104 delete iSkinContext; |
120 delete iSkinContext; |
105 delete iSBFrame; |
121 delete iSBFrame; |
106 delete iScreenStarts; |
122 delete iScreenStarts; |
107 delete iIcon; |
123 delete iIcon; |
108 |
124 |
109 if ( iText ) |
125 if ( iText ) |
110 { |
126 { |
111 iText->ResetAndDestroy(); |
127 iText->ResetAndDestroy(); |
112 delete iText; |
128 delete iText; |
113 } |
129 } |
114 |
130 |
115 if ( iImages ) |
131 if ( iImages ) |
116 { |
132 { |
117 iImages->ResetAndDestroy(); |
133 iImages->ResetAndDestroy(); |
118 delete iImages; |
134 delete iImages; |
119 } |
135 } |
120 } |
136 |
121 |
137 if ( iLoader ) |
|
138 { |
|
139 iLoader->Cancel(); |
|
140 delete iLoader; |
|
141 iLoader = NULL; |
|
142 } |
|
143 |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CAboutContainer::SizeChanged() |
|
148 // ----------------------------------------------------------------------------- |
122 void CAboutContainer::SizeChanged() |
149 void CAboutContainer::SizeChanged() |
123 { |
150 { |
124 TRect parentRect(Rect()); |
151 TRect parentRect( Rect() ); |
125 if (iSkinContext) |
152 if (iSkinContext) |
126 { |
153 { |
127 iSkinContext->SetRect(parentRect); |
154 iSkinContext->SetRect( parentRect ); |
128 } |
155 } |
129 } |
156 } |
|
157 |
130 // ----------------------------------------------------------------------------- |
158 // ----------------------------------------------------------------------------- |
131 // CAboutContainer::Draw() |
159 // CAboutContainer::Draw() |
132 // ----------------------------------------------------------------------------- |
160 // ----------------------------------------------------------------------------- |
133 |
|
134 void CAboutContainer::Draw( const TRect& aRect ) const |
161 void CAboutContainer::Draw( const TRect& aRect ) const |
135 { |
162 { |
136 CWindowGc& gc = SystemGc(); |
163 CWindowGc& gc = SystemGc(); |
137 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
164 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
138 if (iSkinContext) |
165 if ( iSkinContext ) |
139 {//Draw the skin background |
166 { |
|
167 //Draw the skin background |
140 AknsDrawUtils::Background( |
168 AknsDrawUtils::Background( |
141 skin, iSkinContext, this, gc, aRect); |
169 skin, iSkinContext, this, gc, aRect ); |
142 } |
170 } |
143 else |
171 else |
144 {// clear the area |
172 {// clear the area |
145 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ); |
173 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ); |
146 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
174 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
214 position.iY += ( image->StartLine() - firstLine ) * iBaseLineDelta; |
242 position.iY += ( image->StartLine() - firstLine ) * iBaseLineDelta; |
215 |
243 |
216 position.iY -= iBaseLineDelta - iFont->DescentInPixels(); |
244 position.iY -= iBaseLineDelta - iFont->DescentInPixels(); |
217 // Now iY is the top line of rectangle where the picture is |
245 // Now iY is the top line of rectangle where the picture is |
218 // centered in. |
246 // centered in. |
219 position.iY += ( (image->Lines()+1) * iBaseLineDelta - |
247 position.iY += ( ( image->Lines()+1 ) * iBaseLineDelta - |
220 iFont->HeightInPixels() - |
248 iFont->HeightInPixels() - |
221 image->HeightInPixels() ) / 2; |
249 image->HeightInPixels() ) / 2; |
222 |
250 |
223 // If text is right-aligned, also align images to the right. |
251 // If text is right-aligned, also align images to the right. |
224 |
252 |
225 if ( iTextAlign == CGraphicsContext::ERight ) |
253 if ( iTextAlign == CGraphicsContext::ERight ) |
226 { |
254 { |
227 position.iX += ( iLineWidth - image->WidthInPixels() ); |
255 position.iX += ( iLineWidth - image->WidthInPixels() ); |
228 } |
256 } |
229 |
257 |
230 gc.BitBlt( position, image->Bitmap(), aRect ); |
258 // Draw javalogo on Screeen (PictureType: svg) |
|
259 gc.BitBltMasked( position, image->Bitmap(), aRect, |
|
260 image->BitmapMask(), ETrue ); |
231 } |
261 } |
232 } |
262 } |
233 } |
263 } |
234 |
264 |
235 // ----------------------------------------------------------------------------- |
265 // ----------------------------------------------------------------------------- |
652 // This array contains indices for lines that start the subsequent |
684 // This array contains indices for lines that start the subsequent |
653 // screens, for custom scrolling |
685 // screens, for custom scrolling |
654 iScreenStarts = new( ELeave ) CArrayFixFlat<TInt>( 5 ); |
686 iScreenStarts = new( ELeave ) CArrayFixFlat<TInt>( 5 ); |
655 // Initialisation: first screen starts at line 0. |
687 // Initialisation: first screen starts at line 0. |
656 iScreenStarts->AppendL( 0 ); |
688 iScreenStarts->AppendL( 0 ); |
657 |
689 TInt resourceId = 0; |
658 // Read text and image items to be shown on the screen from a resource file. |
690 resourceId = R_ABOUT_MAIN_TEXT; |
659 #ifdef __ABOUT_USE_TEST_RESOURCE__ |
691 iResourcePath.Zero(); |
660 #include <about_test.rsg> |
692 iLoader->SetResourceId( resourceId, ETrue, iResourcePath ); |
661 // test resource |
693 iLoader->StartL(); |
662 _LIT(KDirAndFile, "Z:about_test.rsc"); |
|
663 TParse* fp = new(ELeave) TParse (); |
|
664 fp->Set (KDirAndFile, &KDC_APP_RESOURCE_DIR, NULL); |
|
665 TBuf<254> KAboutTestResourceFileName; |
|
666 KAboutTestResourceFileName.Copy(fp ->FullName()); |
|
667 delete fp; |
|
668 fp=NULL; |
|
669 |
|
670 TFileName fileName( KAboutTestResourceFileName ); |
|
671 BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename ); |
|
672 TInt testResourceFileOffset = iCoeEnv->AddResourceFileL( fileName ); |
|
673 TResourceReader reader; |
|
674 iEikonEnv->CreateResourceReaderLC( reader, R_ABOUT_TEST_MAIN_TEXT ); |
|
675 #else |
|
676 // real resource |
|
677 TResourceReader reader; |
|
678 iEikonEnv->CreateResourceReaderLC( reader, R_ABOUT_MAIN_TEXT ); |
|
679 #endif |
|
680 |
|
681 TInt NumItem( reader.ReadInt16() ); |
|
682 iNumItem = NumItem; |
|
683 |
|
684 for ( TInt i = 0 ; i < iNumItem ; i++ ) |
|
685 { |
|
686 TInt type = reader.ReadInt8(); |
|
687 if ( type == EAboutTextItem ) |
|
688 { |
|
689 HBufC* text; |
|
690 if ( reader.ReadInt8() == EAboutUpdateTime ) |
|
691 { |
|
692 TTime time; |
|
693 time.UniversalTime(); |
|
694 TDateTime currentTime = time.DateTime(); |
|
695 text = StringLoader::LoadLC( reader.ReadInt32(), |
|
696 currentTime.Year(), CEikonEnv::Static() ); |
|
697 } |
|
698 else |
|
699 { |
|
700 text = iEikonEnv->AllocReadResourceLC( reader.ReadInt32() ); |
|
701 } |
|
702 SetTextL( *text , i ); |
|
703 CleanupStack::PopAndDestroy( text ); |
|
704 } |
|
705 else if ( type == EAboutImageItem ) |
|
706 { |
|
707 TPtrC bitmapFile = reader.ReadTPtrC(); |
|
708 TInt bitmapId = reader.ReadInt16(); |
|
709 if( iIsSvg ) |
|
710 { |
|
711 TFileName svgPath; |
|
712 _LIT( KSvgFileName, "Z:about.mif" ); |
|
713 TParse* fpSvg = new( ELeave ) TParse (); |
|
714 fpSvg->Set( KSvgFileName, &KDC_APP_BITMAP_DIR, NULL ); |
|
715 svgPath.Copy( fpSvg ->FullName() ); |
|
716 delete fpSvg; |
|
717 fpSvg = NULL; |
|
718 SetImageL( svgPath, EMbmAboutQgn_graf_java_logo ); |
|
719 } |
|
720 else |
|
721 { |
|
722 SetImageL( bitmapFile, bitmapId ); |
|
723 } |
|
724 } |
|
725 else |
|
726 { |
|
727 User::Panic( KAboutPanicCategory, EAboutNotSupported ); |
|
728 } |
|
729 } |
|
730 |
|
731 CleanupStack::PopAndDestroy(); // reader |
|
732 |
694 |
733 #ifdef __ABOUT_USE_TEST_RESOURCE__ |
695 #ifdef __ABOUT_USE_TEST_RESOURCE__ |
734 if ( testResourceFileOffset ) |
696 if ( testResourceFileOffset ) |
735 { |
697 { |
736 iCoeEnv->DeleteResourceFile( testResourceFileOffset ); |
698 iCoeEnv->DeleteResourceFile( testResourceFileOffset ); |
739 |
701 |
740 SetRect( aRect ); |
702 SetRect( aRect ); |
741 UpdateScrollIndicatorL(); |
703 UpdateScrollIndicatorL(); |
742 } |
704 } |
743 |
705 |
744 |
706 // ----------------------------------------------------------------------------- |
745 void CAboutContainer::HandleResourceChange(TInt aType) |
707 // CAboutContainer::HandleResourceChange() |
746 { |
708 // ----------------------------------------------------------------------------- |
747 |
709 void CAboutContainer::HandleResourceChange( TInt aType ) |
748 switch ( aType ) |
710 { |
749 { |
711 switch ( aType ) |
750 case KEikDynamicLayoutVariantSwitch : |
712 { |
751 { |
713 case KEikDynamicLayoutVariantSwitch : |
752 TRAP_IGNORE(CalculateL(iAvkonAppUi->ClientRect())); |
714 { |
753 DrawNow(); |
715 TRAP_IGNORE( CalculateL( iAvkonAppUi->ClientRect() ) ); |
754 } |
716 DrawNow(); |
755 break; |
717 } |
756 case KEikMessageUnfadeWindows : |
718 break; |
757 case KAknsMessageSkinChange : |
719 case KEikMessageUnfadeWindows : |
758 { |
720 case KAknsMessageSkinChange : |
759 TRAP_IGNORE(iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse)); // window owning scrollbar |
721 { |
760 iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan); |
722 // window owning scrollbar |
761 TRAP_IGNORE(iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn)); |
723 TRAP_IGNORE( iSBFrame->CreateDoubleSpanScrollBarsL( ETrue, EFalse ) ); |
762 TRAP_IGNORE(UpdateScrollIndicatorL()); |
724 iSBFrame->SetTypeOfVScrollBar( CEikScrollBarFrame::EDoubleSpan ); |
763 } |
725 TRAP_IGNORE( iSBFrame->SetScrollBarVisibilityL( |
764 |
726 CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn ) ); |
765 default: |
727 TRAP_IGNORE( UpdateScrollIndicatorL() ); |
766 { |
728 } |
767 CCoeControl::HandleResourceChange(aType); |
729 default: |
768 } |
730 { |
769 break; |
731 CCoeControl::HandleResourceChange( aType ); |
770 } |
732 } |
771 } |
733 break; |
|
734 } |
|
735 } |
772 // --------------------------------------------------------- |
736 // --------------------------------------------------------- |
773 // CAboutContainer::MopSupplyObject() |
737 // CAboutContainer::MopSupplyObject() |
774 // Pass skin information if need. |
738 // Pass skin information if need. |
775 // --------------------------------------------------------- |
739 // --------------------------------------------------------- |
776 |
740 |
777 TTypeUid::Ptr CAboutContainer::MopSupplyObject(TTypeUid aId) |
741 TTypeUid::Ptr CAboutContainer::MopSupplyObject( TTypeUid aId ) |
778 { |
742 { |
779 if (aId.iUid == MAknsControlContext::ETypeId && iSkinContext) |
743 if ( aId.iUid == MAknsControlContext::ETypeId && iSkinContext ) |
780 { |
744 { |
781 return MAknsControlContext::SupplyMopObject(aId, iSkinContext); |
745 return MAknsControlContext::SupplyMopObject( aId, iSkinContext ); |
782 } |
746 } |
783 |
747 return CCoeControl::MopSupplyObject( aId ); |
784 return CCoeControl::MopSupplyObject(aId); |
|
785 } |
748 } |
786 |
749 |
787 // --------------------------------------------------------- |
750 // --------------------------------------------------------- |
788 // CAboutContainer::HandleScrollEventL() |
751 // CAboutContainer::HandleScrollEventL() |
789 // Capture Touch Events on the Scroll Bar |
752 // Capture Touch Events on the Scroll Bar |
790 // --------------------------------------------------------- |
753 // --------------------------------------------------------- |
791 void CAboutContainer::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType) |
754 void CAboutContainer::HandleScrollEventL( CEikScrollBar* aScrollBar, |
|
755 TEikScrollEvent aEventType ) |
792 { |
756 { |
793 //Only on page up/down,scroll up/down and drag events |
757 //Only on page up/down,scroll up/down and drag events |
794 if((aEventType == EEikScrollPageDown) || (aEventType == EEikScrollPageUp) || |
758 if( ( aEventType == EEikScrollPageDown ) || ( aEventType == EEikScrollPageUp ) || |
795 (aEventType == EEikScrollThumbDragVert) || (aEventType == EEikScrollUp) || |
759 ( aEventType == EEikScrollThumbDragVert ) || ( aEventType == EEikScrollUp ) || |
796 (aEventType == EEikScrollDown)) |
760 ( aEventType == EEikScrollDown ) ) |
797 { |
761 { |
798 //Get the current position from the scroll bar |
762 //Get the current position from the scroll bar |
799 iCurrentScreen = aScrollBar->ThumbPosition(); |
763 iCurrentScreen = aScrollBar->ThumbPosition(); |
800 |
764 |
801 // Reset flag when dragging scroll bar |
765 // Reset flag when dragging scroll bar |
802 iScrollBarDragged = ETrue; |
766 iScrollBarDragged = ETrue; |
803 //Refresh now |
767 //Refresh now |
804 DrawNow(); |
768 DrawNow(); |
805 UpdateScrollIndicatorL(); |
769 UpdateScrollIndicatorL(); |
806 } |
770 } |
807 |
|
808 } |
771 } |
|
772 |
|
773 // --------------------------------------------------------- |
|
774 // CAboutContainer::HandleItemsLoadedL() |
|
775 // Handle resource load Items event. |
|
776 // --------------------------------------------------------- |
|
777 void CAboutContainer::HandleItemsLoadedL( TInt aError ) |
|
778 { |
|
779 // Panic if error occurred. |
|
780 if ( aError != KErrNone ) |
|
781 { |
|
782 User::Panic( KAboutPanicCategory, aError ); |
|
783 } |
|
784 |
|
785 // Display loaded texts |
|
786 RPointerArray<CAboutResource>* items = iLoader->LoadedResourceItems(); |
|
787 if ( items ) |
|
788 { |
|
789 for ( TInt i = 0; i < items->Count(); i++ ) |
|
790 { |
|
791 CAboutResource* item = ( *items )[i]; |
|
792 if ( item->ResourceType() == EAboutTextItem ) |
|
793 { |
|
794 if ( R_ABOUT_MAIN_TEXT == iLoader->CurrentResourceId() ) |
|
795 { |
|
796 // Only one data record for each |
|
797 if ( iHandleFlag ) |
|
798 { |
|
799 // Store the count of the current resource |
|
800 iCurrentCount = iLoader->ItemCount(); |
|
801 iHandleFlag = EFalse; |
|
802 } |
|
803 |
|
804 SetTextL( *item->ResourceItem(), item->ResourceIndex() ); |
|
805 |
|
806 // Set the flag to ETrue |
|
807 if ( iCurrentCount == item->ResourceIndex() ) |
|
808 { |
|
809 iHandleFlag = ETrue; |
|
810 } |
|
811 } |
|
812 else if ( R_ABOUT_OSS_TEXT == iLoader->CurrentResourceId() ) |
|
813 { |
|
814 iFinalCount = iCurrentCount + item->ResourceIndex() + 1; |
|
815 SetTextL( *item->ResourceItem(), iFinalCount ); |
|
816 } |
|
817 else |
|
818 { |
|
819 // Only one data record for each |
|
820 if ( iHandleFlag ) |
|
821 { |
|
822 iCurrentCount = iLoader->ItemCount(); |
|
823 iHandleFlag = EFalse; |
|
824 } |
|
825 |
|
826 iFinalCount = iCurrentCount + item->ResourceIndex() + 1; |
|
827 SetTextL( *item->ResourceItem(), iFinalCount ); |
|
828 } |
|
829 } |
|
830 else if( item->ResourceType() == EAboutImageItem ) |
|
831 { |
|
832 SetImageL( *item->ResourceItem(), item->BitmapId() ); |
|
833 } |
|
834 } |
|
835 iLoader->ReleaseLoadedItems(); |
|
836 UpdateScrollIndicatorL(); |
|
837 DrawDeferred(); |
|
838 } |
|
839 } |
|
840 |
|
841 // --------------------------------------------------------- |
|
842 // CAboutContainer::HandleResourceLoadCompletedL() |
|
843 // Handle resource load Completed event. |
|
844 // --------------------------------------------------------- |
|
845 void CAboutContainer::HandleResourceLoadCompletedL( |
|
846 TInt aResourceId, TInt aError ) |
|
847 { |
|
848 // Panic if error occurred. |
|
849 if ( aError != KErrNone ) |
|
850 { |
|
851 User::Panic( KAboutPanicCategory, aError ); |
|
852 } |
|
853 |
|
854 // R_ABOUT_OSS_TEXT_ADD is the last one we loaded, |
|
855 // do nothing here when it loaded. |
|
856 if ( R_ABOUT_OSS_TEXT_ADD == aResourceId ) |
|
857 { |
|
858 return; |
|
859 } |
|
860 |
|
861 // Load other resources including R_ABOUT_OSS_TEXT and R_ABOUT_OSS_TEXT_ADD |
|
862 TInt resourceId( aResourceId ); |
|
863 if( R_ABOUT_MAIN_TEXT == resourceId ) |
|
864 { |
|
865 // Load the R_ABOUT_OSS_TEXT |
|
866 // Set the resource which you want to load next |
|
867 resourceId = R_ABOUT_OSS_TEXT; |
|
868 // Set the resource's path |
|
869 iResourcePath.Copy( KRSCDirAndFile ); |
|
870 } |
|
871 else |
|
872 { |
|
873 // Load the R_ABOUT_OSS_TEXT_ADD |
|
874 resourceId = R_ABOUT_OSS_TEXT_ADD; |
|
875 iResourcePath.Copy( KRSCDirAndFileAdd ); |
|
876 } |
|
877 |
|
878 // Load to complete a resource and continue to load next resources |
|
879 iLoader->SetResourceId( resourceId, EFalse, iResourcePath ); |
|
880 iLoader->StartL(); |
|
881 } |
|
882 |
|
883 // End of File |