<?php
function create_textArea( $textArea,
                          $textArea_Conf)
{
  if( $textArea_Conf['enabled'] == 'true' )
  {
  	$enabled = "";
  }else
  {
  	$enabled = "disabled";
  }// End if( $textArea_Conf['enabled'] == 'true' )

  if( $textArea_Conf['tab_index'] == 'auto' )
  {
    $tab_index = '';
  }else
  {
    $tab_index = $textArea_Conf['tab_index'];
  }//End if( $textArea_Conf['tab_index'] == 'auto' )

  if( $textArea_Conf['caption'] == 'auto' )
  {
    $label = $textArea;
  }else
  {
    $label = $textArea_Conf['caption'];
  }// End if( $textArea_Conf['caption'] == 'auto' )

  if( $textArea_Conf['cols'] == 'auto' )
  {
    $cols = '';
  }else
  {
    $cols = $textArea_Conf['cols'];
	}// End if( $textArea_Conf['cols'] == 'auto' )
  
  if( $textArea_Conf['rows'] == 'auto' )
  {
    $rows = '';
  }else
  {
    $rows = $textArea_Conf['rows'];
	}// End if( $textArea_Conf['rows'] == 'auto' )

  if ( $textArea_Conf[ 'alt_key' ] == 'null' || $textArea_Conf[ 'caption' ] == '' )
  {
    $alt_key = '';
  }else
  {
    $alt_key = $textArea_Conf[ 'alt_key' ];
    $ix = strpos( $label, $alt_key );
    $label = substr( $label, 0, $ix ) . '<span id="'.$textArea.'_key">'.$alt_key.'</span>' . substr( $label, $ix + 1 );

  }//End if ( $textArea_Conf[ 'alt_key' ] == 'null' )

  global $_desenv_;
  $path_img = "http://";
  
  writeTO( '<label id="'.$textArea.'_Caption"  for="'.$textArea.'_Texto"        ' );
  writeTO( '     accesskey="'.$alt_key.'" '.$enabled.'>                         ' );
  writeTO( '                               '. $label .  '</label>               ' );
  writeTO( '  <textarea id="' . $textArea . '_Texto"  cols="'.$cols.'"          ' );
  writeTO( '     rows="'.$rows.'" '.$enabled. ' tabindex="'.$tab_index.'">     ' );
  writeTO( '  </textarea>                                                       ' );

}// End create_textArea()


/**
 *
 */
function create_textArea_css( $textArea,
                              $textArea_Global,
                              $textArea_Style,
			                        $textArea_Conf )
{
  $visible = ( $textArea_Global['visibility'] == 'true' ) ? 'inherit':'hidden';
//  $font_color = ( $textArea_Global['color'] == 'auto' ) ? 'inherit':'hidden';

  $paddingTop = 3;
  $paddingBottom = 0;
  $paddingLeft = 5;
  $cor_borderRight = '#808080';
  
  $topIcone  = 1;
//  $leftIcone = ($textArea_Global['left'] + $textArea_Global['width'])-20;
  $leftIcone = $textArea_Global['width'] - 17;
  $lenLabel  = $textArea_Conf['label_len'];
  $initArea   = ( $lenLabel ) + 15;
 
  $topTexto = 0;
  $widthTexto = $textArea_Global['width'];
  $heightTexto = $textArea_Global['height'];

  $topBox  = ( $topTexto + $heightTexto ) + 4;
  $leftBox = $textArea_Global['left'];
/*
  if ( $textArea_Conf['font_size'] == 'auto' )
  {
    $fontSize = $textArea_Global['fontSize'];
  }else
  {
    $fontSize = $textArea_Conf['font_size'];
  }// End if ( $textArea_Conf['font_size'] == 'auto' )
*/
  if ( $textArea_Conf['back_ground'] == 'auto' )
  {
    $backGround = '#FFFFFF';
  }else
  {
    $backGround = $textArea_Conf['back_ground'];
  }// End if ( $textArea_Conf['back_ground'] == 'auto' )
  
//  echo( $cols . " " . $rows );exit;
  writeTO('  #' . $textArea . '{'                                       );
  writeTO('    position:absolute;'                                      );
  writeTO('    top:' . $textArea_Global['top'] . 'px;'                  );
  writeTO('    left:' . $textArea_Global['left'] .'px;'                 );
  writeTO('    '                                                        );
  writeTO('    z-index:10;'                                             );
  writeTO('    '                                                        );
  writeTO('    width:'  . ($textArea_Global['width'] + $lenLabel - 5). 'px;' );
  writeTO('    height:' . ($textArea_Global['height'] + 30).  'px;'     );
  writeTO('    '                                                        );
  writeTO('    color:' . $textArea_Global['color'] .               ';'  );
  writeTO('    background-color:' . $textArea_Global['bgcolor'] .  ';'  );
  writeTO('    '                                                        );
  writeTO('    visibility: ' .$visible. ';'                             );
  writeTO('    '                                                        );
  writeTO('    border-top:'    . $textArea_Style['borderTop']    . ';'  );
  writeTO('    border-bottom:' . $textArea_Style['borderBottom'] . ';'  );
  writeTO('    border-left:'   . $textArea_Style['borderLeft']   . ';'  );
  writeTO('    border-right:'  . $textArea_Style['borderRight']  . ';'  );
  writeTO('  }'                                                         );
  writeTO('  '                                                          );
  writeTO('  #' . $textArea . '_Texto{'                                 );
  writeTO('    position:absolute;'                                      );
  writeTO('    top:' . $topTexto . 'px;'                                );
  writeTO('    left:' . $initArea .  'px;'                              );
  writeTO('  '                                                          );
  writeTO('    z-index:10;'                                             );
  writeTO('  '                                                          );
  writeTO('    font-family:courier new;'                                );
  writeTO('    font-size:' . $textArea_Global['fontSize'] .  'px;'      );
  writeTO('    padding-top:1px;'                                        );
  writeTO('    padding-left:3px;'                                       );
  writeTO('  '                                                          );
  writeTO('    color:' . $textArea_Global['color'] .              ';'   );
  writeTO('    background-color:' . $backGround . ';'                   );
  writeTO('    visibility: inherit;'                                    );
  writeTO('  '                                                          );
  writeTO('    border-top: 0px; '                                       );
  writeTO('    border-bottom:0px;'                                      );
  writeTO('    border-left:0px;'                                        );
  writeTO('    border-right:0px;'                                       );
  writeTO('  }'                                                         );
  writeTO('  '                                                          );
  writeTO( '  #' . $textArea . '_Caption{ '                             );
  writeTO( '    position:absolute;'                                     );
  writeTO( '    top:0px'                                         . ';'  );
  writeTO( '    left:0px'                                        . ';'  );
  writeTO( '    '                                                       );
  writeTO( '    font-size:' . $textArea_Global['fontSize'] . 'px;'      );
  writeTO( '    width:'. $lenLabel  . 'px'                        . ';' );
  writeTO( '    height:' . $textArea_Global['height'] . 'px'      . ';' );
  writeTO( '  }'                                                        );
  writeTO( '  #' . $textArea . '_key{ '                                 );
  writeTO( '    text-decoration:underline;'                             );
  writeTO( '  }'                                                        );
}// End create_textArea()


 function create_textArea_control( $modo_RAD )
 {
    global $componentes_no_Prj,
           $projeto,
           $esquema;

    //$path  = ( $modo_RAD )? CFG : _CFG_;
    $path  = ( defined('STUDIO') )? _CFG_ : _CFG_;

    $nDest = $path . "textArea.control.js.php";
    $comp  = $componentes_no_Prj;

    $fp = @fopen( $nDest, 'wb' );
    foreach( $comp as $comp_ => $obj_ )
    {
      if( $comp_ == 'textArea' )
      {
        $nrObj  = 0;
        $arrObj = array();
        $arrConf = array();

        /**
         *  Lista das Propriedades
         */
        $textArea_enabled = array();

        /**
         *  conta o numero de objetos textArea no projeto
         *  e armazena os nomes de cada Objetos no
         *  array $arrObj
         */
        foreach( $obj_ as $i_ => $v_ )
        {
          $arrObj[ $nrObj ] = $i_;

          /**
           *  inclui o arquivo .config.def.php de cada Objeto
           */
          include( $path . $i_ . ".config.def.php" );
          $nConf_ = $i_ . "_Conf";
          $arrConf[$i_] = $$nConf_;

          $nrObj ++;
        }// end foreach( $obj_ as $i_ => $v_ )
        writeTO( "textArea_obj = ". $nrObj .";", $fp );
        writeTO( "textArea_enabled = new Array();", $fp );
        writeTO( " ", $fp );

        $idx = 0;
        foreach( $arrConf as $ind => $val)
        {
          writeTO( 'textArea_enabled['.$idx . '] = '  . $val['enabled'] .';', $fp );
          $idx ++;
        }// End foreach($arrConf as $ind => $val)
        writeTO( " ", $fp );
			

      }// End if( $comp_ == 'textArea' )
    }// End foreach( $comp as $comp_ => $obj_ )
    fclose( $fp );

    return( $nDest );
  }// End function create_textArea_control( $modo_RAD )

?>
