Browser 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSGWIDGET_BROWSER
  14. #define OSGWIDGET_BROWSER
  15. #include <osgWidget/PdfReader>
  16. namespace osgWidget {
  17. class BrowserImage;
  18. class OSGWIDGET_EXPORT BrowserManager : public osg::Object
  19. {
  20. public:
  21. static osg::ref_ptr<BrowserManager>& instance();
  22. virtual void init(const std::string& application);
  23. void setApplication(const std::string& application) { _application = application; }
  24. const std::string& getApplication() const { return _application; }
  25. virtual BrowserImage* createBrowserImage(const std::string& url, int width, int height);
  26. protected:
  27. BrowserManager();
  28. BrowserManager(const BrowserManager& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
  29. osg::Object(rhs,copyop) {}
  30. virtual ~BrowserManager();
  31. META_Object(osgWidget,BrowserManager);
  32. std::string _application;
  33. };
  34. /** Pure virtual base class that provides the browser interface for integration with 3rd party implementations.
  35. * Implementations of BrowserImage are provided via the gecko plugin.*/
  36. class BrowserImage : public osg::Image
  37. {
  38. public:
  39. BrowserImage() {}
  40. virtual void navigateTo(const std::string& url) = 0;
  41. protected:
  42. virtual ~BrowserImage() {}
  43. };
  44. /** Convenience class that provides an interactive quad that can be placed directly into the scene.*/
  45. class OSGWIDGET_EXPORT Browser : public osg::Geode
  46. {
  47. public:
  48. Browser() {}
  49. Browser(const std::string& url, const GeometryHints& hints = GeometryHints());
  50. bool assign(BrowserImage* browserImage, const GeometryHints& hints = GeometryHints());
  51. bool open(const std::string& url, const GeometryHints& hints = GeometryHints());
  52. void navigateTo(const std::string& url);
  53. protected:
  54. osg::ref_ptr<BrowserImage> _browserImage;
  55. };
  56. }
  57. #endif