|
1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Template for a listbox class which forwards listbox events |
|
15 * to an observer. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef FLDLISTBOXTEMPLATE_H |
|
21 #define FLDLISTBOXTEMPLATE_H |
|
22 |
|
23 #include <coedef.h> // TKeyResponse |
|
24 #include <w32std.h> // TKeyEvent, TEventCode |
|
25 #include "MFLDFileListBoxObserver.h" |
|
26 #include "CFLDFileListModel.h" |
|
27 #include "CFLDPopupList.h" |
|
28 |
|
29 // CLASS DECLARATION |
|
30 |
|
31 /** |
|
32 * Template for a listbox class which forwards listbox events to an observer. |
|
33 * |
|
34 * @lib filelist.lib |
|
35 * @since Series 60 2.6 |
|
36 */ |
|
37 template<class T> |
|
38 class FLDListBoxTemplate : public T |
|
39 { |
|
40 public: // Constructors and destructor |
|
41 |
|
42 /** |
|
43 * Constructor |
|
44 */ |
|
45 FLDListBoxTemplate( |
|
46 MFLDFileListBoxObserver& aObserver, CFLDFileListModel& aModel ) |
|
47 : iObserver( aObserver ), iModel( aModel ) {} |
|
48 |
|
49 virtual ~FLDListBoxTemplate() |
|
50 { |
|
51 iObserver.HandleFileListBoxEventL( |
|
52 MFLDFileListBoxObserver::EListBoxClosed ); |
|
53 } |
|
54 |
|
55 public: // New functions |
|
56 |
|
57 /** |
|
58 * Sets populist |
|
59 */ |
|
60 void SetListBox( CFLDPopupList* aPopupList ) |
|
61 { |
|
62 iPopupList = aPopupList; |
|
63 } |
|
64 |
|
65 public: // Functions from base classes |
|
66 |
|
67 /** |
|
68 * Method modified to send listbox events to an observer, when |
|
69 * focus changes from one list item to another |
|
70 */ |
|
71 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
72 { |
|
73 /// Current softkeystate |
|
74 MFLDFileListBoxObserver::TFileListSoftKeyState softKeyState; |
|
75 iObserver.HandleSoftKeyState( softKeyState ); |
|
76 |
|
77 if( aType == EEventKey ) |
|
78 { |
|
79 // Get current item index |
|
80 TInt oldIndex( T::CurrentItemIndex() ); |
|
81 // Call OfferKeyEventL |
|
82 TKeyResponse response( T::OfferKeyEventL( aKeyEvent, aType ) ); |
|
83 // Get new item index |
|
84 TInt newIndex( T::CurrentItemIndex() ); |
|
85 // Get current filename |
|
86 TFileName filename; |
|
87 iModel.GetFileName( filename, T::CurrentItemIndex() ); |
|
88 // Compare new and old index |
|
89 if( oldIndex != newIndex ) |
|
90 { |
|
91 // Notify focus change if focus changes |
|
92 iObserver.HandleFileListBoxEventL( |
|
93 MFLDFileListBoxObserver::EFocusChanged, filename ); |
|
94 |
|
95 #ifdef RD_VIDEO_AS_RINGING_TONE |
|
96 // When video is drawn over popuplist and user changes focus |
|
97 // or interrupts the video by using other key |
|
98 // screen must be forced to be redrawn |
|
99 if( ( iPopupList ) && |
|
100 ( softKeyState == MFLDFileListBoxObserver::EPreviewSelectSoftKeyState ) ) |
|
101 { |
|
102 // Set the vertical scroll bar and listbox to not dimmed. |
|
103 if ( iPopupList ) |
|
104 { |
|
105 iPopupList->ListBox()->SetDimmed( EFalse ); |
|
106 iPopupList->ListBox()->ScrollBarFrame()-> |
|
107 VerticalScrollBar()->SetDimmed( EFalse ); |
|
108 } |
|
109 |
|
110 iPopupList->DrawNow( CEikonEnv::Static()->EikAppUi()->ApplicationRect() ); |
|
111 } |
|
112 #endif |
|
113 } |
|
114 else |
|
115 { |
|
116 #ifdef RD_VIDEO_AS_RINGING_TONE |
|
117 if( ( iModel.MediaFileType( filename ) == ECLFMediaTypeVideo ) && |
|
118 ( aKeyEvent.iScanCode == EStdKeyDevice3 ) ) |
|
119 { |
|
120 // Do not notify observer |
|
121 // when joystick key is pressed |
|
122 // and current file is a video file |
|
123 } |
|
124 else |
|
125 { |
|
126 iObserver.HandleFileListBoxEventL( |
|
127 MFLDFileListBoxObserver::EOtherKeyEvent ); |
|
128 |
|
129 // When video is drawn over popuplist and user changes focus |
|
130 // or interrupts the video by using other key |
|
131 // screen must be forced to be redrawn |
|
132 if( ( iPopupList ) && |
|
133 ( softKeyState == MFLDFileListBoxObserver::EPreviewSelectSoftKeyState ) ) |
|
134 { |
|
135 // Set the vertical scroll bar and listbox to not dimmed. |
|
136 if ( iPopupList ) |
|
137 { |
|
138 iPopupList->ListBox()->SetDimmed( EFalse ); |
|
139 iPopupList->ListBox()->ScrollBarFrame()-> |
|
140 VerticalScrollBar()->SetDimmed( EFalse ); |
|
141 } |
|
142 |
|
143 iPopupList->DrawNow( CEikonEnv::Static()->EikAppUi()->ApplicationRect() ); |
|
144 } |
|
145 } |
|
146 |
|
147 #else |
|
148 iObserver.HandleFileListBoxEventL( |
|
149 MFLDFileListBoxObserver::EOtherKeyEvent ); |
|
150 #endif |
|
151 } |
|
152 return response; |
|
153 } |
|
154 return T::OfferKeyEventL( aKeyEvent, aType ); |
|
155 } |
|
156 |
|
157 private: // Data |
|
158 |
|
159 /// Ref: The list box observer, which gets notified about list item focus changes |
|
160 MFLDFileListBoxObserver& iObserver; |
|
161 |
|
162 /// Ref: File list model |
|
163 CFLDFileListModel& iModel; |
|
164 |
|
165 /// Ref: File list popuplist |
|
166 CFLDPopupList* iPopupList; |
|
167 |
|
168 }; |
|
169 |
|
170 #endif // FLDLISTBOXTEMPLATE_H |
|
171 |
|
172 // End of File |