|
1 /* |
|
2 * Copyright (c) 2006-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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HUICONTROLGROUP_H__ |
|
21 #define __HUICONTROLGROUP_H__ |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <barsread.h> |
|
26 |
|
27 #include <uiacceltk/HuiTimedValue.h> |
|
28 #include <uiacceltk/HuiObserverArray.h> |
|
29 #include <uiacceltk/huieventhandler.h> |
|
30 #include <uiacceltk/HuiSessionObject.h> |
|
31 |
|
32 |
|
33 /* Forward declarations. */ |
|
34 class CHuiEnv; |
|
35 class CHuiControl; |
|
36 class CHuiTransformation; |
|
37 |
|
38 |
|
39 /** |
|
40 * CHuiControlgroup instances are used to organize controls into logical |
|
41 * groups (based on, e.g., UI views or functionality). |
|
42 * |
|
43 * Control groups have ownership of CHuiControl instances in the toolkit. |
|
44 * |
|
45 * During the application startup the application programmer sets up |
|
46 * controls into control groups. Typically the initialization phase ends |
|
47 * up showing one or more control groups on a display: |
|
48 * |
|
49 * <code> |
|
50 * iHuiDisplay->Roster().ShowL(group); |
|
51 * </code> |
|
52 */ |
|
53 NONSHARABLE_CLASS(CHuiControlGroup) : public CBase, public MHuiSessionObject |
|
54 { |
|
55 public: |
|
56 |
|
57 /* Constructors and destructor. */ |
|
58 |
|
59 /** |
|
60 * Constructor. |
|
61 */ |
|
62 CHuiControlGroup(TInt aResourceId, CHuiEnv& aEnv); |
|
63 |
|
64 /** |
|
65 * Second-phase constructor. |
|
66 */ |
|
67 void ConstructL(); |
|
68 |
|
69 /** |
|
70 * Second-phase constructor that reads definitions using a resource |
|
71 * reader. |
|
72 * |
|
73 * @param aReader Resource reader initialized with the group definition. |
|
74 */ |
|
75 void ConstructFromResourceL(TResourceReader& aReader); |
|
76 |
|
77 /** |
|
78 * Destructor. |
|
79 */ |
|
80 virtual ~CHuiControlGroup(); |
|
81 |
|
82 |
|
83 /* Methods. */ |
|
84 |
|
85 /** |
|
86 * Determines the identifier of the control group (from a resource file). |
|
87 * |
|
88 * @return Resource identifier. |
|
89 */ |
|
90 IMPORT_C TInt ResourceId() const; |
|
91 |
|
92 /** |
|
93 * Adds a new control into the group. The group takes ownership of the |
|
94 * control. |
|
95 * |
|
96 * @param aControl Control to insert into the group. |
|
97 */ |
|
98 IMPORT_C void AppendL(CHuiControl* aControl); |
|
99 |
|
100 /** |
|
101 * Adds a new control into the group and pops it off of the cleanup |
|
102 * stack. |
|
103 * |
|
104 * @param aControl Control to insert into the group and pop. |
|
105 */ |
|
106 IMPORT_C void AppendAndPopL(CHuiControl* aControl); |
|
107 |
|
108 /** |
|
109 * Removes a control from the control group. |
|
110 * |
|
111 * @param aControl Control to remove from the group. The control's |
|
112 * ownership is transferred to the caller. Note that |
|
113 * controls should never be used unless they are |
|
114 * owned by a control group. |
|
115 * |
|
116 * @return KErrNone, if successful. KErrNotFound, if the control is not |
|
117 * in the group. |
|
118 */ |
|
119 IMPORT_C TInt Remove(CHuiControl* aControl); |
|
120 |
|
121 /** |
|
122 * Returns the number of controls within this group. |
|
123 * |
|
124 * @return Number of controls. |
|
125 */ |
|
126 IMPORT_C TInt Count() const; |
|
127 |
|
128 /** |
|
129 * Access a control within the group, by its index into the |
|
130 * internal list of controls. Will panic if an out-of-bounds |
|
131 * index is passed. |
|
132 * |
|
133 * @param aIndex Index of the control to return. |
|
134 * |
|
135 * @return Reference to the requested control. Always |
|
136 * returns a valid control. |
|
137 */ |
|
138 IMPORT_C CHuiControl& Control(TInt aIndex) const; |
|
139 |
|
140 /** |
|
141 * @return Pointer to the control, or <code>NULL</code> if the control |
|
142 * is not in the group. |
|
143 */ |
|
144 IMPORT_C CHuiControl* FindControl(TInt aId) const; |
|
145 |
|
146 /** |
|
147 * Enables or disables transformation of the control group. |
|
148 */ |
|
149 IMPORT_C void EnableTransformationL(TBool aIsTransformed = ETrue); |
|
150 |
|
151 /** |
|
152 * Determines if the control group has a transformation. |
|
153 */ |
|
154 IMPORT_C TBool IsTransformed() const; |
|
155 |
|
156 /** |
|
157 * Returns the transformation of the control group. |
|
158 * |
|
159 * @return Transformation steps. |
|
160 * |
|
161 * @panic THuiPanic::EVisualTransformNotEnabled |
|
162 */ |
|
163 IMPORT_C CHuiTransformation& Transformation(); |
|
164 |
|
165 /** |
|
166 * Determines whether the group accepts input events. |
|
167 */ |
|
168 IMPORT_C TBool AcceptInput() const; |
|
169 |
|
170 /** |
|
171 * Sets the input event acceptance of the group. |
|
172 * |
|
173 * @param aAcceptInput Accept input events. |
|
174 */ |
|
175 IMPORT_C void SetAcceptInput(TBool aAcceptInput); |
|
176 |
|
177 /** |
|
178 * Determines if the control group has been changed. The roster calls this |
|
179 * to determine if larger updates are necessary. |
|
180 */ |
|
181 TBool Changed() const; |
|
182 |
|
183 /** |
|
184 * Clears the change flags of the control group and its member controls. |
|
185 */ |
|
186 void ClearChanged(); |
|
187 |
|
188 |
|
189 // Implementation of MHuiSessionObject |
|
190 |
|
191 /** |
|
192 * Gets the object type. |
|
193 */ |
|
194 IMPORT_C TType Type() const; |
|
195 |
|
196 /** |
|
197 * Gets the session id for object. |
|
198 */ |
|
199 IMPORT_C TInt SessionId() const; |
|
200 |
|
201 /** |
|
202 * Sets the session id for object. |
|
203 */ |
|
204 IMPORT_C void SetSessionId(TInt aSessionId); |
|
205 |
|
206 private: |
|
207 |
|
208 /* Private methods */ |
|
209 |
|
210 |
|
211 public: |
|
212 |
|
213 /** Events that are not handled by any controls in the control group |
|
214 are offered to these event handlers. */ |
|
215 RHuiObserverArray<MHuiEventHandler> iUnhandledEventObservers; |
|
216 |
|
217 |
|
218 private: |
|
219 |
|
220 /** Resource ID that was passed in the constructor. */ |
|
221 TInt iResourceId; |
|
222 |
|
223 /** Environment. */ |
|
224 CHuiEnv& iEnv; |
|
225 |
|
226 /** Accepts input events. */ |
|
227 TBool iAcceptInput; |
|
228 |
|
229 /** Controls owned by the group. */ |
|
230 RPointerArray<CHuiControl> iControls; |
|
231 |
|
232 /** Common transformation for all the root visuals of the |
|
233 control group. */ |
|
234 CHuiTransformation* iTransform; |
|
235 |
|
236 /** Session id */ |
|
237 TInt iSessionId; |
|
238 |
|
239 public: |
|
240 |
|
241 /** |
|
242 * Common opacity for all the controls of the group. |
|
243 * |
|
244 * @deprecated Do not use control and control group opacities. |
|
245 * Instead, set up common parent layouts and adjust their |
|
246 * opacities. Logic objects should not affect the visible |
|
247 * elements. |
|
248 */ |
|
249 THuiTimedValue iOpacity; |
|
250 |
|
251 }; |
|
252 |
|
253 #endif // __HUICONTROLGROUP_H__ |