Mercurial > projects > dwt-samples
comparison examples/clipboard/ClipboardExample.d @ 109:be3a48f1d596
ClipboardExample: reactivate comment functionality and fixed a bug.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 14:21:59 +0200 |
parents | 4a04b6759f98 |
children | 698e70d0dca3 |
comparison
equal
deleted
inserted
replaced
108:d4e3f8db85f0 | 109:be3a48f1d596 |
---|---|
42 import dwt.widgets.TableItem; | 42 import dwt.widgets.TableItem; |
43 import dwt.widgets.Text; | 43 import dwt.widgets.Text; |
44 import dwt.dwthelper.utils; | 44 import dwt.dwthelper.utils; |
45 | 45 |
46 import tango.io.Stdout; | 46 import tango.io.Stdout; |
47 version(JIVE) import jive.stacktrace; | |
47 | 48 |
48 class ClipboardExample { | 49 class ClipboardExample { |
49 static const int SIZE = 60; | 50 static const int SIZE = 60; |
50 Clipboard clipboard; | 51 Clipboard clipboard; |
51 Shell shell; | 52 Shell shell; |
90 data = new GridData(GridData.FILL_BOTH); | 91 data = new GridData(GridData.FILL_BOTH); |
91 data.horizontalSpan = 2; | 92 data.horizontalSpan = 2; |
92 controlGroup.setLayoutData(data); | 93 controlGroup.setLayoutData(data); |
93 controlGroup.setLayout(new GridLayout(5, false)); | 94 controlGroup.setLayout(new GridLayout(5, false)); |
94 | 95 |
95 /* Enable with Available Types * | 96 /* Enable with Available Types */ |
96 Group typesGroup = new Group(parent, DWT.NONE); | 97 Group typesGroup = new Group(parent, DWT.NONE); |
97 typesGroup.setText("Available Types"); | 98 typesGroup.setText("Available Types"); |
98 data = new GridData(GridData.FILL_BOTH); | 99 data = new GridData(GridData.FILL_BOTH); |
99 data.horizontalSpan = 2; | 100 data.horizontalSpan = 2; |
100 typesGroup.setLayoutData(data); | 101 typesGroup.setLayoutData(data); |
106 data.horizontalSpan = 2; | 107 data.horizontalSpan = 2; |
107 data.heightHint = 60; | 108 data.heightHint = 60; |
108 status.setLayoutData(data); | 109 status.setLayoutData(data); |
109 | 110 |
110 createTextTransfer(copyGroup, pasteGroup); | 111 createTextTransfer(copyGroup, pasteGroup); |
111 //TODO: Doesn't work | 112 createRTFTransfer(copyGroup, pasteGroup); |
112 // createRTFTransfer(copyGroup, pasteGroup); | |
113 createHTMLTransfer(copyGroup, pasteGroup); | 113 createHTMLTransfer(copyGroup, pasteGroup); |
114 //TODO: Doesn't work | 114 createFileTransfer(copyGroup, pasteGroup); |
115 // createFileTransfer(copyGroup, pasteGroup); | |
116 createMyTransfer(copyGroup, pasteGroup); | 115 createMyTransfer(copyGroup, pasteGroup); |
117 createControlTransfer(controlGroup); | 116 createControlTransfer(controlGroup); |
118 //TODO: Causes Segfault | 117 createAvailableTypes(typesGroup); |
119 // createAvailableTypes(typesGroup); | |
120 | 118 |
121 sc.setMinSize(parent.computeSize(DWT.DEFAULT, DWT.DEFAULT)); | 119 sc.setMinSize(parent.computeSize(DWT.DEFAULT, DWT.DEFAULT)); |
122 sc.setExpandHorizontal(true); | 120 sc.setExpandHorizontal(true); |
123 sc.setExpandVertical(true); | 121 sc.setExpandVertical(true); |
124 | 122 |
297 FileDialog dialog = new FileDialog(shell, DWT.OPEN | DWT.MULTI); | 295 FileDialog dialog = new FileDialog(shell, DWT.OPEN | DWT.MULTI); |
298 auto result = dialog.open(); | 296 auto result = dialog.open(); |
299 if (result !is null && result.length > 0){ | 297 if (result !is null && result.length > 0){ |
300 //copyFileTable.removeAll(); | 298 //copyFileTable.removeAll(); |
301 //This cannot be used | 299 //This cannot be used |
302 //auto separator = System.getProperty("file.separator"); | 300 auto separator = tango.io.model.IFile.FileConst.PathSeparatorString; |
303 version(linux) { | |
304 auto separator = "/"; | |
305 } | |
306 version(Windows) { | |
307 auto separator = "\\"; | |
308 } | |
309 auto path = dialog.getFilterPath(); | 301 auto path = dialog.getFilterPath(); |
310 auto names = dialog.getFileNames(); | 302 auto names = dialog.getFileNames(); |
311 for (int i = 0; i < names.length; i++) { | 303 for (int i = 0; i < names.length; i++) { |
312 TableItem item = new TableItem(copyFileTable, DWT.NONE); | 304 TableItem item = new TableItem(copyFileTable, DWT.NONE); |
313 item.setText(path~separator~names[i]); | 305 item.setText(path~separator~names[i]); |
460 styledText = new StyledText(parent, DWT.BORDER | DWT.MULTI | DWT.H_SCROLL | DWT.V_SCROLL); | 452 styledText = new StyledText(parent, DWT.BORDER | DWT.MULTI | DWT.H_SCROLL | DWT.V_SCROLL); |
461 data = new GridData(GridData.FILL_HORIZONTAL); | 453 data = new GridData(GridData.FILL_HORIZONTAL); |
462 data.heightHint = data.widthHint = SIZE; | 454 data.heightHint = data.widthHint = SIZE; |
463 styledText.setLayoutData(data); | 455 styledText.setLayoutData(data); |
464 } | 456 } |
457 | |
458 List list; | |
465 void createAvailableTypes(Composite parent){ | 459 void createAvailableTypes(Composite parent){ |
466 final List list = new List(parent, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL); | 460 list = new List(parent, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL); |
467 GridData data = new GridData(GridData.FILL_BOTH); | 461 GridData data = new GridData(GridData.FILL_BOTH); |
468 data.heightHint = 100; | 462 data.heightHint = 100; |
469 list.setLayoutData(data); | 463 list.setLayoutData(data); |
470 Button b = new Button(parent, DWT.PUSH); | 464 Button b = new Button(parent, DWT.PUSH); |
471 b.setText("Get Available Types"); | 465 b.setText("Get Available Types"); |
479 } | 473 } |
480 }); | 474 }); |
481 } | 475 } |
482 } | 476 } |
483 void main() { | 477 void main() { |
484 Stdout.formatln( "The ClipboardExample: still work left" ); | |
485 Stdout.formatln( "todo: RTF, File Transfer, Available types"); | |
486 Stdout.formatln( "line 300, there might be a better way to do" ); | |
487 Stdout.formatln( "system independent path seperators in tango" ); | |
488 Stdout.formatln( "" ); | |
489 | |
490 | |
491 Display display = new Display(); | 478 Display display = new Display(); |
492 (new ClipboardExample()).open(display); | 479 (new ClipboardExample()).open(display); |
493 display.dispose(); | 480 display.dispose(); |
494 } | 481 } |
495 | 482 |