1 module pixelperfectengine.concrete.elements.smallbutton;
2 
3 public import pixelperfectengine.concrete.elements.base;
4 
5 public class SmallButton : WindowElement, ISmallButton {
6 	public string			iconPressed, iconUnpressed;
7 	private bool			_isPressed;
8 	//protected IRadioButtonGroup		radioButtonGroup;	//If set, the element works like a radio button
9 
10 	//public int brushPressed, brushNormal;
11 
12 	public this(string iconPressed, string iconUnpressed, string source, Box position){
13 		this.position = position;
14 
15 		//this.text = text;
16 		this.source = source;
17 		this.iconPressed = iconPressed;
18 		this.iconUnpressed = iconUnpressed;
19 		
20 		
21 	}
22 	public override void draw(){
23 		StyleSheet ss = getStyleSheet();
24 		Bitmap8Bit icon = isPressed ? ss.getImage(iconPressed) : ss.getImage(iconUnpressed);
25 		parent.bitBLT(position.cornerUL, icon);
26 		Box pos = position;
27 		pos.bottom--;
28 		pos.right--;
29 		if (isFocused) {
30 			const int textPadding = ss.drawParameters["horizTextPadding"];
31 			parent.drawBoxPattern(pos - textPadding, ss.pattern["blackDottedLine"]);
32 		}
33 
34 		if (state == ElementState.Disabled) {
35 			parent.bitBLTPattern(pos, ss.getImage("ElementDisabledPtrn"));
36 		}
37 		if (onDraw !is null) {
38 			onDraw();
39 		}
40 	}
41 	public bool isSmallButtonHeight(int height) {
42 		if (position.width == height && position.height == height) return true;
43 		else return false;
44 	}
45 	///Returns true if left side justified, false otherwise.
46 	public bool isLeftSide() @nogc @safe pure nothrow const {
47 		return flags & IS_LHS ? true : false;
48 	}
49 	///Sets the small button to the left side if true.
50 	public bool isLeftSide(bool val) @nogc @safe pure nothrow {
51 		if (val) flags |= IS_LHS;
52 		else flags &= ~IS_LHS;
53 		return flags & IS_LHS ? true : false;
54 	}
55 }