1 /*
2 * Copyright (C) 2015-2019, by Laszlo Szeremi under the Boost license.
3 *
4 * Pixel Perfect Engine, concrete.interfaces module
5 */6 7 modulepixelperfectengine.concrete.interfaces;
8 9 publicimportpixelperfectengine.graphics.fontsets;
10 publicimportpixelperfectengine.graphics.bitmap;
11 publicimportpixelperfectengine.graphics.common;
12 publicimportpixelperfectengine.graphics.text;
13 14 publicimportpixelperfectengine.concrete.elements.base;
15 publicimportpixelperfectengine.concrete.popup.base;
16 17 publicimportpixelperfectengine.system.input.types;
18 19 /+/**
20 * Checkbox interface.
21 */
22 public interface ICheckBox {
23 ///Returns whether the object is checked.
24 public @property bool isChecked() @safe pure @nogc nothrow const;
25 ///Sets the object to checked position and returns the new state.
26 public bool check() @trusted;
27 ///Sets the object to unchecked position and returns the new state.
28 public bool unCheck() @trusted;
29 }+/30 /**
31 * Radio button interface. Can be used to implement radio button style behavior on almost any component that implements this interface.
32 */33 publicinterfaceIRadioButton {
34 /**
35 * If the radio button is pressed, then it sets to unpressed. Does nothing otherwise.
36 */37 publicvoidlatchOff() @trusted;
38 /**
39 * Sets the radio button into its pressed state.
40 */41 publicvoidlatchOn() @trusted;
42 /**
43 * Sets the group of the radio button.
44 */45 publicvoidsetGroup(IRadioButtonGroupgroup) @safe @property;
46 /**
47 * Workaround the stupid issue of object.opEquals having to be `@system inpure throw`.
48 * The @gc would be fine still.
49 *
50 * Hey DLang foundation! Don't be cowards and commit to some meaningful changes!
51 */52 publicboolequals(IRadioButtonrhs) @safepure @nogcnothrowconst;
53 /**
54 * Returns the assigned value of the radio button.
55 */56 publicstringvalue() @property @safe @nogcpurenothrowconst;
57 }
58 /**
59 * Implements the basis of a radio button group.
60 */61 publicinterfaceIRadioButtonGroup {
62 /**
63 * Adds a radio button to the group.
64 */65 publicvoidadd(IRadioButtonrg) @safe;
66 /**
67 * Removes a radio button from the group.
68 */69 publicvoidremove(IRadioButtonrg) @safe;
70 /**
71 * Groups receive latch signals here.
72 */73 publicvoidlatch(IRadioButtonsender) @safe;
74 }
75 /**
76 * Implements the frontend of a drawable canvas, primarily for GUI elements.
77 * Used to avoid using individual bitmaps for each elements.
78 * Colors are mostly limited to 256 by the `ubyte` type. However certain window types will enable more.
79 */80 publicinterfaceCanvas {
81 ///Draws a line.82 publicvoiddrawLine(Pointfrom, Pointto, ubytecolor) @trusted;
83 ///Draws a line pattern.84 publicvoiddrawLinePattern(Pointfrom, Pointto, ubyte[] pattern) @trusted;
85 ///Draws an empty rectangle.86 publicvoiddrawBox(Boxtarget, ubytecolor) @trusted;
87 ///Draws an empty rectangle with line patterns.88 publicvoiddrawBoxPattern(Boxtarget, ubyte[] pattern) @trusted;
89 ///Draws a filled rectangle with a specified color.90 publicvoiddrawFilledBox(Boxtarget, ubytecolor) @trusted;
91 ///Pastes a bitmap to the given point using blitter, which threats color #0 as transparency.92 publicvoidbitBLT(Pointtarget, ABitmapsource) @trusted;
93 ///Pastes a slice of a bitmap to the given point using blitter, which threats color #0 as transparency.94 publicvoidbitBLT(Pointtarget, ABitmapsource, Boxslice) @trusted;
95 ///Pastes a repeated bitmap pattern over the specified area.96 publicvoidbitBLTPattern(Boxtarget, ABitmappattern) @trusted;
97 ///XOR blits a repeated bitmap pattern over the specified area.98 publicvoidxorBitBLT(Boxtarget, ABitmappattern) @trusted;
99 ///XOR blits a color index over a specified area.100 publicvoidxorBitBLT(Boxtarget, ubytecolor) @trusted;
101 ///Fills an area with the specified color.102 publicvoidfill(Pointtarget, ubytecolor, ubytebackground = 0) @trusted;
103 ///Draws a single line text within the given prelimiter.104 publicvoiddrawTextSL(Boxtarget, Texttext, Pointoffset) @trusted;
105 ///Draws a multi line text within the given prelimiter.106 publicvoiddrawTextML(Boxtarget, Texttext, Pointoffset) @trusted;
107 ///Clears the area within the target108 publicvoidclearArea(Boxtarget) @trusted;
109 }
110 /**
111 * TODO: Use this for implement tabbing and etc.
112 */113 publicinterfaceFocusable {
114 ///Called when an object receives focus.115 publicvoidfocusGiven();
116 ///Called when an object loses focus.117 publicvoidfocusTaken();
118 ///Cycles the focus on a single element.119 ///Returns -1 if end is reached, or the number of remaining elements that120 ///are cycleable in the direction.121 publicintcycleFocus(intdirection);
122 ///Passes key events to the focused element when not in text editing mode.123 publicvoidpassKey(uintkeyCode, ubytemod);
124 }
125 /**
126 * Implements the
127 */128 publicinterfaceElementContainer : PopUpHandler, Canvas {
129 /**
130 * Returns the absolute position of the element.
131 */132 publicBoxgetAbsolutePosition(WindowElementsender);
133 /**
134 * Gives focus to the element if applicable
135 */136 publicvoidrequestFocus(WindowElementsender);
137 /**
138 * Sets the cursor to the given type on request.
139 */140 publicvoidrequestCursor(CursorTypetype);
141 }
142 /**
143 * Implemented by any object that can store stylesheets.
144 */145 publicinterfaceStyleSheetContainer {
146 /**
147 * Returns the stylesheet stored by the object.
148 */149 publicStyleSheetgetStyleSheet();
150 publicint[2] getRasterSizes();
151 }
152 /**
153 * Implements mouse event passing.
154 */155 publicinterfaceMouseEventReceptor {
156 ///Passes mouse click event157 publicvoidpassMCE(MouseEventCommonsmec, MouseClickEventmce);
158 ///Passes mouse move event159 publicvoidpassMME(MouseEventCommonsmec, MouseMotionEventmme);
160 ///Passes mouse scroll event161 publicvoidpassMWE(MouseEventCommonsmec, MouseWheelEventmwe);
162 }
163 /**
164 * Implements identification of small buttons.
165 */166 publicinterfaceISmallButton {
167 ///Returns true if element is in small button capable and is the supplied height.168 publicboolisSmallButtonHeight(intheight);
169 ///Returns true if left side justified, false otherwise.170 publicboolisLeftSide() @nogc @safepurenothrowconst;
171 ///Sets the small button to the left side if true.172 publicboolisLeftSide(boolval) @nogc @safepurenothrow;
173 }
174 /**
175 * Defines functions for pop up handling.
176 */177 publicinterfacePopUpHandler : StyleSheetContainer {
178 /**
179 * Puts a PopUpElement on the GUI.
180 */181 publicvoidaddPopUpElement(PopUpElementp);
182 /**
183 * Puts a PopUpElement on the GUI at the given position.
184 */185 publicvoidaddPopUpElement(PopUpElementp, intx, inty);
186 /**
187 * Ends the popup session and closes all popups.
188 */189 publicvoidendPopUpSession(PopUpElementp);
190 /**
191 * Closes a single popup element.
192 */193 publicvoidclosePopUp(PopUpElementp);
194 }