home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2233.zip / wxOS2-2_3_3.zip / wxWindows-2.3.3 / contrib / src / xrc / xh_html.cpp < prev    next >
C/C++ Source or Header  |  2001-12-31  |  2KB  |  84 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name:        xh_html.cpp
  3. // Purpose:     XRC resource for wxHtmlWindow
  4. // Author:      Bob Mitchell
  5. // Created:     2000/03/21
  6. // RCS-ID:      $Id: xh_html.cpp,v 1.5 2001/12/29 16:14:04 VS Exp $
  7. // Copyright:   (c) 2000 Bob Mitchell and Verant Interactive
  8. // Licence:     wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10.  
  11. #ifdef __GNUG__
  12. #pragma implementation "xh_html.h"
  13. #endif
  14.  
  15. // For compilers that support precompilation, includes "wx.h".
  16. #include "wx/wxprec.h"
  17.  
  18. #ifdef __BORLANDC__
  19.     #pragma hdrstop
  20. #endif
  21.  
  22. #include "wx/xrc/xh_html.h"
  23.  
  24. #if wxUSE_HTML
  25.  
  26. #include "wx/html/htmlwin.h"
  27. #include "wx/filesys.h"
  28.  
  29.  
  30. wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() 
  31. : wxXmlResourceHandler() 
  32. {
  33.     XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER);
  34.     XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO);
  35.     AddWindowStyles();
  36. }
  37.  
  38. wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
  39. {
  40.     XRC_MAKE_INSTANCE(control, wxHtmlWindow)
  41.  
  42.     control->Create(m_parentAsWindow,
  43.                     GetID(),
  44.                     GetPosition(), GetSize(),
  45.                     GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO),
  46.                     GetName());
  47.  
  48.     if (HasParam(wxT("borders")))
  49.     {
  50.         control->SetBorders(GetDimension(wxT("borders")));
  51.     }
  52.  
  53.     if (HasParam(wxT("url")))
  54.     {
  55.         wxString url = GetParamValue(wxT("url"));
  56.         wxFileSystem& fsys = GetCurFileSystem();
  57.         
  58.         wxFSFile *f = fsys.OpenFile(url);
  59.         if (f)
  60.         {
  61.             control->LoadPage(f->GetLocation());
  62.             delete f;
  63.         }
  64.         else
  65.             control->LoadPage(url);
  66.     }
  67.     
  68.     else if (HasParam(wxT("htmlcode")))
  69.     {
  70.         control->SetPage(GetText(wxT("htmlcode")));
  71.     }
  72.  
  73.     SetupWindow(control);
  74.     
  75.     return control;
  76. }
  77.  
  78. bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
  79. {
  80.     return IsOfClass(node, wxT("wxHtmlWindow"));
  81. }
  82.  
  83. #endif // wxUSE_HTML
  84.