<?php
function create_panel( $panel,
                       $panel_Conf )
{
  $tmp = $panel . "_field_lang";
  global $componentes_no_Prj, $$tmp;
  $lang = $$tmp;

  if( $panel_Conf['enabled'] == 'true' )
  {
    $enabled = "";
  }
	else
  {
    $enabled = "disabled";
  }// End if( $panel_Conf['enabled'] == 'true' )

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

  $label = ( $panel_Conf['caption'] == 'auto' )? $panel : $panel_Conf['caption'];
  
  writeTO( '  <div id="' . $panel . '_Box">' );
  writeTO( '  </div end="' . $panel . '">' );
  writeTO( '  ' );
  if( !empty( $label ) )
  {
    writeTO( '  <label id="' . $panel . '_Label" class="panel_Label"  ' );
    writeTO( '         tabindex="'.$tab_index.'" '.$enabled.' >         ' );
    writeTO( '    &nbsp;&nbsp;'.$label.'&nbsp;&nbsp;                                           ' );
    writeTO( '  </label end="' . $panel . '"_Label">                  ' );
    writeTO( '  ' );
  }// End

}// End create_panel()


/**
 *  create_panel_css()
 *  ------------------------------------------------------------------------  //
 */
function create_panel_css( $panel,
                           $panel_Global,
                           $panel_Style,
                           $panel_Conf )
{
  global $projeto,
         $esquema,
         $modo_RAD;

  if( $modo_RAD )
  {
    $visible = 'inherit';
  }else
  {
    $visible = ( $panel_Global['visibility'] == 'true' ) ? 'inherit':'hidden';
  }// End if( $modo_RAD )
  
  $paddingTop = 3;
  $paddingBot = 0;
  $paddingLeft = 5;
//  $lenLabel    = round( $panel_Global['width'] - ( $panel_Global['width'] - $panel_Conf['label_len'] + 15 ) );
//  $lenInput    = round( ( $panel_Global['width'] - $lenLabel ) - 10 );
//  $initInput   = round( ( $lenLabel + $paddingTop + $paddingLeft ) -1 );
//  $colorBorder = '#808080';
  $width_  = $panel_Global['width'] +5;
  $height_ = $panel_Global['height'] +10;
  $zIndex = 100;

  $cor_borderLeft  = $esquema[$projeto['esquema']]['ButtonHighlight'];
  $cor_borderRight = $esquema[$projeto['esquema']]['ButtonShadow'];
                               
  writeTO( '  #' . $panel . '{ '                                       );
  writeTO( '    position:absolute;'                                    );
  writeTO( '    top:' . $panel_Global['top']                 . 'px;'   );
  writeTO( '    left:' . $panel_Global['left']               . 'px;'   );
  writeTO( '    '                                                      );
  writeTO( '    z-index:'.$zIndex.';'                                           );
  writeTO( ''                                                          );
  writeTO( '    width:' . $width_               . 'px;' );
  writeTO( '    height:' . $height_             . 'px;' );
  writeTO( '    '                                                      );
  writeTO( '    padding-top:' . $paddingTop . 'px;'                    );
  writeTO( '    padding-bottom:' . $paddingBot . 'px;'              );
  writeTO( '    '                                                      );
  writeTO( '    overflow:hidden;'   );
  writeTO( '    background-color:' . $panel_Global['bgcolor']  . ';'   );
  writeTO( '    '                                                      );
  writeTO( '    visibility:'. $visible .';'                            );
  writeTO( '    '                                                      );
//  writeTO( '    border-top:'    . $panel_Style['borderTop']    . ';'   );
//  writeTO( '    border-bottom:' . $panel_Style['borderBottom'] . ';'   );
//  writeTO( '    border-left:'   . $panel_Style['borderLeft']   . ';'   );
//  writeTO( '    border-right:'  . $panel_Style['borderRight']  . ';'   );
  writeTO( '  }'                                                       );
  writeTO( '  '                                                        );

  writeTO( '  #' . $panel . '_Box{ '                                       );
  writeTO( '    position:absolute;'                                    );
  writeTO( '    top:8px;'   );
  writeTO( '    left:0px;'   );
  writeTO( '    '                                                      );
  writeTO( '    width:' . $panel_Global['width']               . 'px;' );
  writeTO( '    height:' . $panel_Global['height']             . 'px;' );
  writeTO( '    '                                                      );
  writeTO( '    padding-top:' . $paddingTop . 'px;'                    );
  writeTO( '    padding-bottom:' . $paddingBot . 'px;'              );
  writeTO( '    '                                                      );
  writeTO( '    color:' . $panel_Global['color']               . ';'   );
  writeTO( '    background-color:' . $panel_Global['bgcolor']  . ';'   );
  writeTO( '    '                                                      );
  writeTO( '    visibility:inherit;'                            );
  writeTO( '    '                                                      );
  writeTO( '    border-top:'    . $panel_Style['borderTop']    . ';'   );
  writeTO( '    border-bottom:' . $panel_Style['borderBottom'] . ';'   );
  writeTO( '    border-left:'   . $panel_Style['borderLeft']   . ';'   );
  writeTO( '    border-right:'  . $panel_Style['borderRight']  . ';'   );
  writeTO( '  }'                                                       );
  writeTO( '  '                                                        );

  writeTO( '  #' . $panel . '_Label{ '                                 );
  writeTO( '    position:absolute;'                                    );
  writeTO( '    top:2px'                                       . ';'  );
  writeTO( '    left:10px'                                       . ';' );
//  writeTO( '    width:'. $lenLabel  . 'px'           . ';'             );
//  writeTO( '    height:15'    .  'px'               .  ';'             );
  writeTO( '    font-size:' . $panel_Global['fontSize'] . 'px;'        );
  writeTO( '    background-color:'.$panel_Global['bgcolor']    . ';'   );
  writeTO( '  }'                                                       );
  writeTO( '  '                                                        );

}// End create_panel_css()


function create_panel_control( $modo_RAD )
{

    global $componentes_no_Prj,
           $projeto,
           $esquema;

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

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

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


        /**
         *  conta o numero de objetos panel 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( "panel_obj = ". $nrObj .";", $fp );
        writeTO( "panel_enabled = new Array();", $fp );
        writeTO( " ", $fp );

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

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

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




?>
