| 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 | |
|---|
| 14 | #ifndef OSGWIDGET_BROWSER |
|---|
| 15 | #define OSGWIDGET_BROWSER |
|---|
| 16 | |
|---|
| 17 | #include <osgWidget/PdfReader> |
|---|
| 18 | |
|---|
| 19 | namespace osgWidget { |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | class BrowserImage; |
|---|
| 23 | |
|---|
| 24 | class OSGWIDGET_EXPORT BrowserManager : public osg::Object |
|---|
| 25 | { |
|---|
| 26 | public: |
|---|
| 27 | |
|---|
| 28 | static osg::ref_ptr<BrowserManager>& instance(); |
|---|
| 29 | |
|---|
| 30 | virtual void init(const std::string& application); |
|---|
| 31 | |
|---|
| 32 | void setApplication(const std::string& application) { _application = application; } |
|---|
| 33 | const std::string& getApplication() const { return _application; } |
|---|
| 34 | |
|---|
| 35 | virtual BrowserImage* createBrowserImage(const std::string& url, int width, int height); |
|---|
| 36 | |
|---|
| 37 | protected: |
|---|
| 38 | |
|---|
| 39 | BrowserManager(); |
|---|
| 40 | BrowserManager(const BrowserManager& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): |
|---|
| 41 | osg::Object(rhs,copyop) {} |
|---|
| 42 | |
|---|
| 43 | virtual ~BrowserManager(); |
|---|
| 44 | |
|---|
| 45 | META_Object(osgWidget,BrowserManager); |
|---|
| 46 | |
|---|
| 47 | std::string _application; |
|---|
| 48 | }; |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | /** Pure virtual base class that provides the browser interface for integration with 3rd party implementations. |
|---|
| 52 | * Implementations of BrowserImage are provided via the gecko plugin.*/ |
|---|
| 53 | class BrowserImage : public osg::Image |
|---|
| 54 | { |
|---|
| 55 | public: |
|---|
| 56 | |
|---|
| 57 | BrowserImage() {} |
|---|
| 58 | |
|---|
| 59 | virtual void navigateTo(const std::string& url) = 0; |
|---|
| 60 | |
|---|
| 61 | protected: |
|---|
| 62 | |
|---|
| 63 | virtual ~BrowserImage() {} |
|---|
| 64 | |
|---|
| 65 | }; |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | /** Convenience class that provides an interactive quad that can be placed directly into the scene.*/ |
|---|
| 69 | class OSGWIDGET_EXPORT Browser : public osg::Geode |
|---|
| 70 | { |
|---|
| 71 | public: |
|---|
| 72 | |
|---|
| 73 | Browser() {} |
|---|
| 74 | |
|---|
| 75 | Browser(const std::string& url, const GeometryHints& hints = GeometryHints()); |
|---|
| 76 | |
|---|
| 77 | bool assign(BrowserImage* browserImage, const GeometryHints& hints = GeometryHints()); |
|---|
| 78 | |
|---|
| 79 | bool open(const std::string& url, const GeometryHints& hints = GeometryHints()); |
|---|
| 80 | |
|---|
| 81 | void navigateTo(const std::string& url); |
|---|
| 82 | |
|---|
| 83 | protected: |
|---|
| 84 | |
|---|
| 85 | osg::ref_ptr<BrowserImage> _browserImage; |
|---|
| 86 | }; |
|---|
| 87 | |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | #endif |
|---|