|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <coecntss.h> // class CCoeControlStaticSettings |
|
17 #include <coeaui.h> // class CCoeAppUi |
|
18 |
|
19 |
|
20 const TUid KUidCoeControlStaticSettings = {0x10204232}; |
|
21 |
|
22 /** Constructor |
|
23 */ |
|
24 CCoeControlStaticSettings::CCoeControlStaticSettings() : |
|
25 CCoeStatic(KUidCoeControlStaticSettings), |
|
26 iFocusedByDefault(ETrue), iOrdinalForAllViews(EFalse) |
|
27 { |
|
28 } |
|
29 |
|
30 /** |
|
31 Class Destructor */ |
|
32 CCoeControlStaticSettings::~CCoeControlStaticSettings() |
|
33 { |
|
34 iLogicalToPixelSizes.Reset(); |
|
35 iLogicalToPixelSizes.Close(); |
|
36 } |
|
37 |
|
38 /** Retrieve the one and only CCoeControlStaticSettings object, if it exists. |
|
39 */ |
|
40 CCoeControlStaticSettings* CCoeControlStaticSettings::Self(CCoeEnv* aCoeEnv) |
|
41 { |
|
42 return static_cast<CCoeControlStaticSettings*>(aCoeEnv ? |
|
43 aCoeEnv->FindStatic(KUidCoeControlStaticSettings) : |
|
44 CCoeEnv::Static(KUidCoeControlStaticSettings)); |
|
45 } |
|
46 |
|
47 /** |
|
48 Creates new instance of CCoeControlStaticSettings class |
|
49 |
|
50 @return pointer to the instance of CCoeControlStaticSettings class */ |
|
51 CCoeControlStaticSettings* CCoeControlStaticSettings::NewL() |
|
52 { |
|
53 CCoeControlStaticSettings* staticSettings = new (ELeave) CCoeControlStaticSettings(); |
|
54 CleanupStack::PushL(staticSettings); |
|
55 staticSettings->ConstructL(); |
|
56 CleanupStack::Pop(staticSettings); |
|
57 return staticSettings; |
|
58 } |
|
59 |
|
60 /** |
|
61 Second stage construction of CCoeControlStaticSettings class */ |
|
62 void CCoeControlStaticSettings::ConstructL() |
|
63 { |
|
64 iFocusedByDefault = ETrue; |
|
65 _LIT(KSystemTypeFaceName, "System One"); |
|
66 iTypeface.iName = KSystemTypeFaceName; |
|
67 |
|
68 User::LeaveIfError(iLogicalToPixelSizes.Append(8)); |
|
69 User::LeaveIfError(iLogicalToPixelSizes.Append(14)); |
|
70 User::LeaveIfError(iLogicalToPixelSizes.Append(18)); |
|
71 User::LeaveIfError(iLogicalToPixelSizes.Append(22)); |
|
72 User::LeaveIfError(iLogicalToPixelSizes.Append(26)); |
|
73 } |
|
74 |
|
75 /** |
|
76 Does nothing. |
|
77 @see CCoeControlStaticSettings::ParentByDefault() |
|
78 @deprecated |
|
79 */ |
|
80 EXPORT_C void CCoeControlStaticSettings::SetParentByDefaultL(TBool /*aParentByDefault*/) |
|
81 { |
|
82 } |
|
83 |
|
84 /** |
|
85 Returns value of ROM-patchable constant KCoeSetControlParentByDefault. |
|
86 Patch for emulator builds by adding "patchdata_cone_dll_KCoeSetControlParentByDefault X" |
|
87 to epoc.ini where X is either 0 (zero) for "off" or 1 (one) for "on". |
|
88 Only valid in Symbian OS 9.3 and 9.4. |
|
89 @deprecated |
|
90 */ |
|
91 EXPORT_C TBool CCoeControlStaticSettings::ParentByDefault() |
|
92 // class defined in coecntss.h to keep it away from prying eyes. |
|
93 { |
|
94 return ETrue; |
|
95 } |
|
96 |
|
97 /** Globally sets whether a window's ordinal is set for all views (ETrue) or only |
|
98 when the top view is not active (EFalse) |
|
99 |
|
100 This function should be called from within a CEikLibrary plugin. |
|
101 @param aOrdinalForAllViews ETrue if the window's ordinal will be set for all views, |
|
102 EFalse if not. |
|
103 */ |
|
104 EXPORT_C void CCoeControlStaticSettings::SetOrdinalForAllViewsL(TBool aOrdinalForAllViews) |
|
105 { |
|
106 CCoeControlStaticSettings* self = Self(); |
|
107 if (!self) |
|
108 self = CCoeControlStaticSettings::NewL(); |
|
109 |
|
110 self->iOrdinalForAllViews = aOrdinalForAllViews; |
|
111 } |
|
112 |
|
113 /** Retrieves the global setting that determines whether a window's ordinal is set for |
|
114 all views (ETrue) or only when the top view is not active (EFalse) |
|
115 |
|
116 If the CCoeControlStaticSettings object does not exist, then the default |
|
117 is to return EFalse. |
|
118 @return ETrue if a window's ordinal should be set for all views, EFalse if not. |
|
119 */ |
|
120 EXPORT_C TBool CCoeControlStaticSettings::OrdinalForAllViews() |
|
121 { |
|
122 CCoeControlStaticSettings* self = Self(); |
|
123 TBool retval = EFalse; |
|
124 if (self) |
|
125 retval = self->iOrdinalForAllViews; |
|
126 |
|
127 return retval; |
|
128 } |
|
129 |
|
130 |
|
131 /** Globally sets whether CCoeControls should take focus when they are created. |
|
132 |
|
133 This function should be called from within a CEikLibrary plugin. |
|
134 @param aFocusedByDefault True if CCoeControls should take focus when created, false if not. |
|
135 */ |
|
136 EXPORT_C void CCoeControlStaticSettings::SetFocusedByDefaultL(TBool aFocusedByDefault) |
|
137 { |
|
138 CCoeControlStaticSettings* self = Self(); |
|
139 if (!self) |
|
140 self = CCoeControlStaticSettings::NewL(); |
|
141 |
|
142 self->iFocusedByDefault = aFocusedByDefault; |
|
143 } |
|
144 |
|
145 /** Retrieves the global setting that determines whether CCoeControls take |
|
146 focus when created. |
|
147 |
|
148 If the CCoeControlStaticSettings object does not exist, then the default |
|
149 is to return true, which gives unchanged behaviour from pre-v9.0 releases. |
|
150 @return True if CCoeControls take focus when created, false if not. |
|
151 */ |
|
152 EXPORT_C TBool CCoeControlStaticSettings::FocusedByDefault() |
|
153 { |
|
154 return FocusedByDefault(NULL); |
|
155 } |
|
156 |
|
157 /** Retrieves the global setting that determines whether CCoeControls take |
|
158 focus when created. |
|
159 |
|
160 If the CCoeControlStaticSettings object does not exist, then the default |
|
161 is to return true, which gives unchanged behaviour from pre-v9.0 releases. |
|
162 @return True if CCoeControls take focus when created, false if not. |
|
163 @param aCoeEnv The Control environment. |
|
164 */ |
|
165 EXPORT_C TBool CCoeControlStaticSettings::FocusedByDefault(CCoeEnv* aCoeEnv) |
|
166 // class defined in coecntss.h to keep it away from prying eyes. |
|
167 { |
|
168 CCoeControlStaticSettings* self=Self(aCoeEnv); |
|
169 TBool retval = ETrue; |
|
170 if (self) |
|
171 retval = self->iFocusedByDefault; |
|
172 |
|
173 return retval; |
|
174 } |
|
175 |
|
176 /** |
|
177 Returns the default system type face name. |
|
178 |
|
179 @return default system typeface name */ |
|
180 EXPORT_C const TDesC& CCoeControlStaticSettings::SystemTypeface() |
|
181 { |
|
182 CCoeControlStaticSettings* self = Self(); |
|
183 if (self) |
|
184 return self->iTypeface.iName; |
|
185 else |
|
186 { |
|
187 _LIT(KSystemTypeFaceName, "System One"); |
|
188 return KSystemTypeFaceName; |
|
189 } |
|
190 } |
|
191 |
|
192 /** |
|
193 Sets the default system type face name. |
|
194 |
|
195 @param aTypeface is the name to set default system typeface name to */ |
|
196 EXPORT_C void CCoeControlStaticSettings::SetSystemTypefaceL(const TDesC& aTypeface) |
|
197 { |
|
198 CCoeControlStaticSettings* self = Self(); |
|
199 if (!self) |
|
200 self = CCoeControlStaticSettings::NewL(); |
|
201 |
|
202 self->iTypeface.iName = aTypeface; |
|
203 } |
|
204 |
|
205 /** |
|
206 Populates the TInt array provided as a parameter with the font pixel sizes. |
|
207 |
|
208 @param aLogicalToPixelSizes TInt array to be poulated with font sizes */ |
|
209 EXPORT_C void CCoeControlStaticSettings::GetLogicalToPixelFontSizesL(RArray<TInt>& aLogicalToPixelSizes) |
|
210 { |
|
211 CCoeControlStaticSettings* self = Self(); |
|
212 aLogicalToPixelSizes.Reset(); |
|
213 |
|
214 if (self) |
|
215 { |
|
216 for (TInt i=0; i<self->iLogicalToPixelSizes.Count(); i++) |
|
217 User::LeaveIfError(aLogicalToPixelSizes.Append(self->iLogicalToPixelSizes[i])); |
|
218 } |
|
219 else |
|
220 { |
|
221 User::LeaveIfError(aLogicalToPixelSizes.Append(8)); |
|
222 User::LeaveIfError(aLogicalToPixelSizes.Append(14)); |
|
223 User::LeaveIfError(aLogicalToPixelSizes.Append(18)); |
|
224 User::LeaveIfError(aLogicalToPixelSizes.Append(22)); |
|
225 User::LeaveIfError(aLogicalToPixelSizes.Append(26)); |
|
226 } |
|
227 } |
|
228 |
|
229 /** |
|
230 Sets the default array of font pixel sizes. |
|
231 |
|
232 @param aLogicalToPixelSizes TInt array to use as default with font sizes */ |
|
233 EXPORT_C void CCoeControlStaticSettings::SetLogicalToPixelFontSizesL(const RArray<TInt>& aLogicalToPixelSizes) |
|
234 { |
|
235 CCoeControlStaticSettings* self = Self(); |
|
236 if (!self) |
|
237 self = CCoeControlStaticSettings::NewL(); |
|
238 |
|
239 self->iLogicalToPixelSizes.Reset(); |
|
240 |
|
241 for (TInt i=0; i<aLogicalToPixelSizes.Count(); i++) |
|
242 User::LeaveIfError(self->iLogicalToPixelSizes.Append(aLogicalToPixelSizes[i])); |
|
243 |
|
244 CCoeEnv* env = CCoeEnv::Static(); |
|
245 if (env) |
|
246 { |
|
247 env->RefetchPixelMappingL(); |
|
248 CCoeAppUi* appUi = env->AppUi(); |
|
249 if(appUi) |
|
250 appUi->RefetchPixelMappingL(); |
|
251 } |
|
252 } |
|
253 |