Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HtmlWindow.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
11 /* This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This software is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public
22  * License along with this software. If not, see
23  * <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifdef _WIN32
28 #include "wx/msw/wrapwin.h"
29  // Mingw define still DIFFERENCE, which conflicts with vigra, so disable it
30 #undef DIFFERENCE
31 #endif
32 #include "hugin/HtmlWindow.h"
33 
35 
36 void HtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
37 {
38  if (link.GetHref().StartsWith(_T("http://")))
39  wxLaunchDefaultBrowser(link.GetHref());
40  else
41  wxHtmlWindow::OnLinkClicked(link);
42 }
43 
44 IMPLEMENT_DYNAMIC_CLASS(HtmlWindowXmlHandler, wxHtmlWindowXmlHandler)
45 
46 wxObject *HtmlWindowXmlHandler::DoCreateResource()
47 {
48  XRC_MAKE_INSTANCE(control, HtmlWindow)
49 
50  control->Create(m_parentAsWindow,
51  GetID(),
52  GetPosition(), GetSize(),
53  GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO),
54  GetName());
55 
56  if (HasParam(wxT("borders")))
57  {
58  control->SetBorders(GetDimension(wxT("borders")));
59  }
60 
61  if (HasParam(wxT("url")))
62  {
63  wxString url = GetParamValue(wxT("url"));
64  wxFileSystem& fsys = GetCurFileSystem();
65 
66  wxFSFile *f = fsys.OpenFile(url);
67  if (f)
68  {
69  control->LoadPage(f->GetLocation());
70  delete f;
71  }
72  else
73  control->LoadPage(url);
74  }
75 
76  else if (HasParam(wxT("htmlcode")))
77  {
78  control->SetPage(GetText(wxT("htmlcode")));
79  }
80 
81  SetupWindow(control);
82 
83  return control;
84 }
85 
86 
87 bool HtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
88 {
89  return IsOfClass(node, wxT("HtmlWindow"));
90 }
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
Modified wxHtmlWindow for open external links.
Definition: HtmlWindow.h:43
virtual bool CanHandle(wxXmlNode *node)
Internal use to identify right xml handler.
Definition: HtmlWindow.cpp:87
xrc handler for HTMLWindow
Definition: HtmlWindow.h:53
Definition of HTMLWindow class which supports opening external links in default web browser...