|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Component factory interface |
|
15 * |
|
16 */ |
|
17 |
|
18 // User includes |
|
19 #include "xnappuiadapter.h" |
|
20 #include "xnviewadapter.h" |
|
21 #include "xncomponentfactory.h" |
|
22 #include "xncomponent.h" |
|
23 #include "xnnodepluginif.h" |
|
24 #include "xncomponentnodeimpl.h" |
|
25 #include "xnviewnodeimpl.h" |
|
26 #include "xncontroladapter.h" |
|
27 #include "xnpanic.h" |
|
28 #include "xntype.h" |
|
29 |
|
30 // Constants |
|
31 _LIT8( KToolTip, "tooltip" ); |
|
32 _LIT8( KView, "view" ); |
|
33 |
|
34 // ============================= LOCAL FUNCTIONS =============================== |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // FindParentAdapter |
|
38 // Find a parent control adapter up the node chain |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 static CXnControlAdapter* FindParentAdapter( CXnNode& aNode ) |
|
42 { |
|
43 CXnNode* parent( aNode.Parent() ); |
|
44 |
|
45 for( ; parent; parent = parent->Parent() ) |
|
46 { |
|
47 CXnControlAdapter* control( parent->Control() ); |
|
48 |
|
49 if( control ) |
|
50 { |
|
51 return control; |
|
52 } |
|
53 } |
|
54 |
|
55 return NULL; |
|
56 } |
|
57 |
|
58 // ============================ MEMBER FUNCTIONS =============================== |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // MXnComponentFactory::MXnComponentFactory |
|
62 // C++ default constructor can NOT contain any code, that |
|
63 // might leave. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C MXnComponentFactory::MXnComponentFactory() |
|
67 { |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // MXnComponentFactory::CreateXnComponentL |
|
72 // Creates a component |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C MXnComponentFactory::TXnComponentFactoryResponse MXnComponentFactory::CreateXnComponentL( |
|
76 CXnNodePluginIf& aNode, |
|
77 CXnComponent*& aTargetComponent ) |
|
78 { |
|
79 const TDesC8& type( aNode.Type()->Type() ); |
|
80 |
|
81 MXnComponentFactory::TXnComponentFactoryResponse response = |
|
82 MakeXnComponentL( aNode, aTargetComponent ); |
|
83 |
|
84 CleanupStack::PushL( aTargetComponent ); |
|
85 |
|
86 if ( response != EXnFactoryResponseComponentConstructed ) |
|
87 { |
|
88 CleanupStack::PopAndDestroy( aTargetComponent ); |
|
89 |
|
90 return response; |
|
91 } |
|
92 |
|
93 CXnControlAdapter* parentAdapter( FindParentAdapter( aNode.Node() ) ); |
|
94 CXnControlAdapter* adapter( MakeXnControlAdapterL( aNode, parentAdapter ) ); |
|
95 |
|
96 aTargetComponent->SetNode( aNode ); |
|
97 |
|
98 if ( type == KView ) |
|
99 { |
|
100 CXnAppUiAdapter* appui = static_cast< CXnAppUiAdapter* >( iAvkonAppUi ); |
|
101 |
|
102 adapter->SetContainerWindowL( appui->ViewAdapter().BgControl() ); |
|
103 |
|
104 aNode.ViewNodeImpl()->SetComponent( aTargetComponent ); |
|
105 } |
|
106 else |
|
107 { |
|
108 aNode.ComponentNodeImpl()->SetComponent( aTargetComponent ); |
|
109 } |
|
110 |
|
111 if ( parentAdapter ) |
|
112 { |
|
113 parentAdapter->AppendChildL( *adapter, aNode.Node() ); |
|
114 } |
|
115 |
|
116 aTargetComponent->SetControlAdapter( adapter ); |
|
117 |
|
118 if ( !adapter ) |
|
119 { |
|
120 CleanupStack::Pop( aTargetComponent ); |
|
121 |
|
122 return response; |
|
123 } |
|
124 |
|
125 adapter->SetComponent( aTargetComponent ); |
|
126 adapter->SetComponentsToInheritVisibility( ETrue ); |
|
127 adapter->MakeVisible( EFalse ); |
|
128 |
|
129 if ( type != KToolTip ) |
|
130 { |
|
131 // Don't activate tooltip yet |
|
132 adapter->ActivateL(); |
|
133 } |
|
134 |
|
135 CleanupStack::Pop( aTargetComponent ); |
|
136 |
|
137 return response; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // MXnComponentFactory::DoesNodeNeedComponentImplL |
|
142 // Check whether a node needs a component node implementation |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 EXPORT_C TBool MXnComponentFactory::DoesNodeNeedComponentImplL( |
|
146 const TDesC8& /*aType*/ ) |
|
147 { |
|
148 return ETrue; |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // MXnComponentFactory::MakeXnComponentL |
|
153 // Factory method to create component |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 EXPORT_C MXnComponentFactory::TXnComponentFactoryResponse MXnComponentFactory::MakeXnComponentL( |
|
157 CXnNodePluginIf& /*aNode*/, |
|
158 CXnComponent*& /*aTargetComponent*/ ) |
|
159 { |
|
160 return EXnFactoryResponseComponentNotSupported; |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // MXnComponentFactory::MakeXnComponentL |
|
165 // Factory method to create control adapter |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 EXPORT_C CXnControlAdapter* MXnComponentFactory::MakeXnControlAdapterL( |
|
169 CXnNodePluginIf& /*aNode*/, |
|
170 CXnControlAdapter* /*aParent*/ ) |
|
171 { |
|
172 return NULL; |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // Default destructor |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 EXPORT_C MXnComponentFactory::~MXnComponentFactory() |
|
180 { |
|
181 } |