00001
00002
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "hugin/HtmlWindow.h"
00028
00029 IMPLEMENT_DYNAMIC_CLASS(HtmlWindow, wxHtmlWindow)
00030
00031 void HtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
00032 {
00033 if (link.GetHref().StartsWith(_T("http://")))
00034 wxLaunchDefaultBrowser(link.GetHref());
00035 else
00036 wxHtmlWindow::OnLinkClicked(link);
00037 }
00038
00039 IMPLEMENT_DYNAMIC_CLASS(HtmlWindowXmlHandler, wxHtmlWindowXmlHandler)
00040
00041 wxObject *HtmlWindowXmlHandler::DoCreateResource()
00042 {
00043 XRC_MAKE_INSTANCE(control, HtmlWindow)
00044
00045 control->Create(m_parentAsWindow,
00046 GetID(),
00047 GetPosition(), GetSize(),
00048 GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO),
00049 GetName());
00050
00051 if (HasParam(wxT("borders")))
00052 {
00053 control->SetBorders(GetDimension(wxT("borders")));
00054 }
00055
00056 if (HasParam(wxT("url")))
00057 {
00058 wxString url = GetParamValue(wxT("url"));
00059 wxFileSystem& fsys = GetCurFileSystem();
00060
00061 wxFSFile *f = fsys.OpenFile(url);
00062 if (f)
00063 {
00064 control->LoadPage(f->GetLocation());
00065 delete f;
00066 }
00067 else
00068 control->LoadPage(url);
00069 }
00070
00071 else if (HasParam(wxT("htmlcode")))
00072 {
00073 control->SetPage(GetText(wxT("htmlcode")));
00074 }
00075
00076 SetupWindow(control);
00077
00078 return control;
00079 }
00080
00081
00082 bool HtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
00083 {
00084 return IsOfClass(node, wxT("HtmlWindow"));
00085 }