Mercurial > projects > dwt-samples
annotate dwtexamples/texteditor/Images.d @ 65:a84ba4d1820f
restructure the dsss.conf and resources
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 11 Apr 2008 21:15:36 +0200 |
parents | f9c0133912fc |
children |
rev | line source |
---|---|
16 | 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 *******************************************************************************/ | |
13 module dwtexamples.texteditor.Images; | |
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; | |
65
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
36 |
16 | 37 Image[] AllBitmaps; |
65
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
38 |
16 | 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 | |
65
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
47 Image createBitmapImage(Display display, void[] iImage, void[] iMask) { |
16 | 48 InputStream sourceStream = new ByteArrayInputStream(cast(byte[]) iImage); |
65
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
49 InputStream maskStream = new ByteArrayInputStream(cast(byte[])iMask ); |
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
50 |
16 | 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 } | |
65
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
62 |
16 | 63 public void loadAll (Display display) { |
64 // Bitmap Images | |
65
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
65 Bold = createBitmapImage (display, import( "dwtexamples.texteditor.bold.bmp" ), import( "dwtexamples.texteditor.bold_mask.bmp" )); |
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
66 Italic = createBitmapImage (display, import( "dwtexamples.texteditor.italic.bmp" ), import( "dwtexamples.texteditor.italic_mask.bmp" )); |
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
67 Underline = createBitmapImage (display, import( "dwtexamples.texteditor.underline.bmp" ), import( "dwtexamples.texteditor.underline_mask.bmp" )); |
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
68 Strikeout = createBitmapImage (display, import( "dwtexamples.texteditor.strikeout.bmp" ), import( "dwtexamples.texteditor.strikeout_mask.bmp" )); |
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
69 Red = createBitmapImage (display, import( "dwtexamples.texteditor.red.bmp" ), import( "dwtexamples.texteditor.red_mask.bmp" )); |
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
70 Green = createBitmapImage (display, import( "dwtexamples.texteditor.green.bmp" ), import( "dwtexamples.texteditor.green_mask.bmp" )); |
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
71 Blue = createBitmapImage (display, import( "dwtexamples.texteditor.blue.bmp" ), import( "dwtexamples.texteditor.blue_mask.bmp" )); |
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
72 Erase = createBitmapImage (display, import( "dwtexamples.texteditor.erase.bmp" ), import( "dwtexamples.texteditor.erase_mask.bmp" )); |
a84ba4d1820f
restructure the dsss.conf and resources
Frank Benoit <benoit@tionex.de>
parents:
16
diff
changeset
|
73 |
16 | 74 AllBitmaps = [ Bold, |
75 Italic, | |
76 Underline, | |
77 Strikeout, | |
78 Red, | |
79 Green, | |
80 Blue, | |
81 Erase | |
82 ]; | |
83 } | |
84 } |