1 module pixelperfectengine.concrete.popup.base; 2 3 public import pixelperfectengine.concrete.interfaces; 4 public import pixelperfectengine.concrete.types; 5 package import pixelperfectengine.graphics.draw; 6 7 /** 8 * For creating pop-up elements like menus. 9 */ 10 public abstract class PopUpElement : MouseEventReceptor { 11 //public ActionListener[] al; 12 protected BitmapDrawer output; 13 public static InputHandler inputhandler; 14 //public static StyleSheet styleSheet; 15 protected Box position; 16 public StyleSheet customStyle; 17 protected PopUpHandler parent; 18 protected string source; 19 protected Text text; 20 /*public void delegate(Event ev) onMouseLClickRel; 21 public void delegate(Event ev) onMouseRClickRel; 22 public void delegate(Event ev) onMouseMClickRel; 23 public void delegate(Event ev) onMouseHover; 24 public void delegate(Event ev) onMouseMove; 25 public void delegate(Event ev) onMouseLClickPre; 26 public void delegate(Event ev) onMouseRClickPre; 27 public void delegate(Event ev) onMouseMClickPre;*/ 28 29 public static void delegate() onDraw; ///Called when the element finished drawing 30 public void delegate(Event ev) onMouseClick; ///Called on mouse click on element 31 32 public abstract void draw(); ///Called to draw the element 33 ///Mouse click events passed here 34 public void onClick(int offsetX, int offsetY, int type = 0){ 35 36 } 37 ///Mouse scroll events passed here 38 public void onScroll(int x, int y, int wX, int wY){ 39 40 } 41 ///Mouse movement events passed here 42 public void onMouseMovement(int x, int y){ 43 44 } 45 public void addParent(PopUpHandler p){ 46 parent = p; 47 } 48 49 protected StyleSheet getStyleSheet(){ 50 if(customStyle !is null){ 51 return customStyle; 52 } 53 return parent.getStyleSheet(); 54 } 55 public Box getPosition() @nogc @safe pure nothrow const { 56 return position; 57 } 58 public Box setPosition(Box val) @trusted { 59 position = val; 60 draw(); 61 return position; 62 } 63 ///Moves the PopUp to the given location 64 public Box move(int x, int y) @nogc @safe pure nothrow { 65 position.move(x, y); 66 return position; 67 } 68 ///Relatively moves the PopUp by the given amount 69 public Box relMove(int x, int y) @nogc @safe pure nothrow { 70 position.relMove(x, y); 71 return position; 72 } 73 ///Returns the output of the element. 74 public ABitmap getOutput() @safe{ 75 return output.output; 76 } 77 78 public void passMCE(MouseEventCommons mec, MouseClickEvent mce) { 79 80 } 81 82 public void passMME(MouseEventCommons mec, MouseMotionEvent mme) { 83 84 } 85 86 public void passMWE(MouseEventCommons mec, MouseWheelEvent mwe) { 87 88 } 89 90 }