support for zipped ISOs
[picodrive.git] / platform / uiq2 / launcher / Dialogs.cpp
1 /*******************************************************************\r
2  *\r
3  *      File:           Dialogs.cpp\r
4  *\r
5  *      Author:         Peter van Sebille (peter@yipton.net)\r
6  *\r
7  *  Modified/adapted for picodriveN by notaz, 2006\r
8  *\r
9  *  (c) Copyright 2006, notaz\r
10  *      (c) Copyright 2002, Peter van Sebille\r
11  *      All Rights Reserved\r
12  *\r
13  *******************************************************************/\r
14 \r
15 #include "Dialogs.h"\r
16 #include "Engine.h"\r
17 #include "picodriven.hrh"\r
18 #include "picodriven.rsg"\r
19 \r
20 #include "../version.h"\r
21 #include "CSimpleTextParser.h"\r
22 #include <txtrich.h>                            // CRichText\r
23 #include <eikrted.h>                            // CEikRichTextEditor\r
24 #include <qikvertoptionbuttonlist.h> // CEikHorOptionButtonList\r
25 #include <eikopbut.h>   // CEikOptionButton\r
26 #include <QuartzKeys.h> // EQuartzKeyTwoWayDown\r
27 \r
28 \r
29 /************************************************\r
30  *\r
31  * config Dialog\r
32  *\r
33  ************************************************/\r
34 \r
35 CPicoConfigDialog::CPicoConfigDialog(TPicoConfig &cfg, TPLauncherConfig &cfgl) : config(cfg), config_l(cfgl)\r
36 {\r
37 }\r
38 \r
39 void CPicoConfigDialog::PostLayoutDynInitL()\r
40 {\r
41         CEikHorOptionButtonList *buttons_rot   = (CEikHorOptionButtonList*) Control( ECtlOptRotation );\r
42         CEikHorOptionButtonList *buttons_disp  = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );\r
43         CEikCheckBox            *chkbox_altrend= (CEikCheckBox*)            Control( ECtlOptUseAltRend );\r
44         CEikCheckBox            *chkbox_acctmng= (CEikCheckBox*)            Control( ECtlOptUseAccTiming );\r
45         CEikCheckBox            *chkbox_sram   = (CEikCheckBox*)            Control( ECtlOptUseSRAM );\r
46         CEikCheckBox            *chkbox_fps    = (CEikCheckBox*)            Control( ECtlOptShowFPS );\r
47         CEikCheckBox            *chkbox_sound  = (CEikCheckBox*)            Control( ECtlOptEnableSound );\r
48         CEikCheckBox            *chkbox_z80    = (CEikCheckBox*)            Control( ECtlOptEmulateZ80 );\r
49         CEikCheckBox            *chkbox_ym2612 = (CEikCheckBox*)            Control( ECtlOptEmulateYM2612 );\r
50         CEikCheckBox            *chkbox_sn76496= (CEikCheckBox*)            Control( ECtlOptEmulateSN76496 );\r
51         CEikChoiceListBase      *combo_sndq    = (CEikChoiceListBase*)      Control( ECtlOptSndQuality );\r
52         CEikCheckBox            *chkbox_6bpad  = (CEikCheckBox*)            Control( ECtlOpt6ButtonPad );\r
53         CEikCheckBox            *chkbox_gzipst = (CEikCheckBox*)            Control( ECtlOptGzipStates );\r
54         CEikCheckBox            *chkbox_motvol = (CEikCheckBox*)            Control( ECtlOptMotDontUseVol );\r
55         CEikCheckBox            *chkbox_accsprt= (CEikCheckBox*)            Control( ECtlOptUseAccSprites );\r
56         CEikChoiceListBase      *combo_region  = (CEikChoiceListBase*)      Control( ECtlOptRegion );\r
57         CEikOptionButton        *opt_fit2      = (CEikOptionButton*)        buttons_disp->ComponentControl( TPicoConfig::PMFit2 );\r
58 \r
59         buttons_rot ->SetButtonById(ECtlOptRotation0 + config.iScreenRotation);\r
60         buttons_disp->SetButtonById(ECtlOptScreenModeCenter + config.iScreenMode);\r
61         chkbox_sram   ->SetState(config.iFlags & 1     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
62         chkbox_fps    ->SetState(config.iFlags & 2     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
63         chkbox_sound  ->SetState(config.iFlags & 4     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
64         chkbox_motvol ->SetState(config.iFlags & 0x40  ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
65         chkbox_gzipst ->SetState(config.iFlags & 0x80  ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
66         chkbox_z80    ->SetState(config.iPicoOpt & 4   ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
67         chkbox_ym2612 ->SetState(config.iPicoOpt & 1   ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
68         chkbox_sn76496->SetState(config.iPicoOpt & 2   ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
69         chkbox_altrend->SetState(config.iPicoOpt & 0x10? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
70         chkbox_6bpad  ->SetState(config.iPicoOpt & 0x20? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
71         chkbox_acctmng->SetState(config.iPicoOpt & 0x40? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
72         chkbox_accsprt->SetState(config.iPicoOpt & 0x80? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
73 \r
74         // hide "fit2" if we are not in 0 or 180 mode\r
75         if(config.iScreenRotation != TPicoConfig::PRot0 && config.iScreenRotation != TPicoConfig::PRot180) opt_fit2->MakeVisible(EFalse);\r
76         // dim some stuff for alternative renderer\r
77         if(config.iPicoOpt & 0x10) {\r
78                 buttons_disp->SetDimmed(ETrue);\r
79                 ((CEikOptionButton*)(buttons_rot->ComponentControl(TPicoConfig::PRot0)))->SetDimmed(ETrue);\r
80                 ((CEikOptionButton*)(buttons_rot->ComponentControl(TPicoConfig::PRot180)))->SetDimmed(ETrue);\r
81         }\r
82         // dim accurate sprites\r
83         if(config.iPicoOpt & 0x10) {\r
84                 chkbox_accsprt->SetState(CEikButtonBase::EClear);\r
85                 chkbox_accsprt->SetDimmed(ETrue);\r
86         }\r
87 \r
88         TInt sel = (config.iPicoOpt&8) ? 4 : 0;\r
89         sel+= (config.iFlags>>3)&3;\r
90         combo_sndq->SetCurrentItem(sel);\r
91         switch(config.PicoRegion) {\r
92                 case 1: sel = 4; break;\r
93                 case 2: sel = 3; break;\r
94                 case 4: sel = 2; break;\r
95                 case 8: sel = 1; break;\r
96                 default:sel = 0; // auto\r
97         }\r
98         combo_region->SetCurrentItem(sel);\r
99 }\r
100 \r
101 TBool CPicoConfigDialog::OkToExitL(TInt aButtonId)\r
102 {\r
103         if(aButtonId != EEikBidOk) return ETrue;\r
104 \r
105         CEikHorOptionButtonList *buttons_rot   = (CEikHorOptionButtonList*) Control( ECtlOptRotation );\r
106         CEikHorOptionButtonList *buttons_disp  = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );\r
107         CEikCheckBox            *chkbox_altrend= (CEikCheckBox*)            Control( ECtlOptUseAltRend );\r
108         CEikCheckBox            *chkbox_acctmng= (CEikCheckBox*)            Control( ECtlOptUseAccTiming );\r
109         CEikCheckBox            *chkbox_sram   = (CEikCheckBox*)            Control( ECtlOptUseSRAM );\r
110         CEikCheckBox            *chkbox_fps    = (CEikCheckBox*)            Control( ECtlOptShowFPS );\r
111         CEikCheckBox            *chkbox_sound  = (CEikCheckBox*)            Control( ECtlOptEnableSound );\r
112         CEikCheckBox            *chkbox_z80    = (CEikCheckBox*)            Control( ECtlOptEmulateZ80 );\r
113         CEikCheckBox            *chkbox_ym2612 = (CEikCheckBox*)            Control( ECtlOptEmulateYM2612 );\r
114         CEikCheckBox            *chkbox_sn76496= (CEikCheckBox*)            Control( ECtlOptEmulateSN76496 );\r
115         CEikChoiceListBase      *combo_sndq    = (CEikChoiceListBase*)      Control( ECtlOptSndQuality );\r
116         CEikCheckBox            *chkbox_6bpad  = (CEikCheckBox*)            Control( ECtlOpt6ButtonPad );\r
117         CEikCheckBox            *chkbox_gzipst = (CEikCheckBox*)            Control( ECtlOptGzipStates );\r
118         CEikCheckBox            *chkbox_motvol = (CEikCheckBox*)            Control( ECtlOptMotDontUseVol );\r
119         CEikCheckBox            *chkbox_accsprt= (CEikCheckBox*)            Control( ECtlOptUseAccSprites );\r
120         CEikChoiceListBase      *combo_region  = (CEikChoiceListBase*)      Control( ECtlOptRegion );\r
121 \r
122         config.iScreenRotation = (TPicoConfig::TPicoScreenRotation) (buttons_rot->LabeledButtonId() - ECtlOptRotation0);\r
123         config.iScreenMode = (TPicoConfig::TPicoScreenMode) (buttons_disp->LabeledButtonId() - ECtlOptScreenModeCenter);\r
124 \r
125         if(chkbox_sram   ->State() == CEikButtonBase::ESet) config.iFlags |= 1;     else config.iFlags   &= ~1;\r
126         if(chkbox_fps    ->State() == CEikButtonBase::ESet) config.iFlags |= 2;     else config.iFlags   &= ~2;\r
127         if(chkbox_sound  ->State() == CEikButtonBase::ESet) config.iFlags |= 4;     else config.iFlags   &= ~4;\r
128         if(chkbox_motvol ->State() == CEikButtonBase::ESet) config.iFlags |= 0x40;  else config.iFlags   &= ~0x40;\r
129         if(chkbox_gzipst ->State() == CEikButtonBase::ESet) config.iFlags |= 0x80;  else config.iFlags   &= ~0x80;\r
130         if(chkbox_z80    ->State() == CEikButtonBase::ESet) config.iPicoOpt |= 4;   else config.iPicoOpt &= ~4;\r
131         if(chkbox_ym2612 ->State() == CEikButtonBase::ESet) config.iPicoOpt |= 1;   else config.iPicoOpt &= ~1;\r
132         if(chkbox_sn76496->State() == CEikButtonBase::ESet) config.iPicoOpt |= 2;   else config.iPicoOpt &= ~2;\r
133         if(chkbox_altrend->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x10;else config.iPicoOpt &= ~0x10;\r
134         if(chkbox_6bpad  ->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x20;else config.iPicoOpt &= ~0x20;\r
135         if(chkbox_acctmng->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x40;else config.iPicoOpt &= ~0x40;\r
136         if(chkbox_accsprt->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x80;else config.iPicoOpt &= ~0x80;\r
137 \r
138         TInt sel = combo_sndq->CurrentItem();\r
139         if(sel > 3) { config.iPicoOpt |= 8; sel-=4; } else config.iPicoOpt &= ~8;\r
140         config.iFlags &= ~0x18;\r
141         config.iFlags |= (sel<<3)&0x18;\r
142 \r
143         switch(combo_region->CurrentItem()) {\r
144                 case 4: config.PicoRegion = 1; break;\r
145                 case 3: config.PicoRegion = 2; break;\r
146                 case 2: config.PicoRegion = 4; break;\r
147                 case 1: config.PicoRegion = 8; break;\r
148                 default:config.PicoRegion = 0; // auto\r
149         }\r
150 \r
151         return ETrue;\r
152 }\r
153 \r
154 // simple GUI stuff needs lots of code\r
155 void CPicoConfigDialog::HandleControlStateChangeL(TInt aControlId)\r
156 {\r
157         if(aControlId == ECtlOptEnableSound) {\r
158                 CEikCheckBox *chkbox_sound  = (CEikCheckBox*) Control( ECtlOptEnableSound );\r
159                 CEikCheckBox *chkbox_z80    = (CEikCheckBox*) Control( ECtlOptEmulateZ80 );\r
160                 CEikCheckBox *chkbox_ym2612 = (CEikCheckBox*) Control( ECtlOptEmulateYM2612 );\r
161                 CEikCheckBox *chkbox_sn76496= (CEikCheckBox*) Control( ECtlOptEmulateSN76496 );\r
162 \r
163                 if(chkbox_sound->State() == CEikButtonBase::ESet) {\r
164                         // check all sound chips too, but only if they all are not set\r
165                         if((chkbox_z80->State() | chkbox_ym2612->State() | chkbox_sn76496->State()) == CEikButtonBase::EClear) { // (==0)\r
166                                 chkbox_z80    ->SetState(CEikButtonBase::ESet);\r
167                                 chkbox_ym2612 ->SetState(CEikButtonBase::ESet);\r
168                                 chkbox_sn76496->SetState(CEikButtonBase::ESet);\r
169                                 chkbox_z80    ->DrawDeferred();\r
170                                 chkbox_ym2612 ->DrawDeferred();\r
171                                 chkbox_sn76496->DrawDeferred();\r
172                         }\r
173                 } else {\r
174                         // clear everything, but only if everything is set\r
175                         if((chkbox_z80->State() & chkbox_ym2612->State() & chkbox_sn76496->State()) == CEikButtonBase::ESet) { // (==1)\r
176                                 chkbox_z80    ->SetState(CEikButtonBase::EClear);\r
177                                 chkbox_ym2612 ->SetState(CEikButtonBase::EClear);\r
178                                 chkbox_sn76496->SetState(CEikButtonBase::EClear);\r
179                                 chkbox_z80    ->DrawDeferred();\r
180                                 chkbox_ym2612 ->DrawDeferred();\r
181                                 chkbox_sn76496->DrawDeferred();\r
182                         }\r
183                 }\r
184         } else if(aControlId == ECtlOptUseAltRend) {\r
185                 CEikCheckBox            *chkbox_altrend= (CEikCheckBox*)            Control( ECtlOptUseAltRend );\r
186                 CEikCheckBox            *chkbox_accsprt= (CEikCheckBox*)            Control( ECtlOptUseAccSprites );\r
187                 CEikHorOptionButtonList *buttons_rot   = (CEikHorOptionButtonList*) Control( ECtlOptRotation );\r
188                 CEikHorOptionButtonList *buttons_disp  = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );\r
189 \r
190                 TBool dimmed = chkbox_altrend->State() == CEikButtonBase::ESet;\r
191                 // show/hide more stuff for alternative renderer\r
192                 buttons_disp->SetDimmed(dimmed);\r
193                 chkbox_accsprt->SetDimmed(dimmed);\r
194                 ((CEikOptionButton*)(buttons_rot->ComponentControl(TPicoConfig::PRot0)))->SetDimmed(dimmed);\r
195                 ((CEikOptionButton*)(buttons_rot->ComponentControl(TPicoConfig::PRot180)))->SetDimmed(dimmed);\r
196                 if(dimmed && buttons_rot->LabeledButtonId() != ECtlOptRotation90 && buttons_rot->LabeledButtonId() != ECtlOptRotation270) {\r
197                         buttons_rot->SetButtonById(ECtlOptRotation90);\r
198                         aControlId = ECtlOptRotation; // cause rotation update\r
199                 }\r
200                 buttons_disp->SetButtonById(ECtlOptScreenModeCenter);\r
201                 chkbox_accsprt->DrawDeferred();\r
202                 buttons_disp->DrawDeferred();\r
203                 buttons_rot->DrawDeferred();\r
204         }\r
205         if(aControlId == ECtlOptRotation) {\r
206                 CEikHorOptionButtonList *buttons_rot   = (CEikHorOptionButtonList*) Control( ECtlOptRotation );\r
207                 CEikHorOptionButtonList *buttons_disp  = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );\r
208                 CEikOptionButton        *opt_fit2      = (CEikOptionButton*)        buttons_disp->ComponentControl( TPicoConfig::PMFit2 );\r
209 \r
210                 if(buttons_rot->LabeledButtonId() == ECtlOptRotation0 || buttons_rot->LabeledButtonId() == ECtlOptRotation180) {\r
211                         opt_fit2->MakeVisible(ETrue);\r
212                         opt_fit2->DrawDeferred();\r
213                 } else {\r
214                         if(opt_fit2->State() == CEikButtonBase::ESet) {\r
215                                 buttons_disp->SetButtonById(ECtlOptScreenModeFit);\r
216                                 buttons_disp->DrawDeferred();\r
217                         }\r
218                         opt_fit2->MakeVisible(EFalse);\r
219                 }\r
220         }\r
221 }\r
222 \r
223 \r
224 /*************************************************************\r
225 *\r
226 * Credits dialog\r
227 *\r
228 **************************************************************/\r
229 \r
230 void CCreditsDialog::PreLayoutDynInitL()\r
231 {\r
232         CDesCArrayFlat* desArray = CEikonEnv::Static()->ReadDesCArrayResourceL(iMessageResourceID);\r
233         CleanupStack::PushL(desArray);\r
234 \r
235         TInt iLength;\r
236         TInt count = desArray->Count();\r
237         for (TInt i=0 ;i < count; i++)\r
238         {\r
239                 iLength = static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->TextLength();\r
240                 static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->Text()->InsertL(iLength, desArray->operator[](i));\r
241                 iLength = static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->TextLength();\r
242                 static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->Text()->InsertL(iLength, CEditableText::ELineBreak);\r
243         }\r
244         CleanupStack::PopAndDestroy(desArray);\r
245 }\r
246 \r
247 void CCreditsDialog::PostLayoutDynInitL()\r
248 {\r
249         static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->CreateScrollBarFrameL();\r
250         static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto);\r
251 }\r
252 \r
253 TKeyResponse CCreditsDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)\r
254 {\r
255         if (aType == EEventKey)\r
256         {\r
257                 if (aKeyEvent.iCode == EQuartzKeyTwoWayDown)\r
258                 {\r
259                         static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->MoveDisplayL(TCursorPosition::EFLineDown);\r
260                         static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->UpdateScrollBarsL();\r
261                         return EKeyWasConsumed;\r
262                 }\r
263                 else if (aKeyEvent.iCode == EQuartzKeyTwoWayUp)\r
264                 {\r
265                         static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->MoveDisplayL(TCursorPosition::EFLineUp);\r
266                         static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->UpdateScrollBarsL();\r
267                         return EKeyWasConsumed;\r
268                 }\r
269         }\r
270         return CEikDialog::OfferKeyEventL(aKeyEvent, aType);\r
271 }\r
272 \r
273 \r
274 /*************************************************************\r
275 *\r
276 * Debug dialog\r
277 *\r
278 **************************************************************/\r
279 \r
280 CDebugDialog::CDebugDialog(char *t)\r
281 {\r
282         Mem::Copy(iText, t, 1024);\r
283         iText[1023] = 0;\r
284 }\r
285 \r
286 void CDebugDialog::PreLayoutDynInitL()\r
287 {\r
288         char *p = iText, *line = iText;\r
289         TBool end=0;\r
290         TBuf<128> tbuf;\r
291         CEikGlobalTextEditor *editor = static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit));\r
292 \r
293         while(!end) {\r
294                 while(*p && *p != '\r' && *p != '\n') p++;\r
295                 if(!*p) end=1;\r
296                 *p = 0;\r
297                 TPtrC8 ptr((TUint8*) line);\r
298                 tbuf.Copy(ptr);\r
299                 editor->Text()->InsertL(editor->TextLength(), tbuf);\r
300                 editor->Text()->InsertL(editor->TextLength(), CEditableText::ELineBreak);\r
301                 line = ++p;\r
302         }\r
303 }\r
304 \r
305 void CDebugDialog::PostLayoutDynInitL()\r
306 {\r
307         static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->CreateScrollBarFrameL();\r
308         static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto);\r
309 }\r
310 \r
311 TKeyResponse CDebugDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)\r
312 {\r
313         if (aType == EEventKey)\r
314         {\r
315                 if (aKeyEvent.iCode == EQuartzKeyTwoWayDown)\r
316                 {\r
317                         static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->MoveDisplayL(TCursorPosition::EFLineDown);\r
318                         static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->UpdateScrollBarsL();\r
319                         return EKeyWasConsumed;\r
320                 }\r
321                 else if (aKeyEvent.iCode == EQuartzKeyTwoWayUp)\r
322                 {\r
323                         static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->MoveDisplayL(TCursorPosition::EFLineUp);\r
324                         static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->UpdateScrollBarsL();\r
325                         return EKeyWasConsumed;\r
326                 }\r
327         }\r
328         return CEikDialog::OfferKeyEventL(aKeyEvent, aType);\r
329 }\r
330 \r
331 \r
332 /************************************************\r
333  *\r
334  * SimpleTextInfoDialog\r
335  *\r
336  ************************************************/\r
337 \r
338 \r
339 CSimpleTextInfoDialog::CSimpleTextInfoDialog(TInt aTextIdOne, TInt aRichTextCtlIdOne, TInt aTextIdTwo, TInt aRichTextCtlIdTwo, TBool aSimpleTextResIdOneIsArray, TBool aSimpleTextResIdTwoIsArray)\r
340         : iSimpleTextResIdOne(aTextIdOne),\r
341           iSimpleTextResIdTwo(aTextIdTwo),\r
342           iRichTextCtlIdOne(aRichTextCtlIdOne),\r
343           iRichTextCtlIdTwo(aRichTextCtlIdTwo),\r
344           iSimpleTextResIdOneIsArray(aSimpleTextResIdOneIsArray),\r
345           iSimpleTextResIdTwoIsArray(aSimpleTextResIdTwoIsArray),\r
346           iSetDialogBackground(ETrue)\r
347 {\r
348 }\r
349 \r
350 void CSimpleTextInfoDialog::PreLayoutDynInitL()\r
351 {\r
352         CEikRichTextEditor*             richTextEditor;\r
353         \r
354         if (iRichTextCtlIdOne != -1)\r
355         {\r
356                 richTextEditor=STATIC_CAST(CEikRichTextEditor*, Control(iRichTextCtlIdOne));\r
357                 PreLayoutDynInitRichTextL(*richTextEditor, iRichTextCtlIdOne, iSimpleTextResIdOne);\r
358         }\r
359 \r
360         if (iRichTextCtlIdTwo != -1)\r
361         {\r
362                 richTextEditor=STATIC_CAST(CEikRichTextEditor*, Control(iRichTextCtlIdTwo));\r
363                 richTextEditor->Border().SetType(ENone);\r
364                 PreLayoutDynInitRichTextL(*richTextEditor, iRichTextCtlIdTwo, iSimpleTextResIdTwo);\r
365         }\r
366 }\r
367 \r
368 \r
369 void CSimpleTextInfoDialog::PreLayoutDynInitRichTextL(CEikRichTextEditor& aRichTextEditor, TInt aRichTextCtlId, TInt aSimpleTextResId)\r
370 {\r
371         iEikonEnv->BusyMsgL(_L("Opening"));\r
372         aRichTextEditor.SetEdwinSizeObserver(this);\r
373         if (iSetDialogBackground)\r
374                 aRichTextEditor.SetBackgroundColorL(iEikonEnv->Color(EColorDialogBackground));\r
375         aRichTextEditor.SetSize(aRichTextEditor.Size()); // Set the size of the edwin\r
376 \r
377                 // no scrollbars for us\r
378         aRichTextEditor.CreateScrollBarFrameL(); // Create the scrollbars\r
379         aRichTextEditor.ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, iWantVertScrollbar ? CEikScrollBarFrame::EAuto: CEikScrollBarFrame::EOff);\r
380 \r
381         ShowTextL(*aRichTextEditor.RichText(), aRichTextCtlId, aSimpleTextResId);\r
382 \r
383         aRichTextEditor.UpdateAllFieldsL(); // Updates all the fields in the document\r
384 \r
385         aRichTextEditor.UpdateScrollBarsL();\r
386 }\r
387 \r
388 \r
389 void CSimpleTextInfoDialog::PostLayoutDynInitL()\r
390 {\r
391         Layout();\r
392         iEikonEnv->BusyMsgCancel();\r
393 }\r
394 \r
395 TBool CSimpleTextInfoDialog::HandleEdwinSizeEventL(CEikEdwin* aEdwin, TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize)\r
396 {\r
397         if ((aEventType == EEventSizeChanging))\r
398                 aEdwin->SetSize(aDesirableEdwinSize);\r
399         return EFalse;\r
400 }\r
401 \r
402 void CSimpleTextInfoDialog::ShowTextL(CRichText& aRichText, TInt /*aRichTextCtlId*/, TInt aResId)\r
403 {\r
404         if (aResId != -1)\r
405         {\r
406                 if ( ((aResId == iSimpleTextResIdOne) && (iSimpleTextResIdOneIsArray)) ||\r
407                      ((aResId == iSimpleTextResIdTwo) && (iSimpleTextResIdTwoIsArray))\r
408                    )\r
409                 {\r
410                         CDesCArrayFlat* desArray = CEikonEnv::Static()->ReadDesCArrayResourceL(aResId);\r
411                         CleanupStack::PushL(desArray);\r
412 \r
413                         CSimpleTextFormatParser* parser = CSimpleTextFormatParser::NewLC();\r
414 \r
415                         TInt    count = desArray->Count();\r
416                         for (TInt i=0 ;i<count ; i++)\r
417                                 parser->ParseL(desArray->operator[](i), aRichText);\r
418 \r
419                         CleanupStack::PopAndDestroy(parser);\r
420                         CleanupStack::PopAndDestroy(desArray);\r
421                 }\r
422                 else\r
423                 {\r
424                         HBufC*          text =  CEikonEnv::Static()->AllocReadResourceLC(aResId);\r
425                         ShowSimpleTextL(*text, aRichText);\r
426                         CleanupStack::PopAndDestroy(text);\r
427                 }\r
428         }\r
429 }\r
430 \r
431 void CSimpleTextInfoDialog::ShowSimpleTextL(const TDesC& aSimpleText, CRichText& aRichText)\r
432 {\r
433         CSimpleTextFormatParser* parser = CSimpleTextFormatParser::NewLC();\r
434         parser->ParseL(aSimpleText, aRichText);\r
435 \r
436         CleanupStack::PopAndDestroy(parser);\r
437 }\r
438 \r
439 \r
440 \r
441 /************************************************\r
442  *\r
443  * About Dialog\r
444  *\r
445  ************************************************/\r
446 \r
447 CAboutDialog::CAboutDialog() : CSimpleTextInfoDialog(-1, ECtlAboutVersion, R_SIMPLE_TEXT_ABOUT_LINKS, ECtlAboutLinks)\r
448 {\r
449 }\r
450 \r
451 void CAboutDialog::ShowTextL(CRichText& aRichText, TInt aRichTextCtlId, TInt aResId)\r
452 {\r
453         if (aRichTextCtlId == ECtlAboutLinks)\r
454                 CSimpleTextInfoDialog::ShowTextL(aRichText, aRichTextCtlId, aResId);\r
455         else\r
456         {\r
457                 TBuf<16>        versionText;\r
458                 TBuf<512>       text;\r
459 \r
460                 #if (KPicoBuildNumber != 0)\r
461                         versionText.Format(_L("%d.%d%d"), KPicoMajorVersionNumber, KPicoMinorVersionNumber, KPicoBuildNumber);\r
462                 #else\r
463                         versionText.Format(_L("%d.%d"), KPicoMajorVersionNumber, KPicoMinorVersionNumber);\r
464                 #endif\r
465 \r
466                 HBufC*          aboutFormat =   CEikonEnv::Static()->AllocReadResourceLC(R_SIMPLE_TEXT_ABOUT);\r
467                 text.Format(*aboutFormat, &versionText);\r
468 \r
469                 ShowSimpleTextL(text, aRichText);\r
470 \r
471                 CleanupStack::PopAndDestroy(aboutFormat);\r
472         }\r
473 }\r