00001
00002
00003
00004
00005 #include <barsread.h>
00006 #include <coemain.h>
00007 #include "DBMSEditorView.h"
00008 #include <DBMS.rsg>
00009 #include <eikfrlbd.h>
00010 #include <eiklabel.h>
00011 #include <AknUtils.h>
00012
00013
00014 _LIT(KLabelTextAuthor,"Author:");
00015 _LIT(KLabelTextTitle,"Title:");
00016 _LIT(KLabelTextDescription, "Description:");
00017 _LIT(KEmptyText, "None");
00018
00019
00020
00021
00022
00023
00024
00025 CDBMSEditorView* CDBMSEditorView::NewL(const TRect& aRect)
00026 {
00027 CDBMSEditorView* self = new (ELeave) CDBMSEditorView;
00028 CleanupStack::PushL(self);
00029 self->ConstructL(aRect);
00030 CleanupStack::Pop(self);
00031 return self;
00032 }
00033
00034
00035
00036
00037
00038
00039
00040
00041 void CDBMSEditorView::ConstructL(const TRect& aRect)
00042 {
00043
00044 CreateWindowL();
00045
00046 iItemList = new (ELeave) CAknSettingItemList;
00047 iItemList->SetMopParent(this);
00048 iItemList->ConstructFromResourceL(R_ENTRY_SETTINGS_LIST);
00049
00050 LoadListL();
00051
00052 iItemList->MakeVisible(ETrue);
00053 iItemList->SetRect(aRect);
00054 iItemList->ActivateL();
00055 iItemList->ListBox()->UpdateScrollBarsL();
00056 iItemList->DrawNow();
00057
00058
00059 SetRect(aRect);
00060
00061
00062 ActivateL();
00063
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 void CDBMSEditorView::LoadListL()
00073 {
00074 TBool isNumberedStyle = iItemList->IsNumberedStyle();
00075 CArrayPtr<CGulIcon>* icons = iItemList->ListBox()->ItemDrawer()->FormattedCellData()->IconArray();
00076 TBuf<50> aText;
00077
00078
00079
00080 iAuthor = new (ELeave) CAknTextSettingItem(1, aText);
00081 iAuthor->SetEmptyItemTextL( KEmptyText );
00082
00083 iAuthor->ConstructL(isNumberedStyle, 1, KLabelTextAuthor, icons, R_TEXT_SETTING_PAGE, -1);
00084 iItemList->SettingItemArray()->AppendL(iAuthor);
00085
00086
00087 iTitle = new (ELeave) CAknTextSettingItem(2, aText);
00088 iTitle->SetEmptyItemTextL( KEmptyText );
00089
00090 iTitle->ConstructL(isNumberedStyle, 1, KLabelTextTitle, icons, R_TEXT_SETTING_PAGE, -1);
00091 iItemList->SettingItemArray()->AppendL(iTitle);
00092
00093
00094 iDescription = new (ELeave) CAknTextSettingItem(3, aText);
00095 iDescription->SetEmptyItemTextL( KEmptyText );
00096
00097 iDescription->ConstructL(isNumberedStyle, 1, KLabelTextDescription,
00098 icons, R_TEXT_SETTING_PAGE, -1);
00099 iItemList->SettingItemArray()->AppendL(iDescription);
00100
00101
00102 iItemList->SettingItemArray()->RecalculateVisibleIndicesL();
00103
00104 iItemList->HandleChangeInItemArrayOrVisibilityL();
00105
00106 }
00107
00108
00109
00110
00111
00112
00113 CDBMSEditorView::CDBMSEditorView()
00114 {
00115
00116 }
00117
00118
00119
00120
00121
00122
00123
00124
00125 CDBMSEditorView::~CDBMSEditorView()
00126 {
00127 delete iItemList;
00128 }
00129
00130
00131
00132
00133
00134
00135
00136 TInt CDBMSEditorView::CountComponentControls() const
00137 {
00138 TInt count = 0;
00139 if (iItemList)
00140 count++;
00141 return count;
00142
00143 }
00144
00145
00146
00147
00148
00149
00150
00151 CCoeControl* CDBMSEditorView::ComponentControl(TInt ) const
00152 {
00153 return iItemList;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 TKeyResponse CDBMSEditorView::OfferKeyEventL(const TKeyEvent& aKeyEvent,
00166 TEventCode aType)
00167 {
00168 if(aType != EEventKey)
00169 {
00170 return EKeyWasNotConsumed;
00171 }
00172 else if(iItemList)
00173 {
00174 return iItemList->OfferKeyEventL( aKeyEvent, aType );
00175 }
00176 else
00177 {
00178 return EKeyWasNotConsumed;
00179 }
00180 }
00181
00182
00183
00184
00185
00186
00187
00188 void CDBMSEditorView::GetAuthorL(TDes& aResult) const
00189 {
00190 aResult.Copy(iAuthor->SettingTextL());
00191 }
00192
00193
00194
00195
00196
00197
00198
00199
00200 void CDBMSEditorView::GetTitleL(TDes& aResult) const
00201 {
00202 aResult.Copy(iTitle->SettingTextL());
00203 }
00204
00205
00206
00207
00208
00209
00210
00211
00212 void CDBMSEditorView::GetDescriptionL(TDes& aResult) const
00213 {
00214 aResult.Copy(iDescription->SettingTextL());
00215 }
00216
00217
00218
00219
00220
00221
00222
00223
00224 void CDBMSEditorView::Draw(const TRect& ) const
00225 {
00226
00227 CWindowGc& gc = SystemGc();
00228
00229
00230 TRect rect = Rect();
00231
00232
00233 gc.Clear(rect);
00234 }
00235
00236
00237
00238
00239
00240
00241
00242 void CDBMSEditorView::HandleResourceChange(TInt aType)
00243 {
00244
00245 CCoeControl::HandleResourceChange(aType);
00246
00247
00248
00249
00250
00251 if ( aType==0x101F8121 )
00252 {
00253 TRect rect = Rect();
00254 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00255 SetRect(rect);
00256 iItemList->SetRect(rect);
00257 TRAP_IGNORE (iItemList->ListBox()->UpdateScrollBarsL();)
00258 iItemList->DrawNow();
00259 }
00260 }
00261