Example #1
0
 /**
  * Show fixed positioned block box using the specified output driver
  * 
  * Note that 'show_fixed' is called to box _nested_ to the fixed-positioned boxes too! 
  * Thus, we need to check whether actual 'position' values is 'fixed' for this box 
  * and only in that case attempt to move box
  *
  * @param OutputDriver $driver The output device driver object
  */
 function show_fixed(&$driver)
 {
     $position = $this->get_css_property(CSS_POSITION);
     if ($position == POSITION_FIXED) {
         /**
          * Calculate the distance between the top page edge and top box content edge
          */
         $bottom = $this->get_css_property(CSS_BOTTOM);
         $top = $this->get_css_property(CSS_TOP);
         if (!$top->isAuto()) {
             if ($top->isPercentage()) {
                 $vertical_offset = $driver->getPageMaxHeight() / 100 * $top->getPercentage();
             } else {
                 $vertical_offset = $top->getPoints();
             }
         } elseif (!$bottom->isAuto()) {
             if ($bottom->isPercentage()) {
                 $vertical_offset = $driver->getPageMaxHeight() * (100 - $bottom->getPercentage()) / 100 - $this->get_height();
             } else {
                 $vertical_offset = $driver->getPageMaxHeight() - $bottom->getPoints() - $this->get_height();
             }
         } else {
             $vertical_offset = 0;
         }
         /**
          * Calculate the distance between the right page edge and right box content edge
          */
         $left = $this->get_css_property(CSS_LEFT);
         $right = $this->get_css_property(CSS_RIGHT);
         if (!$left->isAuto()) {
             if ($left->isPercentage()) {
                 $horizontal_offset = $driver->getPageWidth() / 100 * $left->getPercentage();
             } else {
                 $horizontal_offset = $left->getPoints();
             }
         } elseif (!$right->isAuto()) {
             if ($right->isPercentage()) {
                 $horizontal_offset = $driver->getPageWidth() * (100 - $right->getPercentage()) / 100 - $this->get_width();
             } else {
                 $horizontal_offset = $driver->getPageWidth() - $right->getPoints() - $this->get_width();
             }
         } else {
             $horizontal_offset = 0;
         }
         /**
          * Offset current box to the required position on the current page (note that
          * fixed-positioned element are placed relatively to the viewport - page in our case)
          */
         $this->moveto($driver->getPageLeft() + $horizontal_offset, $driver->getPageTop() - $vertical_offset);
     }
     /**
      * After box have benn properly positioned, render it as usual.
      */
     return GenericContainerBox::show_fixed($driver);
 }
 /**
  * Renders the backgroung image using the specified output driver.
  * 
  * @param OutputDriver $driver an output driver object
  * @param GenericFormattedBox $box an box owning this background image
  * @param int $repeat the 'background-repeat' value
  * @param BackgroundPosition $position the 'background-position' value
  *
  * @uses BackgroundPosition
  * @uses OutputDriver
  */
 function show(&$driver, $box, $repeat, $position, $attachment)
 {
     /**
      * If no image should be rendered, just return
      * @see BackgroundImage::$_url
      */
     if (is_null($this->_url)) {
         return;
     }
     if (is_null($this->_image)) {
         return;
     }
     if ($attachment == BACKGROUND_ATTACHMENT_FIXED && $box->getCSSProperty(CSS_DISPLAY) == '-body') {
         $media =& $driver->get_media();
         $left = $box->get_left_background();
         $right = $box->get_right_background();
         $top = $driver->offset + mm2pt($media->margins['bottom']) + mm2pt($media->real_height());
         $bottom = $driver->offset + mm2pt($media->margins['bottom']);
     } else {
         $left = $box->get_left_background();
         $right = $box->get_right_background();
         $top = $box->get_top_background();
         $bottom = $box->get_bottom_background();
     }
     /**
      * Setup clipping region for padding area. Note that background image is drawn in the padding 
      * area which in generic case is greater than content area.
      * 
      * @see OutputDriver::clip()
      *
      * @link http://www.w3.org/TR/CSS21/box.html#box-padding-area CSS 2.1 definition of padding area
      */
     $driver->save();
     $driver->moveto($left, $top);
     $driver->lineto($right, $top);
     $driver->lineto($right, $bottom);
     $driver->lineto($left, $bottom);
     $driver->closepath();
     $driver->clip();
     /**
      * get real image size in device points
      *
      * @see pt2pt()
      * @see px2pt()
      */
     $image_height = px2pt(imagesy($this->_image));
     $image_width = px2pt(imagesx($this->_image));
     /**
      * Get dimensions of the rectangle to be filled with the background image
      */
     $padding_width = $right - $left;
     $padding_height = $top - $bottom;
     /**
      * Calculate the vertical offset from the top padding edge to the background image top edge using current 
      * 'background-position' value. 
      * 
      * @link file:///C:/docs/css/colors.html#propdef-background-position CSS 2 'background-position' description
      */
     if ($position->x_percentage) {
         $x_offset = ($padding_width - $image_width) * $position->x / 100;
     } else {
         $x_offset = $position->x;
     }
     /**
      * Calculate the horizontal offset from the left padding edge to the background image left edge using current 
      * 'background-position' value
      * 
      * @link file:///C:/docs/css/colors.html#propdef-background-position CSS 2 'background-position' description
      */
     if ($position->y_percentage) {
         $y_offset = ($padding_height - $image_height) * $position->y / 100;
     } else {
         $y_offset = $position->y;
     }
     /**
      * Output the image (probably tiling it; depends on current value of 'background-repeat') using 
      * current output driver's tiled image output functions. Note that px2pt(1) is an image scaling factor; as all
      * page element are scaled to fit the media, background images should be scaled too!
      * 
      * @see OutputDriver::image()
      * @see OutputDriver::image_rx()
      * @see OutputDriver::image_ry()
      * @see OutputDriver::image_rxry()
      *
      * @link file:///C:/docs/css/colors.html#propdef-background-repeat CSS 2.1 'background-repeat' property description
      */
     switch ($repeat) {
         case BR_NO_REPEAT:
             /**
              * 'background-repeat: no-repeat' case; no tiling at all
              */
             $driver->image($this->_image, $left + $x_offset, $top - $image_height - $y_offset, px2pt(1));
             break;
         case BR_REPEAT_X:
             /**
              * 'background-repeat: repeat-x' case; horizontal tiling
              */
             $driver->image_rx($this->_image, $left + $x_offset, $top - $image_height - $y_offset, $image_width, $right, $x_offset, $y_offset, px2pt(1));
             break;
         case BR_REPEAT_Y:
             /**
              * 'background-repeat: repeat-y' case; vertical tiling
              */
             $driver->image_ry($this->_image, $left + $x_offset, $top - $image_height - $y_offset, $image_height, $bottom, $x_offset, $y_offset, px2pt(1));
             break;
         case BR_REPEAT:
             /**
              * 'background-repeat: repeat' case; full tiling
              */
             $driver->image_rx_ry($this->_image, $left + $x_offset, $top - $image_height + $y_offset, $image_width, $image_height, $right, $bottom, $x_offset, $y_offset, px2pt(1));
             break;
     }
     /**
      * Restore the previous clipping area
      * 
      * @see OutputDriver::clip()
      * @see OutputDriver::restore()
      */
     $driver->restore();
 }
 /** 
  * Render the checkbox using the specified output driver
  *
  * @param OutputDriver $driver The output device driver object
  */
 function show(&$driver)
 {
     /**
      * Get the coordinates of the check mark
      */
     $x = ($this->get_left() + $this->get_right()) / 2;
     $y = ($this->get_top() + $this->get_bottom()) / 2;
     /**
      * Calculate checkmark size; it looks nice when it takes 
      * 1/3 of the box size
      */
     $size = $this->get_width() / 3;
     /**
      * Draw the box
      */
     $driver->setlinewidth(0.25);
     $driver->moveto($x - $size, $y + $size);
     $driver->lineto($x + $size, $y + $size);
     $driver->lineto($x + $size, $y - $size);
     $driver->lineto($x - $size, $y - $size);
     $driver->closepath();
     $driver->stroke();
     /**
      * Render the interactive button (if requested and possible)
      * Also, field should be rendered only if name is not empty
      */
     global $g_config;
     if ($g_config['renderforms'] && $this->_name != "" && $this->_value != "") {
         $driver->field_checkbox($x - $size, $y + $size, 2 * $size, 2 * $size, $this->_name, $this->_value, $this->_checked);
     } else {
         /**
          * Draw check mark if needed
          */
         if ($this->_checked) {
             $check_size = $this->get_width() / 6;
             $driver->moveto($x - $check_size, $y + $check_size);
             $driver->lineto($x + $check_size, $y - $check_size);
             $driver->stroke();
             $driver->moveto($x + $check_size, $y + $check_size);
             $driver->lineto($x - $check_size, $y - $check_size);
             $driver->stroke();
         }
     }
     return true;
 }
Example #4
0
 /**
  * Render the form field corresponding to this button
  * (Will be overridden by subclasses; they may render more specific button types)
  *
  * @param OutputDriver $driver The output driver object
  */
 function _render_field(&$driver)
 {
     $driver->field_pushbutton($this->get_left_padding(), $this->get_top_padding(), $this->get_width() + $this->get_padding_left() + $this->get_padding_right(), $this->get_height() + $this->get_padding_top() + $this->get_padding_bottom());
 }
Example #5
0
 /**
  * Render interactive field using the driver-specific capabilities;
  * button is rendered as a rectangle defined by margin and padding areas (note that unlike most other boxes,
  * borders are _outside_ the box, so we may treat 
  *
  * @param OutputDriver $driver reference to current output driver object
  */
 function _render_field(&$driver)
 {
     $driver->field_pushbuttonsubmit($this->get_left_padding() - $this->get_margin_left(), $this->get_top_padding() + $this->get_margin_top(), $this->get_width() + $this->get_padding_left() + $this->get_padding_right() + $this->get_margin_left() + $this->get_margin_right(), $this->get_height() + $this->get_padding_top() + $this->get_padding_bottom() + $this->get_margin_top() + $this->get_margin_bottom(), $this->_field_name, $this->_value, $this->_action_url);
 }