<?php

/*******************************************************************************

 WINBINDER - The native Windows binding for PHP for PHP

 Copyright © Hypervisual - see LICENSE.TXT for details
 Author: Rubem Pechansky (http://winbinder.org/contact.php)

 Keyboard accelerator tests

*******************************************************************************/

//------------------------------------------------------------ SYSTEM PARAMETERS

define("PATH_SCRIPT",	dirname(__FILE__) . "/");
define("PATH_DATA",		PATH_SCRIPT);
define("PATH_INC",		PATH_SCRIPT . "../include/");
define("PATH_RES",		PATH_SCRIPT . "../resources/");

//----------------------------------------------------------------- DEPENDENCIES

include PATH_INC . "winbinder.php";

//-------------------------------------------------------------------- CONSTANTS

define("APPNAME",		"Accelerators");	// Application name

// Control identifiers

define("ID_PLUS",		101);
define("ID_C_PLUS",		102);
define("ID_ENTER",		201);
define("ID_C_ENTER",	202);

//-------------------------------------------------------------- EXECUTABLE CODE

// Create main window, then assign a procedure and an icon to it

$mainwin = wb_create_window(NULL, AppWindow, APPNAME . " - PHP " . PHP_VERSION, 320, 240);

// Create menu

wb_create_control($mainwin, Menu, array(
	"&Test",
		array(ID_ENTER,		"Accel1\tEnter",		NULL, "", "enter"),
		array(ID_C_ENTER,	"Accel2\tCtrl+Enter",	NULL, "", "ctrl+enter"),
		null,
		array(ID_PLUS,		"Accel3\t+",			NULL, "", "plus"),
		array(ID_C_PLUS,	"Accel4\tCtrl++",		NULL, "", "ctrl+plus"),
));

// Accelerator table (replaces menu accelerators)

wb_create_control($mainwin, Accel, array(
	array(ID_ENTER,		"enter"),
	array(ID_C_ENTER,	"ctrl+enter"),
	array(ID_PLUS,		"plus"),
	array(ID_C_PLUS,	"ctrl+plus"),

	array(ID_ENTER,		"F6"),
	array(ID_C_ENTER,	"F7"),
	array(ID_PLUS,		"F8"),
	array(ID_C_PLUS,	"F9"),
));

// Enter application loop

wb_set_handler($mainwin, "process_main");
wb_main_loop();

//-------------------------------------------------------------------- FUNCTIONS

/* Process main window commands */

function process_main($window, $id)
{
	switch($id) {

		case ID_PLUS:
			wb_message_box($window, "You pressed Plus.", APPNAME);
			break;

		case ID_C_PLUS:
			wb_message_box($window, "You pressed Ctrl+Plus.", APPNAME);
			break;

		case ID_ENTER:
			wb_message_box($window, "You pressed Enter.", APPNAME);
			break;

		case ID_C_ENTER:
			wb_message_box($window, "You pressed Ctrl+Enter.", APPNAME);
			break;

		case IDCLOSE:
			wb_destroy_window($window);
			break;
	}
}

//------------------------------------------------------------------ END OF FILE

?>