### Home Classes Methods

### In Files

- lib/rabbit/theme/applier.rb

### Parent

Array

### Methods

- ::new
- #[]
- #collect
- #draw_frame
- #draw_image_mark
- #draw_mark
- #draw_order
- #indent
- #map
- #method_missing

### 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::Theme::ElementContainer

### Public Class Methods

new(applier, ary) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 13
    def initialize(applier, ary)
      @applier = applier
      super(ary)
    end

### Public Instance Methods

[](*args) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 26
    def [](*args)
      result = super
      if result.is_a?(Array)
        @applier.make_container(result)
      else
        result
      end
    end

collect(*args, &block) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 18
    def collect(*args, &block)
      @applier.make_container(super)
    end

draw_frame(params={}, &block) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 149
    def draw_frame(params={}, &block)
      proc_name = params[:proc_name] || "draw_frame"
      frame_color = params[:frame_color]
      fill_color = params[:fill_color]
      shadow_color = params[:shadow_color]
      shadow_offset = params[:shadow_offset] || 2
      shadow_width = params[:shadow_width] || 4
      frame_width = params[:frame_width] || 1

      add_pre_draw_proc(proc_name) do |target, canvas, x, y, w, h, simulation|
        unless simulation
          if block_given?
            fx, fy, fw, fh = yield(target, canvas, x, y, w, h)
          end
          fx ||= target.x
          fy ||= target.y + target.centering_adjusted_height
          fw ||= target.width
          fh ||= target.height
          if shadow_color
            fh -= shadow_width
          end
          size = [fx, fy, fw, fh]

          if fill_color
            args = size + [fill_color]
            canvas.draw_rectangle(true, *args)
          end

          if frame_color
            args = size + [frame_color, {:line_width => frame_width}]
            canvas.draw_rectangle(false, *args)
          end

          if shadow_color
            # Under Shadow
            usx = fx + shadow_offset
            usy = fy + fh + frame_width
            usw = fw + shadow_width - shadow_offset
            ush = shadow_width
            canvas.draw_rectangle(true, usx, usy, usw, ush, shadow_color)

            # Right Shadow
            rsx = fx + fw + frame_width
            rsy = fy + shadow_offset
            rsw = shadow_width
            rsh = fh + shadow_width - shadow_offset
            canvas.draw_rectangle(true, rsx, rsy, rsw, rsh, shadow_color)
          end
        end
        [x, y, w, h]
      end
    end

draw_image_mark(image_name, name=nil, options={}) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 92
    def draw_image_mark(image_name, name=nil, options={})
      return if empty?

      loader = ImageLoader.new(image_name)

      width_proc = Proc.new {loader.width}
      height_proc = Proc.new {loader.height}
      custom_indent = options[:indent]
      indent_proc = Proc.new do |item, simulation|
        text_height = item.elements.first.original_height
        if text_height < loader.height
          loader.resize(nil, (text_height * 2.0 / 3.0).ceil)
        end
        if custom_indent.nil?
          loader.width * 2.5
        elsif custom_indent.respond_to?(:call)
          custom_indent.call(item, loader)
        else
          custom_indent
        end
      end

      draw_mark(indent_proc,
                width_proc, height_proc,
                name) do  |item, canvas, x, y, w, h|
        x -= loader.width * 0.5
        loader.draw(canvas, x, y)
      end
    end

draw_mark(indent_width, width_or_proc, height_or_proc, name=nil) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 65
    def draw_mark(indent_width, width_or_proc, height_or_proc, name=nil)
      indent(indent_width, name) do |item, canvas, x, y, w, h|
        first_text = item.elements.first
        text_height = first_text.first_line_height
        text_height += first_text.padding_top + first_text.padding_bottom

        if width_or_proc.respond_to?(:call)
          mark_width = width_or_proc.call(item, canvas)
        else
          mark_width = width_or_proc
        end
        if height_or_proc.respond_to?(:call)
          mark_height = height_or_proc.call(item, canvas)
        else
          mark_height = height_or_proc
        end

        adjust_y = ((text_height / 2.0) - (mark_height / 2.0)).ceil

        indent_base_x = item.x - mark_width
        indent_base_y = item.base_y + first_text.margin_top + adjust_y
        width = mark_width
        height = mark_height
        yield(item, canvas, indent_base_x, indent_base_y, width, height)
      end
    end

draw_order(indent_width, name=nil, &block) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 122
    def draw_order(indent_width, name=nil, &block)
      layouts = {}
      make_order_layout = Proc.new do |item, simulation|
        layout = layouts[item]
        if layout.nil?
          str = block.call(item)
          layout = @applier.make_layout(str)
          layouts[item] = layout
        end
        tw, th = layout.pixel_size
        [tw + indent_width, tw, th, layout]
      end

      draw_order = Proc.new do |item, canvas, x, y, w, h, tw, th, layout|
        first_text = item.elements.first
        text_height = first_text.first_line_height
        text_height += first_text.padding_top + first_text.padding_bottom
        adjust_y = ((text_height / 2.0) - (th / 2.0)).ceil

        new_x = item.base_x + indent_width
        new_y = item.base_y + first_text.margin_top + adjust_y
        canvas.draw_layout(layout, new_x, new_y)
      end

      indent(make_order_layout, name, &draw_order)
    end

indent(size_or_proc, name=nil) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 35
    def indent(size_or_proc, name=nil)
      each do |element|
        element.delete_pre_draw_proc_by_name(name)
        element.delete_post_draw_proc_by_name(name)

        other_infos = []
        element.add_pre_draw_proc(name) do |canvas, x, y, w, h, simulation|
          if simulation
            if size_or_proc.respond_to?(:call)
              result = size_or_proc.call(element, simulation)
              indent_size, *other_infos = result
            else
              indent_size = size_or_proc
            end
            element.margin_left = indent_size
          end
          [x, y, w, h]
        end

        if block_given?
          element.add_post_draw_proc(name) do |canvas, x, y, w, h, simulation|
            unless simulation
              yield(element, canvas, x, y, w, h, *other_infos)
            end
            [x, y, w, h]
          end
        end
      end
    end

map(*args, &block) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 22
    def map(*args, &block)
      @applier.make_container(super)
    end

method_missing(meth, *args, &block) click to toggle source

    # File lib/rabbit/theme/applier.rb, line 202
    def method_missing(meth, *args, &block)
      collect do |elem|
        if block
          proxy_block = Proc.new do |*block_args|
            block.call(elem, *block_args)
          end
        else
          proxy_block = nil
        end
        elem.__send__(meth, *args, &proxy_block)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.