|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "paintcursorappview.h" |
|
20 #include "pointmsgqueue.h" |
|
21 #include "debug.h" |
|
22 |
|
23 |
|
24 CPaintCursorAppView* CPaintCursorAppView::NewL(const TRect& aRect) |
|
25 { |
|
26 CPaintCursorAppView* self = CPaintCursorAppView::NewLC(aRect); |
|
27 CleanupStack::Pop(self); |
|
28 return self; |
|
29 } |
|
30 |
|
31 CPaintCursorAppView* CPaintCursorAppView::NewLC(const TRect& aRect) |
|
32 { |
|
33 CPaintCursorAppView* self = new (ELeave) CPaintCursorAppView; |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(aRect); |
|
36 return self; |
|
37 } |
|
38 |
|
39 void CPaintCursorAppView::ConstructL(const TRect& aRect) |
|
40 { |
|
41 // Create a window for this application view |
|
42 CreateWindowL(); |
|
43 |
|
44 // Set the windows size |
|
45 SetRect(aRect); |
|
46 |
|
47 // Initialise the RMouseCursorDll class |
|
48 TRACE_INFO(_L("[HID]\tCHidMouseDriver::Before SetupMouseCursorDllL()")); |
|
49 SetupMouseCursorDllL(); |
|
50 TRACE_INFO(_L("[HID]\tCHidMouseDriver::After SetupMouseCursorDllL()")); |
|
51 // Initialise the RImageCommander class |
|
52 SetupImageCommanderL(); |
|
53 |
|
54 // Activate the window, which makes it ready to be drawn |
|
55 ActivateL(); |
|
56 |
|
57 ShowCursor(); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CMenuAppUi::SetupMouseCursorDllL() |
|
62 // Setup Mousr Cursor animation client Dll. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 |
|
66 void CPaintCursorAppView::SetupMouseCursorDllL() |
|
67 { |
|
68 TRACE_INFO(_L("[HID]\tCHidMouseDriver::SetupMouseCursorDllL()")); |
|
69 // Create the server dll filename |
|
70 TFileName mouseCurorSrv( KMouseCurorSrvName ); |
|
71 |
|
72 // Load the animation server, if an error occurs then |
|
73 // let higher level handle the problem |
|
74 User::LeaveIfError( iMouseCursorDll.Load( mouseCurorSrv ) ); |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CMenuAppUi::SetupImageCommanderL() |
|
80 // Setup the animation image commander. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CPaintCursorAppView::SetupImageCommanderL() |
|
84 { |
|
85 TRACE_INFO(_L("[HID]\tCHidMouseDriver::SetupImageCommanderL()")); |
|
86 // Tell client to construct a server side object |
|
87 TSize iconRect(13,23); |
|
88 iClientCommander.ImageConstructL( CCoeEnv::Static()->RootWin(), |
|
89 iconRect ); |
|
90 } |
|
91 |
|
92 |
|
93 CPaintCursorAppView::CPaintCursorAppView() : |
|
94 iMouseCursorDll( CCoeEnv::Static()->WsSession() ), |
|
95 iClientCommander( iMouseCursorDll, CCoeEnv::Static()->WsSession() ) |
|
96 { |
|
97 // no implementation required |
|
98 } |
|
99 |
|
100 |
|
101 CPaintCursorAppView::~CPaintCursorAppView() |
|
102 { |
|
103 if ( iMouseInitialized ) |
|
104 { |
|
105 HideCursor(); |
|
106 } |
|
107 |
|
108 // Close the animation object |
|
109 iClientCommander.Close (); |
|
110 |
|
111 // Close the animation server |
|
112 iMouseCursorDll.Close(); |
|
113 } |
|
114 |
|
115 void CPaintCursorAppView::SizeChanged() |
|
116 { |
|
117 DrawNow(); |
|
118 } |
|
119 |
|
120 void CPaintCursorAppView::Draw(const TRect& aRect) const |
|
121 { |
|
122 TRACE_INFO(_L("[PaintCursor]\t CPaintCursorAppView::Draw()")); |
|
123 TRgb color; |
|
124 |
|
125 CWindowGc& gc = SystemGc(); |
|
126 |
|
127 // draw background |
|
128 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
129 |
|
130 // get skin text color |
|
131 AknsUtils::GetCachedColor( skin, color , KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); |
|
132 gc.SetPenColor( color ); |
|
133 |
|
134 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
135 AknsDrawUtils::Background( skin, cc, this, gc, aRect ); |
|
136 } |
|
137 |
|
138 void CPaintCursorAppView::HideCursor() |
|
139 { |
|
140 if (iMouseInitialized) |
|
141 { |
|
142 iClientCommander.ImageCommand( KStopBTCursorAnim ); |
|
143 } |
|
144 |
|
145 iMouseInitialized = EFalse; |
|
146 } |
|
147 |
|
148 void CPaintCursorAppView::ShowCursor() |
|
149 { |
|
150 if (!iMouseInitialized) |
|
151 { |
|
152 iClientCommander.ImageCommand( KStartBTCursorAnim ); |
|
153 } |
|
154 |
|
155 iMouseInitialized = ETrue; |
|
156 } |
|
157 |