1 /* 2 * Copyright (C) 2015-2017, by Laszlo Szeremi under the Boost license. 3 * 4 * Pixel Perfect Engine, concrete.stylesheet module 5 */ 6 7 module PixelPerfectEngine.concrete.stylesheet; 8 9 import PixelPerfectEngine.graphics.bitmap; 10 import PixelPerfectEngine.graphics.fontsets; 11 12 public class StyleSheet{ 13 public static const ubyte[64] defaultpaletteforGUI = 14 [0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0x34,0x9e,0xff, 0xff,0xa2,0xd7,0xff, 15 0xff,0x00,0x2c,0x59, 0xff,0x00,0x75,0xe7, 0xff,0xff,0x00,0x00, 0xFF,0x7F,0x00,0x00, 16 0xFF,0x00,0xFF,0x00, 0xFF,0x00,0x7F,0x00, 0xFF,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x7F, 17 0xFF,0xFF,0xFF,0x00, 0xFF,0xFF,0x7F,0x00, 0xFF,0x7F,0x7F,0x7F, 0xFF,0x00,0x00,0x00]; 18 private Fontset[string] font; 19 private ushort[string] color; 20 private Bitmap16Bit[string] images; ///For icons, pattern fills, etc... 21 22 /** 23 * Creates a default stylesheet. Only uses the first 7 colors (0-6 or 0x0000-0x0006). 24 */ 25 public this(){ 26 color["transparent"] = 0x0000; 27 color["normaltext"] = 0x0001; 28 color["window"] = 0x0002; 29 color["windowascent"] = 0x0003; 30 color["windowdescent"] = 0x0004; 31 color["windowinactive"] = 0x0005; 32 color["selection"] = 0x0006; 33 /*color["red"] = 0x0006; 34 color["darkred"] = 0x0007; 35 color["green"] = 0x0008; 36 color["darkgreen"] = 0x0009; 37 color["blue"] = 0x000A; 38 color["darkblue"] = 0x000B; 39 color["yellow"] = 0x000C; 40 color["orange"] = 0x000D; 41 color["grey"] = 0x000E; 42 color["black"] = 0x000F; 43 color["white"] = 0x0000;*/ 44 } 45 public void addFontset(Fontset f, string style){ 46 font[style] = f; 47 } 48 public Fontset getFontset(string style){ 49 return font.get(style, font["default"]); 50 } 51 public void setColor(ushort c, string colorName){ 52 color[colorName] = c; 53 } 54 public ushort getColor(string colorName){ 55 return color[colorName]; 56 } 57 public void setImage(Bitmap16Bit bitmap, string name){ 58 images[name] = bitmap; 59 } 60 public Bitmap16Bit getImage(string name){ 61 return images.get(name, null); 62 } 63 } 64