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 	///Default color palette. First 16 colors are reserved for GUI defaults in a single workspace, second 16 colors are of the RGBI standard, the rest could
16 	///be used for other GUI elements such as backgrounds and icons
17 	public static enum Color[] defaultpaletteforGUI =
18 	[Color(0x00,0x00,0x00,0x00),	//transparent
19 	Color(0xFF,0xFF,0xFF,0xFF),		//reserved
20 	Color(0xFF,0x77,0x77,0x77),		//window
21 	Color(0xFF,0xCC,0xCC,0xCC),		//windowascent
22 	Color(0xFF,0x33,0x33,0x33),		//windowdescent
23 	Color(0xff,0x22,0x22,0x22),		//windowinactive
24 	Color(0xff,0xff,0x00,0x00),		//selection
25 	Color(0xFF,0x77,0x77,0xFF),		//WHAascent
26 	Color(0xFF,0x00,0x00,0x77),		//WHAdescent
27 	Color(0xFF,0x00,0x00,0xDD),		//WHAtop
28 	Color(0xFF,0x00,0x00,0xFF),		//cursor/selection
29 	Color(0xFF,0x00,0x00,0x7F),		//reserved for windowascentB
30 	Color(0xFF,0xFF,0xFF,0x00),		//reserved
31 	Color(0xFF,0xFF,0x7F,0x00),		//reserved for windowdescentB
32 	Color(0xFF,0x7F,0x7F,0x7F),		//reserved for WHAascentB
33 	Color(0xFF,0x00,0x00,0x00),		//reserved for WHAdescentB
34 
35 	Color(0xFF,0x00,0x00,0x00),		//Black
36 	Color(0xFF,0x7F,0x00,0x00),		//Dark Red
37 	Color(0xFF,0x00,0x7F,0x00),		//Dark Green
38 	Color(0xFF,0x7F,0x7F,0x00),		//Dark Yellow
39 	Color(0xFF,0x00,0x00,0x7F),		//Dark Blue
40 	Color(0xFF,0x7F,0x00,0x7F),		//Dark Purple
41 	Color(0xFF,0x00,0x7F,0x7F),		//Dark Turquiose
42 	Color(0xFF,0x7F,0x7F,0x7F),		//Grey
43 	Color(0xFF,0x3F,0x3F,0x3F),		//Dark Grey
44 	Color(0xFF,0xFF,0x00,0x00),		//Red
45 	Color(0xFF,0x00,0xFF,0x00),		//Green
46 	Color(0xFF,0xFF,0xFF,0x00),		//Yellow
47 	Color(0xFF,0x00,0x00,0xFF),		//Blue
48 	Color(0xFF,0xFF,0x00,0xFF),		//Purple
49 	Color(0xFF,0x00,0xFF,0xFF),		//Turquiose
50 	Color(0xFF,0xFF,0xFF,0xFF),		//White
51 	];
52 	private Fontset!Bitmap8Bit[string] font;		///Fonts stored here.
53 	private ubyte[string] color;		///Colors are identified by strings.
54 	private Bitmap8Bit[string] images;		///For icons, pattern fills, etc...
55 	public int[string] drawParameters;		///Draw parameters are used for border thickness, padding, etc...
56 	public string[string] fontTypes;		///Font type descriptions for various kind of components
57 
58 	/**
59 	 * Creates a default stylesheet.
60 	 */
61 	public this(){
62 		color["transparent"] = 0x0000;
63 		color["normaltext"] = 0x001F;
64 		color["window"] = 0x0002;
65 		color["windowascent"] = 0x0003;
66 		color["windowdescent"] = 0x0004;
67 		color["windowinactive"] = 0x0005;
68 		color["selection"] = 0x0006;
69 		color["red"] = 0x0006;
70 		color["WHAascent"] = 0x0007;
71 		color["WHAdescent"] = 0x0008;
72 		color["WHTextActive"] = 0x001F;
73 		color["WHTextInactive"] = 0x0010;
74 		color["WHAtop"] = 0x0009;
75 		color["blue"] = 0x000A;
76 		color["darkblue"] = 0x000B;
77 		color["yellow"] = 0x000C;
78 		color["secondarytext"] = 0x001B;
79 		color["grey"] = 0x000E;
80 		color["black"] = 0x000F;
81 		color["white"] = 0x0001;
82 		color["PopUpMenuSecondaryTextColor"] = 0x001B;
83 		color["MenuBarSeparatorColor"] = 0x001F;
84 
85 		drawParameters["PopUpMenuHorizPadding"] = 4;
86 		drawParameters["PopUpMenuVertPadding"] = 1;
87 		drawParameters["PopUpMenuMinTextSpace"] = 8;
88 
89 		drawParameters["MenuBarHorizPadding"] = 4;
90 		drawParameters["MenuBarVertPadding"] = 2;
91 
92 		drawParameters["ListBoxRowHeight"] = 16;
93 		drawParameters["TextSpacingTop"] = 1;
94 		drawParameters["TextSpacingBottom"] = 1;
95 		drawParameters["WindowLeftPadding"] = 5;
96 		drawParameters["WindowRightPadding"] = 5;
97 		drawParameters["WindowTopPadding"] = 20;
98 		drawParameters["WindowBottomPadding"] = 5;
99 		drawParameters["ComponentHeight"] = 20;
100 		drawParameters["WindowHeaderHeight"] = 16;
101 	}
102 	public void addFontset(Fontset!Bitmap8Bit f, string style){
103 		font[style] = f;
104 	}
105 	public Fontset!Bitmap8Bit getFontset(string style){
106 		return font.get(fontTypes.get(style, style), font[fontTypes["default"]]);
107 	}
108 	public void setColor(ubyte c, string colorName){
109 		color[colorName] = c;
110 	}
111 	public ubyte getColor(string colorName){
112 		return color[colorName];
113 	}
114 	public void setImage(Bitmap8Bit bitmap, string name){
115 		images[name] = bitmap;
116 	}
117 	public Bitmap8Bit getImage(string name){
118 		return images.get(name, null);
119 	}
120 }
121