|
1 /* |
|
2 * Copyright (c) 2010 Kanrikogaku Kenkyusho, Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "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 * Kanrikogaku Kenkyusho, Ltd. - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * {Description of the file} |
|
16 * |
|
17 */ |
|
18 |
|
19 // System include files |
|
20 #include <aknquerydialog.h> |
|
21 #include <stringloader.h> |
|
22 #include <DirectPrintApp.rsg> |
|
23 |
|
24 #include "directprintfloatcapability.h" |
|
25 |
|
26 const TInt KMaxTRealCharNum( 30 ); |
|
27 const TInt KDecimals( 2 ); |
|
28 |
|
29 // Destructor |
|
30 CDirectPrintFloatCapability::~CDirectPrintFloatCapability() |
|
31 { |
|
32 } |
|
33 |
|
34 // Creates text string for the settings list box |
|
35 HBufC* CDirectPrintFloatCapability::ListBoxTextL() |
|
36 { |
|
37 const TInt KGranularity( 4 ); |
|
38 TRealFormat format( KMaxTRealCharNum, KDecimals ); |
|
39 TBuf<KMaxTRealCharNum> numStr; |
|
40 |
|
41 numStr.Zero(); |
|
42 numStr.AppendNum( iRealValue, format ); |
|
43 |
|
44 CDesCArrayFlat* strings = new ( ELeave ) CDesCArrayFlat( KGranularity ); |
|
45 CleanupStack::PushL( strings ); |
|
46 strings->AppendL( iTitle ); |
|
47 strings->AppendL( numStr ); |
|
48 |
|
49 HBufC* buf = StringLoader::LoadL( R_QTN_LBOX_FORMAT, *strings ); |
|
50 CleanupStack::PopAndDestroy(); // strings |
|
51 |
|
52 return buf; |
|
53 } |
|
54 |
|
55 // Clones itself |
|
56 CDirectPrintBaseCapability* CDirectPrintFloatCapability::CloneL() |
|
57 { |
|
58 CDirectPrintFloatCapability* clone = new ( ELeave ) CDirectPrintFloatCapability; |
|
59 |
|
60 clone->iDenominator = iDenominator; |
|
61 clone->iIndexOnList = iIndexOnList; |
|
62 clone->iMaxNumerator = iMaxNumerator; |
|
63 clone->iValue = iValue; |
|
64 clone->iTitle = iTitle; |
|
65 clone->iUid = iUid; |
|
66 clone->iRealValue = iRealValue; |
|
67 |
|
68 return clone; |
|
69 } |
|
70 |
|
71 // Sets the new values and checks the boundaries |
|
72 TInt CDirectPrintFloatCapability::SetValues( |
|
73 TInt aDenom, |
|
74 TInt aNumerator, |
|
75 TInt aMaxNumerator ) |
|
76 { |
|
77 TInt err( KErrNone ); |
|
78 |
|
79 if ( aNumerator > aMaxNumerator ) |
|
80 { |
|
81 err = KErrArgument; |
|
82 } |
|
83 else |
|
84 { |
|
85 iDenominator = aDenom; |
|
86 iValue = aNumerator; |
|
87 iMaxNumerator = aMaxNumerator; |
|
88 if( iDenominator != 0 ) |
|
89 { |
|
90 iRealValue = TReal( iValue )/TReal( iDenominator ); |
|
91 } |
|
92 } |
|
93 |
|
94 return err; |
|
95 } |
|
96 |
|
97 // Numerator |
|
98 TInt CDirectPrintFloatCapability::Numerator() const |
|
99 { |
|
100 return iValue; |
|
101 } |
|
102 |
|
103 // Denominator |
|
104 TInt CDirectPrintFloatCapability::Denominator() const |
|
105 { |
|
106 return iDenominator; |
|
107 } |
|
108 |
|
109 // Creates setting item for the settings list box |
|
110 CAknSettingItem* CDirectPrintFloatCapability::SettingItemLC(TInt aIndex) |
|
111 { |
|
112 CAknIntegerEdwinSettingItem* item = new (ELeave) CAknIntegerEdwinSettingItem(aIndex, iValue); // Not Float Edwin |
|
113 CleanupStack::PushL(item); |
|
114 item->ConstructL(EFalse, aIndex, iTitle, NULL, R_DIRECTPRINT_PROPERTYSETTING_INTEGER_SETTING_PAGE, -1); |
|
115 |
|
116 return item; |
|
117 } |
|
118 |
|
119 // End of File |