|
1 /* |
|
2 * Copyright (c) 2002 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: Include common routine for each note editor. |
|
15 * For example, handling menu, key event, error handling etc. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <AknColourSelectionGrid.h> |
|
20 #include <eikrted.h> |
|
21 #include <aknnotewrappers.h> |
|
22 #include <bldvariant.hrh> |
|
23 #include <coeaui.h> |
|
24 #include <eikcapc.h> |
|
25 #include <eikedwin.h> |
|
26 #include <StringLoader.h> |
|
27 #include <aknnavi.h> |
|
28 #include <txtrich.h> |
|
29 #include <hlplch.h> |
|
30 #include <calcalendarinfo.h> |
|
31 #include <Calendar.rsg> |
|
32 |
|
33 #include "calenmultidbeditor.h" |
|
34 #include "calendarui_debug.h" |
|
35 #include "calendar.hrh" |
|
36 #include "calentitlepane.h" |
|
37 #include "calencontroller.h" |
|
38 |
|
39 // Constants. |
|
40 const TUint16 KIllegalChars[] = { |
|
41 '<', '>', '"', '/', '//', '|', ':', '*', '?', |
|
42 0xFF02, // Full width quote |
|
43 0xFF0A, // Full width asterisk |
|
44 0xFF0F, // Full width slash |
|
45 0xFF1A, // Full width colon |
|
46 0xFF1C, // Full width left arrow |
|
47 0xFF1E, // Full width right arrow |
|
48 0xFF1F, // Full width question mark |
|
49 0xFF3C, // Full width back slash |
|
50 0xFF5C, // Full width pipe |
|
51 0x201C, // Left quote |
|
52 0x201D, // Right quote |
|
53 0x201F, // Reversed quote |
|
54 0x21B2, // Downwards arrow with tip leftwards |
|
55 0, // Array terminator |
|
56 }; |
|
57 const TInt KCalenMaxELAFTextEditorLength(256); |
|
58 const TInt KCalenColorPalletteStartColor(35); |
|
59 const TInt KOne( 1 ); |
|
60 const TInt KBuffLength ( 16 ); |
|
61 const TInt KTen( 10 ); |
|
62 |
|
63 // Literals. |
|
64 _LIT( KFormatStringTwoDigit, "%02d" ); |
|
65 _LIT( KFormatString, "%d" ); |
|
66 |
|
67 // ================= MEMBER FUNCTIONS ======================= |
|
68 |
|
69 // ---------------------------------------------------------------------------- |
|
70 // CCalenMultiDBEditor::NewL |
|
71 // Two-phased constructor. |
|
72 // ---------------------------------------------------------------------------- |
|
73 // |
|
74 CCalenMultiDBEditor* CCalenMultiDBEditor::NewL( CCalCalendarInfo& aCalendarInfo, |
|
75 CCalenController& aController, TBool aEditFlag) |
|
76 { |
|
77 TRACE_ENTRY_POINT; |
|
78 |
|
79 CCalenMultiDBEditor* self = |
|
80 new(ELeave) CCalenMultiDBEditor( aCalendarInfo, aController, aEditFlag); |
|
81 CleanupStack::PushL( self ); |
|
82 self->ConstructL(); |
|
83 CleanupStack::Pop( self ); |
|
84 |
|
85 TRACE_EXIT_POINT; |
|
86 return self; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CCalenMultiDBEditor::~CCalenMultiDBEditor |
|
91 // Destructor. |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 CCalenMultiDBEditor::~CCalenMultiDBEditor() |
|
95 { |
|
96 TRACE_ENTRY_POINT; |
|
97 |
|
98 if(iCalendarName) |
|
99 { |
|
100 delete iCalendarName; |
|
101 iCalendarName = NULL; |
|
102 } |
|
103 |
|
104 if( iNaviContainer ) |
|
105 { |
|
106 iNaviContainer->Pop(); // Remove navi pane used by settings view |
|
107 iNaviContainer = NULL; // iNaviContainer is not owned |
|
108 } |
|
109 TRACE_EXIT_POINT; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CCalenMultiDBEditor::CCalenMultiDBEditor |
|
114 // C++ constructor can NOT contain any code, that might leave. |
|
115 // This overload is used when the repeat type is known. |
|
116 // (other items were commented in a header). |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 CCalenMultiDBEditor::CCalenMultiDBEditor( CCalCalendarInfo& aCalendarInfo, |
|
120 CCalenController& aController, TBool aEditFlag) |
|
121 :iCalendarInfo( aCalendarInfo ) , iController( aController ), |
|
122 iEditFlag( aEditFlag ) |
|
123 { |
|
124 TRACE_ENTRY_POINT; |
|
125 |
|
126 iCalendarStatus = ECalenMultiDbVisible; |
|
127 |
|
128 TRACE_EXIT_POINT; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CCalenMultiDBEditor::ConstructL |
|
133 // Leaving construction common to all editors. |
|
134 // (other items were commented in a header). |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CCalenMultiDBEditor::ConstructL() |
|
138 { |
|
139 TRACE_ENTRY_POINT; |
|
140 |
|
141 iConflict = CCalenMultiDBEditor::EConflictNone; |
|
142 |
|
143 CAknDialog::ConstructL( R_CALEN_MULTIDB_MENUBAR ); // superclass |
|
144 SetTitlePaneL(); |
|
145 iCalendarName = HBufC::NewL(KCalenMaxELAFTextEditorLength); |
|
146 |
|
147 //Initial color value |
|
148 iColVal = iCalendarInfo.Color().Value(); |
|
149 iColors = TRgb(iColVal); |
|
150 |
|
151 iPicture = new( ELeave )CDbColorPicture( TSize( 0, 0 ) ); |
|
152 iPicture->SetRgbColorsL(iColors); |
|
153 |
|
154 //set sync value |
|
155 // ESyncStatus |
|
156 TBuf8<KBuffLength> keyBuff; |
|
157 keyBuff.AppendNum(ESyncStatus); |
|
158 TPckgC<TBool> pkgSyncStatus(iSyncStatus); |
|
159 TRAPD(err,pkgSyncStatus.Set(iCalendarInfo.PropertyValueL(keyBuff))); |
|
160 if( KErrNone == err ) |
|
161 { |
|
162 iSyncStatus = pkgSyncStatus(); |
|
163 } |
|
164 TRACE_EXIT_POINT; |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CCalenMultiDBEditor::ProcessCommandL |
|
169 // Process commands from the user. |
|
170 // (other items were commented in a header). |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CCalenMultiDBEditor::ProcessCommandL( TInt aCommandId ) |
|
174 { |
|
175 TRACE_ENTRY_POINT; |
|
176 |
|
177 HideMenu(); |
|
178 |
|
179 switch(aCommandId) |
|
180 { |
|
181 case ECalenMultiDbHelp: |
|
182 { |
|
183 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
184 (iEikonEnv->AppUi())->AppHelpContextL ()); |
|
185 } |
|
186 break; |
|
187 case EAknCmdExit: |
|
188 case EAknSoftkeyExit: |
|
189 { |
|
190 TryExitL( EAknSoftkeyExit ); |
|
191 } |
|
192 break; |
|
193 |
|
194 case EAknSoftkeyChange: |
|
195 { |
|
196 if( ECalenMultiDbSyncStatus == IdOfFocusControl() ) |
|
197 { |
|
198 SetSyncFieldL( !iSyncStatus ); |
|
199 iSyncStatus = !iSyncStatus; |
|
200 } |
|
201 else if( ECalenMultiDbHiddenVisible == IdOfFocusControl() ) |
|
202 { |
|
203 iCalendarStatus = iCalendarInfo.Enabled(); |
|
204 |
|
205 if( ECalenMultiDbHidden == iCalendarStatus ) |
|
206 { |
|
207 SetVisiblityFieldL( ECalenMultiDbVisible ); |
|
208 iCalendarStatus = ECalenMultiDbVisible; |
|
209 iCalendarInfo.SetEnabled(iCalendarStatus); |
|
210 } |
|
211 else |
|
212 { |
|
213 SetVisiblityFieldL( ECalenMultiDbHidden ); |
|
214 iCalendarStatus = ECalenMultiDbHidden; |
|
215 iCalendarInfo.SetEnabled(iCalendarStatus); |
|
216 } |
|
217 } |
|
218 else if ( ECalenMultiDbColor == IdOfFocusControl() ) |
|
219 { |
|
220 GetColorL(); |
|
221 iColors = TRgb(iColVal); |
|
222 GetLineByLineAndPageIndex(1,0)->DrawNow(); |
|
223 } |
|
224 } |
|
225 break; |
|
226 |
|
227 case EAknSoftkeyOpen: |
|
228 { |
|
229 GetColorL(); |
|
230 iColors = TRgb(iColVal); |
|
231 GetLineByLineAndPageIndex(1,0)->DrawNow(); |
|
232 } |
|
233 break; |
|
234 |
|
235 default: |
|
236 { |
|
237 // No implementation yet. |
|
238 } |
|
239 break; |
|
240 } |
|
241 |
|
242 TRACE_EXIT_POINT; |
|
243 } |
|
244 |
|
245 // ----------------------------------------------------------------------------- |
|
246 // CCalenMultiDBEditor::HandleEditCommandL |
|
247 // Process commands from the user. |
|
248 // (other items were commented in a header). |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 void CCalenMultiDBEditor::HandleEditCommandL() |
|
252 { |
|
253 switch(IdOfFocusControl()) |
|
254 { |
|
255 case ECalenMultiDbColor: |
|
256 { |
|
257 GetColorL(); |
|
258 iColors = TRgb(iColVal); |
|
259 GetLineByLineAndPageIndex(1,0)->DrawNow(); |
|
260 } |
|
261 break; |
|
262 default: |
|
263 { |
|
264 // No implementation yet. |
|
265 } |
|
266 break; |
|
267 } |
|
268 } |
|
269 |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CCalenMultiDBEditor::SetConflict |
|
273 // (other items were commented in a header). |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 void CCalenMultiDBEditor::SetConflict(TCalendarConflicts aConflict) |
|
277 { |
|
278 TRACE_ENTRY_POINT |
|
279 iConflict = aConflict; |
|
280 TRACE_EXIT_POINT |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CCalenMultiDBEditor::Conflict |
|
285 // (other items were commented in a header). |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 CCalenMultiDBEditor::TCalendarConflicts CCalenMultiDBEditor::Conflict() const |
|
289 { |
|
290 TRACE_ENTRY_POINT |
|
291 TRACE_EXIT_POINT |
|
292 return iConflict; |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // CCalenMultiDBEditor::HandleNotification |
|
297 // (other items were commented in a header). |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CCalenMultiDBEditor::OkToExitL |
|
303 // Handle CBA-key on a form. |
|
304 // (other items were commented in a header). |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 TBool CCalenMultiDBEditor::OkToExitL(TInt aButtonId) |
|
308 { |
|
309 TRACE_ENTRY_POINT; |
|
310 TBool isExitForm(EFalse); |
|
311 |
|
312 switch(aButtonId) |
|
313 { |
|
314 case EAknSoftkeyOpen: |
|
315 { |
|
316 GetColorL(); |
|
317 iColors = TRgb(iColVal); |
|
318 GetLineByLineAndPageIndex(1,0)->DrawNow(); |
|
319 } |
|
320 break; |
|
321 |
|
322 case EAknSoftkeyOptions: |
|
323 { |
|
324 DisplayMenuL(); |
|
325 isExitForm = EFalse; |
|
326 } |
|
327 break; |
|
328 |
|
329 case EAknSoftkeyChange: |
|
330 { |
|
331 isExitForm=EFalse; |
|
332 if( ECalenMultiDbSyncStatus == IdOfFocusControl() ) |
|
333 { |
|
334 SetSyncFieldL( !iSyncStatus ); |
|
335 iSyncStatus = !iSyncStatus; |
|
336 } |
|
337 else if( ECalenMultiDbHiddenVisible == IdOfFocusControl() ) |
|
338 { |
|
339 iCalendarStatus = iCalendarInfo.Enabled(); |
|
340 |
|
341 if( ECalenMultiDbHidden == iCalendarStatus ) |
|
342 { |
|
343 SetVisiblityFieldL( ECalenMultiDbVisible ); |
|
344 iCalendarStatus = ECalenMultiDbVisible; |
|
345 iCalendarInfo.SetEnabled(iCalendarStatus); |
|
346 } |
|
347 else |
|
348 { |
|
349 SetVisiblityFieldL( ECalenMultiDbHidden ); |
|
350 iCalendarStatus = ECalenMultiDbHidden; |
|
351 iCalendarInfo.SetEnabled(iCalendarStatus); |
|
352 } |
|
353 } |
|
354 else if ( ECalenMultiDbColor == IdOfFocusControl() ) |
|
355 { |
|
356 GetColorL(); |
|
357 iColors = TRgb(iColVal); |
|
358 GetLineByLineAndPageIndex(1,0)->DrawNow(); |
|
359 } |
|
360 } |
|
361 break; |
|
362 |
|
363 case EAknSoftkeyDone: |
|
364 { |
|
365 isExitForm = SaveNoteL(aButtonId); |
|
366 } |
|
367 break; |
|
368 case EAknSoftkeyExit: |
|
369 case EAknCmdExit: |
|
370 { |
|
371 SaveNoteL(aButtonId); |
|
372 isExitForm = ETrue; |
|
373 } |
|
374 break; |
|
375 case EAknSoftkeyQuit: |
|
376 { |
|
377 isExitForm = ETrue; |
|
378 } |
|
379 break; |
|
380 default: |
|
381 { |
|
382 isExitForm=CAknForm::OkToExitL(aButtonId); |
|
383 } |
|
384 break; |
|
385 } |
|
386 TRACE_EXIT_POINT; |
|
387 |
|
388 return isExitForm; |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // CCalenMultiDBEditor::OfferKeyEventL |
|
393 // Passes key events to MsgEditorView to enable scrolling. |
|
394 // (other items were commented in a header). |
|
395 // ----------------------------------------------------------------------------- |
|
396 TKeyResponse CCalenMultiDBEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
397 { |
|
398 TRACE_ENTRY_POINT; |
|
399 TKeyResponse keyResponse(EKeyWasNotConsumed); |
|
400 |
|
401 if (aType == EEventKey) |
|
402 { |
|
403 switch (aKeyEvent.iCode) |
|
404 { |
|
405 case EKeyEscape: |
|
406 TryExitL( EAknCmdExit ); |
|
407 keyResponse = EKeyWasConsumed; |
|
408 break; |
|
409 default: |
|
410 keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); |
|
411 break; |
|
412 } |
|
413 } |
|
414 else |
|
415 { |
|
416 // Swallow all other keyevents to prevent the active container processing them. |
|
417 keyResponse = EKeyWasConsumed; |
|
418 } |
|
419 TRACE_EXIT_POINT; |
|
420 return keyResponse; |
|
421 } |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CCalenMultiDBEditor::PreLayoutDynInitL() |
|
425 // Updates fields just before the form is shown. |
|
426 // (other items were commented in a header). |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 void CCalenMultiDBEditor::PreLayoutDynInitL() |
|
430 { |
|
431 TRACE_ENTRY_POINT; |
|
432 |
|
433 // Set data to controls in the editor. |
|
434 SetDataToFormL(); |
|
435 |
|
436 TRACE_EXIT_POINT; |
|
437 } |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // CCalenMultiDBEditor::SetDataToFormL() |
|
441 // Reads data from the entry and updates the form with the appropriate values. |
|
442 // (other items were commented in a header). |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CCalenMultiDBEditor::SetDataToFormL() |
|
446 { |
|
447 TRACE_ENTRY_POINT; |
|
448 //First filed "Name" of the Form |
|
449 CEikEdwin* edwin = |
|
450 reinterpret_cast<CEikEdwin*>(Control(ECalenMultiDbName)); |
|
451 |
|
452 if( edwin ) |
|
453 { |
|
454 edwin->SetTextLimit(KCalenMaxELAFTextEditorLength); |
|
455 edwin->SetSelectionL( edwin->TextLength(), 0 ); |
|
456 } |
|
457 |
|
458 SetEditableL(ETrue); |
|
459 Line(ECalenMultiDbName)->SetFocus(ETrue); |
|
460 Line(ECalenMultiDbName)->ActivateL(); |
|
461 |
|
462 HBufC* calendarName = iCalendarInfo.NameL().AllocLC(); |
|
463 |
|
464 // Check for the empty text. |
|
465 if( ( !calendarName->Size() ) ) |
|
466 { |
|
467 CleanupStack::PopAndDestroy(calendarName); |
|
468 TInt index( KOne ); |
|
469 calendarName = StringLoader::LoadLC( R_CALE_DB_CALENDAR ); |
|
470 TBuf< KBuffLength > numBuf; |
|
471 |
|
472 // Check if name is already there or not. |
|
473 while( IsNameFoundL( *calendarName ) ) |
|
474 { |
|
475 CleanupStack::PopAndDestroy( calendarName ); |
|
476 numBuf.Zero(); |
|
477 if( index < KTen ) |
|
478 { |
|
479 numBuf.Format( KFormatStringTwoDigit, index ); |
|
480 } |
|
481 else |
|
482 { |
|
483 numBuf.Format( KFormatString, index ); |
|
484 } |
|
485 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( |
|
486 numBuf ); |
|
487 calendarName = StringLoader::LoadLC( |
|
488 R_CALE_DB_CALENDAR_DEFAULT_NAME, numBuf ); |
|
489 |
|
490 ++index; |
|
491 } |
|
492 } |
|
493 SetEdwinTextL( ECalenMultiDbName, calendarName ); |
|
494 CleanupStack::PopAndDestroy(calendarName); |
|
495 |
|
496 //Second field "Color" of the form |
|
497 // Instantiate CDbColorPicture object 300x300 twips in size |
|
498 CEikRichTextEditor* colorControl = static_cast<CEikRichTextEditor*>(Control(ECalenMultiDbColor)); |
|
499 |
|
500 //Prepare the iPicture header, which will be inserted into the rich text |
|
501 TPictureHeader header; |
|
502 header.iPicture = TSwizzle<CPicture>(iPicture); |
|
503 |
|
504 // Position where we insert iPicture is not valid as it always draws icon depending the rect we provide |
|
505 colorControl->RichText()->InsertL(0, header); |
|
506 colorControl->AddFlagToUserFlags(CEikEdwin::EAvkonDisableCursor | CEikEdwin::EReadOnly ); |
|
507 GetLineByLineAndPageIndex(1,0)->DrawNow(); |
|
508 |
|
509 iCalendarStatus = iCalendarInfo.Enabled(); |
|
510 |
|
511 //Set the the sync status |
|
512 SetSyncFieldL(iSyncStatus); |
|
513 |
|
514 if( ECalenMultiDbHidden == iCalendarStatus ) |
|
515 { |
|
516 SetVisiblityFieldL( ECalenMultiDbHidden ); |
|
517 } |
|
518 else |
|
519 { |
|
520 SetVisiblityFieldL( ECalenMultiDbVisible ); |
|
521 } |
|
522 TRACE_EXIT_POINT; |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------- |
|
526 // CCalenMultiDBEditor::DynInitMenuPaneL |
|
527 // Gets called before form is displayed |
|
528 // (other items were commented in a header). |
|
529 // --------------------------------------------------------- |
|
530 // |
|
531 void CCalenMultiDBEditor::DynInitMenuPaneL( TInt aResourceId, |
|
532 CEikMenuPane* aMenuPane ) |
|
533 { |
|
534 TRACE_ENTRY_POINT; |
|
535 |
|
536 if( aResourceId != R_CALEN_MULTIDB_MENUPANE ) |
|
537 { |
|
538 return; |
|
539 } |
|
540 |
|
541 // Execute the following commands if the resource belongs to calendar. |
|
542 // Display the menu items based on the current focused control. |
|
543 if( ECalenMultiDbName == IdOfFocusControl() ) |
|
544 { |
|
545 aMenuPane->SetItemDimmed( EAknSoftkeyChange, ETrue ); |
|
546 } |
|
547 |
|
548 TRACE_EXIT_POINT; |
|
549 } |
|
550 |
|
551 // --------------------------------------------------------------------------- |
|
552 // CCalenMultiDBEditor::GetColorL |
|
553 // From class CAknSettingItem. |
|
554 // GetColorL overridden to launch colour selection grid. |
|
555 // --------------------------------------------------------------------------- |
|
556 // |
|
557 void CCalenMultiDBEditor::GetColorL() |
|
558 { |
|
559 TRACE_ENTRY_POINT; |
|
560 |
|
561 TBool retVal = EFalse; |
|
562 |
|
563 // Array for TRgb colour values |
|
564 CArrayFixFlat<TRgb>* colors = new( ELeave ) CArrayFixFlat<TRgb>( 8 ); |
|
565 CleanupStack::PushL( colors ); |
|
566 |
|
567 // array of colors. |
|
568 colors->AppendL(KRgbRed); |
|
569 colors->AppendL(KRgbDarkGray); |
|
570 colors->AppendL(KRgbDarkRed); |
|
571 colors->AppendL(KRgbDarkGreen); |
|
572 colors->AppendL(KRgbDarkYellow); |
|
573 colors->AppendL(KRgbDarkBlue); |
|
574 colors->AppendL(KRgbDarkMagenta); |
|
575 colors->AppendL(KRgbDarkCyan); |
|
576 colors->AppendL(KRgbBlack); |
|
577 colors->AppendL(KRgbGreen); |
|
578 colors->AppendL(KRgbYellow); |
|
579 colors->AppendL(KRgbBlue); |
|
580 colors->AppendL(KRgbMagenta); |
|
581 colors->AppendL(KRgbCyan); |
|
582 colors->AppendL(KRgbGray); |
|
583 colors->AppendL(KRgbWhite); |
|
584 |
|
585 // Get current colour |
|
586 TRgb color = KCalenColorPalletteStartColor; //iDbInfo.GetCalendarColor(); |
|
587 TInt startValue = iColVal; |
|
588 TBool noneChosen = ETrue; |
|
589 |
|
590 // Construct colour selection grid |
|
591 CAknColourSelectionGrid *dlg = CAknColourSelectionGrid::NewL(colors, EFalse, |
|
592 noneChosen,color ); |
|
593 |
|
594 retVal = dlg->ExecuteLD(); |
|
595 |
|
596 iColVal = KErrNotFound; |
|
597 if ( !noneChosen && retVal )//If something is chosen |
|
598 { |
|
599 iColVal = color.Value(); |
|
600 } |
|
601 else//Else set the previous color. |
|
602 { |
|
603 iColVal = startValue; |
|
604 } |
|
605 iColors = TRgb(iColVal); |
|
606 iPicture->SetRgbColorsL(iColors); |
|
607 CleanupStack::PopAndDestroy( colors ); |
|
608 TRACE_EXIT_POINT; |
|
609 } |
|
610 |
|
611 // --------------------------------------------------------------------------- |
|
612 // CCalenMultiDBEditor::SaveNoteL |
|
613 // Try to save note. Initializes all the member variables of DBInfo. |
|
614 // --------------------------------------------------------------------------- |
|
615 // |
|
616 TBool CCalenMultiDBEditor::SaveNoteL( TInt aButtonId ) |
|
617 { |
|
618 TRACE_ENTRY_POINT; |
|
619 |
|
620 if (Conflict() == CCalenMultiDBEditor::EConflictDelete) |
|
621 { |
|
622 CAknNoteDialog *note = new (ELeave) CAknNoteDialog( |
|
623 CAknNoteDialog::EWarningTone, CAknNoteDialog::ENoTimeout); |
|
624 HBufC* buf = StringLoader::LoadLC( R_QTN_CALENDAREDITOR_NOTE_DB_CONFLICT_DELETE, iEikonEnv); |
|
625 note->SetTextL(*buf); |
|
626 note->ExecuteLD(R_CALEN_CALENDAREDITOR_CONFLICT_DIALOG); |
|
627 CleanupStack::PopAndDestroy(buf); |
|
628 return ETrue; |
|
629 } |
|
630 else if (Conflict() == CCalenMultiDBEditor::EConflictUpdate) |
|
631 { |
|
632 CAknNoteDialog *note = new (ELeave) CAknNoteDialog( |
|
633 CAknNoteDialog::EWarningTone, CAknNoteDialog::ENoTimeout); |
|
634 HBufC* buf = StringLoader::LoadLC(R_QTN_CALENDAREDITOR_NOTE_DB_CONFLICT_UPDATE, iEikonEnv); |
|
635 note->SetTextL(*buf); |
|
636 note->ExecuteLD(R_CALEN_CALENDAREDITOR_CONFLICT_DIALOG); |
|
637 CleanupStack::PopAndDestroy(buf); |
|
638 return ETrue; |
|
639 } |
|
640 else |
|
641 { |
|
642 } |
|
643 |
|
644 TBool retValue = ETrue; |
|
645 RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
646 iController.GetAllCalendarInfoL(calendarInfoList); |
|
647 CleanupClosePushL(calendarInfoList); |
|
648 const TBool continueOnError = ETrue; |
|
649 ReadDataFromFormL( continueOnError); |
|
650 |
|
651 iCalendarName->Des().Trim(); |
|
652 // Check for the empty text |
|
653 if((!iCalendarName->Size()) ) |
|
654 { |
|
655 // If in editing mode, just save the name used before. |
|
656 if( iEditFlag ) |
|
657 { |
|
658 iCalendarName = iCalendarInfo.NameL().AllocLC(); |
|
659 CleanupStack::Pop( iCalendarName ); |
|
660 SetEdwinTextL( ECalenMultiDbName, iCalendarName ); |
|
661 } |
|
662 else |
|
663 { |
|
664 // else use the default name. |
|
665 TInt index( KOne ); |
|
666 HBufC* calendarName = StringLoader::LoadLC( R_CALE_DB_CALENDAR ); |
|
667 TBuf< KBuffLength > numBuf; |
|
668 |
|
669 // Check if the name is already present. |
|
670 while( IsNameFoundL( *calendarName ) ) |
|
671 { |
|
672 CleanupStack::PopAndDestroy( calendarName ); |
|
673 numBuf.Zero(); |
|
674 if( index < KTen ) |
|
675 { |
|
676 numBuf.Format( KFormatStringTwoDigit, index ); |
|
677 } |
|
678 else |
|
679 { |
|
680 numBuf.Format( KFormatString, index ); |
|
681 } |
|
682 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( |
|
683 numBuf ); |
|
684 calendarName = StringLoader::LoadLC( |
|
685 R_CALE_DB_CALENDAR_DEFAULT_NAME, numBuf ); |
|
686 |
|
687 ++index; |
|
688 } |
|
689 |
|
690 iCalendarName->Des().Append( calendarName->Des() ); |
|
691 |
|
692 CleanupStack::PopAndDestroy( calendarName ); |
|
693 SetEdwinTextL( ECalenMultiDbName, iCalendarName ); |
|
694 } |
|
695 |
|
696 } |
|
697 |
|
698 // Check for the validity of the calendar name. |
|
699 if( IsNameValid( *iCalendarName ) ) |
|
700 { |
|
701 // Name is valid. then check if it already exists or not. |
|
702 if( IsNameEditedL( *iCalendarName ) ) |
|
703 { |
|
704 TInt index = calendarInfoList.Find( *iCalendarName,CCalenMultiDBEditor::CalenInfoIdentifierL ); |
|
705 if(index != KErrNotFound) |
|
706 { |
|
707 if( EAknCmdExit != aButtonId ) |
|
708 { |
|
709 retValue = EFalse; |
|
710 HBufC* infoText = StringLoader::LoadLC( |
|
711 R_QTN_CALE_DB_ALREADY_EXISTS_NOTE , iCalendarName->Des() ); |
|
712 CAknInformationNote* dialog = new( ELeave ) CAknInformationNote(ETrue); |
|
713 dialog->ExecuteLD( *infoText ); |
|
714 CleanupStack::PopAndDestroy( infoText ); |
|
715 } |
|
716 } |
|
717 else |
|
718 { |
|
719 iCalendarInfo.SetNameL(*iCalendarName); |
|
720 } |
|
721 } |
|
722 |
|
723 } |
|
724 else |
|
725 { |
|
726 if( EAknCmdExit != aButtonId ) |
|
727 { |
|
728 retValue = EFalse; |
|
729 HBufC* infoText(NULL); |
|
730 infoText = AreIllegalChars( *iCalendarName ) ? StringLoader::LoadLC( R_CALEN_ILLEGAL_CHARACTERS ) : |
|
731 StringLoader::LoadLC( R_CALEN_BAD_FILE_NAME ); |
|
732 CAknInformationNote* dialog = new( ELeave ) CAknInformationNote(ETrue); |
|
733 dialog->ExecuteLD( *infoText ); |
|
734 CleanupStack::PopAndDestroy( infoText ); |
|
735 } |
|
736 } |
|
737 |
|
738 |
|
739 if(IsColorEditedL( iColVal ) ) |
|
740 { |
|
741 iCalendarInfo.SetColor(iColVal); |
|
742 } |
|
743 |
|
744 //Filling the sync value into metadata |
|
745 TBuf8<KBuffLength> keyBuff; |
|
746 keyBuff.Zero(); |
|
747 keyBuff.AppendNum(ESyncStatus); |
|
748 |
|
749 TPckgC<TBool> pkgSyncStatus(iSyncStatus); |
|
750 iCalendarInfo.SetPropertyL(keyBuff, pkgSyncStatus); |
|
751 |
|
752 if( IsVisiblityFieldEditedL( iCalendarStatus ) ) |
|
753 { |
|
754 iCalendarInfo.SetEnabled(iCalendarStatus); |
|
755 } |
|
756 |
|
757 CleanupStack::PopAndDestroy(&calendarInfoList); |
|
758 TRACE_EXIT_POINT; |
|
759 return retValue; |
|
760 } |
|
761 |
|
762 // --------------------------------------------------------------------------- |
|
763 // CCalenMultiDBEditor::ExecuteLD |
|
764 // Launches the MultiDB Form |
|
765 // --------------------------------------------------------------------------- |
|
766 // |
|
767 TInt CCalenMultiDBEditor::ExecuteLD() |
|
768 { |
|
769 TRACE_ENTRY_POINT; |
|
770 TRACE_EXIT_POINT; |
|
771 return CAknForm::ExecuteLD(R_CALEN_MULTIDB_EDITOR); |
|
772 } |
|
773 |
|
774 // --------------------------------------------------------------------------- |
|
775 // CCalenMultiDBEditor::ReadDataFromFormL |
|
776 // Read all the data from the form. |
|
777 // --------------------------------------------------------------------------- |
|
778 // |
|
779 void CCalenMultiDBEditor::ReadDataFromFormL( TBool /*aContinueOnError */) |
|
780 { |
|
781 TRACE_ENTRY_POINT; |
|
782 //Initial Name value |
|
783 TPtr summary = iCalendarName->Des(); |
|
784 |
|
785 CEikEdwin* edwin = |
|
786 reinterpret_cast<CEikEdwin*>(Control(ECalenMultiDbName)); |
|
787 GetEdwinText(summary, ECalenMultiDbName); |
|
788 |
|
789 TRACE_EXIT_POINT; |
|
790 } |
|
791 // --------------------------------------------------------------------------- |
|
792 // CCalenMultiDBEditor::IsNameEditedL |
|
793 // Checks wether Name got edited or not. |
|
794 // --------------------------------------------------------------------------- |
|
795 // |
|
796 TBool CCalenMultiDBEditor::IsNameEditedL(const TDesC& aName) |
|
797 { |
|
798 TRACE_ENTRY_POINT; |
|
799 HBufC* calendarName = iCalendarInfo.NameL().AllocLC(); |
|
800 calendarName->Des().Trim(); |
|
801 |
|
802 TBool isEdited = EFalse; |
|
803 if (calendarName->CompareF(aName)) |
|
804 { |
|
805 isEdited = ETrue; |
|
806 } |
|
807 CleanupStack::PopAndDestroy(); |
|
808 TRACE_EXIT_POINT; |
|
809 |
|
810 return isEdited; |
|
811 } |
|
812 |
|
813 // --------------------------------------------------------------------------- |
|
814 // CCalenMultiDBEditor::IsNameFoundL |
|
815 // Checks wether Name got edited or not. |
|
816 // --------------------------------------------------------------------------- |
|
817 // |
|
818 TBool CCalenMultiDBEditor::IsNameFoundL(const TDesC& aName) |
|
819 { |
|
820 TRACE_ENTRY_POINT; |
|
821 |
|
822 TBool retValue = EFalse; |
|
823 RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
824 iController.GetAllCalendarInfoL(calendarInfoList); |
|
825 CleanupClosePushL(calendarInfoList); |
|
826 HBufC *calendarName = aName.AllocLC(); |
|
827 |
|
828 TInt index = calendarInfoList.Find( *calendarName, |
|
829 CCalenMultiDBEditor::CalenInfoIdentifierL ); |
|
830 |
|
831 CleanupStack::PopAndDestroy( calendarName ); |
|
832 CleanupStack::PopAndDestroy( &calendarInfoList ); |
|
833 |
|
834 // Name is matched. |
|
835 if(index != KErrNotFound) |
|
836 { |
|
837 retValue = ETrue; |
|
838 } |
|
839 |
|
840 TRACE_EXIT_POINT; |
|
841 return retValue; |
|
842 } |
|
843 |
|
844 // --------------------------------------------------------------------------- |
|
845 // CCalenMultiDBEditor::AreIllegalChars |
|
846 // Rest of the details are commented in header. |
|
847 // --------------------------------------------------------------------------- |
|
848 // |
|
849 TBool CCalenMultiDBEditor::AreIllegalChars( const TDesC& aName ) |
|
850 { |
|
851 TRACE_ENTRY_POINT; |
|
852 |
|
853 for ( TInt i( 0 ); KIllegalChars[ i ]; i++ ) |
|
854 { |
|
855 if ( aName.Locate( KIllegalChars[ i ] ) != KErrNotFound ) |
|
856 { |
|
857 // name is valid. |
|
858 return ETrue; |
|
859 } |
|
860 } |
|
861 TRACE_EXIT_POINT; |
|
862 |
|
863 return EFalse; |
|
864 } |
|
865 |
|
866 // --------------------------------------------------------------------------- |
|
867 // CCalenMultiDBEditor::IsValidName |
|
868 // Rest of the details are commented in header. |
|
869 // --------------------------------------------------------------------------- |
|
870 // |
|
871 TBool CCalenMultiDBEditor::IsNameValid( const TDesC& aName ) |
|
872 { |
|
873 TRACE_ENTRY_POINT; |
|
874 |
|
875 // Check name for bad chars |
|
876 const TUint16 KMinAllowedChar = 0x0020; |
|
877 const TUint16 KParagraphSeparator = 0x2029; |
|
878 const TUint16 KDot = '.'; |
|
879 |
|
880 TInt nameLen( aName.Length() ); |
|
881 if ( !nameLen ) |
|
882 { |
|
883 return EFalse; |
|
884 } |
|
885 |
|
886 for ( TInt i( 0 ); i < nameLen; i++ ) |
|
887 { |
|
888 TUint16 ch( aName[ i ] ); |
|
889 if ( ch < KMinAllowedChar || ch == KParagraphSeparator ) |
|
890 { |
|
891 return EFalse; |
|
892 } |
|
893 } |
|
894 |
|
895 // File system ignores totally dot in the end of name, so |
|
896 // we set here as not valid name, so that user gets correctly informed |
|
897 if ( aName[ nameLen - 1 ] == KDot || AreIllegalChars( aName ) ) |
|
898 { |
|
899 return EFalse; |
|
900 } |
|
901 return ETrue; |
|
902 } |
|
903 |
|
904 // --------------------------------------------------------------------------- |
|
905 // CCalenMultiDBEditor::IsColorEditedL |
|
906 // Checks wether Color got edited or not. |
|
907 // --------------------------------------------------------------------------- |
|
908 // |
|
909 TBool CCalenMultiDBEditor::IsColorEditedL(TInt iColVal) |
|
910 { |
|
911 TRACE_ENTRY_POINT; |
|
912 TRACE_EXIT_POINT; |
|
913 return (iCalendarInfo.Color() != iColVal); |
|
914 } |
|
915 |
|
916 // --------------------------------------------------------------------------- |
|
917 // CCalenMultiDBEditor::IsVisiblityFieldEditedL |
|
918 // Checks the visibility status of the calendar being edited. |
|
919 // --------------------------------------------------------------------------- |
|
920 // |
|
921 TBool CCalenMultiDBEditor::IsVisiblityFieldEditedL( TInt aCalendarStatus ) |
|
922 { |
|
923 TRACE_ENTRY_POINT; |
|
924 TRACE_EXIT_POINT; |
|
925 return (iCalendarInfo.Enabled() != aCalendarStatus ); |
|
926 } |
|
927 |
|
928 |
|
929 // ---------------------------------------------------------------------------- |
|
930 // CCalenMultiDBEditor::HandleDialogPageEventL |
|
931 // Process pointer event on the dialog. |
|
932 // (other items were commented in a header). |
|
933 // ---------------------------------------------------------------------------- |
|
934 void CCalenMultiDBEditor::HandleDialogPageEventL( TInt aEventID ) |
|
935 { |
|
936 TRACE_ENTRY_POINT; |
|
937 |
|
938 CAknForm::HandleDialogPageEventL( aEventID ); |
|
939 if ( aEventID == MEikDialogPageObserver::EDialogPageTapped ) |
|
940 { |
|
941 TInt focusControl( IdOfFocusControl() ); |
|
942 |
|
943 switch(focusControl) |
|
944 { |
|
945 case ECalenMultiDbColor: |
|
946 { |
|
947 GetColorL(); |
|
948 iColors = TRgb(iColVal); |
|
949 GetLineByLineAndPageIndex(1,0)->DrawNow(); |
|
950 } |
|
951 break; |
|
952 |
|
953 case ECalenMultiDbSyncStatus: |
|
954 { |
|
955 SetSyncFieldL( !iSyncStatus ); |
|
956 iSyncStatus = !iSyncStatus; |
|
957 } |
|
958 break; |
|
959 |
|
960 case ECalenMultiDbHiddenVisible: |
|
961 { |
|
962 iCalendarStatus = iCalendarInfo.Enabled(); |
|
963 |
|
964 if( ECalenMultiDbHidden == iCalendarStatus ) |
|
965 { |
|
966 SetVisiblityFieldL( ECalenMultiDbVisible ); |
|
967 iCalendarStatus = ECalenMultiDbVisible; |
|
968 iCalendarInfo.SetEnabled(iCalendarStatus); |
|
969 } |
|
970 else |
|
971 { |
|
972 SetVisiblityFieldL( ECalenMultiDbHidden ); |
|
973 iCalendarStatus = ECalenMultiDbHidden; |
|
974 iCalendarInfo.SetEnabled(iCalendarStatus); |
|
975 } |
|
976 } |
|
977 break; |
|
978 |
|
979 default: |
|
980 { |
|
981 |
|
982 } |
|
983 break; |
|
984 } |
|
985 } |
|
986 TRACE_EXIT_POINT; |
|
987 } |
|
988 |
|
989 // ----------------------------------------------------------------------------- |
|
990 // CCalenMultiDBEditor::LineChangedL |
|
991 // This function gets called by the framework each time line is changed in |
|
992 // the dialog (form). . |
|
993 // We will use it for MSK label switching. |
|
994 // (other items were commented in a header). |
|
995 // ----------------------------------------------------------------------------- |
|
996 // |
|
997 void CCalenMultiDBEditor::LineChangedL( TInt aControlId ) |
|
998 { |
|
999 TRACE_ENTRY_POINT; |
|
1000 |
|
1001 CEikButtonGroupContainer& cba = ButtonGroupContainer (); |
|
1002 TInt resId = 0; |
|
1003 TInt controlId = aControlId; |
|
1004 |
|
1005 switch( controlId ) |
|
1006 { |
|
1007 case ECalenMultiDbName: |
|
1008 { |
|
1009 resId = R_CALEN_MULTIDB_MSK_EMPTY_CBA; |
|
1010 } |
|
1011 break; |
|
1012 |
|
1013 case ECalenMultiDbColor: |
|
1014 case ECalenMultiDbHiddenVisible: |
|
1015 case ECalenMultiDbSyncStatus: |
|
1016 { |
|
1017 resId = R_CALEN_MULTIDB_MSK_CHANGE_CBA; |
|
1018 } |
|
1019 break; |
|
1020 |
|
1021 default: |
|
1022 { |
|
1023 // No implementation yet. |
|
1024 } |
|
1025 break; |
|
1026 } |
|
1027 |
|
1028 // set desired CBA |
|
1029 cba.SetCommandSetL( resId ); |
|
1030 cba.DrawNow(); |
|
1031 |
|
1032 TRACE_EXIT_POINT; |
|
1033 } |
|
1034 |
|
1035 // ----------------------------------------------------------------------------- |
|
1036 // CCalenEditorBase::PostLayoutDynInitL |
|
1037 // This is called in CEikDialog::ExecuteLD() after a form is drawn. |
|
1038 // (other items were commented in a header). |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // |
|
1041 void CCalenMultiDBEditor::PostLayoutDynInitL() |
|
1042 { |
|
1043 TRACE_ENTRY_POINT; |
|
1044 SetEditableL(ETrue); |
|
1045 |
|
1046 LineChangedL( ECalenMultiDbName ); |
|
1047 |
|
1048 CAknForm::PostLayoutDynInitL(); // chain back up to baseclass |
|
1049 TRACE_EXIT_POINT; |
|
1050 } |
|
1051 |
|
1052 // ----------------------------------------------------------------------------- |
|
1053 // CCalenMultipleDbUi::CalenInfoIdentifierL |
|
1054 // ----------------------------------------------------------------------------- |
|
1055 // |
|
1056 TBool CCalenMultiDBEditor::CalenInfoIdentifierL( const HBufC* aName, |
|
1057 const CCalCalendarInfo& aCalendarInfo ) |
|
1058 { |
|
1059 TRACE_ENTRY_POINT; |
|
1060 HBufC* calendarName = aCalendarInfo.NameL().AllocLC(); |
|
1061 calendarName->Des().Trim(); |
|
1062 TBool retVal = EFalse; |
|
1063 retVal = calendarName->Compare(*aName); |
|
1064 CleanupStack::PopAndDestroy(); |
|
1065 TRACE_EXIT_POINT; |
|
1066 return (!retVal); |
|
1067 } |
|
1068 |
|
1069 // ----------------------------------------------------------------------------- |
|
1070 // CDbColorPicture::SetVisiblityFieldL |
|
1071 // Rest of the details are commented in header. |
|
1072 // ----------------------------------------------------------------------------- |
|
1073 // |
|
1074 void CCalenMultiDBEditor::SetVisiblityFieldL( TBool aStatusVal ) |
|
1075 { |
|
1076 TRACE_ENTRY_POINT; |
|
1077 HBufC* statusString( NULL ); |
|
1078 CEikEdwin* fieldText =( CEikEdwin* )Control( ECalenMultiDbHiddenVisible ); |
|
1079 if( aStatusVal ) |
|
1080 { |
|
1081 // load string Visible |
|
1082 statusString = StringLoader::LoadLC( R_CALE_DB_SHOWN_SETTING ,iCoeEnv ); |
|
1083 } |
|
1084 else |
|
1085 { |
|
1086 // load string Hidden |
|
1087 statusString = StringLoader::LoadLC( R_CALE_DB_HIDDEN_SETTING ,iCoeEnv ); |
|
1088 } |
|
1089 // set status field string |
|
1090 fieldText->SetTextL( statusString ); |
|
1091 fieldText->DrawDeferred(); |
|
1092 CleanupStack::PopAndDestroy( statusString ); |
|
1093 TRACE_EXIT_POINT; |
|
1094 } |
|
1095 |
|
1096 // ----------------------------------------------------------------------------- |
|
1097 // CCalenMultiDBEditor::SetTitlePaneL |
|
1098 // Rest of the details are commented in header. |
|
1099 // ----------------------------------------------------------------------------- |
|
1100 // |
|
1101 void CCalenMultiDBEditor::SetTitlePaneL() |
|
1102 { |
|
1103 TRACE_ENTRY_POINT; |
|
1104 |
|
1105 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
1106 |
|
1107 // Set empty navi pane label |
|
1108 iNaviContainer = static_cast<CAknNavigationControlContainer*>( |
|
1109 sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
1110 iNaviContainer->PushDefaultL(); |
|
1111 |
|
1112 // Set title text |
|
1113 CAknTitlePane* tp = static_cast<CAknTitlePane*>( |
|
1114 sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
1115 |
|
1116 HBufC* titleText = StringLoader::LoadLC( R_QTN_CALE_TITLE_CALENDAR , iCoeEnv ); |
|
1117 tp->SetTextL( *titleText ); |
|
1118 CleanupStack::PopAndDestroy( titleText ); |
|
1119 |
|
1120 TRACE_EXIT_POINT; |
|
1121 } |
|
1122 |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // CCalenMultiDBEditor::SetSyncFieldL |
|
1125 // Rest of the details are commented in header. |
|
1126 // ----------------------------------------------------------------------------- |
|
1127 // |
|
1128 void CCalenMultiDBEditor::SetSyncFieldL( TBool aSyncVal ) |
|
1129 { |
|
1130 TRACE_ENTRY_POINT; |
|
1131 HBufC* syncString( NULL ); |
|
1132 CEikEdwin* syncFieldText =( CEikEdwin* )Control( ECalenMultiDbSyncStatus ); |
|
1133 if( EFalse == aSyncVal ) |
|
1134 { |
|
1135 // load string Off |
|
1136 syncString = StringLoader::LoadLC( R_CALE_SYNC_OFF , iCoeEnv ); |
|
1137 } |
|
1138 else |
|
1139 { |
|
1140 // load string On |
|
1141 syncString = StringLoader::LoadLC( R_CALE_SYNC_ON ,iCoeEnv ); |
|
1142 } |
|
1143 // set sync field string |
|
1144 syncFieldText->SetTextL( syncString ); |
|
1145 syncFieldText->DrawDeferred(); |
|
1146 CleanupStack::PopAndDestroy( syncString ); |
|
1147 TRACE_EXIT_POINT; |
|
1148 } |
|
1149 // ----------------------------------------------------------------------------- |
|
1150 // CDbColorPicture::CDbColorPicture |
|
1151 // C++ Constructor |
|
1152 // ----------------------------------------------------------------------------- |
|
1153 // |
|
1154 CDbColorPicture::CDbColorPicture(TSize aSize) |
|
1155 : iSize(aSize) |
|
1156 { |
|
1157 TRACE_ENTRY_POINT; |
|
1158 TRACE_EXIT_POINT; |
|
1159 } |
|
1160 |
|
1161 // ----------------------------------------------------------------------------- |
|
1162 // CDbColorPicture::ExternalizeL |
|
1163 // Pure virtual from CPicture, intentionally empty. |
|
1164 // ----------------------------------------------------------------------------- |
|
1165 // |
|
1166 void CDbColorPicture::ExternalizeL(RWriteStream& ) const |
|
1167 { |
|
1168 TRACE_ENTRY_POINT; |
|
1169 TRACE_EXIT_POINT; |
|
1170 } |
|
1171 |
|
1172 // ----------------------------------------------------------------------------- |
|
1173 // CDbColorPicture::GetOriginalSizeInTwips |
|
1174 // Convert size to twips |
|
1175 // ----------------------------------------------------------------------------- |
|
1176 // |
|
1177 void CDbColorPicture::GetOriginalSizeInTwips(TSize& /*aSize*/ ) const |
|
1178 { |
|
1179 TRACE_ENTRY_POINT; |
|
1180 TRACE_EXIT_POINT; |
|
1181 } |
|
1182 |
|
1183 void CDbColorPicture::SetRgbColorsL(TRgb aColors) |
|
1184 { |
|
1185 TRACE_ENTRY_POINT; |
|
1186 iColors = aColors; |
|
1187 TRACE_EXIT_POINT; |
|
1188 } |
|
1189 |
|
1190 // ----------------------------------------------------------------------------- |
|
1191 // CDbColorPicture::Draw |
|
1192 // Draw funtion to draw the map icon |
|
1193 // ----------------------------------------------------------------------------- |
|
1194 // |
|
1195 void CDbColorPicture::Draw(CGraphicsContext& aGc, |
|
1196 const TPoint& aTopLeft , |
|
1197 const TRect& /*aClipRect*/ , |
|
1198 MGraphicsDeviceMap* /*aMap*/ ) const |
|
1199 { |
|
1200 TRACE_ENTRY_POINT; |
|
1201 |
|
1202 |
|
1203 //aGc.Reset(); |
|
1204 aGc.CancelClippingRect(); |
|
1205 |
|
1206 TSize pixelsize; |
|
1207 pixelsize.iWidth = 225; |
|
1208 pixelsize.iHeight = 25; |
|
1209 TPoint aPoint; |
|
1210 TRect area = TRect(aTopLeft, pixelsize); |
|
1211 area.Move(0,-20); |
|
1212 // Draw a datbase color rectangle |
|
1213 aGc.SetBrushColor(iColors); |
|
1214 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1215 |
|
1216 aGc.DrawRect(area); |
|
1217 } |
|
1218 |
|
1219 // End of File |