S60 3rd Edition SDK for Symbian OS
Example Applications Guide

CBrCtlSampleAppContainer Class Reference

#include <BrCtlSampleAppContainer.h>

List of all members.

Public Member Functions

void ConstructL (const TRect &aRect)
 ~CBrCtlSampleAppContainer ()
void HandleCommandL (TInt aCommand)
void DynInitMenuPaneL (TInt aResourceId, CEikMenuPane *aMenuPane)
TKeyResponse HandleKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType)
const TDesC & Text () const
void SetText (const TDesC &aText)
void SetPoint (const TPoint &aPoint)
CBrCtlInterface * BrCtlInterface () const

Private Member Functions

void SizeChanged ()
TInt CountComponentControls () const
CCoeControl * ComponentControl (TInt aIndex) const
void Draw (const TRect &aRect) const
TKeyResponse OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType)
void CancelLoad ()
void CreateBasicBrowserControlL ()
void CreateBrowserControlWithObserversL (TUint aCapabilities)
HBufC8 * ReadFileLC (const TDesC &aFileName)
void HandleControlEventL (CCoeControl *aControl, TCoeEvent aEventType)
void BasicBrowserControlL ()
void BrowserControlWithObserversL ()
void LoadingContentWithFileHandleL ()
void LoadingContentWithBufferL ()
void IncrementalLoadingL ()
void SpecialLoadRequestsL ()
void CustomizedDialogsL ()
void CustomizedSoftKeysL ()
void ResolvingEmbeddedLinksL ()
void CustomizedScrollBarsL ()
void HandleStateChangedL ()
void ChangeSizeExtentsL ()
void PageInfoL ()
void ContentSizeImageCountL ()

Private Attributes

CBrCtlInterface * iBrCtlInterface
TUint iBrCtlCapabilities
TInt iCommandBase
CBrCtlSampleAppSpecialLoadObserver * iBrCtlSampleAppSpecialLoadObserver
CBrCtlSampleAppLayoutObserver * iBrCtlSampleAppLayoutObserver
CBrCtlSampleAppSoftkeysObserver * iBrCtlSampleAppSoftkeysObserver
CBrCtlSampleAppLoadEventObserver * iBrCtlSampleAppLoadEventObserver
CBrCtlSampleAppLinkResolver * iBrCtlSampleAppLinkResolver
CBrCtlSampleAppStateChangeObserver * iBrCtlSampleAppStateChangeObserver
CBrCtlSampleAppDialogsProvider * iBrCtlSampleAppDialogsProvider
TBool iCancelInitDataLoad
CFbsScreenDevice * iFbsScrDev
CFont * iFont
TPtrC iText
TPoint iPoint


Detailed Description

CBrCtlSampleAppContainer class. This is the container control class.

Definition at line 38 of file BrCtlSampleAppContainer.h.


Constructor & Destructor Documentation

CBrCtlSampleAppContainer::~CBrCtlSampleAppContainer (   ) 
 

Destructor.

Definition at line 93 of file BrCtlSampleAppContainer.cpp.

References iBrCtlInterface, iBrCtlSampleAppDialogsProvider, iBrCtlSampleAppLayoutObserver, iBrCtlSampleAppLinkResolver, iBrCtlSampleAppLoadEventObserver, iBrCtlSampleAppSoftkeysObserver, iBrCtlSampleAppSpecialLoadObserver, iBrCtlSampleAppStateChangeObserver, iFbsScrDev, and iFont.

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     }


Member Function Documentation

void CBrCtlSampleAppContainer::ConstructL (  const TRect &  aRect  ) 
 

EPOC default constructor.

Parameters:
aRect Frame rectangle for container.

Definition at line 42 of file BrCtlSampleAppContainer.cpp.

References iBrCtlCapabilities, iBrCtlInterface, iBrCtlSampleAppDialogsProvider, iBrCtlSampleAppLayoutObserver, iBrCtlSampleAppLinkResolver, iBrCtlSampleAppLoadEventObserver, iBrCtlSampleAppSoftkeysObserver, iBrCtlSampleAppSpecialLoadObserver, iBrCtlSampleAppStateChangeObserver, iCommandBase, iFbsScrDev, iFont, iPoint, iText, CBrCtlSampleAppDialogsProvider::NewL(), CBrCtlSampleAppStateChangeObserver::NewL(), CBrCtlSampleAppLinkResolver::NewL(), CBrCtlSampleAppLoadEventObserver::NewL(), CBrCtlSampleAppSoftkeysObserver::NewL(), CBrCtlSampleAppLayoutObserver::NewL(), and CBrCtlSampleAppSpecialLoadObserver::NewL().

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     }

void CBrCtlSampleAppContainer::HandleCommandL (  TInt  aCommand  ) 
 

Pass a command to the Browser Control

Since:
2.8
Parameters:
aCommand The command that the Browser Control should process
Returns:
void

Definition at line 231 of file BrCtlSampleAppContainer.cpp.

References BasicBrowserControlL(), BrowserControlWithObserversL(), ChangeSizeExtentsL(), ContentSizeImageCountL(), CustomizedDialogsL(), CustomizedScrollBarsL(), CustomizedSoftKeysL(), HandleStateChangedL(), iBrCtlInterface, iCommandBase, IncrementalLoadingL(), LoadingContentWithBufferL(), LoadingContentWithFileHandleL(), PageInfoL(), ResolvingEmbeddedLinksL(), and SpecialLoadRequestsL().

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     }

void CBrCtlSampleAppContainer::DynInitMenuPaneL (  TInt  aResourceId,
CEikMenuPane *  aMenuPane
) 
 

Dynamically initialises a menu pane. The Uikon framework calls this function, if it is implemented in a menu’s observer, immediately before the menu pane is activated.

Since:
2.8
Parameters:
aResourceId Resource ID identifying the menu pane to initialise
aMenuPane The in-memory representation of the menu pane.
Returns:
void

Definition at line 382 of file BrCtlSampleAppContainer.cpp.

References iBrCtlInterface.

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     }

TKeyResponse CBrCtlSampleAppContainer::HandleKeyEventL (  const TKeyEvent &  aKeyEvent,
TEventCode  aType
) 
 

Handles key events

Since:
2.8
Parameters:
aKeyEvent The key event that occurred.
aType The window server event type that is being handled
Returns:
TKeyResponse Value indicates whether or not the key event was consumed by the control. The default implementation simply returns EKeyWasNotConsumed.

Definition at line 192 of file BrCtlSampleAppContainer.cpp.

00194     {
00195     return EKeyWasNotConsumed;
00196     }

const TDesC& CBrCtlSampleAppContainer::Text (   )  const [inline]
 

Accessor method for iText

Since:
2.8
Parameters:
void 
Returns:
TDesc& The descriptor of the text

Definition at line 89 of file BrCtlSampleAppContainer.h.

References iText.

00089 {return iText;}

void CBrCtlSampleAppContainer::SetText (  const TDesC &  aText  ) 
 

Setter method for iText

Since:
2.8
Parameters:
aText The descriptor for the text you wish to display
Returns:
void

Definition at line 203 of file BrCtlSampleAppContainer.cpp.

References iText.

00204     {
00205     iText.Set(aText);
00206     }

void CBrCtlSampleAppContainer::SetPoint (  const TPoint &  aPoint  ) 
 

Setter method for iPoint

Since:
2.8
Parameters:
aPoint The point at which you want to display the text
Returns:
void

Definition at line 213 of file BrCtlSampleAppContainer.cpp.

References iPoint.

00214     {
00215     iPoint = aPoint;
00216     }

CBrCtlInterface* CBrCtlSampleAppContainer::BrCtlInterface (   )  const [inline]
 

Accessor method iBrCtlInterface

Since:
2.8
Parameters:
void 
Returns:
CBrCtlInterface* A pointer to the browser control interface as a convenience to the observers

Definition at line 113 of file BrCtlSampleAppContainer.h.

References iBrCtlInterface.

00113 {return iBrCtlInterface;}

void CBrCtlSampleAppContainer::SizeChanged (   )  [private]
 

From CoeControl,SizeChanged.

Definition at line 123 of file BrCtlSampleAppContainer.cpp.

References iBrCtlInterface.

00124     {
00125     if (iBrCtlInterface)
00126         {
00127         iBrCtlInterface->SetRect(Rect());
00128         }
00129     }

TInt CBrCtlSampleAppContainer::CountComponentControls (   )  const [private]
 

From CoeControl,CountComponentControls.

Definition at line 135 of file BrCtlSampleAppContainer.cpp.

References iBrCtlInterface.

00136     {
00137     if (iBrCtlInterface)
00138         return 1;
00139     return 0;
00140     }

CCoeControl * CBrCtlSampleAppContainer::ComponentControl (  TInt  aIndex  )  const [private]
 

From CCoeControl,ComponentControl.

Definition at line 146 of file BrCtlSampleAppContainer.cpp.

References iBrCtlInterface.

00147     {
00148     switch ( aIndex )
00149         {
00150         case 0:
00151             return iBrCtlInterface; // Could be NULL
00152         default:
00153             return NULL;
00154         }
00155     }

void CBrCtlSampleAppContainer::Draw (  const TRect &  aRect  )  const [private]
 

From CCoeControl,Draw.

Definition at line 161 of file BrCtlSampleAppContainer.cpp.

References iFont, iPoint, and iText.

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     }

TKeyResponse CBrCtlSampleAppContainer::OfferKeyEventL (  const TKeyEvent &  aKeyEvent,
TEventCode  aType
)  [private]
 

Handle key events.

Definition at line 367 of file BrCtlSampleAppContainer.cpp.

References iBrCtlInterface.

00368     {
00369     if (iBrCtlInterface)
00370         {
00371         return iBrCtlInterface->OfferKeyEventL(aKeyEvent, aType);
00372         }
00373     return EKeyWasConsumed;
00374     }

void CBrCtlSampleAppContainer::CancelLoad (   )  [private]
 

From MBrCtlDataLoadSupplier, Cancel an on-going load

Definition at line 222 of file BrCtlSampleAppContainer.cpp.

References iCancelInitDataLoad.

00223     {
00224     iCancelInitDataLoad = ETrue;
00225     }

void CBrCtlSampleAppContainer::CreateBasicBrowserControlL (   )  [private]
 

Create a Basic Browser Control that does not have observers with scrolling and HTTP framework capabilities

Definition at line 412 of file BrCtlSampleAppContainer.cpp.

References iBrCtlInterface.

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     }

void CBrCtlSampleAppContainer::CreateBrowserControlWithObserversL (  TUint  aCapabilities  )  [private]
 

Create Browser Control with observers with the given capabilities

Definition at line 439 of file BrCtlSampleAppContainer.cpp.

References iBrCtlCapabilities, iBrCtlInterface, iBrCtlSampleAppLayoutObserver, iBrCtlSampleAppLinkResolver, iBrCtlSampleAppLoadEventObserver, iBrCtlSampleAppSoftkeysObserver, iBrCtlSampleAppSpecialLoadObserver, and iBrCtlSampleAppStateChangeObserver.

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     }

HBufC8 * CBrCtlSampleAppContainer::ReadFileLC (  const TDesC &  aFileName  )  [private]
 

Read the file.

Definition at line 469 of file BrCtlSampleAppContainer.cpp.

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     }

void CBrCtlSampleAppContainer::HandleControlEventL (  CCoeControl *  aControl,
TCoeEvent  aEventType
)  [private]
 

Handles an event from an observed control.

Definition at line 182 of file BrCtlSampleAppContainer.cpp.

00184     {
00185     }

void CBrCtlSampleAppContainer::BasicBrowserControlL (   )  [private]
 

The following methods are used to demonstrate the functionality of the browser control API

Definition at line 493 of file BrCtlSampleAppContainer.cpp.

References iBrCtlInterface, and iCommandBase.

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     }


© Nokia 2006

Back to top