HtmlWindow.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00011 /*  This program is free software; you can redistribute it and/or
00012  *  modify it under the terms of the GNU General Public
00013  *  License as published by the Free Software Foundation; either
00014  *  version 2 of the License, or (at your option) any later version.
00015  *
00016  *  This software is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  *  General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public
00022  *  License along with this software; if not, write to the Free Software
00023  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 }

Generated on 30 Oct 2014 for Hugintrunk by  doxygen 1.4.7