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 * Defines style data for the Concrete GUI. 13 */ 14 public class StyleSheet{ 15 public static const Color[] defaultpaletteforGUI = 16 [Color(0x00,0x00,0x00,0x00),Color(0xFF,0xFF,0xFF,0xFF),Color(0xFF,0x34,0x9e,0xff),Color(0xff,0xa2,0xd7,0xff), 17 Color(0xff,0x00,0x2c,0x59),Color(0xff,0x00,0x75,0xe7),Color(0xff,0xff,0x00,0x00),Color(0xFF,0x7F,0x00,0x00), 18 Color(0xFF,0x00,0xFF,0x00),Color(0xFF,0x00,0x7F,0x00),Color(0xFF,0x00,0x00,0xFF),Color(0xFF,0x00,0x00,0x7F), 19 Color(0xFF,0xFF,0xFF,0x00),Color(0xFF,0xFF,0x7F,0x00),Color(0xFF,0x7F,0x7F,0x7F),Color(0xFF,0x00,0x00,0x00)]; ///Default 16 color palette 20 private Fontset!Bitmap16Bit[string] font; ///Fonts stored here. 21 public ushort[string] color; ///Colors are identified by strings. 22 private Bitmap16Bit[string] images; ///For icons, pattern fills, etc... 23 public int[string] drawParameters; ///Draw parameters are used for border thickness, padding, etc... 24 public string[string] fontTypes; ///Font type descriptions for various kind of components 25 26 /** 27 * Creates a default stylesheet. 28 */ 29 public this(){ 30 color["transparent"] = 0x0000; 31 color["normaltext"] = 0x0001; 32 color["window"] = 0x0002; 33 color["windowascent"] = 0x0003; 34 color["windowdescent"] = 0x0004; 35 color["windowinactive"] = 0x0005; 36 color["selection"] = 0x0006; 37 color["red"] = 0x0006; 38 color["darkred"] = 0x0007; 39 color["green"] = 0x0008; 40 color["darkgreen"] = 0x0009; 41 color["blue"] = 0x000A; 42 color["darkblue"] = 0x000B; 43 color["yellow"] = 0x000C; 44 color["orange"] = 0x000D; 45 color["grey"] = 0x000E; 46 color["black"] = 0x000F; 47 color["white"] = 0x0001; 48 color["PopUpMenuSecondaryTextColor"] = 0x000D; 49 color["MenuBarSeparatorColor"] = 0x000D; 50 51 drawParameters["PopUpMenuHorizPadding"] = 4; 52 drawParameters["PopUpMenuVertPadding"] = 1; 53 drawParameters["PopUpMenuMinTextSpace"] = 8; 54 55 drawParameters["MenuBarHorizPadding"] = 4; 56 drawParameters["MenuBarVertPadding"] = 2; 57 58 drawParameters["ListBoxRowHeight"] = 16; 59 drawParameters["TextSpacingTop"] = 1; 60 drawParameters["TextSpacingBottom"] = 1; 61 drawParameters["WindowLeftPadding"] = 5; 62 drawParameters["WindowRightPadding"] = 5; 63 drawParameters["WindowTopPadding"] = 20; 64 drawParameters["WindowBottomPadding"] = 5; 65 drawParameters["ComponentHeight"] = 20; 66 67 fontTypes["Label"] = "default"; 68 } 69 public void addFontset(Fontset!Bitmap16Bit f, string style){ 70 font[style] = f; 71 } 72 public Fontset!Bitmap16Bit getFontset(string style){ 73 return font.get(style, font["default"]); 74 } 75 public void setColor(ushort c, string colorName){ 76 color[colorName] = c; 77 } 78 public ushort getColor(string colorName){ 79 return color[colorName]; 80 } 81 public void setImage(Bitmap16Bit bitmap, string name){ 82 images[name] = bitmap; 83 } 84 public Bitmap16Bit getImage(string name){ 85 return images.get(name, null); 86 } 87 } 88