<?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)

 Change control styles

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

//------------------------------------------------------------ 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", "Change styles");

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

// Create main window

$win = wb_create_window(NULL, PopupWindow, APPNAME, 520, 240);
wb_set_handler($win, "process_main");

// Create child controls

$ctrl = wb_create_control($win, ListView,	"",			20, 40, 270,  120, 	101, WBC_LINES | WBC_CHECKBOXES);
wb_set_text($ctrl, array("Column 1","Column 2","Column 3"));
wb_create_items($ctrl, array("i1","i2","i3"));

$ctrl = wb_create_control($win, TreeView,	"",			320, 40, 170,  120, 103, WBC_LINES);
wb_create_items($ctrl, array(
	array("Hello",	0, 2, 3),
	array("Hallo"),	1,
	array("Hi",		1, 6, 7),
	array("Oi"),	1,
	array("Oye",	1, 	4, 5),
	array("Hola"),	2,
	array("Aloha"),	1,
	array("Allo",	0, 2, 3),
	array("Olá"),	1,
	array("Alô"),	1,
	array("Viva"),	1,
));

$ctrl = wb_create_control($win, Slider,		"",		130,  5, 146,  26, 	102, WBC_LINES);

wb_create_control($win, PushButton,	"Gridlines",	 10, 180,  80,  22,    1001, 0, 0);
wb_create_control($win, PushButton,	"Check boxes",	 100,180,  80,  22,    1002, 0, 0);

wb_main_loop();

function process_main($window, $id, $ctrl)
{
	static $grid = 0, $check = 0;

	switch($id) {

		case 1001:
			wb_set_style(wb_get_control($window, 101), WBC_LINES, $grid);
			wb_set_style(wb_get_control($window, 102), WBC_LINES, $grid);
			wb_set_style(wb_get_control($window, 103), WBC_LINES, $grid);
			$grid = !$grid;
			break;

		case 1002:
			wb_set_style(wb_get_control($window, 101), WBC_CHECKBOXES, $check);
			$check = !$check;
			break;

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

//-------------------------------------------------------------------------- END

?>