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