### Home Classes Methods

### In Files

- lib/rabbit/element/container-element.rb

### Methods

- ::new
- #<<
- #[]
- #[]=
- #_width
- #add_element
- #clear_theme
- #compile
- #compile_elements
- #compile_horizontal
- #compile_horizontal_element
- #container_clear_theme
- #delete
- #dirty?
- #draw_element
- #draw_elements
- #have_tag?
- #have_wait_tag?
- #height
- #inspect
- #prop_delete
- #prop_get
- #prop_set
- #replace_element
- #substitute_text
- #text
- #to_html
- #to_rd
- #unshift
- #width

### Included Modules

- Enumerable
- Rabbit::Element::Base

### Class/Module Index

Quicksearch

- Rabbit
- Rabbit::AAFigureCanNotHandleError
- Rabbit::Action
- Rabbit::ApplyFinish
- Rabbit::AuthorConfiguration
- Rabbit::BlockDiagCanNotHandleError
- Rabbit::CantAllocateColorError
- Rabbit::CantFindHTMLTemplate
- Rabbit::CantFindThemeRDTemplate
- Rabbit::Canvas
- Rabbit::Command
- Rabbit::Command::Rabbit
- Rabbit::Command::RabbitSlide
- Rabbit::Command::RabbitTheme
- Rabbit::Config
- Rabbit::Console
- Rabbit::Converter
- Rabbit::CursorManager
- Rabbit::DependencyCanvas
- Rabbit::DiaCanNotHandleError
- Rabbit::DirtyCount
- Rabbit::EPSCanNotHandleError
- Rabbit::Element
- Rabbit::Element::Author
- Rabbit::Element::Base
- Rabbit::Element::Base::DrawHook
- Rabbit::Element::BlockElement
- Rabbit::Element::BlockHorizontalCentering
- Rabbit::Element::BlockQuote
- Rabbit::Element::Body
- Rabbit::Element::ClassName
- Rabbit::Element::Code
- Rabbit::Element::Comment
- Rabbit::Element::Container
- Rabbit::Element::ContainerElement
- Rabbit::Element::ContentSource
- Rabbit::Element::CustomTag
- Rabbit::Element::Date
- Rabbit::Element::DeletedText
- Rabbit::Element::DescriptionContent
- Rabbit::Element::DescriptionList
- Rabbit::Element::DescriptionListItem
- Rabbit::Element::DescriptionTerm
- Rabbit::Element::Emphasis
- Rabbit::Element::EnumList
- Rabbit::Element::EnumListItem
- Rabbit::Element::FootText
- Rabbit::Element::FootTextBlock
- Rabbit::Element::Footnote
- Rabbit::Element::HeadLine
- Rabbit::Element::Image
- Rabbit::Element::ImageTitleSlide
- Rabbit::Element::Index
- Rabbit::Element::IndexSlide
- Rabbit::Element::IndexThumbnail
- Rabbit::Element::IndexThumbnailRow
- Rabbit::Element::Institution
- Rabbit::Element::ItemList
- Rabbit::Element::ItemListItem
- Rabbit::Element::Keyboard
- Rabbit::Element::Keyword
- Rabbit::Element::MethodDescription
- Rabbit::Element::MethodKind
- Rabbit::Element::MethodList
- Rabbit::Element::MethodListItem
- Rabbit::Element::MethodName
- Rabbit::Element::MethodTerm
- Rabbit::Element::Note
- Rabbit::Element::Paragraph
- Rabbit::Element::Place
- Rabbit::Element::PopplerPage
- Rabbit::Element::PopplerSlide
- Rabbit::Element::PopplerTitleSlide
- Rabbit::Element::PreformattedBlock
- Rabbit::Element::PreformattedText
- Rabbit::Element::ReferText
- Rabbit::Element::Slide
- Rabbit::Element::SlideElement
- Rabbit::Element::Subscript
- Rabbit::Element::Subtitle
- Rabbit::Element::Superscript
- Rabbit::Element::SyntaxHighlightingBlock
- Rabbit::Element::SyntaxHighlightingText
- Rabbit::Element::Table
- Rabbit::Element::TableBody
- Rabbit::Element::TableCell
- Rabbit::Element::TableHead
- Rabbit::Element::TableHeader
- Rabbit::Element::TableRow
- Rabbit::Element::Text
- Rabbit::Element::TextBlock
- Rabbit::Element::TextBlockElement
- Rabbit::Element::TextContainer
- Rabbit::Element::TextContainerElement
- Rabbit::Element::TextElement
- Rabbit::Element::TextRenderer
- Rabbit::Element::Title
- Rabbit::Element::TitleSlide
- Rabbit::Element::Variable
- Rabbit::Element::Verbatim
- Rabbit::Element::Video
- Rabbit::Element::WaitBlock
- Rabbit::Element::WaitTag
- Rabbit::Element::When
- Rabbit::Element::Where
- Rabbit::EmbedFrame
- Rabbit::Error
- Rabbit::Format
- Rabbit::Format::ConvenienceTextFormatter
- Rabbit::Format::Foreground
- Rabbit::Format::Formatter
- Rabbit::Format::Size
- Rabbit::Format::SpanTextFormatter
- Rabbit::Format::ValueContainerFormatter
- Rabbit::Frame
- Rabbit::Front
- Rabbit::Front::PublicLevel
- Rabbit::GIMPCanNotHandleError
- Rabbit::GemBuilder
- Rabbit::GemFinder
- Rabbit::Gesture
- Rabbit::Gesture::Handler
- Rabbit::Gesture::Processor
- Rabbit::GetText
- Rabbit::Graffiti
- Rabbit::Graffiti::ConfigDialog
- Rabbit::Graffiti::Processor
- Rabbit::HTML
- Rabbit::HTML::Generator
- Rabbit::ImageFileDoesNotExistError
- Rabbit::ImageLoadError
- Rabbit::ImageLoadWithExternalCommandError
- Rabbit::ImageLoader
- Rabbit::ImageManipulable
- Rabbit::ImageManipulable::Base
- Rabbit::ImageManipulable::Default
- Rabbit::ImageManipulable::Dia
- Rabbit::ImageManipulable::EPS
- Rabbit::ImageManipulable::GIMP
- Rabbit::ImageManipulable::PDF
- Rabbit::ImageManipulable::SVG
- Rabbit::ImmutableSourceTypeError
- Rabbit::InfoWindow
- Rabbit::InvalidImageSizeError
- Rabbit::InvalidMotionError
- Rabbit::Keys
- Rabbit::Keys::Alt
- Rabbit::Keys::Control
- Rabbit::Keys::Shift
- Rabbit::Logger
- Rabbit::Logger::Base
- Rabbit::Logger::GUI
- Rabbit::Logger::STDERR
- Rabbit::Logger::Severity
- Rabbit::Menu
- Rabbit::ModuleLoader
- Rabbit::NoPrintSupportError
- Rabbit::NotAvailableInterfaceError
- Rabbit::NotExistError
- Rabbit::NotFileError
- Rabbit::NotReadableError
- Rabbit::NullFrame
- Rabbit::ParseError
- Rabbit::ParseFinish
- Rabbit::Parser
- Rabbit::Parser::Base
- Rabbit::Parser::Ext
- Rabbit::Parser::Ext::AAFigure
- Rabbit::Parser::Ext::BlockDiag
- Rabbit::Parser::Ext::CodeRay
- Rabbit::Parser::Ext::CodeRay::RabbitEncoder
- Rabbit::Parser::Ext::Emacs
- Rabbit::Parser::Ext::Enscript
- Rabbit::Parser::Ext::Entity
- Rabbit::Parser::Ext::Escape
- Rabbit::Parser::Ext::Image
- Rabbit::Parser::Ext::Image::Private
- Rabbit::Parser::Ext::Inline
- Rabbit::Parser::Ext::TeX
- Rabbit::Parser::Ext::Video
- Rabbit::Parser::Image
- Rabbit::Parser::Markdown
- Rabbit::Parser::Markdown::Converter
- Rabbit::Parser::NoteSetter
- Rabbit::Parser::PDF
- Rabbit::Parser::PauseSupport
- Rabbit::Parser::RD
- Rabbit::Parser::RD::Ext
- Rabbit::Parser::RD::Ext::Base
- Rabbit::Parser::RD::Ext::BlockVerbatim
- Rabbit::Parser::RD::Ext::CharacterReference
- Rabbit::Parser::RD::Ext::Image
- Rabbit::Parser::RD::Ext::InlineVerbatim
- Rabbit::Parser::RD::Ext::Refer
- Rabbit::Parser::RD::Ext::Video
- Rabbit::Parser::RD::RD2RabbitVisitor
- Rabbit::Parser::RD::Visitor
- Rabbit::Parser::SlidePropertySetter
- Rabbit::Parser::Wiki
- Rabbit::Parser::Wiki::RabbitOutput
- Rabbit::Parser::Wiki::RabbitOutput::BlockPlugin
- Rabbit::Parser::Wiki::RabbitOutput::InlinePlugin
- Rabbit::Parser::Wiki::RabbitOutput::InlinePlugin::Private
- Rabbit::PathManipulatable
- Rabbit::Progress
- Rabbit::READMEParser
- Rabbit::RT2RabbitVisitor
- Rabbit::Renderer
- Rabbit::Renderer::Base
- Rabbit::Renderer::Color
- Rabbit::Renderer::Display
- Rabbit::Renderer::Display::Base
- Rabbit::Renderer::Display::ButtonHandler
- Rabbit::Renderer::Display::ClutterEmbed
- Rabbit::Renderer::Display::Cursor
- Rabbit::Renderer::Display::DrawingArea
- Rabbit::Renderer::Display::DrawingAreaBase
- Rabbit::Renderer::Display::DrawingAreaPrimitive
- Rabbit::Renderer::Display::DrawingAreaViewOnly
- Rabbit::Renderer::Display::GL
- Rabbit::Renderer::Display::Gesture
- Rabbit::Renderer::Display::Graffiti
- Rabbit::Renderer::Display::HookHandler
- Rabbit::Renderer::Display::Info
- Rabbit::Renderer::Display::KeyHandler
- Rabbit::Renderer::Display::Magnifier
- Rabbit::Renderer::Display::Mask
- Rabbit::Renderer::Display::Menu
- Rabbit::Renderer::Display::Progress
- Rabbit::Renderer::Display::ScrollHandler
- Rabbit::Renderer::Display::Search
- Rabbit::Renderer::Display::Spotlight
- Rabbit::Renderer::Engine
- Rabbit::Renderer::Engine::Cairo
- Rabbit::Renderer::Engine::GDK
- Rabbit::Renderer::GL
- Rabbit::Renderer::Kernel
- Rabbit::Renderer::Pixmap
- Rabbit::Renderer::Pixmap::Base
- Rabbit::Renderer::Pixmap::Cairo
- Rabbit::Renderer::Pixmap::GDK
- Rabbit::Renderer::Pixmap::GL
- Rabbit::Renderer::Print
- Rabbit::Renderer::Print::Base
- Rabbit::Renderer::Print::Cairo
- Rabbit::Renderer::Print::Layout2
- Rabbit::Renderer::Print::LayoutBase
- Rabbit::Renderer::Print::LayoutMore
- Rabbit::Renderer::Print::Multiple
- Rabbit::SOAP
- Rabbit::SOAP::Driver
- Rabbit::SOAP::Server
- Rabbit::ScreenInfo
- Rabbit::SearchWindow
- Rabbit::Searcher
- Rabbit::SlideConfiguration
- Rabbit::Source
- Rabbit::Source::ARGF
- Rabbit::Source::Base
- Rabbit::Source::File
- Rabbit::Source::Hiki
- Rabbit::Source::LimitAccessInterval
- Rabbit::Source::Memory
- Rabbit::Source::SlideShare
- Rabbit::Source::URI
- Rabbit::SourceGenerator
- Rabbit::SourceGenerator::Hiki
- Rabbit::SourceGenerator::Markdown
- Rabbit::SourceGenerator::RD
- Rabbit::SourceUnreadableError
- Rabbit::Stock
- Rabbit::SystemRunner
- Rabbit::Task
- Rabbit::Task::Slide
- Rabbit::Task::SlideShare
- Rabbit::Task::SlideShare::Error
- Rabbit::Task::Theme
- Rabbit::TeXCanNotHandleError
- Rabbit::TemporaryFile
- Rabbit::Theme
- Rabbit::Theme::Applier
- Rabbit::Theme::DirectoryEntry
- Rabbit::Theme::ElementContainer
- Rabbit::Theme::Entry
- Rabbit::Theme::FileEntry
- Rabbit::Theme::GemEntry
- Rabbit::Theme::ImageDirectoryEntry
- Rabbit::Theme::ImageFileEntry
- Rabbit::Theme::ImageGemEntry
- Rabbit::Theme::Manager
- Rabbit::Theme::Searcher
- Rabbit::ThemeConfiguration
- Rabbit::ThemeExit
- Rabbit::TrackBall
- Rabbit::TrackBall::Vector
- Rabbit::UnknownCursorTypeError
- Rabbit::UnknownPropertyError
- Rabbit::UnsupportedFormatError
- Rabbit::Utils
- Rabbit::VideoWindow
- Rabbit::VideoWindow::VideoWidget
- Rabbit::XMLRPC
- Rabbit::XMLRPC::Client
- Rabbit::XMLRPC::Server
- Rabbit::XMLRPC::Servlet
- OptionParser
- OptionParser::Category
- OptionParser::List
- OptionParser::Switch
- Cairo
- Cairo::Context
- Gtk
- Gtk::Action
- Pango
- Pango::Context
- Object

No matching classes.

# Rabbit::Element::ContainerElement

### Attributes

elements[R]

### Public Class Methods

new(elems=[]) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 18
    def initialize(elems=[])
      @elements = []
      elems = [elems] unless elems.is_a?(Array)
      elems.each do |elem|
        add_element(elem)
      end
      super()
    end

### Public Instance Methods

<<(element) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 27
    def <<(element)
      @elements << element
      element.parent = self
      dirty!
    end

Also aliased as: add_element
[](name_or_index) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 246
    def [](name_or_index)
      if name_or_index.is_a?(Integer)
        @elements[name_or_index]
      else
        super
      end
    end

[]=(name_or_index, value) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 254
    def []=(name_or_index, value)
      if name_or_index.is_a?(Integer)
        @elements[name_or_index] = value
      else
        super
      end
    end

_width() click to toggle source

SLOW!!

    # File lib/rabbit/element/container-element.rb, line 176
    def _width
      block_widths = []
      block_widths << @elements.inject(0) do |result, elem|
        if elem.width
          if elem.inline_element?
            result + elem.width
          else
            block_widths << elem.width
            elem.width
          end
        else
          result
        end
      end
      block_widths.max.to_i
    end

add_element(element) click to toggle source
Alias for: <<
clear_theme() click to toggle source

    # File lib/rabbit/element/container-element.rb, line 214
    def clear_theme
      @elements.each do |element|
        element.clear_theme
      end
      super
    end

Also aliased as: container_clear_theme
compile(canvas, x, y, w, h) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 107
    def compile(canvas, x, y, w, h)
      super
      if_dirty do
        x, y, w, h = setup_padding(@x, @y, @w, @h)
        compile_elements(canvas, x, y, w, h)
        x, w = restore_x_padding(x, w)
        x, w = adjust_x_centering(x, w)
        y, h = adjust_y_padding(y, h)
      end
    end

compile_elements(canvas, x, y, w, h) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 118
    def compile_elements(canvas, x, y, w, h)
      prev_is_inline = false
      @elements.each do |element|
        element.compile(canvas, x, y, w, h)
        compile_horizontal_element(element, canvas, x, y, w, h)
        x, y, w, h = element.draw(true)
      end
    end

compile_horizontal(canvas, x, y, w, h) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 127
    def compile_horizontal(canvas, x, y, w, h)
      @elements.each do |element|
        compile_horizontal_element(element, canvas, x, y, w, h)
      end
    end

compile_horizontal_element(element, canvas, x, y, w, h) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 133
    def compile_horizontal_element(element, canvas, x, y, w, h)
      if do_horizontal_centering? or element.do_horizontal_centering?
        element.do_horizontal_centering(canvas, x, y, w, h)
      else
        element.reset_horizontal_centering(canvas, x, y, w, h)
      end
    end

container_clear_theme() click to toggle source
Alias for: clear_theme
delete(element) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 40
    def delete(element)
      return if @elements.delete(element).nil?
      element.parent = nil
      dirty!
      element
    end

dirty?() click to toggle source

    # File lib/rabbit/element/container-element.rb, line 222
    def dirty?
      super or @elements.any?{|x| x.dirty?}
    end

draw_element(canvas, x, y, w, h, simulation) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 75
    def draw_element(canvas, x, y, w, h, simulation)
      draw_elements(canvas, x, y, w, h, simulation)
    end

draw_elements(canvas, x, y, w, h, simulation) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 79
    def draw_elements(canvas, x, y, w, h, simulation)
      args = [x, y, w, h]
      adjust_height = 0
      if do_vertical_centering?
        adjust_height = ((h - height - @padding_bottom) / 2.0).ceil
        if y + adjust_height > 0
          args = [x, y + adjust_height, w, h - adjust_height]
        else
          adjust_height = 0
        end
      end
      @centering_adjusted_height = adjust_height
      compile_elements(canvas, *args)
      base_x, base_w = x, w
      @elements.each do |element|
        x, y, w, h = element.draw(simulation)
      end
      last_element = @elements.last
      if last_element and last_element.inline_element?
        container_height = height
        x = base_x
        y += container_height
        w = base_w
        h -= container_height
      end
      [x, y, w, h]
    end

have_tag?(name) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 238
    def have_tag?(name)
      @elements.any? {|element| element.have_tag?(name)}
    end

have_wait_tag?() click to toggle source

    # File lib/rabbit/element/container-element.rb, line 242
    def have_wait_tag?
      @elements.any? {|element| element.have_wait_tag?}
    end

height() click to toggle source

perhaps SLOW!!

    # File lib/rabbit/element/container-element.rb, line 194
    def height
      inline_heights = []
      @elements.inject(0) do |result, elem|
        elem_height = elem.height
        if elem_height
          if elem.inline_element?
            inline_heights << elem_height
            result
          else
            prev_inlines_max_height = inline_heights.max.to_i
            inline_heights.clear
            h = elem_height + elem.margin_top + elem.margin_bottom
            result + h + prev_inlines_max_height
          end
        else
          result
        end
      end + inline_heights.max.to_i + @padding_top + @padding_bottom
    end

inspect(verbose=false) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 226
    def inspect(verbose=false)
      elem_info = @elements.collect do |x|
        _indent(x.inspect(verbose))
      end.join("\n")
      if verbose
        self_info = super(verbose)
      else
        self_info = "<#{self.class.name}>"
      end
      self_info + (elem_info.empty? ? "" : "\n") + elem_info
    end

prop_delete(name) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 159
    def prop_delete(name)
      collect do |elem|
        elem.prop_delete(name)
      end
    end

prop_get(name) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 153
    def prop_get(name)
      collect do |elem|
        elem.prop_get(name)
      end
    end

prop_set(*args) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 147
    def prop_set(*args)
      each do |elem|
        elem.prop_set(*args)
      end
    end

replace_element(child, *targets) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 70
    def replace_element(child, *targets)
      index = @elements.index(child)
      @elements[index, 1] = targets
    end

substitute_text(&block) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 59
    def substitute_text(&block)
      substituted = false
      e = @elements.dup
      e.each_with_index do |element, i|
        element_substituted = element.substitute_text(&block)
        substituted ||= element_substituted
      end
      dirty! if substituted
      substituted
    end

text() click to toggle source

    # File lib/rabbit/element/container-element.rb, line 47
    def text
      @elements.collect do |element|
        element.text
      end.join("\n")
    end

to_html(generator) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 141
    def to_html(generator)
      collect do |element|
        element.to_html(generator)
      end.join("\n")
    end

to_rd() click to toggle source

    # File lib/rabbit/element/container-element.rb, line 53
    def to_rd
      @elements.collect do |element|
        element.to_rd
      end.join("\n")
    end

unshift(element) click to toggle source

    # File lib/rabbit/element/container-element.rb, line 34
    def unshift(element)
      @elements.unshift(element)
      element.parent = self
      dirty!
    end

width() click to toggle source

    # File lib/rabbit/element/container-element.rb, line 165
    def width
      @elements.collect do |elem|
        w = elem.w
        if w
          w += elem.margin_left + elem.margin_right
        end
        w
      end.compact.max.to_i + @padding_left + @padding_right
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.