S60 3rd Edition SDK for Symbian OS
Example Applications Guide

BrCtlSampleAppContainer.cpp

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

© Nokia 2006

Back to top