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

 Code sample: Shapes and line widths and 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", 	"Lines and shapes");	// Application name

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

create_main_window();
wb_main_loop();

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

// Create main window

function create_main_window()
{
	global $font;

	$font = wb_create_font("Tahoma", 9, null, FTA_BOLD);

	// Create main window (invisible) and controls

	$wb->mainwin = wb_create_window(NULL, AppWindow, APPNAME, WBC_CENTER, WBC_CENTER,
	  520, 190, WBC_INVISIBLE | WBC_NOTIFY | WBC_CUSTOMDRAW, WBC_REDRAW);

	// Size, move and show main window

	wb_set_handler($wb->mainwin, "process_main");
	wb_set_visible($wb->mainwin, true);
}

function process_main($window, $id, $ctrl, $lparam1=0, $lparam2=0)
{
	global $font;

	switch($id) {

		case IDDEFAULT:

			if($lparam1 & WBC_REDRAW) {

				// Set some variables

				$buffer = $lparam2;

				for($i = 0; $i < 5; $i ++) {
					wb_draw_rect($buffer, 10 + 50 * $i, 10, 40, 40, 0x0000A0, false, $i + 1);
					wb_draw_text($buffer, (string)$i, 10 + 50 * $i, 10, 40, 40, $font, WBC_CENTER | WBC_MIDDLE);
				}

				for($i = 0; $i < 5; $i ++) {
					wb_draw_ellipse($buffer, 260 + 50 * $i, 10, 40, 40, 0xA00000, false, $i + 1);
					wb_draw_text($buffer, (string)$i, 260 + 50 * $i, 10, 40, 40, $font, WBC_CENTER | WBC_MIDDLE);
				}

				for($i = 0; $i < 10; $i ++) {
					wb_draw_rect($buffer, 10 + 50 * $i, 60, 40, 40, 0x004080, false, 0, $i);
					wb_draw_text($buffer, (string)$i, 10 + 50 * $i, 60, 40, 40, $font, WBC_CENTER | WBC_MIDDLE);
				}

				for($i = 0; $i < 10; $i ++) {
					wb_draw_ellipse($buffer, 10 + 50 * $i, 110, 40, 40, 0x204000, false, 0, $i);
					wb_draw_text($buffer, (string)$i, 10 + 50 * $i, 110, 40, 40, $font, WBC_CENTER | WBC_MIDDLE);
				}
			}
			break;

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

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

?>