Mercurial > projects > dynamin
comparison dynamin/gui/windows_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 |
comparison
equal
deleted
inserted
replaced
105:97997a544ac0 | 106:acdbb30fee7e |
---|---|
12 | 12 |
13 import dynamin.c.windows; | 13 import dynamin.c.windows; |
14 import Utf = tango.text.convert.Utf; | 14 import Utf = tango.text.convert.Utf; |
15 | 15 |
16 template ClipboardBackend() { | 16 template ClipboardBackend() { |
17 void backend_setText(string text) { | 17 void backend_setText(cstring text) { |
18 if(!OpenClipboard(msgWnd)) | 18 if(!OpenClipboard(msgWnd)) |
19 return; | 19 return; |
20 EmptyClipboard(); | 20 EmptyClipboard(); |
21 auto wtext = Utf.toString16(text); | 21 auto wtext = Utf.toString16(text); |
22 HGLOBAL hmem = GlobalAlloc(GMEM_MOVEABLE, (wtext.length+1)*wchar.sizeof); | 22 HGLOBAL hmem = GlobalAlloc(GMEM_MOVEABLE, (wtext.length+1)*wchar.sizeof); |
25 data[wtext.length] = 0; | 25 data[wtext.length] = 0; |
26 GlobalUnlock(hmem); | 26 GlobalUnlock(hmem); |
27 SetClipboardData(CF_UNICODETEXT, data); | 27 SetClipboardData(CF_UNICODETEXT, data); |
28 CloseClipboard(); | 28 CloseClipboard(); |
29 } | 29 } |
30 string backend_getText() { | 30 mstring backend_getText() { |
31 if(!OpenClipboard(msgWnd)) | 31 if(!OpenClipboard(msgWnd)) |
32 return null; | 32 return null; |
33 wchar* data = cast(wchar*)GetClipboardData(CF_UNICODETEXT); | 33 wchar* data = cast(wchar*)GetClipboardData(CF_UNICODETEXT); |
34 CloseClipboard(); | 34 CloseClipboard(); |
35 if(data is null) | 35 if(data is null) |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 // Windows only has one clipboard | 49 // Windows only has one clipboard |
50 template SelectionBackend() { | 50 template SelectionBackend() { |
51 void backend_setText(string text) { | 51 void backend_setText(cstring text) { |
52 } | 52 } |
53 string backend_getText() { | 53 mstring backend_getText() { |
54 return null; | 54 return null; |
55 } | 55 } |
56 bool backend_containsText() { | 56 bool backend_containsText() { |
57 return false; | 57 return false; |
58 } | 58 } |