Source for file controls.inc.php
Documentation is available at controls.inc.php
* This file is part of the VCL for PHP project
* Copyright (c) 2004-2007 qadram software <support@qadram.com>
* Checkout AUTHORS file for more information on the developers
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
define('alBottom','alBottom');
define('alClient','alClient');
define('alCustom','alCustom');
define('agCenter','agCenter');
define('crPointer','crPointer');
define('crCrossHair','crCrossHair');
define('crDefault','crDefault');
define('crEResize','crE-Resize');
define('crNEResize','crNE-Resize');
define('crNResize','crN-Resize');
define('crNWResize','crNW-Resize');
define('crWResize','crW-Resize');
define('crSWResize','crSW-Resize');
define('crSResize','crS-Resize');
define('crSEResize','crSE-Resize');
* Base class for all controls
private $_doparentreset = true;
* Fires when the object is set as the active element.
protected function readjsOnActivate () { return $this->_jsonactivate; }
* Fires when the activeElement is changed from the current object to another object in the parent document.
protected function readjsOnDeactivate () { return $this->_jsondeactivate; }
* Fires on the source object before the selection is copied to the system clipboard.
protected function readjsOnBeforeCopy () { return $this->_jsonbeforecopy; }
* Fires on the source object before the selection is deleted from the document.
protected function readjsOnBeforeCut () { return $this->_jsonbeforecut; }
* Fires immediately before the activeElement is changed from the current object to another object in the parent document.
* Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected.
* Fires on the target object before the selection is pasted from the system clipboard to the document.
* Fires when the object loses the input focus.
protected function readjsOnBlur () { return $this->_jsonblur; }
* Fires when the contents of the object or selection have changed.
protected function readjsOnChange () { return $this->_jsonchange; }
* Fires when the user clicks the left mouse button on the object.
protected function readjsOnClick () { return $this->_jsonclick; }
* Fires when the user clicks the right mouse button in the client area, opening the context menu.
* Fires when the user is about to make a control selection of the object.
* Fires on the source element when the user copies the object or selection, adding it to the system clipboard.
protected function readjsOnCopy () { return $this->_jsoncopy; }
* Fires on the source element when the object or selection is removed from the document and added to the system clipboard.
protected function readjsOnCut () { return $this->_jsoncut; }
* Fires when the user double-clicks the object.
protected function readjsOnDblClick () { return $this->_jsondblclick; }
* Fires on the source object continuously during a drag operation.
protected function readjsOnDrag () { return $this->_jsondrag; }
* Fires on the target element when the user drags the object to a valid drop target.
protected function readjsOnDragEnter () { return $this->_jsondragenter; }
* Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation.
protected function readjsOnDragLeave () { return $this->_jsondragleave; }
* Fires on the target element continuously while the user drags the object over a valid drop target.
protected function readjsOnDragOver () { return $this->_jsondragover; }
* Fires on the source object when the user starts to drag a text selection or selected object.
protected function readjsOnDragStart () { return $this->_jsondragstart; }
* Fires on the target object when the mouse button is released during a drag-and-drop operation.
protected function readjsOnDrop () { return $this->_jsondrop; }
* Fires when a visual filter changes state or completes a transition.
* Fires when the object receives focus
protected function readjsOnFocus () { return $this->_jsonfocus; }
* Fires when the user presses the F1 key while the browser is the active window.
protected function readjsOnHelp () { return $this->_jsonhelp; }
* Fires when the user presses a key.
protected function readjsOnKeyDown () { return $this->_jsonkeydown; }
* Fires when the user presses an alphanumeric key.
protected function readjsOnKeyPress () { return $this->_jsonkeypress; }
* Fires when the user releases a key.
protected function readjsOnKeyUp () { return $this->_jsonkeyup; }
* Fires when the object loses the mouse capture.
* Fires when the user clicks the object with either mouse button.
protected function readjsOnMouseDown () { return $this->_jsonmousedown; }
* Fires when the user releases a mouse button while the mouse is over the object.
protected function readjsOnMouseUp () { return $this->_jsonmouseup; }
* Fires when the user moves the mouse pointer into the object.
protected function readjsOnMouseEnter () { return $this->_jsonmouseenter; }
* Fires when the user moves the mouse pointer outside the boundaries of the object.
protected function readjsOnMouseLeave () { return $this->_jsonmouseleave; }
* Fires when the user moves the mouse over the object.
protected function readjsOnMouseMove () { return $this->_jsonmousemove; }
* Fires when the user moves the mouse pointer outside the boundaries of the object.
protected function readjsOnMouseOut () { return $this->_jsonmouseout; }
* Fires when the user moves the mouse pointer into the object.
protected function readjsOnMouseOver () { return $this->_jsonmouseover; }
* Fires on the target object when the user pastes data, transferring the data from the system clipboard to the document.
protected function readjsOnPaste () { return $this->_jsonpaste; }
* Fires when a property changes on the object.
* Fires when the state of the object has changed.
* Fires when the size of the object is about to change.
protected function readjsOnResize () { return $this->_jsonresize; }
* Fires when the user finishes changing the dimensions of the object in a control selection.
protected function readjsOnResizeEnd () { return $this->_jsonresizeend; }
* Fires when the user begins to change the dimensions of the object in a control selection
* Fires when the object is being selected
protected function writejsOnActivate($value) { $this->_jsonactivate= $value; }
protected function writejsOnDeactivate($value) { $this->_jsondeactivate= $value; }
protected function writejsOnBeforeCopy($value) { $this->_jsonbeforecopy= $value; }
protected function writejsOnBeforeCut($value) { $this->_jsonbeforecut= $value; }
protected function writejsOnBeforePaste($value) { $this->_jsonbeforepaste= $value; }
protected function writejsOnBlur($value) { $this->_jsonblur= $value; }
protected function writejsOnChange($value) { $this->_jsonchange= $value; }
protected function writejsOnClick($value) { $this->_jsonclick= $value; }
protected function writejsOnContextMenu($value) { $this->_jsoncontextmenu= $value; }
protected function writejsOnCopy($value) { $this->_jsoncopy= $value; }
protected function writejsOnCut($value) { $this->_jsoncut= $value; }
protected function writejsOnDblClick($value) { $this->_jsondblclick= $value; }
protected function writejsOnDrag($value) { $this->_jsondrag= $value; }
protected function writejsOnDragEnter($value) { $this->_jsondragenter= $value; }
protected function writejsOnDragLeave($value) { $this->_jsondragleave= $value; }
protected function writejsOnDragOver($value) { $this->_jsondragover= $value; }
protected function writejsOnDragStart($value) { $this->_jsondragstart= $value; }
protected function writejsOnDrop($value) { $this->_jsondrop= $value; }
protected function writejsOnFilterChange($value) { $this->_jsonfilterchange= $value; }
protected function writejsOnFocus($value) { $this->_jsonfocus= $value; }
protected function writejsOnHelp($value) { $this->_jsonhelp= $value; }
protected function writejsOnKeyDown($value) { $this->_jsonkeydown= $value; }
protected function writejsOnKeyPress($value) { $this->_jsonkeypress= $value; }
protected function writejsOnKeyUp($value) { $this->_jsonkeyup= $value; }
protected function writejsOnLoseCapture($value) { $this->_jsonlosecapture= $value; }
protected function writejsOnMouseDown($value) { $this->_jsonmousedown= $value; }
protected function writejsOnMouseUp($value) { $this->_jsonmouseup= $value; }
protected function writejsOnMouseEnter($value) { $this->_jsonmouseenter= $value; }
protected function writejsOnMouseLeave($value) { $this->_jsonmouseleave= $value; }
protected function writejsOnMouseMove($value) { $this->_jsonmousemove= $value; }
protected function writejsOnMouseOut($value) { $this->_jsonmouseout= $value; }
protected function writejsOnMouseOver($value) { $this->_jsonmouseover= $value; }
protected function writejsOnPaste($value) { $this->_jsonpaste= $value; }
protected function writejsOnResize($value) { $this->_jsonresize= $value; }
protected function writejsOnResizeEnd($value) { $this->_jsonresizeend= $value; }
protected function writejsOnResizeStart($value) { $this->_jsonresizestart= $value; }
protected function writejsOnSelectStart($value) { $this->_jsonselectstart= $value; }
function defaultjsOnActivate () { return null; }
function defaultjsOnDeactivate () { return null; }
function defaultjsOnBeforeCopy () { return null; }
function defaultjsOnBeforeCut () { return null; }
function defaultjsOnBeforeDeactivate () { return null; }
function defaultjsOnBeforeEditfocus () { return null; }
function defaultjsOnBeforePaste () { return null; }
function defaultjsOnBlur () { return null; }
function defaultjsOnChange () { return null; }
function defaultjsOnClick () { return null; }
function defaultjsOnContextMenu () { return null; }
function defaultjsOnControlSelect () { return null; }
function defaultjsOnCopy () { return null; }
function defaultjsOnCut () { return null; }
function defaultjsOnDblClick () { return null; }
function defaultjsOnDrag () { return null; }
function defaultjsOnDragEnter () { return null; }
function defaultjsOnDragLeave () { return null; }
function defaultjsOnDragOver () { return null; }
function defaultjsOnDragStart () { return null; }
function defaultjsOnDrop () { return null; }
function defaultjsOnFilterChange () { return null; }
function defaultjsOnFocus () { return null; }
function defaultjsOnHelp () { return null; }
function defaultjsOnKeyDown () { return null; }
function defaultjsOnKeyPress () { return null; }
function defaultjsOnKeyUp () { return null; }
function defaultjsOnLoseCapture () { return null; }
function defaultjsOnMouseDown () { return null; }
function defaultjsOnMouseUp () { return null; }
function defaultjsOnMouseEnter () { return null; }
function defaultjsOnMouseLeave () { return null; }
function defaultjsOnMouseMove () { return null; }
function defaultjsOnMouseOut () { return null; }
function defaultjsOnMouseOver () { return null; }
function defaultjsOnPaste () { return null; }
function defaultjsOnPropertyChange () { return null; }
function defaultjsOnReadyStateChange () { return null; }
function defaultjsOnResize () { return null; }
function defaultjsOnResizeEnd () { return null; }
function defaultjsOnResizeStart () { return null; }
function defaultjsOnSelectStart () { return null; }
* CSS style to be used when rendering the component
function readStyle() { return $this->_style; }
function writeStyle($value) { $this->_style= $value; }
function defaultStyle() { return ""; }
* If true, the control should adjust to the selected layout
function defaultAdjustToLayout() { return "0"; }
* Return the normalized CSS style
function readStyleClass()
if ($res[0]== '.') $res= substr($res,1);
* Constructor for the class
* @param $aowner The owner component for this class
* @return An instance of this class
$this->_font->_control= $this;
//Calls inherited constructor
* Determines whether a control can be shown or not
* @return <code>true</code> if the control can be shown
* <code>false</code> otherwise.
if ($this->_parent->inheritsFrom('CustomPanel'))
* Return assigned javascript events as attributes for the tag
if ($this->_jsonblur!= null) { $event= $this->_jsonblur; $result.= " onblur=\"return $event(event)\" "; }
if ($this->_jsonclick!= null) { $event= $this->_jsonclick; $result.= " onclick=\"return $event(event)\" "; }
if ($this->_jsoncopy!= null) { $event= $this->_jsoncopy; $result.= " oncopy=\"return $event(event)\" "; }
if ($this->_jsoncut!= null) { $event= $this->_jsoncut; $result.= " oncut=\"return $event(event)\" "; }
if ($this->_jsondrag!= null) { $event= $this->_jsondrag; $result.= " ondrag=\"return $event(event)\" "; }
if ($this->_jsondrop!= null) { $event= $this->_jsondrop; $result.= " ondrop=\"return $event(event)\" "; }
if ($this->_jsonfocus!= null) { $event= $this->_jsonfocus; $result.= " onfocus=\"return $event(event)\" "; }
if ($this->_jsonhelp!= null) { $event= $this->_jsonhelp; $result.= " onhelp=\"return $event(event)\" "; }
if ($this->_jsonkeyup!= null) { $event= $this->_jsonkeyup; $result.= " onkeyup=\"return $event(event)\" "; }
// add the popup mouse up handler (the real mouseup event is wrapped by this event)
$event= "{ $this->_name}Popup"; $result.= " onmouseup=\" return $event( event)\" ";
if ($this->_jsonpaste!= null) { $event= $this->_jsonpaste; $result.= " onpaste=\"return $event(event)\" "; }
* Dumps a javascript named $event
function dumpJSEvent($event)
echo "function $event(event)\n";
echo "var event = event || window.event;\n"; //To get the right event object
echo "var params=null;\n"; //For Ajax calls
$this->$event($this, array());
if ($this->owner!= null) $this->owner->$event($this, array());
* Dump Javascript code required for this component to work
function dumpJavascript()
echo "function { $this->_name}Popup( event)\n ";
// add wrapper so the mouseup event still gets called
// just to be sure it really exists...
echo " var rightclick;\n";
echo " if (!event) var event = window.event;\n";
echo " if (event.which) rightclick = (event.which == 3);\n";
echo " else if (event.button) rightclick = (event.button == 2);\n";
echo " if (rightclick)\n";
echo " Show{ $this->_popupmenu->Name}( event, 0);\n ";
// allow the event be handled by others
function dumpHeaderCode()
parent::dumpHeaderCode();
// only dump the style sheet at design-time and if the style sheet is used by the sub-classed control
if (($this->ControlState & csDesigning) == csDesigning && isset ($this->_controlstyle['csRenderAlso']) && $this->_controlstyle['csRenderAlso'] == 'StyleSheet')
$components=$this->owner->components->items;
while (list ($k,$v)= each($components))
if ($v->inheritsFrom('StyleSheet'))
* This function returns the attribute for the hint that can be included
* in any tag. The attribute's name is "title".
* @return string If the hint is defined and can be shown a string with
* the attribute, otherwise an empty string.
protected function getHintAttribute()
$hintspecial = htmlspecialchars($this->_hint, ENT_QUOTES);
$hint = "title=\"$hintspecial\"";
* @param boolean $return_contents return contents as string or dump to output
function show($return_contents=false)
//A call to show, will dump out control code
if ($return_contents) ob_start();
$contents=ob_get_contents();
* Dump all children components
* Dump the control contents, inherit and fill this method with the code
* your control must generate
//Inherit and fill this method to show up your control
* Add or replace the JS event attribute with the wrapper.
* The wrapper is used to notify the PHP script that a event occured. The
* script then may fire an event itself (for example OnClick of a button).
* @param string $events A string that is empty or contains already
* existing JS event-handlers. This string passed
* @param string $event String representation of the event (ex. $this->_onclick;)
* @param string $jsEvent String representation of the JS event (ex. $this->_jsonclick;)
* @param string $jsEventAttr Name of attribute for the JS event (ex. "onclick")
protected function addJSWrapperToEvents(&$events, $event, $jsEvent, $jsEventAttr)
$hiddenfield = $this->getJSWrapperHiddenFieldName();
$hiddenfield = ($this->owner != null) ? "document.forms[0].$hiddenfield" : "null";
$events = str_replace("$jsEventAttr=\"return $jsEvent(event)\"",
"$jsEventAttr=\"return $wrapperEvent(event, $hiddenfield, '$submitEventValue', $jsEvent)\"",
$events .= " $jsEventAttr=\"return $wrapperEvent(event, $hiddenfield, '$submitEventValue')\" ";
* Get the function name of a JS event wrapper.
* @param string $event String representation of the event (ex. $this->_onclick;)
* @return string Name of the function
protected function getJSWrapperFunctionName($event)
$res = ($event != null) ? $event."Wrapper" : "";
* JS wrapper function that forwards a JS event to the PHP script by
* submitting the HTML form.
* It is the responsiblity of the component to add this function to the
* <javascript> section in the HTML header. Usually this is done in the
* dumpJavascript() function of the component.
* @param string $event String representation of the event (ex. $this->_onclick;)
* @return string Returns the whole JS wrapper function for the $event.
protected function getJSWrapperFunction($event)
$res .= "function $funcName(event, hiddenfield, submitvalue, wrappedfunc)\n";
$res .= "var event = event || window.event;\n";
$res .= "submit1=true;\n";
$res .= "submit2=true;\n";
// call the user defined JS function first, if it exists
$res .= "if (typeof(wrappedfunc) == 'function') submit1=wrappedfunc(event);\n";
// set the hidden field value so we later know which event was fired
$res .= "hiddenfield.value = submitvalue;\n";
$res .= "if ((hiddenfield.form.onsubmit) && (typeof(hiddenfield.form.onsubmit) == 'function')) submit2=hiddenfield.form.onsubmit();\n";
$res .= "if ((submit1) && (submit2)) hiddenfield.form.submit();\n";
// make sure the event handler of element does not handle
// the JS event again (this might happen with a submit button)
$res .= "return false;\n";
* Get the name of the hidden field used to submit the value which event
* There is should one hidden field for each component that can forward
* JS event to the PHP script. It is the responsiblity of the component to
* @return string Name of the hidden field
protected function getJSWrapperHiddenFieldName()
return "{ $this->_name}SubmitEvent";
* Value set to the hidden field when the specific JS event was fired and
* the wrapper function was called.
* Have a look at getJSWrapperFunction(), that is where the value gets set
* It is also used in the component to check if the defined $event has been
* fired on the page. This should be done in the init() function of the
* @param string $event String representation of the event (ex. $this->_onclick;)
* @return string The value that will be set in the hidden input.
protected function getJSWrapperSubmitEventValue($event)
return "{ $this->_name}_$event";
//Sets the caption if not already changed
if (!$this->_caption==$oldname)
$this->_caption=$this->_name;
* Performs a parent reset if true
function readDoParentReset() { return $this->_doparentreset; }
* Returns the caption property
protected function readCaption() { return $this->_caption; }
protected function writeCaption($value) { $this->_caption= $value; }
function defaultCaption() { return ""; }
* Returns the color property
protected function readColor() { return $this->_color; }
protected function writeColor($value)
if (($this->ControlState & csLoading) != csLoading)
$this->updateChildrenColors();
// check if the ParentColor property cn be reset
if ($this->_doparentreset)
function defaultColor() { return ""; }
* Determines if the controls is enabled or not
protected function readEnabled() { return $this->_enabled; }
protected function writeEnabled($value) { $this->_enabled= $value; }
function defaultEnabled() { return 1; }
* Specifies the PopupMenu component to show when right clicking the control
protected function readPopupMenu() { return $this->_popupmenu; }
function defaultPopupmenu() { return null; }
* Determines where a control looks for its color information.
* To have a control use the same color as its parent control,
* set ParentColor to true. If ParentColor is false,
* the control uses its own Color property.
protected function readParentColor() { return $this->_parentcolor; }
protected function writeParentColor($value)
// only change the color if parentcolor is set to true;
// otherwise leave it as it is
// set the color through writeColor() so child controls are updated too
$this->writeColor($this->_parent->_color);
function defaultParentColor() { return true; }
* Determines the Font to be used when generating this control
protected function readFont() { return $this->_font; }
protected function writeFont($value)
if (($this->ControlState & csLoading) != csLoading)
$this->updateChildrenFonts();
// check if the ParentFont property cn be reset
if ($this->_doparentreset)
* Specifies if this control is a Layer instead be integrated into the document
protected function readIsLayer() { return $this->_islayer; }
protected function writeIsLayer($value) { $this->_islayer= $value; }
function defaultIsLayer() { return 0; }
* Determines where a control looks for its font information.
* To have a control use the same font as its parent control,
* set ParentFont to true. If ParentFont is false,
* the control uses its own Font property.
protected function readParentFont() { return $this->_parentfont; }
protected function writeParentFont($value)
if ($this->_parentfont!= $value && $this->_doparentreset)
// only change the font if parentfont is set to true;
// otherwise leave it as it is
// do not allow to update ParentFont while assigning
// the parent font to this control, otherwise the
// Font::modified() function will try to set $this->ParentFont to false
// because the font has changed.
$this->_doparentreset = false;
$this->Parent->Font->assignTo($this->Font);
$this->_doparentreset = true;
function defaultParentFont() { return 1; }
* Determines the layer this control is going to be rendered
function getLayer() { return $this->_layer; }
function setLayer($value) { $this->_layer= $value; }
function defaultLayer() { return 0; }
* Specifies the Align for this control
function readAlign() { return $this->_align; }
function writeAlign($value) { $this->_align= $value; }
function defaultAlign() { return alNone; }
//TODO: Check if alignment,color and designcolor must be here or not
* Specifies the alignment to be used by the control
function readAlignment() { return $this->_alignment; }
function writeAlignment($value) { $this->_alignment= $value; }
function defaultAlignment() { return agNone; }
* Specifies a color can be used by the control in design time
function writeDesignColor($value) { $this->_designcolor= $value; }
function defaultDesignColor() { return ""; }
* Determines whether the control displays a Help Hint
* when the mouse pointer rests momentarily on the control.
function readShowHint() { return $this->_showhint; }
function writeShowHint($value)
if (($this->ControlState & csLoading) != csLoading)
$this->updateChildrenShowHints();
if ($this->_doparentreset)
function defaultShowHint() { return 0; }
* Determines where a control looks to find out if its Help Hint
* Use ParentShowHint to ensure that all the controls on a form
* either uniformly show their Help Hints or uniformly do not show them.
* If ParentShowHint is true, the control uses the ShowHint property
* value of its parent. If ParentShowHint is false, the control uses
* the value of its own ShowHint property.
* To provide Help Hints for only selected controls on a form,
* set the ShowHint property for those controls that should have
* Help Hints to true, and ParentShowHint becomes false automatically.
* Note: Enable or disable all Help Hints for the entire application
* using the ShowHint property of the application object.
function writeParentShowHint($value)
// only change the showhint if parentshowhint is set to true;
// otherwise leave it as it is
//$this->_showhint=$this->_parent->_showhint;
$this->writeShowHint($this->_parent->_showhint);
function defaultParentShowHint() { return 1; }
* Updates all properties that use the parent property as source.
* These include ShowHint, Color and Font.
function updateParentProperties()
* If ParentFont == true the parent's font is assigned to this control.
function updateParentFont()
$this->_doparentreset = false;
$this->_parent->_font->assignTo($this->Font);
$this->_doparentreset = true;
* If ParentColor == true the parent's color is assigned to this control.
function updateParentColor()
$this->_doparentreset = false;
$this->_doparentreset = true;
* If ParentShowHint == true the parent's showhint is assigned to this control.
function updateParentShowHint()
$this->_doparentreset = false;
$this->_doparentreset = true;
* Determines if the controls is visible in run-time or not
function readVisible() { return $this->_visible; }
function writeVisible($value) { $this->_visible= $value; }
function defaultVisible() { return 1; }
* Determines the parent control which holds this control
function readParent() { return $this->_parent; }
function writeParent($value)
//Remove component from the previous parent, if any
if (is_object($this->_parent)) $this->_parent->controls->remove($this);
//Adds this component to the parent's control list
$this->_parent->controls->add($this);
* An array which holds the control style, with settings for the IDE
function writeControlStyle($value)
$pieces=split("=",$value);
function writeControlState($value)
parent::writeControlState($value);
// Detect when the state changes after loading has finished
// ($oldvalue has csLoading, $value does not have it)
if (($oldstate & csLoading) == csLoading && ($value & csLoading) != csLoading)
// Update the parent properties after the loading to ensure all properties
// were read from the stream and set.
// At the moment of writeParent() the control does not have
// the properties initialized because it's the first property set.
// Update all controls that accept controls inside itself, but do not update the
// root (usually Page) control.
// check if the parent control will not update this container;
// if $this->_parentcolor == 1 then it will be updated by the parent
// (and also all children of this control)
// check if there are any children that have $this->_parentcolor == 1
// if there are, update them
$this->updateChildrenColors();
// same comment as $this->_parentcolor
$this->updateChildrenFonts();
// same comment as $this->_parentcolor
$this->updateChildrenShowHints();
// put the Page (parent == null) to the end of the if-statement because it's called only once
$this->updateChildrenParentProperties();
function getLeft() { return $this->_left; }
function setLeft($value) { $this->_left= $value; }
function defaultLeft() { return 0; }
function getTop() { return $this->_top; }
function setTop($value) { $this->_top= $value; }
function defaultTop() { return 0; }
function getWidth() { return $this->_width; }
function setWidth($value) { $this->_width= $value; }
function defaultWidth() { return 0; }
function getHeight() { return $this->_height; }
function setHeight($value) { $this->_height= $value; }
function defaultHeight() { return 0; }
* Cursor to show when the mouse is over the control
function getCursor() { return $this->_cursor; }
function setCursor($value) { $this->_cursor= $value; }
function defaultCursor() { return ""; }
* Text to show in a tooltip when the mouse is over the control for some time
function getHint() { return $this->_hint; }
function setHint($value) { $this->_hint= $value; }
function defaultHint() { return ""; }
* Event fired before show the control
function setOnBeforeShow($value) { $this->_onbeforeshow= $value; }
function defaultOnBeforeShow() { return null; }
* Event fired after show the control
function setOnAfterShow($value) { $this->_onaftershow= $value; }
function defaultOnAfterShow() { return null; }
* Event fired at the same moment the control is show, some controls can
* prevent the control to be shown when this event is attached
function getOnShow() { return $this->_onshow; }
function setOnShow($value) { $this->_onshow= $value; }
function defaultOnShow() { return null; }
* Base class for controls with input focus
class FocusControl extends Control
* If this control has any children that have ParentFont==true then
* this function will assign the Font property to all children Font properties.
* Note: This must be in FocusControl, not in Control, as it's here where the controls property is defined
function updateChildrenFonts()
//Iterates through all child controls and assign the new font
//to all that have ParentFont=true
reset($this->controls->items);
while (list ($k,$v) = each($this->controls->items))
* Update the colors for all the children if parentcolor is set
function updateChildrenColors()
//Iterates through all child controls and assign the new color
//to all that have ParentColor=true
reset($this->controls->items);
while (list ($k,$v) = each($this->controls->items))
* Update the ShowHints properties for all children controlss
function updateChildrenShowHints()
//Iterates through all child controls and assign the new showhint
//to all that have ParentShowHint=true
reset($this->controls->items);
while (list ($k,$v) = each($this->controls->items))
$v->updateParentShowHint();
* If this control has any children that use a property's value from the parent then
* this function will update all necessary properties.
* Note: This must be in FocusControl, not in Control, as it's here where the controls property is defined
function updateChildrenParentProperties()
//Iterates through all child controls and assign the new font
//to all that have ParentFont=true
reset($this->controls->items);
while (list ($k,$v) = each($this->controls->items))
// first check if it is really necessary to update the parent properties
if ($v->ParentColor || $v->ParentFont || $v->ParentShowHint)
$v->updateParentProperties();
function __construct($aowner=null)
//Creates the controls list
$this->controls= new Collection();
//Calls inherited constructor
parent::__construct($aowner);
$this->_layout= new Layout();
$this->_layout->_control= $this;
* Return the number of controls for which this control is the Parent
function readControlCount() { return $this->controls->count(); }
* Specifies the Layout this control lives in @see ActiveLayout
function readLayout() { return $this->_layout; }
function writeLayout($value) { if (is_object($value)) $this->_layout= $value; }
//Iterates through controls calling show for all of them
reset($this->controls->items);
while (list ($k,$v)= each($this->controls->items))
* Base class for custom control
class CustomControl extends FocusControl
* Base class for controls with graphic capabilities
class GraphicControl extends CustomControl
* CustomListControl is the base class for controls that display a list of items.
abstract class CustomListControl extends FocusControl
protected $_itemindex = -1;
* Returns the number of items in the list.
* @return integer Number of items in the list.
abstract function readCount();
* Returns the value of the ItemIndex property.
* @return mixed Return the ItemIndex of the list.
abstract function readItemIndex();
* Set new ItemIndex value.
* @param mixed $value Value of the new ItemIndex.
abstract function writeItemIndex($value);
* Return default ItemIndex.
* @return mixed Returns default ItemIndex.
abstract function defaultItemIndex();
* Adds an item to the list control.
* @param mixed $item Value of item to add.
* @param mixed $object Object to assign to the $item. is_object() is used to
* test if $object is an object.
* @param mixed $itemkey Key of the item in the array. Default key is used if null.
* @return integer Return the number of items in the list.
abstract function AddItem($item, $object = null, $itemkey = null);
* Deletes all of the items from the list control.
abstract function Clear();
* Removes the selection, leaving all items unselected.
abstract function ClearSelection();
//abstract function CopySelection($destination);
//abstract function DeleteSelection();
//abstract function MoveSelection($destination);
* Selects all items or all text in the selected item.
abstract function SelectAll();
abstract class CustomMultiSelectListControl extends CustomListControl
protected $_multiselect = 0;
* Returns how many items are selected in the list.
* @return integer Returns how many items are selected in the list.
abstract function readSelCount();
* Reads the value of the MultiSelect property.
* @return bool Returns if the list is MultiSelect or not.
abstract function readMultiSelect();
* Sets the value of the MultiSelect property.
* @param bool $value Set MultiSelect to true or false.
abstract function writeMultiSelect($value);
* Return default MultiSelect value.
* @return bool Returns default MultiSelect value.
abstract function defaultMultiSelect();
|