<?php 
  function create_treeView( $treeView,
                            $treeView_Conf,
                            $treeView_Item )
  {
    writeTO( '  <img id="'. $treeView.'_pasta" src="imagens/pasta_aberta.gif">' );
    writeTO( '  <label id="'.$treeView.'_label" class="treeView_label">'        );
    writeTO( '  ' . $treeView_Conf['rootName'] . '</label>'                     );
    writeTO( '    '                                                             );
    writeTO( '    <div id="'.$treeView.'_linhas">'                              );
    $nrLinha = 0;
    foreach( $treeView_Item as $nivel_ => $label_ )
    {
      $nrLinha ++;
      writeTO( '  <img id="' . $treeView . '_linha'.$nrLinha.'" src="imagens/cotovelo1.gif" >' );
      writeTO( '  <img id="'. $treeView.$nivel_.'" src="imagens/projeto.gif">' );
      writeTO( '  <label id="'.$treeView.$nivel_.'_label" class="treeView_label">'.$label_.'</label>' );
    }
    writeTO( '    </div end="'.$treeView.'_linhas">'                                           );
  }// End create_treeView()
  
  
  
  function create_treeView_css( $treeView,
                              $treeView_Global,
                              $treeView_Style,
                              $treeView_Conf,
                              $treeView_Item,
                              $flag_treeView )
  {
    global $projeto,
           $esquema;
    
    $visible = ($treeView_Global['visibility'] == 'visible' ) ? 'inherit':'hidden';
    $paddingTop  = 0;
    $paddingLeft = 0;
    $topPasta  = 0;
    $leftPasta = 0;
    $topLabel  = 3;
    $leftLabel = 25;

    // 1º nível
    writeTO( '  #' . $treeView . '{ '                           );
    writeTO( '    position:absolute; '                          );
    writeTO( '    top:' . $treeView_Global['top'] . 'px;'       );
    writeTO( '    left:' . $treeView_Global['left'] . 'px;'     );
    writeTO( '    '                                             );
    writeTO( '    z-index:10;'                                  );
    writeTO( '    '                                             );
    writeTO( '    width:' . $treeView_Global['width'] . 'px;'   );
    writeTO( '    height:' . $treeView_Global['height'] . 'px;' );
    writeTO( '    '                                             );
    writeTO( '    visibility:'.$visible.';'                     );
    writeTO( '    }'                                            );
    writeTO( '  #' . $treeView . '_pasta{ '                     );
    writeTO( '    position:absolute; '                          );
    writeTO( '    top:' . $topPasta . 'px;'                     );
    writeTO( '    left:' . $leftPasta . 'px;'                   );
    writeTO( '    z-index:20;'                                  );
    writeTO( '    }'                                            );
    writeTO( '  #' . $treeView . '_label{ '                     );
    writeTO( '    position:absolute; '                          );
    writeTO( '    top:' . $topLabel . 'px;'                     );
    writeTO( '    left:' . $leftLabel . 'px;'                   );
    writeTO( '    z-index:20;'                                  );
    writeTO( '    }'                                            );
    writeTO( '    '                                             );
    
    $topLinha  = 10;
    $leftLinha = 8;
    $nrLinha   = 0;
    
    foreach( $treeView_Item as $nivel_ => $label_ )
    {
    $nrLinha   ++;
    $topNivel        = $topLinha + 5;
    $leftNivel       = $leftLinha + 20;
    $topNivel_label  = $topNivel + 5;
    $leftNivel_label = $leftNivel + 30;
    
    writeTO( '  #' . $treeView . '_linha'.$nrLinha.'{ '                           );
    writeTO( '    position:absolute; '                        );
    writeTO( '    top:' . $topLinha . 'px;'       );
    writeTO( '    left:' . $leftLinha . 'px;'     );
    writeTO( '    z-index:10;'                                );
    writeTO( '    }'                                          );
    writeTO( '  #' . $treeView .$nivel_. '{ '                           );
    writeTO( '    position:absolute; '                        );
    writeTO( '    top:' . $topNivel . 'px;'       );
    writeTO( '    left:' . $leftNivel . 'px;'     );
    writeTO( '    z-index:20;'                                );
    writeTO( '    }'                                          );
    writeTO( '  #' . $treeView .$nivel_. '_label{ '                           );
    writeTO( '    position:absolute; '                        );
    writeTO( '    top:' . $topNivel_label . 'px;'       );
    writeTO( '    left:' . $leftNivel_label . 'px;'     );
    writeTO( '    z-index:20;'                                );
    writeTO( '    }'                                          );
    $topLinha  += 18;
    }

    if ( $flag_treeView )
    {
      writeTO( '  .treeView_dinamico{ '                                   );
      writeTO( '    position:absolute'                              . ';' );
      writeTO( '    '                                                     );
      writeTO( '    visibility:inherit'                             . ';' );
      writeTO( '  }'                                                      );
      writeTO( '    '                                                     );
      writeTO( '  .treeView_label{ '                                      );
      writeTO( '    position:absolute'                              . ';' );
      writeTO( '    font-family:' .$treeView_Global['fontFamily']   . ';' );
      writeTO( '    font-size:' .$treeView_Global['fontSize']. 'px' . ';' );
      writeTO( '    padding-top:'.$paddingTop.'px'                  . ';' );
      writeTO( '    padding-left:'.$paddingLeft.'px'                . ';' );
      writeTO( '    '                                                     );
      writeTO( '    visibility:inherit'                             . ';' );
      writeTO( '  }'                                                      );
      writeTO( '    '                                                     );
      writeTO( '  .treeView_line{ '                                       );
      writeTO( '    width:20px;'                                          );
      writeTO( '    height:20px;'                                         );
      writeTO( '    border-left:1px dotted #000000'                 . ';' );
      writeTO( '    border-bottom:1px solid #000000'                . ';' );
      writeTO( '  }'                                                      );
    }
  }// End create_treeView_css() 


function create_treeView_config( $modo_RAD )
{
  global $componentes_no_Prj;
  $comps_no_Prj = $componentes_no_Prj;
  $path  = ( $modo_RAD )? _CFG_ : CFG;
  $nDest = $path . "treeView.config.php";

  $fp = @fopen( $nDest, 'wb' );
  foreach( $comps_no_Prj as $comp_ => $obj_ )
  {
    if( $comp_ == 'treeView' )
    {
      $nrObj  = 0;
      $arrObj = array();
      foreach( $obj_ as $i_ => $v_ )
      {
        $arrObj[ $nrObj ] = $i_;
        $nrObj ++;
      }// end foreach()

      writeTO( "treeView_obj       = ". $nrObj . ";", $fp );
      writeTO( "  "                                 , $fp );
      writeTO( "treeView_nrItens = new Array(); "   , $fp );
      
      for( $ix = 0; $ix < $nrObj; $ix ++)
      {
        $tmp = $arrObj[$ix];
        include( CFG . $tmp . ".config.item.php" );
        $tmp .= "_Item";
        $arr = $$tmp;
        
        writeTO( "treeView_nrItens[" . $ix . "] = ".count($arr) . ";", $fp );

      }// End for()
      
    }// End if()
  }// End foreach()
  fclose( $fp );

  return( $nDest );
}// End function


?> 
