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

 How to work with separate radio button groups

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

//------------------------------------------------------------ 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", 			"Radio buttons");

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

// Create main window

$mainwin = wb_create_window(NULL, PopupWindow, APPNAME, WBC_CENTER, WBC_CENTER, 210, 150, WBC_INVISIBLE, 0);
wb_set_handler($mainwin, "process_main");

// Insert two groups of radio buttons. Each new group starts with a WBC_GROUP flag.
// If the control order is changed, the WBC_GROUP flags must be changed as well.

// Group A

wb_create_control($mainwin, Frame,       "Group A",   10,  6, 85, 89);       // For cosmetics only
wb_create_control($mainwin, Label,       "(Nothing)", 10,100, 90, 22, 301);
wb_create_control($mainwin, RadioButton, "Option A1", 20, 24, 70, 14, 101, WBC_GROUP);
wb_create_control($mainwin, RadioButton, "Option A2", 20, 48, 70, 14, 102);
wb_create_control($mainwin, RadioButton, "Option A3", 20, 73, 70, 14, 103);

// Group B

wb_create_control($mainwin, Frame,       "Group B",   110,  6, 85, 89);      // For cosmetics only
wb_create_control($mainwin, Label,       "(Nothing)", 110,100, 90, 22, 302);
wb_create_control($mainwin, RadioButton, "Option B1", 120, 24, 70, 14, 201, WBC_GROUP);
wb_create_control($mainwin, RadioButton, "Option B2", 120, 48, 70, 14, 202);
wb_create_control($mainwin, RadioButton, "Option B3", 120, 73, 70, 14, 203);

// Show window and enter main loop

wb_set_visible($mainwin, true);
wb_main_loop();

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

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

		case 101: case 102: case 103:
			wb_set_text(wb_get_control($window, 301), wb_get_text($ctrl) . " (#$id)");
			break;

		case 201: case 202: case 203:
			wb_set_text(wb_get_control($window, 302), wb_get_text($ctrl) . " (#$id)");
			break;

		case IDCLOSE:
			wb_destroy_window($window);
			break;

	}
}

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

?>