1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <aknappui.h> |
|
19 #include <aknQueryControl.h> |
|
20 #include <AknQueryDialog.h> |
|
21 #include <aknsoundsystem.h> |
|
22 #include <devencui.rsg> |
|
23 #include <eikseced.h> |
|
24 |
|
25 #include "DevEncLog.h" |
|
26 #include "DevEnc.hrh" |
|
27 #include "DevEncUiSecretMinMaxCodeQuery.h" |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 // |
|
31 // ---------------------------------------------------------- |
|
32 // CCodeQueryDialog::CCodeQueryDialog() |
|
33 // C++ constructor |
|
34 // ---------------------------------------------------------- |
|
35 // |
|
36 CDevEncUiSecretMinMaxCodeQuery::CDevEncUiSecretMinMaxCodeQuery( |
|
37 TDes& aDataText, |
|
38 TInt aMinLength, |
|
39 TInt aMaxLength ) |
|
40 : CAknTextQueryDialog( aDataText, ENoTone ), |
|
41 iMinLength( aMinLength ), |
|
42 iMaxLength( aMaxLength ) |
|
43 { |
|
44 } |
|
45 // |
|
46 // ---------------------------------------------------------- |
|
47 // CDevEncUiSecretMinMaxCodeQuery::~CodeQueryDialog() |
|
48 // Destructor |
|
49 // ---------------------------------------------------------- |
|
50 // |
|
51 CDevEncUiSecretMinMaxCodeQuery::~CDevEncUiSecretMinMaxCodeQuery() |
|
52 { |
|
53 } |
|
54 // |
|
55 // ---------------------------------------------------------- |
|
56 // CDevEncUiSecretMinMaxCodeQuery::PreLayoutDynInitL() |
|
57 // Called by framework before dialog is shown |
|
58 // ---------------------------------------------------------- |
|
59 // |
|
60 void CDevEncUiSecretMinMaxCodeQuery::PreLayoutDynInitL() |
|
61 { |
|
62 CAknTextQueryDialog::PreLayoutDynInitL(); |
|
63 SetMaxLength( iMaxLength ); |
|
64 } |
|
65 // |
|
66 // --------------------------------------------------------- |
|
67 // CDevEncUiSecretMinMaxCodeQuery::OfferKeyEventL |
|
68 // called by framework when any key is pressed |
|
69 // --------------------------------------------------------- |
|
70 // |
|
71 TKeyResponse CDevEncUiSecretMinMaxCodeQuery::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
72 TEventCode aType ) |
|
73 { |
|
74 // '#' key |
|
75 if ( aKeyEvent.iScanCode == EStdKeyHash && aType == EEventKeyUp ) |
|
76 { |
|
77 TryExitL( EEikBidOk ); |
|
78 return EKeyWasConsumed; |
|
79 } |
|
80 |
|
81 // '*' key |
|
82 if ( aKeyEvent.iCode == '*' ) |
|
83 { |
|
84 return EKeyWasConsumed; |
|
85 } |
|
86 |
|
87 // end key |
|
88 if ( aKeyEvent.iCode == EKeyPhoneEnd ) |
|
89 { |
|
90 TryExitL( EAknSoftkeyCancel ); |
|
91 return EKeyWasConsumed; |
|
92 } |
|
93 |
|
94 return CAknTextQueryDialog::OfferKeyEventL( aKeyEvent,aType ); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // CDevEncUiSecretMinMaxCodeQuery::OkToExitL() |
|
99 // Called by framework when the softkey is pressed |
|
100 // --------------------------------------------------------- |
|
101 TBool CDevEncUiSecretMinMaxCodeQuery::OkToExitL( TInt aButtonId ) |
|
102 { |
|
103 TInt length = 0; |
|
104 TBool returnvalue( EFalse ); |
|
105 |
|
106 switch( aButtonId ) |
|
107 { |
|
108 case EAknSoftkeyOk: |
|
109 { |
|
110 CAknQueryControl* control = QueryControl(); |
|
111 if ( control ) |
|
112 { |
|
113 length = control->GetTextLength(); |
|
114 } |
|
115 if ( length < iMinLength ) |
|
116 { |
|
117 returnvalue = EFalse; |
|
118 } |
|
119 else |
|
120 { |
|
121 returnvalue = CAknTextQueryDialog::OkToExitL( aButtonId ); |
|
122 } |
|
123 } |
|
124 break; |
|
125 |
|
126 case EEikBidCancel: //Also includes EAknSoftkeyCancel as they have the same numerical value |
|
127 { |
|
128 returnvalue = ETrue; |
|
129 break; |
|
130 } |
|
131 default: |
|
132 break; |
|
133 } |
|
134 return returnvalue; |
|
135 } |
|
136 |
|
137 void CDevEncUiSecretMinMaxCodeQuery::UpdateLeftSoftKeyL() |
|
138 { |
|
139 CAknQueryControl* control = QueryControl(); |
|
140 if ( control ) |
|
141 { |
|
142 TBool makeVisible( control->GetTextLength() >= iMinLength ); |
|
143 MakeLeftSoftkeyVisible( makeVisible ); |
|
144 } |
|
145 } |
|
146 |
|
147 // End of file |
|