1 /* Copyright (c) 2005 Nokia. All rights reserved. */
3 /* The PerlUi class is licensed under the same terms as Perl itself. */
9 # include <aknnotewrappers.h>
10 # include <AknCommonDialogs.h>
11 # ifndef __SERIES60_1X__
12 # include <CAknFileSelectionDialog.h>
14 #endif /* #ifdef __SERIES60__ */
18 # include <cknflash.h>
19 # include <ckndgopn.h>
20 # include <ckndgfob.h>
21 # include <eiklabel.h>
23 #endif /* #ifdef __SERIES80__ */
27 # include <eikedwin.h>
28 # include <eiklabel.h>
29 #endif /* #ifdef __UIQ__ */
47 #endif /* #ifdef __SERIES80__ */
56 #define symbian_get_vars() Dll::Tls() // Not visible from perlXYZ.lib?
58 _LIT(KDefaultScript, "default.pl");
60 EXPORT_C void CPerlUiAppUi::ConstructL()
63 iAppView = CPerlUiAppView::NewL(ClientRect());
64 AddToStackL(iAppView);
65 CEikonEnv::Static()->DisableExitChecks(ETrue); // Symbian FAQ-0577.
68 EXPORT_C TBool CPerlUi::OkCancelDialogL(TDesC& aMessage)
72 new (ELeave) CAknNoteDialog(CAknNoteDialog::EConfirmationTone);
73 dlg->PrepareLC(R_PERLUI_OK_CANCEL_DIALOG);
74 dlg->SetTextL(aMessage);
75 return dlg->RunDlgLD() == EAknSoftkeyOk;
76 #endif /* #ifdef __SERIES60__ */
78 return CCknConfirmationDialog::RunDlgWithDefaultIconLD(aMessage, R_EIK_BUTTONS_CANCEL_OK);
79 #endif /* #ifdef __SERIES80__ */
81 CEikDialog* dlg = new (ELeave) CEikDialog();
82 return dlg->ExecuteLD(R_PERLUI_OK_CANCEL_DIALOG) == EEikBidOk;
83 #endif /* #ifdef __UIQ__ */
86 EXPORT_C TBool CPerlUi::YesNoDialogL(TDesC& aMessage)
90 new (ELeave) CAknNoteDialog(CAknNoteDialog::EConfirmationTone);
91 dlg->PrepareLC(R_PERLUI_YES_NO_DIALOG);
92 dlg->SetTextL(aMessage);
93 return dlg->RunDlgLD() == EAknSoftkeyOk;
94 #endif /* #ifdef __SERIES60__ */
96 return CCknConfirmationDialog::RunDlgWithDefaultIconLD(aMessage, R_EIK_BUTTONS_NO_YES);
97 #endif /* #ifdef __SERIES80__ */
99 CEikDialog* dlg = new (ELeave) CEikDialog();
100 return dlg->ExecuteLD(R_PERLUI_YES_NO_DIALOG) == EEikBidOk;
101 #endif /* #ifdef __UIQ__ */
104 EXPORT_C void CPerlUi::InformationNoteL(TDesC& aMessage)
107 CAknInformationNote* note = new (ELeave) CAknInformationNote;
108 note->ExecuteLD(aMessage);
109 #endif /* #ifdef __SERIES60__ */
110 #if defined(__SERIES80__) || defined(__UIQ__)
111 CEikonEnv::Static()->InfoMsg(aMessage);
112 #endif /* #if defined(__SERIES80__) || defined(__UIQ__) */
115 EXPORT_C TInt CPerlUi::WarningNoteL(TDesC& aMessage)
118 CAknWarningNote* note = new (ELeave) CAknWarningNote;
119 return note->ExecuteLD(aMessage);
120 #endif /* #ifdef __SERIES60__ */
121 #if defined(__SERIES80__) || defined(__UIQ__)
122 CEikonEnv::Static()->AlertWin(aMessage);
124 #endif /* #if defined(__SERIES80__) || defined(__UIQ__) */
127 #if defined(__SERIES80__) || defined(__UIQ__)
129 CPerlUiTextQueryDialog::CPerlUiTextQueryDialog(HBufC*& aBuffer) :
134 TBool CPerlUiTextQueryDialog::OkToExitL(TInt /* aKeycode */)
136 iData = static_cast<CEikEdwin*>(Control(EPerlUiTextQueryInputField))->GetTextInHBufL();
140 void CPerlUiTextQueryDialog::PreLayoutDynInitL()
143 CEikLabel* promptLabel = ControlCaption(EPerlUiTextQueryInputField);
144 promptLabel->SetTextL(iPrompt);
147 /* TODO: OfferKeyEventL() so that newline can be seen as 'OK'.
148 * Or a hotkey for the button? */
150 #endif /* #if defined(__SERIES80__) || defined(__UIQ__) */
152 EXPORT_C TBool CPerlUi::TextQueryDialogL(const TDesC& aTitle, const TDesC& aPrompt, TDes& aData, const TInt aMaxLength)
155 CAknTextQueryDialog* dlg =
156 new (ELeave) CAknTextQueryDialog(aData);
157 dlg->SetPromptL(aPrompt);
158 dlg->SetMaxLength(aMaxLength);
159 return dlg->ExecuteLD(R_PERLUI_TEXT_QUERY_DIALOG);
160 #endif /* #ifdef __SERIES60__ */
161 #if defined(__SERIES80__) || defined(__UIQ__)
163 CPerlUiTextQueryDialog* dlg =
164 new (ELeave) CPerlUiTextQueryDialog(data);
165 dlg->iTitle.Set(aTitle);
166 dlg->iPrompt.Set(aPrompt);
167 dlg->iMaxLength = aMaxLength;
168 if (dlg->ExecuteLD(R_PERLUI_ONELINER_DIALOG)) {
173 #endif /* #if defined(__SERIES80__) || defined(__UIQ__) */
176 EXPORT_C TBool CPerlUi::FileQueryDialogL(TDes& aFilename)
179 return AknCommonDialogs::RunSelectDlgLD(aFilename,
180 R_PERLUI_FILE_SELECTION_DIALOG);
181 #endif /* #ifdef __SERIES60__ */
183 if (CCknOpenFileDialog::RunDlgLD(aFilename,
184 CCknFileListDialogBase::EShowAllDrives
185 |CCknFileListDialogBase::EShowSystemFilesAndFolders
186 |CCknFileListDialogBase::EShowBothFilesAndFolders
188 TEntry aEntry; // Be paranoid and check that the file is there.
191 if (aFs.Entry(aFilename, aEntry) == KErrNone)
194 CEikonEnv::Static()->InfoMsg(_L("File not found"));
197 #endif /* #ifdef __SERIES80__ */
199 return EFalse; // No filesystem access in UIQ 2.x!
200 #endif /* #ifdef __UIQ__ */
205 EXPORT_C void CPerlUiAppUi::HandleCommandL(TInt aCommand)
210 case EAknSoftkeyExit:
214 DoHandleCommandL(aCommand);
219 #endif /* #ifdef __SERIES60__ */
221 #if defined(__SERIES80__) || defined(__UIQ__)
223 EXPORT_C void CPerlUiAppView::HandleCommandL(TInt aCommand, CPerlUiAppUi* aAppUi) {
224 aAppUi->DoHandleCommandL(aCommand);
227 EXPORT_C void CPerlUiAppUi::HandleCommandL(TInt aCommand) {
234 iAppView->HandleCommandL(aCommand, this);
239 #endif /* #if defined(__SERIES80__) || defined(__UIQ__) */
241 CPerlUiAppView* CPerlUiAppView::NewL(const TRect& aRect)
243 CPerlUiAppView* self = CPerlUiAppView::NewLC(aRect);
244 CleanupStack::Pop(self);
248 CPerlUiAppView* CPerlUiAppView::NewLC(const TRect& aRect)
250 CPerlUiAppView* self = new (ELeave) CPerlUiAppView;
251 CleanupStack::PushL(self);
252 self->ConstructL(aRect);
256 void CPerlUiAppView::ConstructL(const TRect& aRect)
263 CPerlUiAppView::~CPerlUiAppView()
267 void CPerlUiAppView::Draw(const TRect& /*aRect*/) const
269 CWindowGc& gc = SystemGc();