1 module PixelPerfectEngine.concrete.elements.button; 2 3 public import PixelPerfectEngine.concrete.elements.base; 4 5 public class Button : WindowElement { 6 private bool isPressed; 7 public bool enableRightButtonClick; 8 public bool enableMiddleButtonClick; 9 public this(dstring text, string source, Box position) { 10 this(new Text(text,getStyleSheet.getChrFormatting("button")), source, position); 11 } 12 public this(Text text, string source, Box position) { 13 this.position = position; 14 this.text = text; 15 this.source = source; 16 //output = new BitmapDrawer(coordinates.width, coordinates.height); 17 } 18 public override void draw() { 19 StyleSheet ss = getStyleSheet(); 20 parent.clearArea(position); 21 if (isPressed) { 22 /+output.drawFilledRectangle(1, position.width()-1, 1,position.height()-1, getAvailableStyleSheet().getColor("windowinactive")); 23 output.drawLine(0, position.width()-1, 0, 0, getAvailableStyleSheet().getColor("windowdescent")); 24 output.drawLine(0, 0, 0, position.height()-1, getAvailableStyleSheet().getColor("windowdescent")); 25 output.drawLine(0, position.width()-1, position.height()-1, position.height()-1, getAvailableStyleSheet().getColor("windowascent")); 26 output.drawLine(position.width()-1, position.width()-1, 0, position.height()-1, getAvailableStyleSheet().getColor("windowascent"));+/ 27 with (parent) { 28 drawFilledBox(position, ss.getColor("windowinactive")); 29 drawLine(position.cornerUL, position.cornerUR, ss.getColor("windowdescent")); 30 drawLine(position.cornerUL, position.cornerLL, ss.getColor("windowdescent")); 31 drawLine(position.cornerLL, position.cornerLR, ss.getColor("windowascent")); 32 drawLine(position.cornerUR, position.cornerLR, ss.getColor("windowascent")); 33 } 34 } else { 35 /+output.drawFilledRectangle(1, position.width()-1, 1,position.height()-1, getAvailableStyleSheet().getColor("window")); 36 output.drawLine(0, position.width()-1, 0, 0, getAvailableStyleSheet().getColor("windowascent")); 37 output.drawLine(0, 0, 0, position.height()-1, getAvailableStyleSheet().getColor("windowascent")); 38 output.drawLine(0, position.width()-1, position.height()-1, position.height()-1, getAvailableStyleSheet().getColor("windowdescent")); 39 output.drawLine(position.width()-1, position.width()-1, 0, position.height()-1, getAvailableStyleSheet().getColor("windowdescent"));+/ 40 with (parent) { 41 drawFilledBox(position, ss.getColor("buttonTop")); 42 drawLine(position.cornerUL, position.cornerUR, ss.getColor("windowascent")); 43 drawLine(position.cornerUL, position.cornerLL, ss.getColor("windowascent")); 44 drawLine(position.cornerLL, position.cornerLR, ss.getColor("windowdescent")); 45 drawLine(position.cornerUR, position.cornerLR, ss.getColor("windowdescent")); 46 } 47 } 48 if (isFocused) { 49 const int textPadding = ss.drawParameters["horizTextPadding"]; 50 parent.drawBoxPattern(position - textPadding, ss.pattern["blackDottedLine"]); 51 } 52 parent.drawTextSL(position, text, Point(0, 0)); 53 if (state == ElementState.Disabled) { 54 parent.bitBLTPattern(position, ss.getImage("ElementDisabledPtrn")); 55 } 56 } 57 58 }