|
1 /* |
|
2 * Copyright (c) 2008 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: smiley utility class |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_SMILEYICONRECORD_H |
|
19 #define C_SMILEYICONRECORD_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <e32std.h> |
|
23 #include "smileymanager.h" |
|
24 |
|
25 class CSmileyImageData; |
|
26 |
|
27 NONSHARABLE_CLASS( CSmileyIcon ) : public CBase |
|
28 { |
|
29 friend class CSmileyTextLink; |
|
30 public: |
|
31 CSmileyIcon( TText aCode ); |
|
32 ~CSmileyIcon(); |
|
33 // new functions |
|
34 void SetRect( TRect aRect ){ iRect = aRect; }; |
|
35 TRect Rect(){ return iRect; }; |
|
36 void SetPlayTimes( TInt aPlayTimes ){ iLoop = aPlayTimes; }; |
|
37 TInt PlayTimes(){ return iLoop; }; |
|
38 void EnableHighlight( TBool aEnable ){ iHighlight = aEnable; }; |
|
39 TBool IsHighlight(){ return iHighlight; }; |
|
40 void SetImageData( CSmileyImageData* aImage ){ iImage = aImage; }; |
|
41 CSmileyImageData* ImageData(){ return iImage; }; |
|
42 TText Code(){ return iCode; }; |
|
43 void IncreasePlayCount(){ iPlayCount++; }; |
|
44 TInt PlayCount(){ return iPlayCount; }; |
|
45 void PlayOneTime(){ iPlayCount = iLoop - 1; }; |
|
46 void ResetPlayCount(){ iPlayCount = 0; }; |
|
47 TBool IsPlayFinished(){ return ( iPlayCount >= iLoop ); }; |
|
48 TInt DocPos(){ return iDocPos; }; |
|
49 void SetDocPos( TInt aDocPos ){ iDocPos = aDocPos; }; |
|
50 |
|
51 TInt SmileyLength(){ return iStr.Length(); }; |
|
52 TInt EndPos(){ return iDocPos + iStr.Length(); }; |
|
53 void SetSmileyString( const TDesC& aString ); |
|
54 const TDesC& SmileyString(){ return iStr; }; |
|
55 |
|
56 TBool IsDisabled(){ return iDisabled; }; |
|
57 void DisableIcon( TBool aDisable = ETrue ){ iDisabled = aDisable; }; |
|
58 |
|
59 private: // data |
|
60 TText iCode; |
|
61 TRect iRect; |
|
62 TInt iDocPos; |
|
63 TInt iLoop; |
|
64 TInt iPlayCount; |
|
65 TBool iHighlight; |
|
66 // not own |
|
67 CSmileyImageData* iImage; |
|
68 TBuf<CSmileyManager::KMaxLength> iStr; |
|
69 TBool iDisabled; |
|
70 }; |
|
71 |
|
72 NONSHARABLE_CLASS( CSmileyIconRecord ) : public CBase |
|
73 { |
|
74 public: |
|
75 CSmileyIconRecord(); |
|
76 ~CSmileyIconRecord(); |
|
77 |
|
78 void InsertIconL( CSmileyIcon* aIcon ); |
|
79 void HandleTextDelete( TInt aStart, TInt aLength ); |
|
80 void HandleTextInsert( TInt aStart, TInt aLength ); |
|
81 void CancelSelection(); |
|
82 void SetSelection( TInt aStart, TInt aLength ); |
|
83 CSmileyIcon* SmileyIconAtPos( TInt aDocPos ); |
|
84 TBool HasSmileyIcon(); |
|
85 |
|
86 private: |
|
87 void InsertIconAtL( CSmileyIcon* aIcon, TInt aIndex ); |
|
88 void DeleteIconsIn( TInt aStart, TInt aLength ); |
|
89 TInt FirstIndexAfter( TInt aDocPos, TInt aSearchStart = 0 ); |
|
90 TInt FirstIndexIn( TInt aStart, TInt aLength ); |
|
91 TInt LastIndexIn( TInt aStart, TInt aLength, TInt aStartIndex ); |
|
92 |
|
93 private: // data |
|
94 RPointerArray<CSmileyIcon> iIconArray; |
|
95 }; |
|
96 |
|
97 #endif // C_SMILEYICONRECORD_H |