0
|
1 |
/*
|
|
2 |
===============================================================================
|
|
3 |
Name : NPRBrowserConatiner.cpp
|
|
4 |
Author : Symsource
|
|
5 |
|
|
6 |
Copyright (c) 2009 Symbian Foundation Ltd
|
|
7 |
This component and the accompanying materials are made available
|
|
8 |
under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
which accompanies this distribution, and is available
|
|
10 |
at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
|
|
12 |
Initial Contributors:
|
|
13 |
- Symsource
|
|
14 |
|
|
15 |
Contributors:
|
|
16 |
- Symsource
|
|
17 |
|
|
18 |
Description : Container for Nokia browser control to show NPR's Story
|
|
19 |
================================================================================
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include <avkon.hrh>
|
|
23 |
#include <aknwaitdialog.h>
|
|
24 |
#include <BrCtlInterface.h>
|
|
25 |
#include <aknmessagequerydialog.h>
|
|
26 |
|
|
27 |
#include "NPRBrowserContainer.h"
|
|
28 |
#include "npr.hrh"
|
|
29 |
#include "NPRAppUi.h"
|
|
30 |
#include "NPRAppEngine.h"
|
|
31 |
|
|
32 |
|
|
33 |
_LIT(KStoryHtmlFile, "file:///c:\\data\\npr\\story.html");
|
|
34 |
|
|
35 |
void CBrowserContainer::ConstructL(const TRect& aRect)
|
|
36 |
{
|
|
37 |
CreateWindowL();
|
|
38 |
SetRect(aRect);
|
|
39 |
|
|
40 |
iCommandBase = TBrCtlDefs::ECommandIdBase;
|
|
41 |
iBrowserCaps = TBrCtlDefs::ECapabilityDisplayScrollBar | TBrCtlDefs::ECapabilityLoadHttpFw |
|
|
42 |
TBrCtlDefs::ECapabilityGraphicalHistory | TBrCtlDefs::ECapabilityGraphicalPage;
|
|
43 |
|
|
44 |
iBrowser = CreateBrowserControlL(this, Rect(), iBrowserCaps, iCommandBase, NULL, NULL, NULL, NULL, NULL);
|
|
45 |
|
|
46 |
TRAP_IGNORE(iBrowser->SetBrowserSettingL(TBrCtlDefs::ESettingsAutoLoadImages,1));
|
|
47 |
iBrowser->AddLoadEventObserverL(this);
|
|
48 |
iBrowser->ActivateL();
|
|
49 |
}
|
|
50 |
|
|
51 |
CBrowserContainer::~CBrowserContainer()
|
|
52 |
{
|
|
53 |
if (iBrowser)
|
|
54 |
iBrowser->RemoveLoadEventObserver(this);
|
|
55 |
delete iBrowser;
|
|
56 |
}
|
|
57 |
|
|
58 |
void CBrowserContainer::SizeChanged()
|
|
59 |
{
|
|
60 |
if(iBrowser)
|
|
61 |
{
|
|
62 |
iBrowser->SetRect(Rect());
|
|
63 |
}
|
|
64 |
}
|
|
65 |
|
|
66 |
TInt CBrowserContainer::CountComponentControls() const
|
|
67 |
{
|
|
68 |
if(iBrowser)
|
|
69 |
return 1;
|
|
70 |
return 0;
|
|
71 |
}
|
|
72 |
|
|
73 |
CCoeControl* CBrowserContainer::ComponentControl(TInt aIndex) const
|
|
74 |
{
|
|
75 |
switch(aIndex)
|
|
76 |
{
|
|
77 |
case 0:
|
|
78 |
return iBrowser; // Could be NULL
|
|
79 |
default:
|
|
80 |
return NULL;
|
|
81 |
}
|
|
82 |
}
|
|
83 |
|
|
84 |
void CBrowserContainer::Draw(const TRect& /*aRect*/) const
|
|
85 |
{
|
|
86 |
CWindowGc& gc=SystemGc(); // graphics context we draw to
|
|
87 |
gc.Clear();
|
|
88 |
}
|
|
89 |
|
|
90 |
void CBrowserContainer::HandleControlEventL(CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/)
|
|
91 |
{
|
|
92 |
}
|
|
93 |
|
|
94 |
TKeyResponse CBrowserContainer::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
|
|
95 |
{
|
|
96 |
return EKeyWasNotConsumed;
|
|
97 |
}
|
|
98 |
|
|
99 |
|
|
100 |
void CBrowserContainer::HandleResourceChange(TInt aType)
|
|
101 |
{
|
|
102 |
CCoeControl::HandleResourceChange(aType);
|
|
103 |
SetRect(CEikonEnv::Static()->EikAppUi()->ClientRect());
|
|
104 |
}
|
|
105 |
|
|
106 |
void CBrowserContainer::ProcessCommandL(TInt aCommandId)
|
|
107 |
{
|
|
108 |
switch(aCommandId)
|
|
109 |
{
|
|
110 |
case ELoadPage:
|
|
111 |
if (iBrowser!=NULL)
|
|
112 |
iBrowser->LoadUrlL(KStoryHtmlFile());
|
|
113 |
break;
|
|
114 |
default:
|
|
115 |
if (aCommandId >= iCommandBase && aCommandId < iCommandBase + TBrCtlDefs::ECommandIdWMLBase && iBrowser)
|
|
116 |
{
|
|
117 |
iBrowser->HandleCommandL(aCommandId);
|
|
118 |
}
|
|
119 |
|
|
120 |
if (aCommandId >= iCommandBase + TBrCtlDefs::ECommandIdWMLBase && aCommandId < iCommandBase + TBrCtlDefs::ECommandIdRange && iBrowser)
|
|
121 |
{
|
|
122 |
iBrowser->HandleCommandL(aCommandId);
|
|
123 |
}
|
|
124 |
break;
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
TKeyResponse CBrowserContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
|
|
129 |
{
|
|
130 |
if(iBrowser)
|
|
131 |
{
|
|
132 |
return iBrowser->OfferKeyEventL(aKeyEvent, aType);
|
|
133 |
}
|
|
134 |
return EKeyWasConsumed;
|
|
135 |
}
|
|
136 |
|
|
137 |
void CBrowserContainer::DynInitMenuPaneL(TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/)
|
|
138 |
{
|
|
139 |
}
|
|
140 |
|
|
141 |
void CBrowserContainer::HandleBrowserLoadEventL(TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, TUint /*aSize*/, TUint16 /*aTransactionId*/)
|
|
142 |
{
|
|
143 |
if(aLoadEvent == TBrCtlDefs::EEventLoadFinished)
|
|
144 |
{
|
|
145 |
iBrowser->DrawNow();
|
|
146 |
}
|
|
147 |
}
|
|
148 |
|
|
149 |
|
|
150 |
void CBrowserContainer::Listen()
|
|
151 |
{
|
|
152 |
static_cast<CNPRAppUi*>(CEikonEnv::Static()->EikAppUi())->Engine().SendNPRCommandL(EPlayNewsStream, KNullDesC());
|
|
153 |
}
|