1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef GLK_SELECTION_H 24 #define GLK_SELECTION_H 25 26 #include "glk/glk_types.h" 27 #include "glk/utils.h" 28 #include "common/array.h" 29 #include "common/rect.h" 30 #include "common/ustr.h" 31 32 namespace Glk { 33 34 enum ClipSource { PRIMARY = 0, CLIPBOARD = 1 }; 35 36 class Window; 37 38 /** 39 * Acts as interface to and from the system's clipboard storage 40 */ 41 class Clipboard { 42 private: 43 Common::U32String _text; 44 public: 45 /** 46 * Makes a copy of selected text in preparation for the user copying it 47 * to the clpboard 48 */ 49 void clipboardStore(const Common::U32String &text); 50 51 /** 52 * Send previously designated text to the clipboard 53 */ 54 void clipboardSend(ClipSource source); 55 56 /** 57 * Receive text from the clipboard, and paste it into the current window 58 */ 59 void clipboardReceive(ClipSource source); 60 }; 61 62 /** 63 * Manages hyperlinks for the screen 64 */ 65 class WindowMask { 66 private: 67 /** 68 * Clear the links data 69 */ 70 void clear(); 71 public: 72 size_t _hor, _ver; 73 uint **_links; 74 Rect _select; 75 Point _last; 76 public: 77 /** 78 * Constructor 79 */ 80 WindowMask(); 81 82 /** 83 * Destructor 84 */ 85 ~WindowMask(); 86 87 /** 88 * Resize the links array 89 */ 90 void resize(size_t x, size_t y); 91 92 void putHyperlink(uint linkval, uint x0, uint y0, uint x1, uint y1); 93 94 uint getHyperlink(const Point &pos) const; 95 }; 96 97 /** 98 * Overall manager for selecting areas on the screen, copying to/from the clipboard, 99 * and managing hyperlinks 100 */ 101 class Selection : public Clipboard, public WindowMask { 102 public: 103 /** 104 * Start selecting an area of the screen 105 * @param pos Position to start selection area at 106 */ 107 void startSelection(const Point &pos); 108 109 /** 110 * Move the end point of the selection area 111 * @param pos Position to end selection area at 112 */ 113 void moveSelection(const Point &pos); 114 115 /** 116 * Remove any previously selected area 117 */ 118 void clearSelection(); 119 120 /** 121 * Checks whether the passed area intersects the selection area 122 */ 123 bool checkSelection(const Rect &r) const; 124 125 bool getSelection(const Rect &r, int *rx0, int *rx1) const; 126 }; 127 128 } // End of namespace Glk 129 130 #endif 131