<?php 
function create_comboBox( $comboBox,
                          $comboBox_Conf)
{
  global $_desenv_;

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

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

  if( defined( 'STUDIO' ) )
  {
    $path  = ( STUDIO == 'core' )? CFG : _CFG_;
  }else
  {
    $path  = _CFG_;
  }// End if( defined( 'STUDIO' ) )
  $nFile = $path . $comboBox . ".config.lista.ini";
  if( file_exists( $nFile ) )
  {
    $arr = readINIfile( $nFile );
    $ite1 = $arr[ strtolower($comboBox) . '_lista' ];
    $val  = each( $ite1 );
    //echo('combo: '.$val['value'] );exit;
  }else
  {
    $val['value'] = "";
  }// End if( file_exists( $nFile ) )
  
  $path_img = "http://";

  writeTO( '  <label id="' . $comboBox . '_Caption"'                        );
  writeTO( '         class="' . $comboBox . '"'                             );
  writeTO( '         for="' . $comboBox . '"></label>'                      );

  writeTO( '  <input id="' . $comboBox . '_Texto" type="text"  '            );
  writeTO( '         type="text" '                                          );
  writeTO( '         value="'.$val['value'].'" '                                      );
  writeTO( '         readOnly="true" '                                      );
  writeTO( '         tabindex="'.$tab_index.'"     '.$enabled. '>'          );
  writeTO( '  <img id="' . $comboBox . '_Icone" src="imagens/seta3.gif" />' );
  writeTO( '  '                                                             );
  writeTO( '  <div id="' . $comboBox . '_Box">'                             );
  writeTO( '  </div end="' . $comboBox . '_Box">'                           );
}// End create_comboBox()
   

/**
 *
 */
function create_comboBox_css( $comboBox,
                              $comboBox_Global,
                              $comboBox_Style)
{
  global $modo_RAD;
  
  if( $modo_RAD )
  {
    $visible = 'inherit';
  }else
  {
    $visible = ( $comboBox_Global['visibility'] == 'true' ) ? 'inherit':'hidden';
  }// End if( $modo_RAD )
  $topTexto = 0;
  $widthTexto = $comboBox_Global['width']-5; 
  $heightTexto = $comboBox_Global['height'] -1;
  
  $topIcone  = 1;
//  $leftIcone = ($comboBox_Global['left'] + $comboBox_Global['width'])-20;
  $leftIcone = $comboBox_Global['width']-17;

  $topBox  = ($topTexto + $heightTexto ) + 4;
//  $leftBox = $comboBox_Global['left'];
  $leftBox = '1';
  $widthBox = $comboBox_Global['width'] -5;

  writeTO('  #' . $comboBox . '{'                                       );
  writeTO('    position:absolute;'                                      );
  writeTO('    top:' . $comboBox_Global['top'] . 'px;'                  );
  writeTO('    left:' . $comboBox_Global['left'] .'px;'                 );
  writeTO('    '                                                        );    
  writeTO('    z-index:10;'                                             );
  writeTO('    '                                                        );    
  writeTO('    width:' . $comboBox_Global['width']              . 'px;' );
  writeTO('    height:' . $comboBox_Global['height']            . 'px;' );
  writeTO('    '                                                        );    
  writeTO('    color:' . $comboBox_Global['color']              . ';'   );
  writeTO('    background-color:' . $comboBox_Global['bgcolor'] . ';'   );
  writeTO('    '                                                        );    
  writeTO('    visibility: ' .$visible. ';'                             );
  writeTO('    '                                                        );    
  writeTO('    border-top:'    . $comboBox_Style['borderTop']    . ';'  );
  writeTO('    border-bottom:' . $comboBox_Style['borderBottom'] . ';'  );
  writeTO('    border-left:'   . $comboBox_Style['borderLeft']   . ';'  );
  writeTO('    border-right:'  . $comboBox_Style['borderRight']  . ';'  );
  writeTO('  }'                                                         );
  writeTO('  '                                                          );

  writeTO('  #' . $comboBox . '_Texto{'                                 );
  writeTO('    position:absolute;'                                      );
  writeTO('    top:' . $topTexto . 'px;'                                );
  writeTO('    left:0px;'                                               );
  writeTO('  '                                                          );    
  writeTO('    z-index:10;'                                             );
  writeTO('  '                                                          );
  writeTO('    font-family:verdana;'                                    );
  writeTO('    font-size:11px;'                                         );
  writeTO('    padding-top:1px;'                                        );
  writeTO('    padding-left:3px;'                                       );
  writeTO('  '                                                          );
  writeTO('    color:' . $comboBox_Global['color']              . ';'   );
  writeTO('    background-color:#FFFFFF'  . ';'                         );
  writeTO('    visibility: inherit ;'                                   );
  writeTO('  '                                                          );
  writeTO('    width:' . $widthTexto              . 'px;'               );
  writeTO('    height:' . $heightTexto            . 'px;'               );
  writeTO('  '                                                          );
  writeTO('    border-top: 0px; '  );
  writeTO('    border-bottom:0px;'  );
  writeTO('    border-left:0px;'  );
  writeTO('    border-right:0px;'  );
  writeTO('  }'                                                         );
  writeTO('  '                                                          );

  writeTO('  #' . $comboBox . '_Icone{'                                 );
  writeTO('    position:absolute;'                                      );
  writeTO('    top:' .  $topIcone . 'px;'                               );
  writeTO('    left:' . $leftIcone .'px;'                               );
  writeTO('    '                                                          );    
  writeTO('    z-index:10;'                                             );
  writeTO('    width:16px'              . ';'                           );
  writeTO('    height:17px'            . ';'                            );
  writeTO('    visibility: inherit ;'                                   );
  writeTO('  }'                                                         );
  writeTO('  '                                                          );

  writeTO('  #' . $comboBox . '_Box{'                                   );
  writeTO('    position:absolute;'                                      );
  writeTO('    top:' .  $topBox . 'px;'                                 );
  writeTO('    left:' . $leftBox .'px;'                                 );
  writeTO('    '                                                        );    
  writeTO('    color:' . $comboBox_Global['color']              . ';'   );
  writeTO('    background-color:#FFFFFF'  . ';'                         );
  writeTO('    '                                                        );    
  writeTO('    font-family:verdana;'                                    );
  writeTO('    font-size:16px;'                                         );
  writeTO('    padding-top:2px;'                                        );
  writeTO('    padding-left:1px;'                                       );
  writeTO('    '                                                        );    
  writeTO('    visibility: hidden;'                                     );
//  writeTO('    visibility: inherit;'                                     );
  writeTO('    '                                                        );
  writeTO('    width:'.$widthBox.'px;'                  );
  writeTO('  '                                                          );    
  writeTO('    border-top:1px solid #000000'     . ';'  );
  writeTO('    border-bottom:1px solid #000000' . ';'  );
  writeTO('    border-left:1px solid #000000'     . ';'  );
  writeTO('    border-right:1px solid #000000'   . ';'  );
  writeTO('  }'                                                         );

  writeTO('  .' . $comboBox . '_Label{'                                 );
  writeTO('    '                                                        );    
  writeTO('    font-family:verdana;'                                    );
  writeTO('    font-size:11px;'                                         );
  writeTO('    background-color:#FAFAFF;'                               );
  writeTO('    color:#000080;'                                          );
  writeTO('  }'                                                         );
  writeTO('  '                                                          );

}// End create_comboBox() 


function create_comboBox_control( $modo_RAD )
{
  global $componentes_no_Prj;

  if( defined( 'STUDIO' ) )
  {
    $path  = ( STUDIO == 'core' )? CFG : _CFG_;
  }else
  {
    $path  = _CFG_;
  }// End if( defined( 'STUDIO' ) )

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

  $fp = @fopen( $nDest, 'wb' );
  foreach( $comp as $comp_ => $obj_ )
  {
    if( $comp_ == 'comboBox' )
    {
      $nrObj  = 0;
      $arrObj = array();
      foreach( $obj_ as $i_ => $v_ )
      {
        $arrObj[ $nrObj ] = $i_;
        $nrObj ++;
      }// end foreach()
      writeTO( "comboBox_obj      = ". $nrObj .";", $fp );
      writeTO( "comboBox_selected = 0;"           , $fp );
      writeTO( "comboBox_aberto   = new Array();" , $fp );
      writeTO( "comboBox_itens    = new Array();" , $fp );
      writeTO( "comboBox_value    = new Array();" , $fp );
      writeTO( "comboBox_lista    = new Array();" , $fp );
      writeTO( "comboBox_onChange = new Array();" , $fp );
      writeTO( "  "       , $fp );

      for( $ix = 0; $ix < $nrObj; $ix ++)
      {
        $tmp = $arrObj[$ix];
        $nFile = $path . $tmp . ".config.lista.ini";
        if( file_exists( $nFile ) )
        {
          $arrLista = $tmp . "_Lista";
          //$$arrLista = readINIfile( $nFile );
          $arrLista = readINIfile( $nFile );
          $arr = $arrLista[ strtolower($tmp) . '_lista' ];
//        echo("\n<pre>");print_r($arrLista);exit;
        }else
        {
          include( $path . $tmp . ".config.lista.php" );
          // echo $tmp . ".config.lista.php";
          $tmp .= "_Lista";
          $arr = $$tmp;
        }// End if( file_exists( $path . $tmp . ".config.lista.ini" ) )
        
        writeTO( "comboBox_aberto[" . $ix . "] = false;" , $fp );
        writeTO( "comboBox_onChange[" . $ix . "] = false;", $fp );
        writeTO( "  ", $fp );

        $max   = count( $arr );
        $lista = 'new Array(' . $max . ');';
        writeTO( "comboBox_itens[" . $ix . "] = " . $max . ";" , $fp );
        writeTO( "comboBox_value[" . $ix . "] = " . $lista , $fp );
        writeTO( "comboBox_lista[" . $ix . "] = " . $lista , $fp );

        $ind_ = 0;
        foreach( $arr as $ii_ => $val )
        {
          $lista = '"'.$val.'";';
          writeTO( 'comboBox_value[' . $ix . '][' . $ind_ . '] = "' . $ii_ . '"',   $fp );
          writeTO( 'comboBox_lista[' . $ix . '][' . $ind_ . '] = "' . $val . '"', $fp );
          $ind_ ++;
        }
        //echo("\n<pre>");print_r($arr);exit;

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

   
?> 
