188 parent::__construct(
$name );
191 $this->
id = ( ( $this->name == NULL ) ?
'm'.$this->_numberId :
$this->name );
192 $this->cssClass =
'';
193 $this->enabled =
true;
196 $this->visible =
true;
198 $this->maintainState =
false;
199 $this->readonly =
false;
204 $this->eventHandlers = array ( );
207 $this->painter = $this->manager->GetPainter();
233 $this->_addStyle(
$name, $value );
238 $this->_addStyle(
'font-size', $value );
243 $this->_addStyle(
'font-style', $value );
248 $this->_addStyle(
'font-family', $value );
253 $this->_addStyle(
'font-weight', $value );
258 $this->_addStyle(
'cursor', $value );
264 $this->_addStyle (
'text-align', $value );
270 $this->_addStyle (
'text-indent', $value );
276 $this->_addStyle(
'line-height', $value );
303 case 'backgroundColor':
308 case 'verticalAlign':
338 $this->style->addValue(
$name, $value);
345 $this->readonly = $status;
356 $this->enabled = $state;
361 MUtil::setIfNull($this->
id,
$name);
363 parent::setName(
$name);
370 MUtil::setIfNull( $this->name,
$id );
414 if ( !array_key_exists(
"REQUISICAO_PELA_API", $GLOBALS) || !$GLOBALS[
'REQUISICAO_PELA_API'])
416 $this->page->AddStyle($styleFile);
429 $this->
$name = $value;
434 $this->style->items =
$style;
439 return $this->style->hasItems() ?
" style=\"" . $this->style->getText(
':',
';') .
"\"" :
'';
445 $this->attrs->addValue(
$name, ( $value !=
'' ) ?
"\"$value\"" :
'' );
451 $this->
getBox()->addAttribute(
'rel',
'tooltip');
452 $this->
getBox()->addAttribute(
'data-html',
'true');
453 $this->
getBox()->addAttribute(
'data-placement', $placement);
466 if ( is_array($attr) )
468 foreach( $attr as $ak => $av )
473 else if ( is_string($attr) )
475 $attr = str_replace(
"\"",
'', trim($attr) );
477 foreach ( explode(
' ', $attr) as $a )
479 $a = explode(
'=', $a);
488 if ( $mergeDuplicates )
490 $items = $this->attrs->getItems();
492 $items_new = array( );
493 foreach( $items as
$id=>$item )
495 if ( isset($items_new[ strtolower(
$id) ]) )
497 $items_new[ strtolower(
$id) ] = substr($items_new[ strtolower(
$id) ], 0, -1) .
';' . substr($item, 1);
501 $items_new[ strtolower(
$id) ] = $item;
504 $this->attrs->setItems( $items_new );
506 return $this->attrs->hasItems() ?
' ' . $this->attrs->getText(
"=",
" ") :
'';
516 $this->formMode = $mode;
523 $this->jsHint = $hint;
524 $this->page->addScript(
'x/x_core.js');
525 $this->page->addScript(
'x/x_dom.js');
526 $this->page->addScript(
'x/x_event.js');
527 $this->page->addScript(
'x/x_tip.js');
528 $this->page->onLoad(
"new xTooltipGroup('tipHint', '', 'left', 3, 0);");
546 if ( strpos($value,
'%') ===
false && $value !=
'auto')
565 if ( strpos($value,
'%') ===
false )
579 $this->AddStyle(
'color', $value);
584 $value = ($value ?
'visible' :
'hidden');
585 $this->visibility = $value;
608 private function _AddControl($control, $pos = 0, $op =
'add')
610 if(is_array($control))
612 foreach($control as $c)
614 $this->_AddControl($c);
617 elseif ( $control instanceof
MControl )
621 $this->controlsId->add($control, $control->GetId() );
622 $this->controls->add($control);
624 elseif ( $op ==
'ins' )
626 $this->controlsId->add($control, $control->GetId() );
627 $this->controls->insert($control, $pos);
629 elseif ( $op ==
'set' )
631 $this->controlsId->set( $control->GetId(), $control );
632 $this->controls->set($pos, $control);
635 $control->parent = $this;
637 elseif ( ! is_null($control) )
639 if ( ! is_object($control) )
642 "Using non-object with _AddControl;<br/>type: " . gettype($control) .
';<br/>value: ' . $control
643 .
';<br/>Try using Label control instead');
647 throw new EControlException(
'Using non-control with _AddControl; class: ' . get_class($control).
'; name: '.$control->name.
'; id: '.$control->id);
654 $this->_AddControl($control);
659 $this->_AddControl($control, $pos,
'ins');
664 $this->_AddControl($control, $pos,
'set');
677 return $this->controls->items;
682 return $this->controls->get($pos);
687 return $this->controlsId->get(
$id);
702 elseif ( ( $k = $c->FindControlById(
$id) ) != NULL )
711 $this->controlsId->set(
$id, $control);
716 $this->controls->clear();
717 $this->controlsId->clear();
727 $event = $_REQUEST[
'__EVENTTARGETVALUE'] ??
null;
728 $args = $_REQUEST[
'__EVENTARGUMENT'] ??
null;
732 $eventTokens = explode(
':', $event);
733 $sender = $subject->FindControlById( $eventTokens[0] );
734 $func = str_replace(
':',
'_', $event);
736 if ( method_exists($subject, $func) )
738 $subject->$func($sender, $args);
740 elseif ( $sender instanceof
MControl )
742 $eventType = $eventTokens[1];
743 $func = $sender->eventHandlers[$eventType][
'handler'];
745 if ( ! is_null($func) )
747 if ( method_exists($subject, $func) )
749 $subject->$func($sender, $args);
751 elseif ( function_exists($func) )
753 $func($sender, $args);
760 $e = str_replace(
':',
'_', $eventTokens[0]);
762 if ( (strtolower($e) !== strtolower($func ??
'')) && (method_exists($subject, $e) ) )
764 $params = $eventTokens[1];
765 $subject->$e(NULL, $params);
773 $this->eventHandlers[
$name][
'handler'] = $handler;
774 $this->eventHandlers[
$name][
'param'] = $param;
782 if ( is_null($this->box) )
784 $this->box =
new mSpan(
'm_' .
MUtil::NVL( $this->name, $this->uniqueId ) );
805 return $this->
getBox()->cssClass;
811 $this->
getBox()->setAttributes($attr);
816 return $this->
getBox()->getAttributes();
821 $this->GetBox()->_AddStyle(
$name, $value);
828 $box->inner = $content;
830 return $box->getRender(
'div');
835 return $this->painter->$method( $this );
841 return $this->painter->generateToString( $this->
getInner() );
847 if ( $this->inner ==
'' )
849 if ( $this->controls->hasItems() )
851 $this->inner = $this->controls->items;
862 if ( $this->jsHint !=
'' )
864 $hint =
new mSpan(
'', $content,
'tipHint');
865 $hint->addAttribute(
"title",
"{$this->jsHint}" );
867 $content = $hint->generate();
872 $hint =
new MSpan(NULL, $this->hint,
'm-hint');
874 if ( is_string($content) )
876 $content .= $hint->generate();
880 $content =
new MDiv(NULL, array($content, $hint));
887 if (property_exists($this,
'label') && !empty($this->label) && $this->label !=
' ')
891 $divContainer =
new MDiv(
'', $content,
'm-new-container');
892 $content = $divContainer->generate();
897 return ( $this->cssp ? $this->
generateBox($content) : $this->painter->generateToString($content) );
const TOOLTIP_PLACEMENT_BOTTOM
const FORM_MODE_SHOW_NBSP
const TOOLTIP_PLACEMENT_TOP
insertControl($control, $pos=0, $width=null, $float=null)
setControl($control, $pos=0)
attributes( $mergeDuplicates=false)
const TOOLTIP_PLACEMENT_LEFT
setAttribute( $name, $value)
const TOOLTIP_PLACEMENT_RIGHT
setClass( $cssClass, $add=true)
setBoxClass( $cssClass, $add=true)
setTooltip($title, $placement=self::TOOLTIP_PLACEMENT_AUTO)
const FORM_MODE_WHOLE_ROW
addStyleFile( $styleFile)
const TOOLTIP_PLACEMENT_AUTO
addBoxStyle($name, $value='')
getAttributes( $mergeDuplicates=false)
attachEventHandler( $name, $handler, $param=NULL)
const CLASS_CAPTION_REQUIRED
addAttribute( $name, $value='')
const FORM_MODE_SHOW_SIDE
setPosition($left, $top, $position='absolute')
setControlById($control, $id)
const FORM_MODE_SHOW_ABOVE
static _REQUEST( $vars, $from='ALL')
static NVL($value1, $value2)
static IfNull($value1, $value2, $value3)