|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 thumbnail popup. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBK2THUMBNAILPOPUP_H |
|
20 #define CPBK2THUMBNAILPOPUP_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <MPbk2ImageOperationObservers.h> |
|
25 #include <eiklbx.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class MPbk2ThumbnailPopupControl; |
|
29 class CPbk2ImageManager; |
|
30 class CPbk2ThumbnailScaler; |
|
31 class CPbk2ThumbnailScalerObserver; |
|
32 class CVPbkContactManager; |
|
33 class MVPbkBaseContact; |
|
34 class MVPbkFieldType; |
|
35 class TPbk2ImageManagerParams; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * Phonebook 2 thumbnail location. |
|
41 */ |
|
42 enum TPbk2ThumbnailLocation |
|
43 { |
|
44 // Thumbnail is placed either upper or lower corner of |
|
45 // the listbox control |
|
46 ELocationUpDown = 0, |
|
47 // Thumbnail hangs either under or above the focus |
|
48 ELocationHanging |
|
49 }; |
|
50 |
|
51 /** |
|
52 * Phonebook 2 thumbnail popup observer. |
|
53 */ |
|
54 class MPbk2ThumbnailPopupObserver |
|
55 { |
|
56 public: // Interface |
|
57 |
|
58 /** |
|
59 * Called when loading of the popup thumbnail has completed |
|
60 * succesfully. |
|
61 */ |
|
62 virtual void PopupLoadComplete() = 0; |
|
63 |
|
64 /** |
|
65 * Called when loading of the popup thumbnail failed. |
|
66 * |
|
67 * @param aError Error code. |
|
68 */ |
|
69 virtual void PopupLoadFailed( |
|
70 TInt aError ) = 0; |
|
71 |
|
72 protected: // Disabled functions |
|
73 ~MPbk2ThumbnailPopupObserver() |
|
74 {} |
|
75 }; |
|
76 |
|
77 /** |
|
78 * Phonebook 2 thumbnail popup. |
|
79 * |
|
80 * Loads a thumbnail image attached to Phonebook's contact |
|
81 * and displays it in a popup control. |
|
82 */ |
|
83 class CPbk2ThumbnailPopup : public CBase, |
|
84 private MPbk2ImageGetObserver |
|
85 { |
|
86 public: // Constructors and destructor |
|
87 |
|
88 /** |
|
89 * Creates a new instance of this class. |
|
90 * |
|
91 * @param aContactManager Virtual Phonebook contact manager. |
|
92 * @return A new instance of this class. |
|
93 */ |
|
94 static CPbk2ThumbnailPopup* NewL( |
|
95 CVPbkContactManager& aContactManager ); |
|
96 |
|
97 /** |
|
98 * Destructor. |
|
99 * Hides any thumbnail popup visible, cancels any Load() in |
|
100 * progress and destroys this object. |
|
101 */ |
|
102 ~CPbk2ThumbnailPopup(); |
|
103 |
|
104 public: // Interface |
|
105 |
|
106 /** |
|
107 * Loads contact's thumbnail image (if any) and displays it |
|
108 * in a popup control. If a previous thumbnail is visible |
|
109 * when this function is called it is immediately hidden. |
|
110 * The loading and displaying of the thumbnail image is done |
|
111 * asynchronously, so the thumbnail is not immediately visible |
|
112 * when this function returns. |
|
113 * |
|
114 * This function ignores all errors that might occur when loading |
|
115 * and displaying the thumbnail image. If there are errors the |
|
116 * thumbnail is simply not shown. No error note is displayed |
|
117 * to the user. |
|
118 * |
|
119 * @param aContact Contact whose thumbnail to show. |
|
120 * @param aObserver Observer of the thumbnail popup. |
|
121 * @param aListBox If given, thumbnail position is depended on |
|
122 * list box focus. If NULL, thumbnail position |
|
123 * is fixed. |
|
124 * @param aFieldType Type of the field from where to load |
|
125 * the thumbnail, if NULL the default thumbnail |
|
126 * field is used. |
|
127 */ |
|
128 void Load( |
|
129 MVPbkBaseContact& aContact, |
|
130 MPbk2ThumbnailPopupObserver& aObserver, |
|
131 const CEikListBox* aListBox = NULL, |
|
132 const MVPbkFieldType* aFieldType = NULL ); |
|
133 |
|
134 /** |
|
135 * Hides the thumbnail popup control and cancels any Load() in |
|
136 * progress. |
|
137 */ |
|
138 void HideAndCancel(); |
|
139 |
|
140 /** |
|
141 * Shows the given bitmap in a popup control. |
|
142 * Note that the bitmap has to be scaled down before calling this |
|
143 * function. |
|
144 * |
|
145 * @param aBitmap Bitmap to show in a popup control. |
|
146 */ |
|
147 void ShowPopupBitmap( |
|
148 CFbsBitmap* aBitmap ); |
|
149 |
|
150 /** |
|
151 * Refreshes an already loaded thumbnail. |
|
152 */ |
|
153 void Refresh(); |
|
154 |
|
155 /** |
|
156 * Sets the location where thumbnail is drawn |
|
157 * |
|
158 * @param aThumbnailLocation Thumbnail location. |
|
159 */ |
|
160 void SetThumbnailLocation( |
|
161 TPbk2ThumbnailLocation aThumbnailLocation ); |
|
162 |
|
163 private: // From MPbk2ImageGetObserver |
|
164 void Pbk2ImageGetComplete( |
|
165 MPbk2ImageOperation& aOperation, |
|
166 CFbsBitmap* aBitmap ); |
|
167 void Pbk2ImageGetFailed( |
|
168 MPbk2ImageOperation& aOperation, |
|
169 TInt aError ); |
|
170 |
|
171 private: // Implementation |
|
172 CPbk2ThumbnailPopup( |
|
173 CVPbkContactManager& aContactManager ); |
|
174 void ConstructL(); |
|
175 void DoLoadL( |
|
176 MVPbkBaseContact& aContact, |
|
177 const MVPbkFieldType* aFieldType ); |
|
178 void HideControl(); |
|
179 void GetThumbnailL( |
|
180 MVPbkBaseContact& aContact, |
|
181 const MVPbkFieldType& aFieldType ); |
|
182 void ReadFieldTypeL(); |
|
183 void LoadThumbnailBackgL(); |
|
184 void SetupImageParams( |
|
185 TPbk2ImageManagerParams& aParams ); |
|
186 |
|
187 private: // Data |
|
188 /// Own: Thumbnail manager |
|
189 CPbk2ImageManager* iManager; |
|
190 /// Own: Bitmap popup control |
|
191 MPbk2ThumbnailPopupControl* iThumbnailPopupControl; |
|
192 /// Own: Asynchronous thumbnail operation |
|
193 MPbk2ImageOperation* iThumbOperation; |
|
194 /// Own: Thumbnail scaler |
|
195 CPbk2ThumbnailScaler* iThumbnailScaler; |
|
196 /// Own: Scaler observer |
|
197 CPbk2ThumbnailScalerObserver* iScalerObserver; |
|
198 /// Ref: Virtual Phonebook contact manager |
|
199 CVPbkContactManager& iContactManager; |
|
200 /// Ref: Observer for the load function |
|
201 MPbk2ThumbnailPopupObserver* iLoadObserver; |
|
202 /// Ref: Field type |
|
203 const MVPbkFieldType* iFieldType; |
|
204 |
|
205 /// Not Own: |
|
206 CFbsBitmap* iBitmap; |
|
207 |
|
208 |
|
209 /// Own: Thumbnail background shadow |
|
210 CFbsBitmap* iThumbnailBackg; |
|
211 /// Own: Thumbnail background shadow mask |
|
212 CFbsBitmap* iThumbnailBackgMask; |
|
213 /// Ref: Listbox for finding out where the focus is |
|
214 const CEikListBox* iListBox; |
|
215 /// Own: Thumbnail location |
|
216 TPbk2ThumbnailLocation iThumbnailLocation; |
|
217 }; |
|
218 |
|
219 #endif // CPBK2THUMBNAILPOPUP_H |
|
220 |
|
221 // End of File |