NTKHBox.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. class NTKHBox
  3. {
  4. function NTKHBox($id, $padding, $spacing, $debug = False)
  5. {
  6. $this->id = $id;
  7. $this->padding = $padding;
  8. $this->spacing = $spacing;
  9. $this->debug = $debug;
  10. $this->elems = array();
  11. }
  12. function add($elem, $width = -1, $height = -1, $style = "")
  13. {
  14. $this->elems[] = array($elem, $width, $height, $style);
  15. }
  16. function getHtml()
  17. {
  18. $html = "";
  19. $html .= "<table id=\"$this->id\" class=\"hbox\" ";
  20. if($this->debug)
  21. $html .= "border=\"1\" ";
  22. $html .= "cellspacing=\"$this->spacing\" cellpadding=\"$this->padding\" style=\"table-layout: fixed; width: 100%; height: 100%;\">\n";
  23. $html .= "<tr>\n";
  24. for($i = 0; $i < count($this->elems); $i++)
  25. {
  26. if($this->elems[$i][1] != -1)
  27. $width = $this->elems[$i][1];
  28. else
  29. $width = "100%";
  30. if($this->elems[$i][2] != -1)
  31. $height = $this->elems[$i][2];
  32. else
  33. $height = "100%";
  34. $html .= "<td style=\"width: $width; height: $height; ".$this->elems[$i][3]."\">\n";
  35. $html .= $this->elems[$i][0]->getHtml();
  36. $html .= "</td>\n";
  37. }
  38. $html .= "</tr>\n";
  39. $html .= "</table>\n";
  40. return $html;
  41. }
  42. }
  43. ?>