|
1 /* |
|
2 * Copyright (c) 2008-2009 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: general ui utilities |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <StringLoader.h> |
|
22 #include <glxuiutilities.rsg> |
|
23 #include <bautils.h> |
|
24 #include "glxgeneraluiutilities.h" |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // GlxGeneralUiUtilities::ShowErrorNoteL |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 EXPORT_C void GlxGeneralUiUtilities::ShowErrorNoteL(TInt aError) |
|
31 { |
|
32 // TextResolver instance for error resolving. |
|
33 CTextResolver* textresolver = CTextResolver::NewLC(); |
|
34 // Resolve the error text |
|
35 const TDesC& text = |
|
36 textresolver->ResolveErrorString( aError ); |
|
37 ShowErrorNoteL(text, ETrue); |
|
38 CleanupStack::PopAndDestroy( textresolver ); |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // GlxGeneralUiUtilities::ConfirmQueryL |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C TBool GlxGeneralUiUtilities::ConfirmQueryL( TInt aQueryResourceId, |
|
46 const TDesC& aTitleText ) |
|
47 { |
|
48 CAknQueryDialog* query = CAknQueryDialog::NewL(); |
|
49 TInt ret = query->ExecuteLD( aQueryResourceId, aTitleText ); |
|
50 |
|
51 if ( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) ) |
|
52 { |
|
53 return ETrue; |
|
54 } |
|
55 |
|
56 return EFalse; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // GlxGeneralUiUtilities::ConfirmQueryL |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 EXPORT_C TBool GlxGeneralUiUtilities::ConfirmQueryL( const TDesC& aTitleText ) |
|
64 { |
|
65 return ConfirmQueryL(R_GLX_QUERY_OK_CANCEL, aTitleText); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // GlxGeneralUiUtilities::ShowErrorNoteL |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 EXPORT_C void GlxGeneralUiUtilities::ShowErrorNoteL( const TDesC& aInfoText, |
|
73 TBool aWaitingDialog ) |
|
74 { |
|
75 CAknErrorNote* infoNote = |
|
76 new( ELeave ) CAknErrorNote( aWaitingDialog ); |
|
77 infoNote->ExecuteLD( aInfoText ); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // GlxGeneralUiUtilities::ShowInfoNoteL |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 EXPORT_C void GlxGeneralUiUtilities::ShowInfoNoteL( const TDesC& aInfoText, |
|
85 TBool aWaitingDialog ) |
|
86 { |
|
87 CAknInformationNote* infoNote = |
|
88 new( ELeave ) CAknInformationNote( aWaitingDialog ); |
|
89 infoNote->ExecuteLD( aInfoText ); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // GlxGeneralUiUtilities::ShowConfirmationNoteL |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 EXPORT_C void GlxGeneralUiUtilities::ShowConfirmationNoteL( const TDesC& aInfoText, |
|
97 TBool aWaitingDialog ) |
|
98 { |
|
99 CAknConfirmationNote* confNote = |
|
100 new( ELeave ) CAknConfirmationNote( aWaitingDialog ); |
|
101 confNote->ExecuteLD( aInfoText ); |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // GlxGeneralUiUtilities::FormatString |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C void GlxGeneralUiUtilities::FormatString( TDes& aDestination, |
|
110 const TDesC& aSource, |
|
111 TInt aPosition, |
|
112 TInt aNumber, |
|
113 TBool aNumberConversion ) |
|
114 { |
|
115 StringLoader::Format( aDestination, aSource, aPosition, aNumber ); |
|
116 |
|
117 if( aNumberConversion ) |
|
118 { |
|
119 AknTextUtils::LanguageSpecificNumberConversion( aDestination ); |
|
120 } |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // GlxGeneralUiUtilities::IsLandscape() |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C TBool GlxGeneralUiUtilities::IsLandscape() |
|
128 { |
|
129 // This class does not have access to a CEikonEnv and hence |
|
130 // pls ignore the code scanner warning - Using CEikonEnv::Static |
|
131 CAknAppUiBase::TAppUiOrientation orientation = static_cast<CAknAppUi*>((CEikonEnv::Static()->EikAppUi()))->Orientation(); |
|
132 |
|
133 if (orientation == CAknAppUiBase::EAppUiOrientationLandscape) |
|
134 { |
|
135 return true; |
|
136 } |
|
137 |
|
138 else if (orientation == CAknAppUiBase::EAppUiOrientationUnspecified ) |
|
139 { |
|
140 AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); |
|
141 if ( (cbaLocation == AknLayoutUtils::EAknCbaLocationRight) || |
|
142 (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft) ) |
|
143 { |
|
144 //landscape |
|
145 return true; |
|
146 } |
|
147 else |
|
148 { |
|
149 // Portrait |
|
150 return false; |
|
151 } |
|
152 } |
|
153 |
|
154 return false; |
|
155 } |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // GlxGeneralUiUtilities::LayoutIsMirrored |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C TBool GlxGeneralUiUtilities::LayoutIsMirrored() |
|
163 { |
|
164 // remove comment from next line to force arabic/hebrew layout for testing |
|
165 //#define FORCE_ARABIC_HEBREW_LAYOUT |
|
166 #ifdef FORCE_ARABIC_HEBREW_LAYOUT |
|
167 return ETrue; |
|
168 #else |
|
169 return AknLayoutUtils::LayoutMirrored(); |
|
170 #endif |
|
171 } |