1 module test3.app;
2 
3 import pixelperfectengine.graphics.outputscreen;
4 import pixelperfectengine.graphics.layers;
5 import pixelperfectengine.graphics.raster;
6 import pixelperfectengine.concrete.window;
7 import pixelperfectengine.system.input;
8 import pixelperfectengine.system.systemutility;
9 import pixelperfectengine.system.file;
10 import pixelperfectengine.system.common;
11 
12 
13 import std.conv;
14 
15 /** 
16  * Tests GUI elements by displaying them.
17  */
18 int main() {
19     initialzeSDL();
20     INIT_CONCRETE();
21     TestElements te = new TestElements();
22     te.whereTheMagicHappens();
23     return 0;
24 }
25 
26 public class TestElements : InputListener, SystemEventListener {
27     Raster				mainRaster;
28 	OutputScreen		outScrn;
29     SpriteLayer			sprtL;
30     WindowHandler		wh;
31     InputHandler        ih;
32     bool                isRunning;
33 
34     public this() {
35         sprtL = new SpriteLayer(RenderingMode.Copy);
36 		outScrn = new OutputScreen("WindowMaker for PPE/Concrete",1696,960);
37 		mainRaster = new Raster(848,480,outScrn,0);
38 		mainRaster.addLayer(sprtL,0);
39         mainRaster.loadPalette(loadPaletteFromFile("../system/concreteGUIE1.tga"));
40         wh = new WindowHandler(1696,960,848,480,sprtL);
41         ih = new InputHandler();
42         ih.inputListener = this;
43         ih.systemEventListener = this;
44         ih.mouseListener = wh;
45 
46         isRunning = true;
47         wh.addWindow(new TestWindow());
48     }
49     public void whereTheMagicHappens() {
50         while(isRunning) {
51             mainRaster.refresh();
52             ih.test();
53         }
54     }
55 
56     public void keyEvent(uint id, BindingCode code, uint timestamp, bool isPressed) {
57 
58     }
59 
60     public void axisEvent(uint id, BindingCode code, uint timestamp, float value) {
61 
62     }
63 
64     public void onQuit() {
65         isRunning = false;
66     }
67 
68     public void controllerAdded(uint id) {
69 
70     }
71 
72     public void controllerRemoved(uint id) {
73 
74     }
75 }
76 
77 public class TestWindow : Window {
78     CheckBox            modeToggle;
79     Panel               panelTest;
80     RadioButton[]       radioButtonTest;
81     RadioButtonGroup    radioButtonTestGr;
82     ListView            listViewTest;
83     Button              buttonTest0, buttonTest1;
84     public this() {
85         super(Box.bySize(0, 0, 848, 480), "Test");
86         panelTest = new Panel("Selections", "", Box(5, 20, 200, 200));
87         addElement(panelTest);
88         for (int i ; i < 7 ; i++) {
89             RadioButton rb = new RadioButton
90                     ("Option "d ~ i.to!dstring(), "", Box(10, 40 + i * 20, 195, 40 + i * 20 + 16));
91             panelTest.addElement(rb);
92             radioButtonTest ~= rb;
93         }
94         radioButtonTestGr = new RadioButtonGroup(radioButtonTest);
95 
96         listViewTest = new ListView(new ListViewHeader(16, [50, 50], ["Column 1", "Column 2"]), [
97             new ListViewItem(16, ["First", "000000000000000000000"]),
98             new ListViewItem(16, ["Second", "000000000000000000000"]),
99             new ListViewItem(16, ["Third", "000000000000000000000"]),
100             new ListViewItem(16, ["Fourth", "000000000000000000000"]),
101             new ListViewItem(16, ["Last", "000000000000000000000"]),
102         ], "", Box(5, 220, 105, 313));
103         addElement(listViewTest);
104 
105         buttonTest0 = new Button("A", "", Box(205, 20, 205 + 39, 20 + 39));
106         addElement(buttonTest0);
107         buttonTest0.state = ElementState.Disabled;
108         
109     }
110 
111 }