|
1 /* |
|
2 * Copyright (c) 2004 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: Checkbox Setting page |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CWVSettingsUICheckboxSettingPage.h" |
|
20 #include <cwvsettingsuing.rsg> |
|
21 |
|
22 // ============================ MEMBER FUNCTIONS =============================== |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CWVSettingsUICheckboxSettingPage::NewL |
|
26 // Two-phased constructor. |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 CWVSettingsUICheckboxSettingPage* CWVSettingsUICheckboxSettingPage::NewL( |
|
30 TInt aResourceId, |
|
31 CSelectionItemList* aSelectionItemList ) |
|
32 { |
|
33 CWVSettingsUICheckboxSettingPage* self = new( ELeave ) |
|
34 CWVSettingsUICheckboxSettingPage( aResourceId, aSelectionItemList ); |
|
35 CleanupStack::PushL( self ); |
|
36 self->ConstructL(); |
|
37 self->SetSettingPageObserver( self ); |
|
38 self->SetCbaL(); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CWVSettingsUICheckboxSettingPage::HandleSettingPageEventL() |
|
45 // |
|
46 // (other items were commented in a header). |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CWVSettingsUICheckboxSettingPage::HandleSettingPageEventL( CAknSettingPage* /*aSettingPage*/, |
|
50 TAknSettingPageEvent aEventType ) |
|
51 { |
|
52 if ( aEventType == EEventSettingChanged ) |
|
53 { |
|
54 SetCbaL(); |
|
55 } |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CWVSettingsUICheckboxSettingPage::OfferKeyEventL() |
|
60 // |
|
61 // (other items were commented in a header). |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 TKeyResponse CWVSettingsUICheckboxSettingPage::OfferKeyEventL( |
|
65 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
66 { |
|
67 // Store current selection |
|
68 TInt oldInd = ListBoxControl()->CurrentItemIndex(); |
|
69 // Offer event to base class |
|
70 TKeyResponse retVal = CAknCheckBoxSettingPage::OfferKeyEventL( aKeyEvent, |
|
71 aType ); |
|
72 // Get new index |
|
73 TInt curInd = ListBoxControl()->CurrentItemIndex(); |
|
74 if ( curInd != oldInd ) |
|
75 { |
|
76 // CBA update needed |
|
77 SetCbaL(); |
|
78 } |
|
79 |
|
80 return retVal; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CWVSettingsUICheckboxSettingPage::HandlePointerEventL() |
|
85 // |
|
86 // (other items were commented in a header). |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CWVSettingsUICheckboxSettingPage::HandlePointerEventL( |
|
90 const TPointerEvent& aPointerEvent ) |
|
91 { |
|
92 // Deliver event to base class |
|
93 CAknCheckBoxSettingPage::HandlePointerEventL( aPointerEvent ); |
|
94 // CBA update may be needed |
|
95 SetCbaL(); |
|
96 } |
|
97 |
|
98 // C++ default constructor can NOT contain any code, that |
|
99 // might leave. |
|
100 // |
|
101 CWVSettingsUICheckboxSettingPage::CWVSettingsUICheckboxSettingPage( TInt aResourceId, |
|
102 CSelectionItemList* aSelectionItemList ) |
|
103 : CAknCheckBoxSettingPage( aResourceId, aSelectionItemList ), |
|
104 iSelectionItemList( aSelectionItemList ) |
|
105 { |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CWVSettingsUICheckboxSettingPage::SetCbaL() |
|
110 // |
|
111 // (other items were commented in a header). |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CWVSettingsUICheckboxSettingPage::SetCbaL() |
|
115 { |
|
116 TInt count = iSelectionItemList->Count(); |
|
117 TBool anySelected( EFalse ); |
|
118 // check if any item is selected |
|
119 for ( TInt index( 0 ); index < count; index++ ) |
|
120 { |
|
121 if ( iSelectionItemList->At( index )->SelectionStatus() ) |
|
122 { |
|
123 // atleast one item selected |
|
124 anySelected = ETrue; |
|
125 break; |
|
126 } |
|
127 } |
|
128 |
|
129 // change the CBA |
|
130 TInt resId = R_AVKON_SOFTKEYS_OK_CANCEL; |
|
131 if ( !anySelected ) |
|
132 { |
|
133 // if no items are selected we must hide the "ok"-key |
|
134 resId = R_WVSETTINGSVIEW_SOFTKEYS_EMPTY_CANCEL__MARK; |
|
135 } |
|
136 else |
|
137 { |
|
138 TInt curSel = ListBoxControl()->CurrentItemIndex(); |
|
139 TBool curSelected = iSelectionItemList->At( curSel )->SelectionStatus(); |
|
140 if ( curSelected ) |
|
141 { |
|
142 // OK/Cancel/Unmark |
|
143 resId = R_WVSETTINGSVIEW_SOFTKEYS_OK_CANCEL__UNMARK; |
|
144 } |
|
145 else |
|
146 { |
|
147 // OK/Cancel/Mark |
|
148 resId = R_WVSETTINGSVIEW_SOFTKEYS_OK_CANCEL__MARK; |
|
149 } |
|
150 } |
|
151 |
|
152 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
153 cba->SetCommandSetL( resId ); |
|
154 cba->DrawNow(); |
|
155 DrawNow(); |
|
156 } |
|
157 |
|
158 // Destructor |
|
159 CWVSettingsUICheckboxSettingPage::~CWVSettingsUICheckboxSettingPage() |
|
160 { |
|
161 } |
|
162 |
|
163 // End of File |