### Home Classes Methods

### In Files

- lib/rabbit/element/text-renderer.rb

### Methods

- ::new
- #align=
- #as_large_as_possible
- #clear_theme
- #compile
- #compute_next_font_size
- #dirty!
- #dirty?
- #do_horizontal_centering
- #do_horizontal_centering?
- #font_size
- #have_numerical_font_size?
- #height
- #initial_font_size_for_compute_font_size
- #justify=
- #keep_in_size
- #markuped_text
- #pixel_font_size
- #reset_horizontal_centering
- #set_computed_font_size
- #spacing=
- #text_clear_theme
- #text_compile
- #text_dirty?
- #text_props
- #text_renderer?
- #text_to_html
- #width

### Included Modules

- 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::TextRenderer

### Attributes

first_line_height[R]
first_line_width[R]
indent[W]
layout[R]
original_height[R]
original_width[R]
wrap_mode[W]

### Public Class Methods

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

    # File lib/rabbit/element/text-renderer.rb, line 14
    def initialize(*args, &block)
      super
      text_clear_theme
    end

### Public Instance Methods

align=(new_value) click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 23
    def align=(new_value)
      if new_value.is_a?(String)
        new_value = Pango::Layout.const_get("ALIGN_#{new_value.to_s.upcase}")
      end
      dirty! if @align != new_value
      @align = new_value
    end

as_large_as_possible(proc_name=nil, &compute_max_size) click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 162
    def as_large_as_possible(proc_name=nil, &compute_max_size)
      proc_name ||= "as-large-as-possible"
      make_params = Proc.new do |canvas, x, y, w, h,
                                 initial_width, initial_height,
                                 max_width, max_height|
        if (max_width and initial_width > max_width) or
            (max_height and initial_height > max_height)
          scale = 0.95
          compare = Proc.new do |_width, _height|
            (max_width.nil? or _width < max_width) and
              (max_height.nil? or _height < max_height)
          end
        else
          scale = 1.05
          compare = Proc.new do |_width, _height|
            (max_width and _width > max_width) or
              (max_height and _height > max_height)
          end
        end
        [scale, compare]
      end
      dynamic_font_size_computation(proc_name, compute_max_size, &make_params)
    end

clear_theme() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 92
    def clear_theme
      super
      text_clear_theme
    end

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

    # File lib/rabbit/element/text-renderer.rb, line 58
    def compile(canvas, x, y, w, h)
      super
      text_compile(canvas, x, y, w, h)
    end

dirty!() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 106
    def dirty!
      super
      @layout = nil
    end

dirty?() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 111
    def dirty?
      super or text_dirty?
    end

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

    # File lib/rabbit/element/text-renderer.rb, line 80
    def do_horizontal_centering(canvas, x, y, w, h)
      self.align = Pango::Layout::ALIGN_CENTER
    end

do_horizontal_centering?() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 76
    def do_horizontal_centering?
      @horizontal_centering
    end

font_size() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 127
    def font_size
      text_props["size"]
    end

have_numerical_font_size?() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 140
    def have_numerical_font_size?
      font_size.is_a?(Numeric)
    end

height() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 50
    def height
      if @height
        @height + @padding_top + @padding_bottom
      else
        nil
      end
    end

justify=(new_value) click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 31
    def justify=(new_value)
      new_value = true if new_value
      dirty! if @justify != new_value
      @justify = new_value
    end

keep_in_size(proc_name=nil, &compute_max_size) click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 144
    def keep_in_size(proc_name=nil, &compute_max_size)
      proc_name ||= "keep-in-size"
      make_params = Proc.new do |canvas, x, y, w, h,
                                 initial_width, initial_height,
                                 max_width, max_height|
        if (max_width and initial_width > max_width) or
            (max_height and initial_height > max_height)
          scale = 0.95
          compare = Proc.new do |_width, _height|
            (max_width.nil? or _width < max_width) and
              (max_height.nil? or _height < max_height)
          end
          [scale, compare]
        end
      end
      dynamic_font_size_computation(proc_name, compute_max_size, &make_params)
    end

markuped_text() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 88
    def markuped_text
      markup(text)
    end

pixel_font_size() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 131
    def pixel_font_size
      _font_size = font_size
      if _font_size
        _font_size / Pango::SCALE
      else
        original_height
      end
    end

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

    # File lib/rabbit/element/text-renderer.rb, line 84
    def reset_horizontal_centering(canvas, x, y, w, h)
      self.align = default_align if @align == Pango::Layout::ALIGN_CENTER
    end

spacing=(new_spacing) click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 37
    def spacing=(new_spacing)
      dirty! if @spacing != new_spacing
      @spacing = new_spacing
    end

text_clear_theme() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 97
    def text_clear_theme
      @layout = nil
      @indent = 0
      @spacing = 0
      @wrap_mode = default_wrap_mode
      @align = default_align
      @justify = default_justify
    end

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

    # File lib/rabbit/element/text-renderer.rb, line 63
    def text_compile(canvas, x, y, w, h)
      if (@width and @width > @w) or (@height and @height > @h)
        dirty!
      end
      if_dirty do
        setup_draw_info(markuped_text, canvas, w)
      end
    end

text_dirty?() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 115
    def text_dirty?
      @layout.nil?
    end

text_props() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 119
    def text_props
      props = {}
      @prop.each do |name, formatter|
        props[name] = formatter.value
      end
      props
    end

text_renderer?() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 19
    def text_renderer?
      true
    end

text_to_html(generator) click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 72
    def text_to_html(generator)
      markup_as_html(text)
    end

width() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 42
    def width
      if @width
        @width + @padding_left + @padding_right
      else
        nil
      end
    end

### Protected Instance Methods

compute_next_font_size(previous_size, scale) click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 333
    def compute_next_font_size(previous_size, scale)
      if previous_size
        (previous_size * scale).ceil
      else
        nil
      end
    end

initial_font_size_for_compute_font_size() click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 329
    def initial_font_size_for_compute_font_size
      font_size
    end

set_computed_font_size(new_size) click to toggle source

    # File lib/rabbit/element/text-renderer.rb, line 341
    def set_computed_font_size(new_size)
      if new_size
        font :size => new_size
        dirty!
      end
      dirty?
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.