MCMLBrowserCtrl
a simple mcml web page browser window
Title |
a simple mcml web page browser window |
Author(s) |
LiXizhi |
Date |
2008/3/10 |
File |
script/kids/3DMapSystemApp/MCML/BrowserWnd.lua |
Description
a thin wrapper of
PageCtrl in a web browser style API.
Sample Code
NPL.load("(gl)script/kids/3DMapSystemApp/mcml/BrowserWnd.lua");
local ctl = Map3DSystem.mcml.BrowserWnd:new{
name = "McmlBrowserWnd1",
alignment = "_lt",
left=0, top=0,
width = 512,
height = 290,
parent = nil,
};
ctl:Show();
-- One can also create NavBar elsewhere, like below
ctl:CreateNavBar(_parent, "_mt", 0, 0, 0,32)
ctl:Goto("%WIKI%/Main/ParaWorldFrontPageMCML");
ctl:Goto(url, Map3DSystem.localserver.CachePolicy:new("access plus 1 day"));
Member Functions
BrowserWnd:new
--------------------------------------------------------------------
a browser window instance: internally it is a PageCtrl
--------------------------------------------------------------------
local BrowserWnd = {
-- the top level control name
name = "BrowserWnd1",
-- normal window size
alignment = "_lt",
left = 0,
top = 0,
width = 300,
height = 290,
parent = nil,
background = "",
-- current url
url = nil,
-- boolean: whether to create the nav bar, if nil NavBar will not be created. if false, it will be created but not visible.
DisplayNavBar = nil,
-- whether to display nav address combo box, if this is DisplayNavBar is not true, this parameter takes no effect.
DisplayNavAddress = true,
-- a file containing url addresses
historyFileName = "config/mcmlbrowser_urls.txt";
-- max number of history files
max_history_items = 200,
-- window object that will be passed to the internal pageCtrl.
window = nil,
}
Map3DSystem.mcml.BrowserWnd =
BrowserWnd;
constructor
syntax
function BrowserWnd:new (o)
parameters
BrowserWnd:Destroy
Destroy the UI control
syntax
function BrowserWnd:Destroy ()
BrowserWnd:CreateNavBar
create navigation bar for this window
syntax
function BrowserWnd:CreateNavBar(_parent, alignment, left, right, width, height)
parameters
parent |
|
alignment |
|
left |
|
right |
|
width |
|
height |
|
BrowserWnd:Show
- param bShow : boolean to show or hide. if nil, it will toggle current setting.
- return true : if UI is created
syntax
function BrowserWnd:Show(bShow)
parameters
bShow |
boolean to show or hide. if nil, it will toggle current setting. |
BrowserWnd:Goto
public method
go to a given url, refresh
- param url : if nil it will clear the browser. it can also be string "backward", "forward" which opens last page and forward page.
syntax
function BrowserWnd:Goto(url, cache_policy, bRefresh)
parameters
url |
if nil it will clear the browser. it can also be string "backward", "forward" which opens last page and forward page. |
cache |
|
policy |
|
bRefresh |
|
BrowserWnd:GetUrl
return nil or current url
syntax
function BrowserWnd:GetUrl()
BrowserWnd:ShowNavBar
show or hide the nav bar on top.
syntax
function BrowserWnd:ShowNavBar(bShow)
parameters
BrowserWnd:ShowAddressBar
show or hide the nav address bar on top.
syntax
function BrowserWnd:ShowAddressBar(bShow)
parameters
BrowserWnd:UpdateHistoryFiles
load history test files
syntax
function BrowserWnd:UpdateHistoryFiles()
BrowserWnd:SaveToHistoryFile
save recently opened file to history
syntax
function BrowserWnd:SaveToHistoryFile(url)
parameters
BrowserWnd.OnPage_CallBack
called when a new page is downloaded.
syntax
function BrowserWnd.OnPage_CallBack(sCtrlName)
parameters
BrowserWnd:open
replace the context in this window with input mcmlNode.
- param mcmlNode : must be a raw mcmlNode, such as from a url or local server.
syntax
function BrowserWnd:open(mcmlNode)
parameters
mcmlNode |
must be a raw mcmlNode, such as from a url or local server. |
BrowserWnd:ShowMessage
show a message to inform the user about a background action or status.
- param text : string or nil. if nil, it will clear the message box.
syntax
function BrowserWnd:ShowMessage(text)
parameters
text |
string or nil. if nil, it will clear the message box. |
BrowserWnd.OnClose
close the given control
syntax
function BrowserWnd.OnClose(sCtrlName)
parameters
BrowserWnd.OnClickNavBackward
navigate to last url
syntax
function BrowserWnd.OnClickNavBackward(sCtrlName)
parameters
BrowserWnd.OnClickNavForward
navigate to next url
syntax
function BrowserWnd.OnClickNavForward(sCtrlName)
parameters
BrowserWnd.OnClickNavTo
navigate to the current url in combo box
syntax
function BrowserWnd.OnClickNavTo(sCtrlName)
parameters
Map3DSystem.mcml.BrowserWnd.OnClickNavRefresh
do not use cached version and refresh
syntax
function Map3DSystem.mcml.BrowserWnd.OnClickNavRefresh(sCtrlName)
parameters