|
1 /* |
|
2 * Copyright (c) 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: Utility class for passing data between touchpane and toolbar. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <coecntrl.h> |
|
21 #include "touchtoolbardata.h" |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // ----------------------------------------------------------------------------- |
|
25 // |
|
26 TInt CTouchToolbarData::SetData( const CCoeControl* aControl, |
|
27 TRect aDemarcationRect, |
|
28 TBool aDemarcationRectSet ) |
|
29 { |
|
30 CTouchToolbarData* self = new CTouchToolbarData; |
|
31 if ( !self ) |
|
32 { |
|
33 return KErrNoMemory; |
|
34 } |
|
35 self->iDemarcationRect = aDemarcationRect; |
|
36 self->iDemarcationRectSet = aDemarcationRectSet; |
|
37 self->iBetweenRegisterAndBegin = EFalse; |
|
38 self->iSelectPressed = EFalse; |
|
39 |
|
40 // If there's already data stored for this key, remove and free it. |
|
41 TInt key = reinterpret_cast<TInt>( aControl ); |
|
42 CTouchToolbarData* data = |
|
43 reinterpret_cast<CTouchToolbarData*>( CAknTransitionUtils::GetData( key ) ); |
|
44 if ( data ) |
|
45 { |
|
46 CAknTransitionUtils::RemoveObserver( data, 0xffffffff ); |
|
47 CAknTransitionUtils::RemoveData( key ); |
|
48 delete data; |
|
49 } |
|
50 |
|
51 return CAknTransitionUtils::SetData( key, reinterpret_cast<TAny*>( self ) ); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CTouchToolbarData* CTouchToolbarData::GetData( const CCoeControl* aControl ) |
|
58 { |
|
59 return ( CTouchToolbarData* )CAknTransitionUtils::GetData( |
|
60 reinterpret_cast<TInt>( aControl ) ); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 TRect& CTouchToolbarData::DemarcationRect() |
|
67 { |
|
68 return iDemarcationRect; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 TBool CTouchToolbarData::DemarcationRectSet() const |
|
75 { |
|
76 return iDemarcationRectSet; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 TBool CTouchToolbarData::BetweenRegisterAndBegin() const |
|
83 { |
|
84 return iBetweenRegisterAndBegin; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 TBool CTouchToolbarData::SelectPressed() const |
|
91 { |
|
92 return iSelectPressed; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CTouchToolbarData::SetBetweenRegisterAndBegin( TBool aBetweenRegisterAndBegin ) |
|
99 { |
|
100 iBetweenRegisterAndBegin = aBetweenRegisterAndBegin; |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CTouchToolbarData::SetSelectPressed( TBool aSelectPressed ) |
|
107 { |
|
108 iSelectPressed = aSelectPressed; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CTouchToolbarData::SetFocusedItem( CCoeControl* aItem ) |
|
115 { |
|
116 iFocusedItem = aItem; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TInt CTouchToolbarData::AknTransitionCallback(TInt aEvent, TInt /* aState */, |
|
123 const TDesC8* aParams) |
|
124 { |
|
125 if ( iFocusedItem ) |
|
126 { |
|
127 // Show tooltip |
|
128 iFocusedItem->SetFocus( EFalse, ENoDrawNow ); |
|
129 iFocusedItem->PrepareForFocusGainL(); |
|
130 iFocusedItem->SetFocus( ETrue, EDrawNow ); |
|
131 } |
|
132 const CCoeControl* control = reinterpret_cast<const CCoeControl*>( aParams ); |
|
133 TInt key = reinterpret_cast<TInt>( aParams ); |
|
134 |
|
135 GfxTransEffect::Deregister( control ); |
|
136 |
|
137 CTouchToolbarData* data = |
|
138 reinterpret_cast<CTouchToolbarData*>( CAknTransitionUtils::GetData( key ) ); |
|
139 |
|
140 CAknTransitionUtils::RemoveObserver( this, aEvent ); |
|
141 CAknTransitionUtils::RemoveData( key ); |
|
142 delete data; |
|
143 |
|
144 return KErrNone; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 CTouchToolbarData::CTouchToolbarData() : iFocusedItem( NULL ) |
|
151 { |
|
152 } |