4 template
= "webig_browser",
8 function WebBrowser
:addWindow(id
, title
, ui
)
10 for k
,app
in pairs(self
.apps
) do
19 if found_app
== nil then
25 app
.winid
= "ui:interface:" .. id
32 table.insert(self
.apps
, app
)
38 function WebBrowser
:openWindow(id
, url
)
39 -- default value if url is not set
40 url
= url
or "http://app.ryzom.com/"
42 local newWindow
= false
43 local app
= self
:findAppById(id
)
52 app
.winid
= "ui:interface:" .. id
60 table.insert(self
.apps
, app
)
63 if not app
.uiWindow
then
64 -- if there is window present (eg, 'webig'), then reuse it
65 app
.uiWindow
= getUI(app
.winid
, false)
66 if not app
.uiWindow
then
67 app
.uiWindow
= createRootGroupInstance(self
.template
, app
.id
, {
68 x
= 0, y
= 0, w
= app
.winw
, h
= app
.winh
, home
= app
.url
,
69 browse_redo
= "ui:interface:" .. app
.id
.. ":browser:header_opened:browse_redo",
70 browse_undo
= "ui:interface:" .. app
.id
.. ":browser:header_opened:browse_undo",
71 browse_refresh
= "ui:interface:" .. app
.id
.. ":browser:header_opened:browse_refresh"
73 if not app
.uiWindow
then
84 -- trigger on_open event
85 if not app
.uiWindow
.opened
then
86 app
.uiWindow
.opened
= true
89 -- trigger on_active event
90 if not app
.uiWindow
.active
then
91 app
.uiWindow
.active
= true
94 local html
= app
.uiWindow
:find("html")
97 setTopWindow(app
.uiWindow
)
100 function WebBrowser
:findAppById(id
)
101 for k
,app
in pairs(self
.apps
) do
109 function WebBrowser
:findAppFromUiCaller()
111 local id
= getUICaller().id
:match("ui:interface:([^:]*):?")
112 local app
= self
:findAppById(id
)
118 function WebBrowser
:onActive()
120 self
:restoreWindow(app
)
124 function WebBrowser
:onClickHeaderClose()
125 local app
= self
:findAppFromUiCaller()
131 function WebBrowser
:onClickHeaderOpen()
132 local app
= self
:findAppFromUiCaller()
134 self
:restoreWindow(app
)
138 -- save current window dimension and minimize window
139 function WebBrowser
:saveWindow(app
)
141 app
.winw
= app
.uiWindow
.w
142 app
.winh
= app
.uiWindow
.h
144 app
.uiWindow
.w
= app
.closedw
145 app
.uiWindow
.h
= app
.closedh
148 function WebBrowser
:restoreWindow(app
)
149 if app
.minimized
then
150 app
.uiWindow
.w
= app
.winw
151 app
.uiWindow
.h
= app
.winh
152 app
.minimized
= false
157 ------------------------------------------------------------------------------------------------------------
159 function WebBrowser
:saveWindowPop(app
)
161 app
= self
:findAppFromUiCaller()
167 app
.winw
= app
.uiWindow
.w
168 app
.winh
= app
.uiWindow
.h
169 app
.pop_min_h
= app
.uiWindow
.pop_min_h
170 app
.pop_max_h
= app
.uiWindow
.pop_max_h
171 app
.pop_min_w
= app
.uiWindow
.pop_min_w
173 app
.uiWindow
.w
= app
.closedw
174 app
.uiWindow
.h
= app
.closedh
175 app
.uiWindow
.pop_min_h
= 32
176 app
.uiWindow
.pop_min_w
= app
.closedw
180 ------------------------------------------------------------------------------------------------------------
182 function WebBrowser
:restoreWindowPop(app
)
184 app
= self
:findAppFromUiCaller()
187 if app
and app
.minimized
then
188 app
.uiWindow
.w
= app
.winw
189 app
.uiWindow
.h
= app
.winh
190 if app
.pop_min_h
~= nil then
191 app
.uiWindow
.pop_min_h
= app
.pop_min_h
194 if app
.pop_max_h
~= nil then
195 app
.uiWindow
.pop_max_h
= app
.pop_max_h
198 if app
.pop_min_w
~= nil then
199 app
.uiWindow
.pop_min_w
= app
.pop_min_w
201 app
.minimized
= false
208 function WebBrowser
:onClickRedo()
209 -- caller is :header_opened:browse_redo
210 local uiWindow
= getUICaller().parent
.parent
211 local html
= uiWindow
:find("html")
213 runAH(nil, "browse_redo", "name=" .. html
.id
)
217 function WebBrowser
:onClickUndo()
218 -- caller is :header_opened:browse_undo
219 local uiWindow
= getUICaller().parent
.parent
221 local html
= uiWindow
:find("html")
223 runAH(nil, "browse_undo", "name=" .. html
.id
)
227 function WebBrowser
:onClickRefresh()
228 -- caller is :header_opened:browse_refresh
229 local uiWindow
= getUICaller().parent
.parent
231 local html
= uiWindow
:find("html")
237 function WebBrowser
:onClickHome()
238 -- caller is :header_opened:browse_home
239 local uiWindow
= getUICaller().parent
.parent
241 local html
= uiWindow
:find("html")
248 RYZOM_WEBBROWSER_VERSION
= 10469