53 // CONSTANTS |
54 // CONSTANTS |
54 const TInt KAboutOSSIndex = 14; // For adding blank break between OSS Text and real Text |
55 const TInt KAboutOSSIndex = 14; // For adding blank break between OSS Text and real Text |
55 |
56 |
56 _LIT( KAboutPanicCategory, "About" ); |
57 _LIT( KAboutPanicCategory, "About" ); |
57 // Resource files for about application loading real data because this rsc file must be loaded by yourself |
58 // Resource files for about application loading real data because this rsc file must be loaded by yourself |
|
59 _LIT( KRSCDirAndFileFirst, "Z:\\resource\\apps\\about_oss_text.rsc" ); |
58 _LIT( KRSCDirAndFile, "Z:\\resource\\apps\\about_oss_part_text.rsc" ); |
60 _LIT( KRSCDirAndFile, "Z:\\resource\\apps\\about_oss_part_text.rsc" ); |
59 _LIT( KRSCDirAndFileAdd, "Z:\\resource\\apps\\about_oss_other_text.rsc" ); |
61 _LIT( KRSCDirAndFileAdd, "Z:\\resource\\apps\\about_oss_other_text.rsc" ); |
60 |
62 |
61 |
63 |
62 enum TAboutPanic |
64 enum TAboutPanic |
99 void CAboutContainer::ConstructL( const TRect& aRect ) |
101 void CAboutContainer::ConstructL( const TRect& aRect ) |
100 { |
102 { |
101 CreateWindowL(); |
103 CreateWindowL(); |
102 iScrollBarDragged = EFalse; |
104 iScrollBarDragged = EFalse; |
103 iBreakFlag = EFalse; |
105 iBreakFlag = EFalse; |
104 iSkinContext = NULL; |
106 iSkinContext = NULL; |
105 iText = NULL; |
107 iText = NULL; |
106 iImages = NULL; |
108 iImages = NULL; |
107 iScreenStarts = NULL; |
109 iScreenStarts = NULL; |
108 iSBFrame = NULL; |
110 iSBFrame = NULL; |
109 iHandleFlag = ETrue; |
|
110 iLoader = CAboutResourceLoader::NewL( iEikonEnv, this ); |
111 iLoader = CAboutResourceLoader::NewL( iEikonEnv, this ); |
111 CalculateL( aRect ); |
112 CalculateL(aRect); |
112 ActivateL(); |
113 ActivateL(); |
113 } |
114 } |
114 |
115 |
115 // ----------------------------------------------------------------------------- |
116 // ----------------------------------------------------------------------------- |
116 // CAboutContainer::~CAboutContainer() |
117 // CAboutContainer::~CAboutContainer() |
117 // ----------------------------------------------------------------------------- |
118 // ----------------------------------------------------------------------------- |
118 CAboutContainer::~CAboutContainer() |
119 CAboutContainer::~CAboutContainer() |
119 { |
120 { |
120 delete iSkinContext; |
121 delete iSkinContext; |
121 delete iSBFrame; |
122 delete iSBFrame; |
122 delete iScreenStarts; |
123 delete iScreenStarts; |
123 delete iIcon; |
124 delete iIcon; |
124 |
125 |
125 if ( iText ) |
126 if ( iText ) |
126 { |
127 { |
127 iText->ResetAndDestroy(); |
128 iText->ResetAndDestroy(); |
128 delete iText; |
129 delete iText; |
129 } |
130 } |
130 |
131 |
131 if ( iImages ) |
132 if ( iImages ) |
132 { |
133 { |
133 iImages->ResetAndDestroy(); |
134 iImages->ResetAndDestroy(); |
134 delete iImages; |
135 delete iImages; |
135 } |
136 } |
146 // ----------------------------------------------------------------------------- |
147 // ----------------------------------------------------------------------------- |
147 // CAboutContainer::SizeChanged() |
148 // CAboutContainer::SizeChanged() |
148 // ----------------------------------------------------------------------------- |
149 // ----------------------------------------------------------------------------- |
149 void CAboutContainer::SizeChanged() |
150 void CAboutContainer::SizeChanged() |
150 { |
151 { |
151 TRect parentRect( Rect() ); |
152 TRect parentRect(Rect()); |
152 if (iSkinContext) |
153 if (iSkinContext) |
153 { |
154 { |
154 iSkinContext->SetRect( parentRect ); |
155 iSkinContext->SetRect(parentRect); |
155 } |
156 } |
156 } |
157 } |
157 |
|
158 // ----------------------------------------------------------------------------- |
158 // ----------------------------------------------------------------------------- |
159 // CAboutContainer::Draw() |
159 // CAboutContainer::Draw() |
160 // ----------------------------------------------------------------------------- |
160 // ----------------------------------------------------------------------------- |
|
161 |
161 void CAboutContainer::Draw( const TRect& aRect ) const |
162 void CAboutContainer::Draw( const TRect& aRect ) const |
162 { |
163 { |
163 CWindowGc& gc = SystemGc(); |
164 CWindowGc& gc = SystemGc(); |
164 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
165 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
165 if ( iSkinContext ) |
166 if (iSkinContext) |
166 { |
167 { |
167 //Draw the skin background |
168 //Draw the skin background |
168 AknsDrawUtils::Background( |
169 AknsDrawUtils::Background( |
169 skin, iSkinContext, this, gc, aRect ); |
170 skin, iSkinContext, this, gc, aRect); |
170 } |
171 } |
171 else |
172 else |
172 {// clear the area |
173 {// clear the area |
173 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ); |
174 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ); |
174 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
175 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
214 topLeft = TPoint( position.iX, position.iY-iBaseLineDelta ); |
215 topLeft = TPoint( position.iX, position.iY-iBaseLineDelta ); |
215 TRgb color; |
216 TRgb color; |
216 TInt error = AknsUtils::GetCachedColor( skin, |
217 TInt error = AknsUtils::GetCachedColor( skin, |
217 color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); |
218 color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); |
218 |
219 |
219 if( error == KErrNone ) |
220 if(error == KErrNone) |
220 { |
221 { |
221 gc.SetPenColor( color ); |
222 gc.SetPenColor(color); |
222 } |
223 } |
223 gc.DrawText( *text, |
224 gc.DrawText( *text, |
224 TRect( topLeft, rectSize ), |
225 TRect( topLeft, rectSize ), |
225 iBaseLineDelta, |
226 iBaseLineDelta, |
226 iTextAlign ); |
227 iTextAlign ); |
242 position.iY += ( image->StartLine() - firstLine ) * iBaseLineDelta; |
243 position.iY += ( image->StartLine() - firstLine ) * iBaseLineDelta; |
243 |
244 |
244 position.iY -= iBaseLineDelta - iFont->DescentInPixels(); |
245 position.iY -= iBaseLineDelta - iFont->DescentInPixels(); |
245 // Now iY is the top line of rectangle where the picture is |
246 // Now iY is the top line of rectangle where the picture is |
246 // centered in. |
247 // centered in. |
247 position.iY += ( ( image->Lines()+1 ) * iBaseLineDelta - |
248 position.iY += ( (image->Lines()+1) * iBaseLineDelta - |
248 iFont->HeightInPixels() - |
249 iFont->HeightInPixels() - |
249 image->HeightInPixels() ) / 2; |
250 image->HeightInPixels() ) / 2; |
250 |
251 |
251 // If text is right-aligned, also align images to the right. |
252 // If text is right-aligned, also align images to the right. |
252 |
253 |
548 // Decide which type of scrollbar is to be shown |
549 // Decide which type of scrollbar is to be shown |
549 CAknAppUi* appUi = iAvkonAppUi; |
550 CAknAppUi* appUi = iAvkonAppUi; |
550 if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan) |
551 if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan) |
551 { |
552 { |
552 // For EDoubleSpan type scrollbar |
553 // For EDoubleSpan type scrollbar |
553 iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse); // non-window owning scrollbar |
554 iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse); // non-window owning scrollbar |
554 iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan); |
555 iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan); |
555 } |
556 } |
556 else |
557 else |
557 { |
558 { |
558 // For EArrowHead type scrollbar |
559 // For EArrowHead type scrollbar |
704 } |
705 } |
705 |
706 |
706 // ----------------------------------------------------------------------------- |
707 // ----------------------------------------------------------------------------- |
707 // CAboutContainer::HandleResourceChange() |
708 // CAboutContainer::HandleResourceChange() |
708 // ----------------------------------------------------------------------------- |
709 // ----------------------------------------------------------------------------- |
709 void CAboutContainer::HandleResourceChange( TInt aType ) |
710 void CAboutContainer::HandleResourceChange(TInt aType) |
710 { |
711 { |
711 switch ( aType ) |
712 |
712 { |
713 switch ( aType ) |
713 case KEikDynamicLayoutVariantSwitch : |
714 { |
714 { |
715 case KEikDynamicLayoutVariantSwitch : |
|
716 { |
715 TRAP_IGNORE( CalculateL( iAvkonAppUi->ClientRect() ) ); |
717 TRAP_IGNORE( CalculateL( iAvkonAppUi->ClientRect() ) ); |
716 DrawNow(); |
718 DrawNow(); |
717 } |
719 } |
718 break; |
720 break; |
719 case KEikMessageUnfadeWindows : |
721 case KEikMessageUnfadeWindows : |
720 case KAknsMessageSkinChange : |
722 case KAknsMessageSkinChange : |
721 { |
723 { |
722 // window owning scrollbar |
724 // window owning scrollbar |
723 TRAP_IGNORE( iSBFrame->CreateDoubleSpanScrollBarsL( ETrue, EFalse ) ); |
725 TRAP_IGNORE( iSBFrame->CreateDoubleSpanScrollBarsL( ETrue, EFalse ) ); |
724 iSBFrame->SetTypeOfVScrollBar( CEikScrollBarFrame::EDoubleSpan ); |
726 iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan); |
725 TRAP_IGNORE( iSBFrame->SetScrollBarVisibilityL( |
727 TRAP_IGNORE( iSBFrame->SetScrollBarVisibilityL( |
726 CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn ) ); |
728 CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn ) ); |
727 TRAP_IGNORE( UpdateScrollIndicatorL() ); |
729 TRAP_IGNORE(UpdateScrollIndicatorL()); |
728 } |
730 } |
729 default: |
731 |
730 { |
732 default: |
731 CCoeControl::HandleResourceChange( aType ); |
733 { |
732 } |
734 CCoeControl::HandleResourceChange(aType); |
733 break; |
735 } |
734 } |
736 break; |
735 } |
737 } |
|
738 } |
736 // --------------------------------------------------------- |
739 // --------------------------------------------------------- |
737 // CAboutContainer::MopSupplyObject() |
740 // CAboutContainer::MopSupplyObject() |
738 // Pass skin information if need. |
741 // Pass skin information if need. |
739 // --------------------------------------------------------- |
742 // --------------------------------------------------------- |
740 |
743 |
741 TTypeUid::Ptr CAboutContainer::MopSupplyObject( TTypeUid aId ) |
744 TTypeUid::Ptr CAboutContainer::MopSupplyObject(TTypeUid aId) |
742 { |
745 { |
743 if ( aId.iUid == MAknsControlContext::ETypeId && iSkinContext ) |
746 if (aId.iUid == MAknsControlContext::ETypeId && iSkinContext) |
744 { |
747 { |
745 return MAknsControlContext::SupplyMopObject( aId, iSkinContext ); |
748 return MAknsControlContext::SupplyMopObject(aId, iSkinContext); |
746 } |
749 } |
747 return CCoeControl::MopSupplyObject( aId ); |
750 return CCoeControl::MopSupplyObject(aId); |
748 } |
751 } |
749 |
752 |
750 // --------------------------------------------------------- |
753 // --------------------------------------------------------- |
751 // CAboutContainer::HandleScrollEventL() |
754 // CAboutContainer::HandleScrollEventL() |
752 // Capture Touch Events on the Scroll Bar |
755 // Capture Touch Events on the Scroll Bar |
753 // --------------------------------------------------------- |
756 // --------------------------------------------------------- |
754 void CAboutContainer::HandleScrollEventL( CEikScrollBar* aScrollBar, |
757 void CAboutContainer::HandleScrollEventL( CEikScrollBar* aScrollBar, |
755 TEikScrollEvent aEventType ) |
758 TEikScrollEvent aEventType ) |
756 { |
759 { |
757 //Only on page up/down,scroll up/down and drag events |
760 //Only on page up/down,scroll up/down and drag events |
758 if( ( aEventType == EEikScrollPageDown ) || ( aEventType == EEikScrollPageUp ) || |
761 if((aEventType == EEikScrollPageDown) || (aEventType == EEikScrollPageUp) || |
759 ( aEventType == EEikScrollThumbDragVert ) || ( aEventType == EEikScrollUp ) || |
762 (aEventType == EEikScrollThumbDragVert) || (aEventType == EEikScrollUp) || |
760 ( aEventType == EEikScrollDown ) ) |
763 ( aEventType == EEikScrollDown ) ) |
761 { |
764 { |
762 //Get the current position from the scroll bar |
765 //Get the current position from the scroll bar |
763 iCurrentScreen = aScrollBar->ThumbPosition(); |
766 iCurrentScreen = aScrollBar->ThumbPosition(); |
764 |
767 |
791 CAboutResource* item = ( *items )[i]; |
793 CAboutResource* item = ( *items )[i]; |
792 if ( item->ResourceType() == EAboutTextItem ) |
794 if ( item->ResourceType() == EAboutTextItem ) |
793 { |
795 { |
794 if ( R_ABOUT_MAIN_TEXT == iLoader->CurrentResourceId() ) |
796 if ( R_ABOUT_MAIN_TEXT == iLoader->CurrentResourceId() ) |
795 { |
797 { |
796 // Only one data record for each |
798 SetTextL( *item->ResourceItem(), item->ResourceIndex() ); |
797 if ( iHandleFlag ) |
799 if ( iLoader->ItemCount() == item->ResourceIndex() + 1 ) |
798 { |
800 { |
799 // Store the count of the current resource |
801 iFinalCount = iLoader->ItemCount() + 1; |
800 iCurrentCount = iLoader->ItemCount(); |
|
801 iHandleFlag = EFalse; |
|
802 } |
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 } |
803 } |
817 else |
804 else |
818 { |
805 { |
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 ); |
806 SetTextL( *item->ResourceItem(), iFinalCount ); |
|
807 iFinalCount++; |
828 } |
808 } |
829 } |
809 } |
830 else if( item->ResourceType() == EAboutImageItem ) |
810 else if( item->ResourceType() == EAboutImageItem ) |
831 { |
811 { |
832 SetImageL( *item->ResourceItem(), item->BitmapId() ); |
812 SetImageL( *item->ResourceItem(), item->BitmapId() ); |
860 |
840 |
861 // Load other resources including R_ABOUT_OSS_TEXT and R_ABOUT_OSS_TEXT_ADD |
841 // Load other resources including R_ABOUT_OSS_TEXT and R_ABOUT_OSS_TEXT_ADD |
862 TInt resourceId( aResourceId ); |
842 TInt resourceId( aResourceId ); |
863 if( R_ABOUT_MAIN_TEXT == resourceId ) |
843 if( R_ABOUT_MAIN_TEXT == resourceId ) |
864 { |
844 { |
|
845 // Load the R_ABOUT_OSS_TEXT_FIRST |
|
846 // Set the resource which you want to load next |
|
847 resourceId = R_ABOUT_OSS_TEXT_FIRST; |
|
848 // Set the resource's path |
|
849 iResourcePath.Copy( KRSCDirAndFileFirst ); |
|
850 } |
|
851 else if ( R_ABOUT_OSS_TEXT_FIRST == resourceId ) |
|
852 { |
865 // Load the R_ABOUT_OSS_TEXT |
853 // Load the R_ABOUT_OSS_TEXT |
866 // Set the resource which you want to load next |
|
867 resourceId = R_ABOUT_OSS_TEXT; |
854 resourceId = R_ABOUT_OSS_TEXT; |
868 // Set the resource's path |
|
869 iResourcePath.Copy( KRSCDirAndFile ); |
855 iResourcePath.Copy( KRSCDirAndFile ); |
870 } |
856 } |
871 else |
857 else |
872 { |
858 { |
873 // Load the R_ABOUT_OSS_TEXT_ADD |
859 // Load the R_ABOUT_OSS_TEXT_ADD |