| 1 | // Clipboard access for Nasal |
| 2 | // |
| 3 | // Copyright (C) 2012 Thomas Geymayer <[email protected]> |
| 4 | // |
| 5 | // This program is free software; you can redistribute it and/or |
| 6 | // modify it under the terms of the GNU General Public License as |
| 7 | // published by the Free Software Foundation; either version 2 of the |
| 8 | // License, or (at your option) any later version. |
| 9 | // |
| 10 | // This program is distributed in the hope that it will be useful, but |
| 11 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | // General Public License for more details. |
| 14 | // |
| 15 | // You should have received a copy of the GNU General Public License |
| 16 | // along with this program; if not, write to the Free Software |
| 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | |
| 19 | #ifndef NASAL_CLIPOARD_HXX_ |
| 20 | #define NASAL_CLIPOARD_HXX_ |
| 21 | |
| 22 | #include <simgear/nasal/nasal.h> |
| 23 | #include <memory> |
| 24 | #include <string> |
| 25 | |
| 26 | class FGNasalSys; |
| 27 | class NasalClipboard |
| 28 | { |
| 29 | public: |
| 30 | |
| 31 | enum Type |
| 32 | { |
| 33 | /// Standard clipboard as supported by nearly all operating systems |
| 34 | CLIPBOARD, |
| 35 | |
| 36 | /// X11 platforms support also a mode called PRIMARY selection which |
| 37 | /// contains the current (mouse) selection and can typically be inserted |
| 38 | /// via a press on the middle mouse button |
| 39 | PRIMARY |
| 40 | }; |
| 41 | |
| 42 | typedef std::shared_ptr<NasalClipboard> Ptr; |
| 43 | |
| 44 | virtual void update() {} |
| 45 | virtual std::string getText(Type type = CLIPBOARD) = 0; |
| 46 | virtual bool setText( const std::string& text, |
| 47 | Type type = CLIPBOARD ) = 0; |
| 48 | |
| 49 | /** |
| 50 | * Sets up the clipboard and puts all the extension functions into a new |
| 51 | * "clipboard" namespace. |
| 52 | */ |
| 53 | static void init(FGNasalSys *nasal); |
| 54 | |
| 55 | /** |
| 56 | * Get clipboard platform specific instance |
| 57 | */ |
| 58 | static Ptr getInstance(); |
| 59 | |
| 60 | protected: |
| 61 | |
| 62 | static Ptr _clipboard; |
| 63 | |
| 64 | /** |
| 65 | * Implementation supplied by actual platform implementation |
| 66 | */ |
| 67 | static Ptr create(); |
| 68 | |
| 69 | virtual ~NasalClipboard() = 0; |
| 70 | }; |
| 71 | |
| 72 | #endif /* NASAL_CLIPOARD_HXX_ */ |