What does Pidget code look like?

To generate a page that looks like this, the code would look like the following:


This document is from "CVS/inputs.php"
<?php

	/*
	**     SAMPLE: inputs.php
	** CREATED BY: Luke Ehresman <luke@ehresman.org>
	** CREATED ON: October 15, 2003
	**
	** This example was created to deomonstrate how to create input forms
	** from the stock form widgets that are available.  Note that there are
	** two main types of widgets: form widgets and regular widgets.  This
	** example only demonstrates form widgets.
	*/

	chdir("../../src");
	include_once("pGeneral.inc");
	include_once("pGridLayout.inc");
	include_once("pVLayout.inc");
	include_once("pPage.inc");
	include_once("pRadio.inc");
	include_once("pGroup.inc");
	include_once("pCheckbox.inc");
	include_once("pEditbox.inc");
	include_once("pForm.inc");
	include_once("pButton.inc");
	include_once("pTextarea.inc");

	/*
	** Now here we create objects for all of our widgets.  Note that the
	** developer still does have to know a basic layout of the screen, but
	** he does not need to worry about how it gets rendered to HTML.
	*/
	$page = new pPage();
	$layout = new pGridLayout(3, 3);
	$radioLayout = new pVLayout(3);
	$checkLayout = new pVLayout(3);
	$form = new pForm("inputs.php");
	$editbox = new pEditbox($form, "Sample Text", 45);
	$group = new pGroup($form);
	$radio1 = new pRadio($form, 1, "First Radio Button", $group);
	$radio2 = new pRadio($form, 2, "Second Radio Button", $group);
	$radio3 = new pRadio($form, 3, "Third Radio Button", $group);
	$check1 = new pCheckbox($form, "cb1", "First Checkbox");
	$check2 = new pCheckbox($form, "cb2", "Second Checkbox");
	$check3 = new pCheckbox($form, "cb3", "Third Checkbox");
	$button = new pButton("Button Test", "alert('This is a test of a button');");
	$textarea = new pTextarea($form, "Here is some more sample text.", 5, 18);

	/*
	** Now that all the widgets have been instanciated, we can do some
	** configuring.  Hopefully in the future a lot of this will be handled
	** by data bindings, but for now it is a manual process.
	*/

	/* Configure the main layout engine */
	$layout->SetInnerPadding(2);
	$layout->AddLayout(0, 0, $radioLayout);
	$layout->AddLayout(0, 1, $checkLayout);
	$layout->SetColumnSpan(1, 0, 2);
	$layout->AddWidget(1, 0, $editbox);
	$layout->AddWidget(2, 0, $button);
	$layout->AddWidget(2, 1, $textarea);
	$layout->SetForm($form);

	/* Configure the Radio Button Layout Engine */
	$radioLayout->AddWidget(0, $radio1);
	$radioLayout->AddWidget(1, $radio2);
	$radioLayout->AddWidget(2, $radio3);

	/* Configure the Checkbox Layout Engine */
	$checkLayout->AddWidget(0, $check1);
	$checkLayout->AddWidget(1, $check2);
	$checkLayout->AddWidget(2, $check3);

	/* Configure the Page widget */
	$page->SetLayout($layout);

	/*
	** It is necessary to register the page widget instance with the
	** page handler so it knows which page object to render.  Then once
	** that is registered, we can render the page.
	*/
	pPageHandler::SetPage($page);
	pPageHandler::Render();

?>
All content is copyright © 2003 by the Pidget Development Team.