Mercurial > projects > dwt-samples
annotate examples/texteditor/Images.d @ 179:89de7ff0752c default tip
Add JFace snippet Snippet054NativeControlsInViewers, thanks to WasserDragoon
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 29 Apr 2009 11:01:41 +0200 |
parents | 7248e4c09c4f |
children |
rev | line source |
---|---|
78 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2005 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Thomas Graber <d4rkdragon@gmail.com> | |
12 *******************************************************************************/ | |
144
7248e4c09c4f
Fix: make TextEditor not using the tango.util.collection
Frank Benoit <benoit@tionex.de>
parents:
80
diff
changeset
|
13 module texteditor.Images; |
78 | 14 |
15 import dwt.dwthelper.InputStream; | |
16 | |
17 import dwt.graphics.Image; | |
18 import dwt.graphics.ImageData; | |
19 import dwt.widgets.Display; | |
20 import dwt.dwthelper.ByteArrayInputStream; | |
21 | |
22 import tango.core.Exception; | |
23 import tango.io.Stdout; | |
24 | |
25 public class Images { | |
26 | |
27 // Bitmap Images | |
28 public Image Bold; | |
29 public Image Italic; | |
30 public Image Underline; | |
31 public Image Strikeout; | |
32 public Image Red; | |
33 public Image Green; | |
34 public Image Blue; | |
35 public Image Erase; | |
36 | |
37 Image[] AllBitmaps; | |
38 | |
39 this () { | |
40 } | |
41 | |
42 public void freeAll () { | |
43 for (int i=0; i<AllBitmaps.length; i++) AllBitmaps [i].dispose (); | |
44 AllBitmaps = null; | |
45 } | |
46 | |
47 Image createBitmapImage(Display display, void[] iImage, void[] iMask) { | |
48 InputStream sourceStream = new ByteArrayInputStream(cast(byte[]) iImage); | |
49 InputStream maskStream = new ByteArrayInputStream(cast(byte[])iMask ); | |
50 | |
51 ImageData source = new ImageData (sourceStream); | |
52 ImageData mask = new ImageData (maskStream); | |
53 Image result = new Image (null, source, mask); | |
54 try { | |
55 sourceStream.close (); | |
56 maskStream.close (); | |
57 } catch (IOException e) { | |
58 Stderr.formatln( "Stacktrace: {}", e.toString ); | |
59 } | |
60 return result; | |
61 } | |
62 | |
63 public void loadAll (Display display) { | |
64 // Bitmap Images | |
80 | 65 Bold = createBitmapImage (display, import( "examples.texteditor.bold.bmp" ), import( "examples.texteditor.bold_mask.bmp" )); |
66 Italic = createBitmapImage (display, import( "examples.texteditor.italic.bmp" ), import( "examples.texteditor.italic_mask.bmp" )); | |
67 Underline = createBitmapImage (display, import( "examples.texteditor.underline.bmp" ), import( "examples.texteditor.underline_mask.bmp" )); | |
68 Strikeout = createBitmapImage (display, import( "examples.texteditor.strikeout.bmp" ), import( "examples.texteditor.strikeout_mask.bmp" )); | |
69 Red = createBitmapImage (display, import( "examples.texteditor.red.bmp" ), import( "examples.texteditor.red_mask.bmp" )); | |
70 Green = createBitmapImage (display, import( "examples.texteditor.green.bmp" ), import( "examples.texteditor.green_mask.bmp" )); | |
71 Blue = createBitmapImage (display, import( "examples.texteditor.blue.bmp" ), import( "examples.texteditor.blue_mask.bmp" )); | |
72 Erase = createBitmapImage (display, import( "examples.texteditor.erase.bmp" ), import( "examples.texteditor.erase_mask.bmp" )); | |
78 | 73 |
74 AllBitmaps = [ Bold, | |
75 Italic, | |
76 Underline, | |
77 Strikeout, | |
78 Red, | |
79 Green, | |
80 Blue, | |
81 Erase | |
82 ]; | |
83 } | |
84 } |