Mercurial > projects > dynamin
annotate dynamin/gui/clipboard.d @ 106:acdbb30fee7e
Port to D2.
Most of the effort was dealing with immutable and const.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Mon, 17 Dec 2012 23:41:50 -0600 |
parents | 73060bc3f004 |
children |
rev | line source |
---|---|
0 | 1 |
2 /* | |
103
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
3 * Copyright Jordan Miner |
0 | 4 * |
103
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
5 * This Source Code Form is subject to the terms of the Mozilla Public |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
6 * License, v. 2.0. If a copy of the MPL was not distributed with this |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
0 | 8 * |
9 */ | |
10 | |
11 module dynamin.gui.clipboard; | |
12 | |
13 import dynamin.core.string; | |
14 import dynamin.gui.window; | |
15 import dynamin.gui_backend; | |
16 import tango.io.Stdout; | |
17 | |
18 /* | |
19 * Goals of this class: | |
20 * - Allow copying and pasting of plain text, 32 bpp images, file lists, | |
21 * formatted text, and user defined data | |
22 * - As this does not depend on the audio classes, copying audio data should | |
23 * be handled in the audio code. | |
24 */ | |
25 /// | |
26 static class Clipboard { | |
27 static: | |
28 private: | |
29 mixin ClipboardBackend; | |
30 public: | |
31 /** | |
32 * This event occurs after the data on clipboard has been changed. | |
33 * Note: This event will not always be fired when the data on the clipboard | |
34 * changes, as some backends have no way of being notified of such an event. | |
35 */ | |
36 //Event!() DataChanged; | |
37 static this() { | |
38 //DataChanged = new Event!()(null); | |
39 } | |
40 | |
41 /** | |
42 * Sets the data on the clipboard to the specified _text. | |
43 */ | |
106 | 44 void setText(cstring text) { |
0 | 45 backend_setText(text); |
46 } | |
47 alias setText copyText; | |
48 /** | |
49 * Gets text from the clipboard. If the clipboard does not have any text | |
50 * or has an empty string, null is returned. | |
51 */ | |
106 | 52 mstring getText() { |
0 | 53 return backend_getText(); |
54 } | |
55 alias getText pasteText; | |
56 // TODO: don't need this? | |
57 bool containsText() { | |
58 return backend_containsText(); | |
59 } | |
60 | |
61 } | |
62 | |
63 /** | |
64 * On the X window system, this holds the current selection. Whenever the | |
65 * selection is changed in a program, X's selection should be updated using | |
66 * this class. | |
67 * On Windows, this class does not do anything. | |
68 * | |
69 * See the Clipboard documentation for a description of the functionality | |
70 * of this class. | |
71 */ | |
72 static class Selection { | |
73 static: | |
74 private: | |
75 mixin SelectionBackend; | |
76 public: | |
77 /// | |
106 | 78 void setText(cstring text) { |
0 | 79 backend_setText(text); |
80 } | |
81 /// | |
106 | 82 mstring getText() { |
0 | 83 return backend_getText(); |
84 } | |
85 /// | |
86 bool containsText() { | |
87 return backend_containsText(); | |
88 } | |
89 } | |
90 |