%eden
autocalc=0;

DFfont="{courier 20}";

## set up this display just once!
/*
if (buttonMenu==@) 
{
	OpenDisplay("buttonMenu",325,300);
	## need to set these parameters appropriately on start up
}
*/

OpenDisplay("buttonMenu",325,370);
## need to set these parameters appropriately on start up


proc buttonMenu_display_screen : buttonMenu { 
	DisplayScreen(&buttonMenu, "buttonMenu");
};


## location ="http://www.dcs.warwick.ac.uk/~wmb/sudokuExperience/Activity2/";

## where the files to be input are located

%scout

## global settings here

integer ydisp, buttontextlen;
ydisp = 14; buttontextlen = 20; ## fudge for web eden
## buttontextlen = 23; ## maximum length of button rubric in this case

%eden
/**************************TEMPLATE ONLY********************************

## template for a button and action:
## label is button1text / action is button1action / loadfile is filename1

%scout

string button1text, filename1;
button1text = ""; filename1 = "DUMMY.e";

window button1 = {
        type: TEXT
        frame: ([{10,ydisp}, 1, 20])
        string: button1text
        border: 1
        bgcolor: "white"
        sensitive: ON
};

%eden

proc button1action : button1_mouse_1 {
        ## writeln("init button1act");
        if (button1_mouse_1[2]==4) onlineinclude(location // filename1);
	## if (button1_mouse_1[2]==4) onlineinclude(localdirectory // filename1);
        ## ydisp = ydisp-40;
        ## writeln("act1end");
}


******** END OF TEMPLATE **************************************************/

%scout

## where to put local modifications to the button specification

string bgcol_1, bgcol_3, bgcol_6, bgcol_8;

%eden

button1_loaded = 0;
button3_loaded = 0;
button6_loaded = 0;
button8_loaded = 0;
bgcol_1 is (button1_loaded) ? "grey" : "white";
bgcol_3 is (button3_loaded) ? "grey" : "white";
bgcol_6 is (button6_loaded) ? "grey" : "white";
bgcol_8 is (button8_loaded) ? "grey" : "white";

## definition of the actual buttons

%scout

string button1text, filename1;
button1text="Define the Sudoku grid"; filename1 = "1_basicsudoku.e";

window button1 = {
        type: TEXT
        frame: ([{10,ydisp}, 1, buttontextlen])
        string: button1text
        border: 1
        bgcolor: bgcol_1
        sensitive: ON
};

%eden

proc button1action : button1_mouse_1 {
        ## writeln("init button1act");
        if ((button1_mouse_1[2]==4)&&(!button1_loaded)) {
		button1_loaded = 1;
		onlineinclude(location // filename1);
        	## ydisp = ydisp-40;
	}
        ## writeln("act1end");
}

%scout

string button2text, filename2;
button2text="Load/reset puzzle"; filename2 = "puzzles/puzzle_0.txt";

window button2 = {
        type: TEXT
        frame: ([{10,ydisp+40}, 1, buttontextlen])
        string: button2text
        border: 1
        bgcolor: "white"
        sensitive: ON
};

%eden

proc button2action : button2_mouse_1 {
        ## writeln("init button2act");
        if (button2_mouse_1[2]==4) onlineinclude(location // filename2);
        ## ydisp = ydisp-40;
        ## writeln("act2end");
}


%scout

string button3text, filename3;
button3text = "Define plausible digits"; filename3 = "2_possibilitiesnew.e";

window button3 = {
        type: TEXT
        frame: ([{10,ydisp+80}, 1, buttontextlen])
        string: button3text
        border: 1
        bgcolor: bgcol_3
        sensitive: ON
};

%eden

button3_loaded =0;
bgcol_3 is (button3_loaded) ? "grey" : "white";

proc button3action : button3_mouse_1 {
        ## writeln("init button3act");
        if ((button3_mouse_1[2]==4)&&(!button3_loaded)) {
		button3_loaded = 1;
		onlineinclude(location // filename3);
        	## ydisp = ydisp-40;
	}
        ## writeln("act3end");
}


%scout

string button4text, filename4;
button4text="Add colour"; filename4 = "3_coloursudoku.e";

window button4 = {
        type: TEXT
        frame: ([{10,ydisp+120}, 1, buttontextlen])
        string: button4text
        border: 1
        bgcolor: "white"
        sensitive: ON
};

%eden

proc button4action : button4_mouse_1 {
        ## writeln("init button4act");
        if (button4_mouse_1[2]==4) onlineinclude(location // filename4);
        ## ydisp = ydisp-40;
        ## writeln("act4end");
}


%scout

string button5text, filename5;
button5text="Remove colour"; filename5 = "4_restorestandardsudoku.e";

window button5 = {
        type: TEXT
        frame: ([{10,ydisp+160}, 1, buttontextlen])
        string: button5text
        border: 1
        bgcolor: "white"
        sensitive: ON
};

%eden

proc button5action : button5_mouse_1 {
        ## writeln("init button5act");
        if (button5_mouse_1[2]==4) onlineinclude(location // filename5);
        ## ydisp = ydisp-40;
        ## writeln("act5end");
}



%scout

string button6text, filename6;
button6text="Prototype history"; filename6 = "prototypehistory.e";

window button6 = {
        type: TEXT
        frame: ([{10,ydisp+200}, 1, buttontextlen])
        string: button6text
        border: 1
        bgcolor: bgcol_6
        sensitive: ON
};

%eden

button6_loaded =0;
bgcol_6 is (button6_loaded) ? "grey" : "white";

proc button6action : button6_mouse_1 {
        ## writeln("init button6act");
        if ((button6_mouse_1[2]==4)&&(!button6_loaded)) {
		button6_loaded = 1;
		onlineinclude(location // filename6);
        	## ydisp = ydisp-40;
	}
        ## writeln("act6end");
}



%scout

string button7text, filename7;
button7text="Prototype automation"; filename7 = "draftsolver.e";

window button7 = {
        type: TEXT
        frame: ([{10,ydisp+240}, 1, buttontextlen])
        string: button7text
        border: 1
        bgcolor: "white"
        sensitive: ON
};

%eden

proc button7action : button7_mouse_1 {
        ## writeln("init button7act");
        if (button7_mouse_1[2]==4) onlineinclude(location // filename7);
        ## ydisp = ydisp-40;
        ## writeln("act7end");
}


%scout

string button8text, filename8;
button8text="Add button interface"; filename8 = "interfacesolver.e";

window button8 = {
        type: TEXT
        frame: ([{10,ydisp+280}, 1, buttontextlen])
        string: button8text
        border: 1
        bgcolor: bgcol_8
        sensitive: ON
};

%eden

button8_loaded =0;
bgcol_8 is (button8_loaded) ? "grey" : "white";

proc button8action : button8_mouse_1 {
        ## writeln("init button8act");
        if ((button8_mouse_1[2]==4)&&(!button8_loaded)) {
		button8_loaded = 1;
		onlineinclude(location // filename8);
        	## ydisp = ydisp-40;
	}
        ## writeln("act8end");
}


%scout

string button9text, filename9;
button9text="Show history"; filename9 = "DUMMY.e";

window button9 = {
        type: TEXT
        frame: ([{10,ydisp+320}, 1, buttontextlen])
        string: button9text
        border: 1
        bgcolor: "white"
        sensitive: ON
};

%eden

proc button9action : button9_mouse_1 {
        ## writeln("init button9act");
        ## if (button9_mouse_1[2]==4) onlineinclude(location // filename9);
        if (button9_mouse_1[2]==4) execute("%eddi\n?history;\n%eden\n");
        ## ydisp = ydisp-40;
        ## writeln("act9end");
}

%scout
buttonMenu = <button1 / button2 /button3 /button4 /button5 /button6 /button7 /button8 /button9 >;
## buttonMenu = <button1 / button2 /button3 /button4 /button5 /button6 /button7 /button8 >;

%eden
autocalc=1;


%eden
FileLoadedOkay = 1;
