|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================ 00003 * Name : BrCtlSampleAppContainer.cpp 00004 * Part of : BrCtlSampleApp 00005 * Interface : Browser Control API 00006 * Description : Implementation of the container control for Browser Control Sample application. 00007 * Version : 00008 * 00009 * Copyright (c) 2005-2006 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. 00013 * ============================================================================ 00014 */ 00015 00016 // INCLUDE FILES 00017 #include "BrCtlSampleAppContainer.h" 00018 #include "BrCtlSampleAppSpecialLoadObserver.h" 00019 #include "BrCtlSampleAppLayoutObserver.h" 00020 #include "BrCtlSampleAppSoftkeysObserver.h" 00021 #include "BrCtlSampleAppLoadEventObserver.h" 00022 #include "BrCtlSampleAppLinkResolver.h" 00023 #include "BrCtlSampleAppStateChangeObserver.h" 00024 #include "BrCtlSampleAppDialogsProvider.h" 00025 #include "BrCtlSampleAppQueryDialog.h" 00026 #include <eiklabel.h> // for example label control 00027 #include <avkon.hrh> 00028 #include <BrCtlSampleApp.rsg> 00029 #include "brctlsampleapp.hrh" 00030 #include <BrCtlInterface.h> 00031 #include <CHARCONV.H> 00032 #include <gdi.h> 00033 #include <bitdev.h> 00034 00035 // ================= MEMBER FUNCTIONS ======================= 00036 00037 // --------------------------------------------------------- 00038 // CBrCtlSampleAppContainer::ConstructL(const TRect& aRect) 00039 // EPOC two phased constructor 00040 // --------------------------------------------------------- 00041 // 00042 void CBrCtlSampleAppContainer::ConstructL(const TRect& aRect) 00043 { 00044 CreateWindowL(); 00045 SetRect(aRect); 00046 ActivateL(); 00047 00048 iCommandBase = TBrCtlDefs::ECommandIdBase; 00049 00050 // Create the Observers 00051 iBrCtlSampleAppSpecialLoadObserver = CBrCtlSampleAppSpecialLoadObserver::NewL(); 00052 iBrCtlSampleAppLayoutObserver = CBrCtlSampleAppLayoutObserver::NewL(this); 00053 iBrCtlSampleAppSoftkeysObserver = CBrCtlSampleAppSoftkeysObserver::NewL(this); 00054 iBrCtlSampleAppLoadEventObserver = CBrCtlSampleAppLoadEventObserver::NewL(this); 00055 iBrCtlSampleAppLinkResolver = CBrCtlSampleAppLinkResolver::NewL(); 00056 iBrCtlSampleAppStateChangeObserver = CBrCtlSampleAppStateChangeObserver::NewL(this); 00057 iBrCtlSampleAppDialogsProvider = CBrCtlSampleAppDialogsProvider::NewL(this); 00058 00059 // Initialize memeber variables 00060 _LIT(KEmpty, ""); 00061 iText.Set(KEmpty); 00062 iPoint = TPoint(0,130); 00063 iBrCtlCapabilities = TBrCtlDefs::ECapabilityDisplayScrollBar | TBrCtlDefs::ECapabilityLoadHttpFw | 00064 TBrCtlDefs::ECapabilityGraphicalHistory | TBrCtlDefs::ECapabilityGraphicalPage; 00065 00066 // Create a Screen device for use with fonts for writing text to the screen 00067 CEikonEnv* eikEnv = CEikonEnv::Static(); 00068 CWsScreenDevice& screenDev = *eikEnv->ScreenDevice(); 00069 _LIT( KDummy, "Dummy"); 00070 iFbsScrDev = CFbsScreenDevice::NewL( KDummy, screenDev.DisplayMode()); 00071 00072 // Create a font spec in order to retrieve a valid font 00073 _LIT(KFontFamily, "S60 Sans"); 00074 TFontSpec fs(KFontFamily, 100); 00075 iFbsScrDev->GetNearestFontInTwips((CFont*&)iFont, fs); 00076 00077 TRect rect(Position(), Size()); 00078 iBrCtlInterface = CreateBrowserControlL( this, 00079 rect, 00080 iBrCtlCapabilities, 00081 iCommandBase, 00082 iBrCtlSampleAppSoftkeysObserver, 00083 iBrCtlSampleAppLinkResolver, 00084 iBrCtlSampleAppSpecialLoadObserver, 00085 iBrCtlSampleAppLayoutObserver, 00086 iBrCtlSampleAppDialogsProvider); 00087 00088 // These observers can be added and removed dynamically 00089 iBrCtlInterface->AddLoadEventObserverL(iBrCtlSampleAppLoadEventObserver); 00090 iBrCtlInterface->AddStateChangeObserverL(iBrCtlSampleAppStateChangeObserver); 00091 } 00092 00093 // Destructor 00094 CBrCtlSampleAppContainer::~CBrCtlSampleAppContainer() 00095 { 00096 if (iBrCtlInterface) 00097 { 00098 iBrCtlInterface->RemoveLoadEventObserver(iBrCtlSampleAppLoadEventObserver); 00099 iBrCtlInterface->RemoveStateChangeObserver(iBrCtlSampleAppStateChangeObserver); 00100 delete iBrCtlInterface; 00101 } 00102 00103 // we are required to release the font 00104 iFbsScrDev->ReleaseFont(iFont); 00105 00106 // delete the screen device 00107 delete iFbsScrDev; 00108 00109 // delete the observers 00110 delete iBrCtlSampleAppSpecialLoadObserver; 00111 delete iBrCtlSampleAppLayoutObserver; 00112 delete iBrCtlSampleAppSoftkeysObserver; 00113 delete iBrCtlSampleAppLoadEventObserver; 00114 delete iBrCtlSampleAppLinkResolver; 00115 delete iBrCtlSampleAppStateChangeObserver; 00116 delete iBrCtlSampleAppDialogsProvider; 00117 } 00118 00119 // --------------------------------------------------------- 00120 // CBrCtlSampleAppContainer::SizeChanged() 00121 // Called by framework when the view size is changed 00122 // --------------------------------------------------------- 00123 // 00124 void CBrCtlSampleAppContainer::SizeChanged() 00125 { 00126 if (iBrCtlInterface) 00127 { 00128 iBrCtlInterface->SetRect(Rect()); 00129 } 00130 } 00131 00132 // --------------------------------------------------------- 00133 // CBrCtlSampleAppContainer::CountComponentControls() const 00134 // --------------------------------------------------------- 00135 // 00136 TInt CBrCtlSampleAppContainer::CountComponentControls() const 00137 { 00138 if (iBrCtlInterface) 00139 return 1; 00140 return 0; 00141 } 00142 00143 // --------------------------------------------------------- 00144 // CBrCtlSampleAppContainer::ComponentControl(TInt aIndex) const 00145 // --------------------------------------------------------- 00146 // 00147 CCoeControl* CBrCtlSampleAppContainer::ComponentControl(TInt aIndex) const 00148 { 00149 switch ( aIndex ) 00150 { 00151 case 0: 00152 return iBrCtlInterface; // Could be NULL 00153 default: 00154 return NULL; 00155 } 00156 } 00157 00158 // --------------------------------------------------------- 00159 // CBrCtlSampleAppContainer::Draw(const TRect& aRect) const 00160 // --------------------------------------------------------- 00161 // 00162 void CBrCtlSampleAppContainer::Draw(const TRect& aRect) const 00163 { 00164 00165 CWindowGc& gc = SystemGc(); 00166 gc.SetPenStyle(CGraphicsContext::ESolidPen); 00167 gc.SetBrushColor(KRgbGray); 00168 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); 00169 gc.DrawRect(aRect); 00170 00171 gc.UseFont(iFont); 00172 00173 gc.DrawText(iText, iPoint); 00174 00175 gc.DiscardFont(); 00176 } 00177 00178 // --------------------------------------------------------- 00179 // CBrCtlSampleAppContainer::HandleControlEventL( 00180 // CCoeControl* aControl,TCoeEvent aEventType) 00181 // --------------------------------------------------------- 00182 // 00183 void CBrCtlSampleAppContainer::HandleControlEventL( 00184 CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) 00185 { 00186 // TODO: Add your control event handler code here 00187 } 00188 00189 // ---------------------------------------------------- 00190 // CBrCtlSampleAppContainer::HandleKeyEventL( 00191 // const TKeyEvent& aKeyEvent,TEventCode /*aType*/) 00192 // ---------------------------------------------------- 00193 // 00194 TKeyResponse CBrCtlSampleAppContainer::HandleKeyEventL( 00195 const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/) 00196 { 00197 return EKeyWasNotConsumed; 00198 } 00199 00200 // ---------------------------------------------------- 00201 // CBrCtlSampleAppContainer::SetText(const TDesC& aText) 00202 // ---------------------------------------------------- 00203 // 00204 void 00205 CBrCtlSampleAppContainer::SetText(const TDesC& aText) 00206 { 00207 iText.Set(aText); 00208 } 00209 00210 // ---------------------------------------------------- 00211 // CBrCtlSampleAppContainer::SetPoint(const TPoint& aPoint) 00212 // ---------------------------------------------------- 00213 // 00214 void 00215 CBrCtlSampleAppContainer::SetPoint(const TPoint& aPoint) 00216 { 00217 iPoint = aPoint; 00218 } 00219 00220 // ---------------------------------------------------- 00221 // CBrCtlSampleAppContainer::CancelLoad() 00222 // ---------------------------------------------------- 00223 // 00224 void CBrCtlSampleAppContainer::CancelLoad() 00225 { 00226 iCancelInitDataLoad = ETrue; 00227 } 00228 00229 // ---------------------------------------------------- 00230 // CBrCtlSampleAppContainer::HandleCommandL(TInt aCommand) 00231 // ---------------------------------------------------- 00232 // 00233 void CBrCtlSampleAppContainer::HandleCommandL(TInt aCommand) 00234 { 00235 switch ( aCommand ) 00236 { 00237 case EBrCtlSampleAppCmdAppRestoreSetting: 00238 { 00239 if (iBrCtlInterface) 00240 { 00241 TRect rect( Position(), Size() ); 00242 iBrCtlInterface->SetRect( rect ); 00243 iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsSmallScreen, 1); 00244 iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsSecurityWarnings, 1); 00245 iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsAutoLoadImages, 1); 00246 iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsECMAScriptEnabled, 1); 00247 } 00248 break; 00249 } 00250 case EBrCtlSampleAppCmdAppReload: 00251 { 00252 if (iBrCtlInterface) 00253 { 00254 iBrCtlInterface->HandleCommandL(iCommandBase + TBrCtlDefs::ECommandReload); 00255 } 00256 break; 00257 } 00258 case EBrCtlSampleAppCmdAppBack: 00259 { 00260 if (iBrCtlInterface) 00261 { 00262 iBrCtlInterface->HandleCommandL(iCommandBase + TBrCtlDefs::ECommandBack); 00263 } 00264 break; 00265 } 00266 case EBrCtlSampleAppCmdAppForward: 00267 { 00268 if (iBrCtlInterface) 00269 { 00270 iBrCtlInterface->HandleCommandL(iCommandBase + TBrCtlDefs::ECommandForward); 00271 } 00272 break; 00273 } 00274 case EBrCtlSampleAppCmdApp1: 00275 { 00276 BasicBrowserControlL(); 00277 break; 00278 } 00279 case EBrCtlSampleAppCmdApp2: 00280 { 00281 BrowserControlWithObserversL(); 00282 break; 00283 } 00284 case EBrCtlSampleAppCmdApp3: 00285 { 00286 LoadingContentWithFileHandleL(); 00287 break; 00288 } 00289 case EBrCtlSampleAppCmdApp4: 00290 { 00291 LoadingContentWithBufferL(); 00292 break; 00293 } 00294 case EBrCtlSampleAppCmdApp5: 00295 { 00296 IncrementalLoadingL(); 00297 break; 00298 } 00299 case EBrCtlSampleAppCmdApp6: 00300 { 00301 SpecialLoadRequestsL(); 00302 break; 00303 } 00304 case EBrCtlSampleAppCmdApp7: 00305 { 00306 CustomizedDialogsL(); 00307 break; 00308 } 00309 case EBrCtlSampleAppCmdApp8: 00310 { 00311 CustomizedSoftKeysL(); 00312 break; 00313 } 00314 case EBrCtlSampleAppCmdApp9: 00315 { 00316 ResolvingEmbeddedLinksL(); 00317 break; 00318 } 00319 case EBrCtlSampleAppCmdApp10: 00320 { 00321 CustomizedScrollBarsL(); 00322 break; 00323 } 00324 case EBrCtlSampleAppCmdApp11: 00325 { 00326 HandleStateChangedL(); 00327 break; 00328 } 00329 case EBrCtlSampleAppCmdApp12: 00330 { 00331 ChangeSizeExtentsL(); 00332 break; 00333 } 00334 case EBrCtlSampleAppCmdApp13: 00335 { 00336 PageInfoL(); 00337 break; 00338 } 00339 case EBrCtlSampleAppCmdApp14: 00340 { 00341 ContentSizeImageCountL(); 00342 break; 00343 } 00344 00345 default: 00346 if (aCommand >= iCommandBase && 00347 aCommand < iCommandBase + TBrCtlDefs::ECommandIdWMLBase && 00348 iBrCtlInterface) 00349 { 00350 iBrCtlInterface->HandleCommandL(aCommand); 00351 } 00352 00353 if (aCommand >= iCommandBase + TBrCtlDefs::ECommandIdWMLBase && 00354 aCommand < iCommandBase + TBrCtlDefs::ECommandIdRange && 00355 iBrCtlInterface) 00356 { 00357 iBrCtlInterface->HandleCommandL(aCommand); 00358 } 00359 break; 00360 } 00361 } 00362 00363 // ---------------------------------------------------- 00364 // CBrCtlSampleAppContainer::OfferKeyEventL(const 00365 // TKeyEvent& aKeyEvent,TEventCode aType) 00366 // ---------------------------------------------------- 00367 // 00368 TKeyResponse 00369 CBrCtlSampleAppContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) 00370 { 00371 if (iBrCtlInterface) 00372 { 00373 return iBrCtlInterface->OfferKeyEventL(aKeyEvent, aType); 00374 } 00375 return EKeyWasConsumed; 00376 } 00377 00378 // ---------------------------------------------------- 00379 // CBrCtlSampleAppContainer::DynInitMenuPaneL( 00380 // TInt aResourceId, CEikMenuPane* aMenuPane) 00381 // ---------------------------------------------------- 00382 // 00383 void 00384 CBrCtlSampleAppContainer::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) 00385 { 00386 if (iBrCtlInterface && aResourceId == R_BRCTLSAMPLEAPP_MENU ) 00387 { 00388 iBrCtlInterface->AddOptionMenuItemsL(*aMenuPane, aResourceId); 00389 RPointerArray<TBrCtlWmlServiceOption>* options; 00390 options = iBrCtlInterface->WMLOptionMenuItemsL(); 00391 TInt i; 00392 TInt count = options->Count(); 00393 for (i = 0; i < count; i++) 00394 { 00395 TBrCtlWmlServiceOption* option = (*options)[i]; 00396 if (option != NULL) 00397 { 00398 CEikMenuPaneItem::SData item; 00399 item.iText.Copy(option->Text()); 00400 item.iCommandId = option->ElemID(); 00401 item.iFlags = 0; 00402 item.iCascadeId = 0; 00403 aMenuPane->InsertMenuItemL(item, 0); 00404 } 00405 } 00406 } 00407 } 00408 00409 // ---------------------------------------------------- 00410 // CBrCtlSampleAppContainer::CreateBasicBrowserControlL() 00411 // ---------------------------------------------------- 00412 // 00413 void 00414 CBrCtlSampleAppContainer::CreateBasicBrowserControlL() 00415 { 00416 if (iBrCtlInterface != NULL) 00417 { 00418 delete iBrCtlInterface; 00419 iBrCtlInterface = NULL; 00420 } 00421 else 00422 { 00423 TRect rect(Position(), Size()); 00424 00425 iBrCtlInterface = CreateBrowserControlL( this, 00426 rect, 00427 TBrCtlDefs::ECapabilityDisplayScrollBar | TBrCtlDefs::ECapabilityLoadHttpFw | 00428 TBrCtlDefs::ECapabilityGraphicalHistory | TBrCtlDefs::ECapabilityGraphicalPage, 00429 TBrCtlDefs::ECommandIdBase, 00430 NULL, 00431 NULL, 00432 NULL, 00433 NULL); 00434 } 00435 } 00436 00437 // ---------------------------------------------------- 00438 // CBrCtlSampleAppContainer::CreateBrowserControlWithObserversL(TUint aCapabilities) 00439 // ---------------------------------------------------- 00440 // 00441 void 00442 CBrCtlSampleAppContainer::CreateBrowserControlWithObserversL(TUint aCapabilities) 00443 { 00444 if (iBrCtlCapabilities != aCapabilities) 00445 { 00446 delete iBrCtlInterface; 00447 iBrCtlInterface = NULL; 00448 } 00449 iBrCtlCapabilities = aCapabilities; 00450 if (iBrCtlInterface == NULL) 00451 { 00452 TRect rect(Position(), Size()); 00453 iBrCtlInterface = CreateBrowserControlL( this, 00454 rect, 00455 iBrCtlCapabilities, 00456 TBrCtlDefs::ECommandIdBase, 00457 iBrCtlSampleAppSoftkeysObserver, 00458 iBrCtlSampleAppLinkResolver, 00459 iBrCtlSampleAppSpecialLoadObserver, 00460 iBrCtlSampleAppLayoutObserver); 00461 00462 iBrCtlInterface->AddLoadEventObserverL(iBrCtlSampleAppLoadEventObserver); 00463 iBrCtlInterface->AddStateChangeObserverL(iBrCtlSampleAppStateChangeObserver); 00464 } 00465 } 00466 00467 // ---------------------------------------------------- 00468 // CBrCtlSampleAppContainer::ReadFileLC(const TDesC& aFileName) 00469 // ---------------------------------------------------- 00470 // 00471 HBufC8* 00472 CBrCtlSampleAppContainer::ReadFileLC(const TDesC& aFileName) 00473 { 00474 RFs rfs; 00475 RFile file; 00476 User::LeaveIfError(rfs.Connect()); 00477 CleanupClosePushL(rfs); 00478 User::LeaveIfError(file.Open(rfs, aFileName, EFileRead)); 00479 CleanupClosePushL(file); 00480 TInt size; 00481 User::LeaveIfError(file.Size(size)); 00482 HBufC8* buf = HBufC8::NewLC(size); 00483 TPtr8 bufPtr(buf->Des()); 00484 User::LeaveIfError(file.Read(bufPtr)); 00485 CleanupStack::Pop(); // buf 00486 CleanupStack::PopAndDestroy(2); // file, rfs 00487 CleanupStack::PushL(buf); 00488 return buf; 00489 } 00490 00491 // ---------------------------------------------------- 00492 // CBrCtlSampleAppContainer::BasicBrowserControlL() 00493 // ---------------------------------------------------- 00494 // 00495 void 00496 CBrCtlSampleAppContainer::BasicBrowserControlL() 00497 { 00498 if (iBrCtlInterface == NULL) 00499 { 00500 TRect rect(Position(), Size()); 00501 iBrCtlInterface = CreateBrowserControlL( this, 00502 rect, 00503 TBrCtlDefs::ECapabilityDisplayScrollBar | TBrCtlDefs::ECapabilityLoadHttpFw | 00504 TBrCtlDefs::ECapabilityGraphicalHistory | TBrCtlDefs::ECapabilityGraphicalPage, 00505 iCommandBase, 00506 NULL, 00507 NULL, 00508 NULL, 00509 NULL, 00510 NULL); 00511 } 00512 00513 _LIT(KUrl, "file:///c:\\BrCtlSampleApp\\sample1.htm"); 00514 00515 iBrCtlInterface->LoadUrlL( KUrl ); 00516 } 00517 00518 // ---------------------------------------------------- 00519 // CBrCtlSampleAppContainer::BrowserControlWithObserversL() 00520 // ---------------------------------------------------- 00521 // 00522 void 00523 CBrCtlSampleAppContainer::BrowserControlWithObserversL() 00524 { 00525 CreateBrowserControlWithObserversL( TBrCtlDefs::ECapabilityDisplayScrollBar | 00526 TBrCtlDefs::ECapabilityLoadHttpFw | 00527 TBrCtlDefs::ECapabilityGraphicalHistory | 00528 TBrCtlDefs::ECapabilityGraphicalPage); 00529 _LIT(KUrl, "file:///c:\\BrCtlSampleApp\\sample2.htm"); 00530 00531 iBrCtlInterface->LoadUrlL( KUrl ); 00532 } 00533 00534 // ---------------------------------------------------- 00535 // CBrCtlSampleAppContainer::LoadingContentWithFileHandleL() 00536 // ---------------------------------------------------- 00537 // 00538 void 00539 CBrCtlSampleAppContainer::LoadingContentWithFileHandleL() 00540 { 00541 CreateBrowserControlWithObserversL(TBrCtlDefs::ECapabilityDisplayScrollBar | 00542 TBrCtlDefs::ECapabilityLoadHttpFw | 00543 TBrCtlDefs::ECapabilityGraphicalHistory | 00544 TBrCtlDefs::ECapabilityGraphicalPage); 00545 _LIT(KUrl, "c:\\BrCtlSampleApp\\sample3.htm"); 00546 RFs rfs; 00547 RFile file; 00548 User::LeaveIfError(rfs.Connect()); 00549 CleanupClosePushL(rfs); 00550 User::LeaveIfError(file.Open(rfs, KUrl(), EFileShareReadersOnly)); 00551 CleanupClosePushL(file); 00552 iBrCtlInterface->LoadFileL(file); 00553 CleanupStack::PopAndDestroy(2); // file, rfs 00554 } 00555 00556 // ---------------------------------------------------- 00557 // CBrCtlSampleAppContainer::LoadingContentWithBufferL() 00558 // ---------------------------------------------------- 00559 // 00560 void 00561 CBrCtlSampleAppContainer::LoadingContentWithBufferL() 00562 { 00563 CreateBrowserControlWithObserversL(TBrCtlDefs::ECapabilityDisplayScrollBar | 00564 TBrCtlDefs::ECapabilityLoadHttpFw | 00565 TBrCtlDefs::ECapabilityGraphicalHistory | 00566 TBrCtlDefs::ECapabilityGraphicalPage ); 00567 _LIT(KUrl, "c:\\BrCtlSampleApp\\sample4.htm"); 00568 _LIT8(KDataType, "text/html"); 00569 00570 HBufC8* data = ReadFileLC(KUrl); 00571 TDataType dataType(KDataType()); 00572 TUid uid; 00573 uid.iUid = KCharacterSetIdentifierIso88591; 00574 iBrCtlInterface->LoadDataL(KUrl, *data, dataType, uid); 00575 CleanupStack::PopAndDestroy(); // data 00576 } 00577 00578 // ---------------------------------------------------- 00579 // CBrCtlSampleAppContainer::IncrementalLoadingL() 00580 // ---------------------------------------------------- 00581 // 00582 void 00583 CBrCtlSampleAppContainer::IncrementalLoadingL() 00584 { 00585 CreateBrowserControlWithObserversL(TBrCtlDefs::ECapabilityDisplayScrollBar | 00586 TBrCtlDefs::ECapabilityLoadHttpFw | 00587 TBrCtlDefs::ECapabilityGraphicalHistory | 00588 TBrCtlDefs::ECapabilityGraphicalPage ); 00589 _LIT(KUrl, "c:\\BrCtlSampleApp\\sample5.htm"); 00590 HBufC8* data = ReadFileLC(KUrl); 00591 _LIT8(KDataType, "text/html"); 00592 TDataType dataType(KDataType()); 00593 MBrCtlDataLoadConsumer* brCtlDataLoadConsumer = NULL; 00594 TUid uid; 00595 uid.iUid = KCharacterSetIdentifierIso88591; 00596 iBrCtlInterface->InitLoadDataL(KUrl, dataType, uid, data->Length(), 00597 this, &brCtlDataLoadConsumer); 00598 00599 if (brCtlDataLoadConsumer) 00600 { 00601 brCtlDataLoadConsumer->HandleNextDataChunk(*data); 00602 if (!iCancelInitDataLoad) 00603 { 00604 brCtlDataLoadConsumer->HandleLoadComplete(); 00605 } 00606 } 00607 iCancelInitDataLoad = EFalse; 00608 CleanupStack::PopAndDestroy(); // data 00609 } 00610 00611 // ---------------------------------------------------- 00612 // CBrCtlSampleAppContainer::SpecialLoadRequestsL() 00613 // ---------------------------------------------------- 00614 // 00615 void 00616 CBrCtlSampleAppContainer::SpecialLoadRequestsL() 00617 { 00618 CreateBrowserControlWithObserversL(TBrCtlDefs::ECapabilityDisplayScrollBar | 00619 TBrCtlDefs::ECapabilityClientNotifyURL | 00620 TBrCtlDefs::ECapabilityGraphicalHistory | 00621 TBrCtlDefs::ECapabilityGraphicalPage ); 00622 00623 _LIT(KUrl, "file:///c:\\BrCtlSampleApp\\sample6.htm"); 00624 00625 iBrCtlInterface->LoadUrlL( KUrl ); 00626 } 00627 00628 // ---------------------------------------------------- 00629 // CBrCtlSampleAppContainer::CustomizedDialogsL() 00630 // ---------------------------------------------------- 00631 // 00632 void 00633 CBrCtlSampleAppContainer::CustomizedDialogsL() 00634 { 00635 CreateBrowserControlWithObserversL(TBrCtlDefs::ECapabilityDisplayScrollBar | 00636 TBrCtlDefs::ECapabilityLoadHttpFw | 00637 TBrCtlDefs::ECapabilityGraphicalHistory | 00638 TBrCtlDefs::ECapabilityGraphicalPage); 00639 _LIT(KUrl, "file:///c:\\BrCtlSampleApp\\sample7.htm"); 00640 00641 iBrCtlInterface->LoadUrlL( KUrl ); 00642 } 00643 00644 // ---------------------------------------------------- 00645 // CBrCtlSampleAppContainer::CustomizedSoftKeysL() 00646 // ---------------------------------------------------- 00647 // 00648 void 00649 CBrCtlSampleAppContainer::CustomizedSoftKeysL() 00650 { 00651 CreateBrowserControlWithObserversL(TBrCtlDefs::ECapabilityDisplayScrollBar | 00652 TBrCtlDefs::ECapabilityLoadHttpFw | 00653 TBrCtlDefs::ECapabilityGraphicalHistory | 00654 TBrCtlDefs::ECapabilityGraphicalPage); 00655 _LIT(KUrl, "file:///c:\\BrCtlSampleApp\\sample8.htm"); 00656 00657 iBrCtlInterface->LoadUrlL( KUrl ); 00658 } 00659 00660 // ---------------------------------------------------- 00661 // CBrCtlSampleAppContainer::ResolvingEmbeddedLinksL() 00662 // ---------------------------------------------------- 00663 // 00664 void 00665 CBrCtlSampleAppContainer::ResolvingEmbeddedLinksL() 00666 { 00667 CreateBrowserControlWithObserversL(TBrCtlDefs::ECapabilityDisplayScrollBar | 00668 TBrCtlDefs::ECapabilityClientResolveEmbeddedURL | 00669 TBrCtlDefs::ECapabilityGraphicalHistory | 00670 TBrCtlDefs::ECapabilityGraphicalPage); 00671 _LIT(KUrl, "file:///c:\\BrCtlSampleApp\\sample9.htm"); 00672 00673 iBrCtlInterface->LoadUrlL( KUrl ); 00674 } 00675 00676 // ---------------------------------------------------- 00677 // CBrCtlSampleAppContainer::CustomizedScrollBarsL() 00678 // ---------------------------------------------------- 00679 // 00680 void 00681 CBrCtlSampleAppContainer::CustomizedScrollBarsL() 00682 { 00683 CreateBrowserControlWithObserversL(TBrCtlDefs::ECapabilityDisplayScrollBar | 00684 TBrCtlDefs::ECapabilityLoadHttpFw | 00685 TBrCtlDefs::ECapabilityGraphicalHistory | 00686 TBrCtlDefs::ECapabilityGraphicalPage ); 00687 _LIT(KUrl, "file:///c:\\BrCtlSampleApp\\sample10.htm"); 00688 00689 iBrCtlInterface->SetExtent(Position(), TSize(300, 180)); 00690 00691 iBrCtlInterface->SetBrowserSettingL(TBrCtlDefs::ESettingsSmallScreen, 0); 00692 00693 iBrCtlInterface->LoadUrlL( KUrl ); 00694 } 00695 00696 // ---------------------------------------------------- 00697 // CBrCtlSampleAppContainer::HandleStateChangedL() 00698 // ---------------------------------------------------- 00699 // 00700 void 00701 CBrCtlSampleAppContainer::HandleStateChangedL() 00702 { 00703 CreateBrowserControlWithObserversL(TBrCtlDefs::ECapabilityDisplayScrollBar | 00704 TBrCtlDefs::ECapabilityLoadHttpFw | 00705 TBrCtlDefs::ECapabilityGraphicalHistory | 00706 TBrCtlDefs::ECapabilityGraphicalPage); 00707 _LIT(KUrl, "file:///c:\\BrCtlSampleApp\\sample11.htm"); 00708 00709 iBrCtlInterface->SetExtent(Position(), TSize(176, 72)); 00710 00711 iBrCtlInterface->LoadUrlL( KUrl ); 00712 } 00713 00714 // ---------------------------------------------------- 00715 // CBrCtlSampleAppContainer::ChangeSizeExtentsL() 00716 // ---------------------------------------------------- 00717 // 00718 void 00719 CBrCtlSampleAppContainer::ChangeSizeExtentsL() 00720 { 00721 if (iBrCtlInterface) 00722 { 00723 _LIT(KTitle,"Query Dialog"); 00724 _LIT(KPromptWidth, "Enter new width"); 00725 _LIT(KPromptHeight, "Enter new height"); 00726 HBufC* returnedInput = NULL; 00727 TUint width = iBrCtlInterface->Rect().Width(); 00728 TUint height = iBrCtlInterface->Rect().Height(); 00729 TBool ret; 00730 // defInput is not modified by the dialog. 00731 TBuf<10>defInput; 00732 defInput.Num(width); 00733 00734 CBrCtlSampleAppQueryDialog* dialog = new (ELeave) CBrCtlSampleAppQueryDialog( defInput, returnedInput ); 00735 CleanupStack::PushL(dialog); 00736 00737 dialog->PrepareLC( R_DATA_QUERY_WITH_HEADING ); 00738 dialog->SetHeaderTextL( KTitle ); 00739 dialog->SetPromptL( KPromptWidth ); 00740 CleanupStack::Pop(); // dialog 00741 ret = dialog->RunLD(); 00742 if (ret) 00743 { 00744 TInt i = 0; 00745 for (width = 0; i < returnedInput->Length(); i++) 00746 { 00747 if (((*returnedInput)[i] > '9') || ((*returnedInput)[i] < '0')) 00748 break; 00749 width *= 10; 00750 width += ((*returnedInput)[i] - '0'); 00751 } 00752 00753 defInput.Num(height); 00754 00755 dialog = new (ELeave) CBrCtlSampleAppQueryDialog( defInput, returnedInput ); 00756 CleanupStack::PushL(dialog); 00757 dialog->PrepareLC( R_DATA_QUERY_WITH_HEADING ); 00758 dialog->SetHeaderTextL( KTitle ); 00759 dialog->SetPromptL( KPromptHeight ); 00760 CleanupStack::Pop(); // dialog 00761 ret = dialog->RunLD(); 00762 i = 0; 00763 for (height = 0; i < returnedInput->Length(); i++) 00764 { 00765 if ((*returnedInput)[i] > '9' || (*returnedInput)[i] < '0') 00766 break; 00767 height *= 10; 00768 height += ((*returnedInput)[i] - '0'); 00769 } 00770 if (width && height) 00771 { 00772 iBrCtlInterface->SetExtent(Position(), TSize(width, height)); 00773 } 00774 } 00775 } 00776 } 00777 00778 // ---------------------------------------------------- 00779 // CBrCtlSampleAppContainer::PageInfoL() 00780 // ---------------------------------------------------- 00781 // 00782 void 00783 CBrCtlSampleAppContainer::PageInfoL() 00784 { 00785 if (iBrCtlInterface) 00786 { 00787 HBufC* title = iBrCtlInterface->PageInfoLC(TBrCtlDefs::EPageInfoTitle); 00788 if (title) 00789 { 00790 CAknQueryDialog* dialog = new (ELeave) CAknQueryDialog(); 00791 dialog->PrepareLC( R_CONFIRM_QUERY ); 00792 dialog->SetPromptL( *title ); 00793 dialog->RunLD(); 00794 CleanupStack::PopAndDestroy(); 00795 } 00796 HBufC* url = iBrCtlInterface->PageInfoLC(TBrCtlDefs::EPageInfoUrl); 00797 if (url) 00798 { 00799 CAknQueryDialog* dialog = new (ELeave) CAknQueryDialog(); 00800 dialog->PrepareLC( R_CONFIRM_QUERY ); 00801 dialog->SetPromptL( *url ); 00802 dialog->RunLD(); 00803 CleanupStack::PopAndDestroy(); 00804 } 00805 } 00806 } 00807 00808 // ---------------------------------------------------- 00809 // CBrCtlSampleAppContainer::ContentSizeImageCountL() 00810 // ---------------------------------------------------- 00811 // 00812 void 00813 CBrCtlSampleAppContainer::ContentSizeImageCountL() 00814 { 00815 if (iBrCtlInterface) 00816 { 00817 TSize size(0, 0); 00818 size = iBrCtlInterface->ContentSize(); 00819 TInt images = iBrCtlInterface->ImageCountL(); 00820 _LIT(KStr, "Width = %d, Height = %d. %d images"); 00821 00822 TBuf<100> str; 00823 str.Format(KStr, size.iWidth, size.iHeight, images); 00824 CAknQueryDialog* dialog = new (ELeave) CAknQueryDialog(); 00825 dialog->PrepareLC( R_CONFIRM_QUERY ); 00826 dialog->SetPromptL( str ); 00827 dialog->RunLD(); 00828 } 00829 } 00830 00831 // End of File 00832
|
© Nokia 2009 |