[pidget-cvs] pidget/examples/samples inputs.php,NONE,1.1 twiddle.php,NONE,1.1
Brought to you by:
lkehresman
From: <lke...@us...> - 2003-10-15 16:16:39
|
Update of /cvsroot/pidget/pidget/examples/samples In directory sc8-pr-cvs1:/tmp/cvs-serv24009/examples/samples Added Files: inputs.php twiddle.php Log Message: Added a couple example scripts that demonstrate how to use Pidget. --- NEW FILE: inputs.php --- <?php /* ** SAMPLE: inputs.php ** CREATED BY: Luke Ehresman <lu...@eh...> ** 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(); ?> --- NEW FILE: twiddle.php --- <?php /* ** SAMPLE: twiddle.php ** CREATED BY: Luke Ehresman <lu...@eh...> ** CREATED ON: October 15, 2003 ** ** This is an example of how to render a simple Twiddle box. The page ** doesn't do a whole lot, and you can't even submit the form. But it ** demonstrates how to create a simple page. */ chdir("../../src"); include_once("pGeneral.inc"); include_once("pHLayout.inc"); include_once("pPage.inc"); include_once("pForm.inc"); include_once("pTwiddle.inc"); /* ** This section defines some data that will be used in the twiddle boxes. ** In a real setting, this data would come from a database or some other ** data source. In the future this will be handled through bindings. */ $data['AL'] = "Alabama"; $data['AK'] = "Alaska"; $data['AZ'] = "Arizona"; $data['AR'] = "Arkinsas"; $data['CA'] = "California"; $data['CO'] = "Colorado"; $data['CN'] = "Connecticut"; $data['DE'] = "Delaware"; $data['FL'] = "Florida"; $data['GA'] = "Georgia"; $data['HA'] = "Hawaii"; $data['ID'] = "Idaho"; $data['IL'] = "Illinois"; $data['IN'] = "Indiana"; /* ** 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 pHLayout(3); $form = new pForm("twiddle.php"); $twiddle = new pTwiddle($form); /* ** 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 Twiddle Box */ while (list($key,$val) = each($data)) { $twiddle->AddOption($key, $val); } $twiddle->AddChosen('CA'); $twiddle->AddChosen('IN'); /* Configure the Layout Engine */ $layout->AddWidget(0, $twiddle); $layout->SetForm($form); /* 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(); ?> |