Sha256: 5aba2de7df1e92d3bd2aba519a15da5717154bcce9827bcb2f4c14bf031d422c
Contents?: true
Size: 914 Bytes
Versions: 7
Compression:
Stored size: 914 Bytes
Contents
# -*- coding: utf-8 -*- require 'reflex/image' require 'reflex/bitmap' require 'reflex/view' module Reflex class TextView < View has_model attr_accessor :font def initialize (*args, &block) @outdated = false super end def content_size () s = string return 0, 0 unless s && window font = @font || window.painter.font [font.width(s), font.height].map &:ceil end def on_draw (e) @image = create_text_image if @outdated return unless @image pa = e.painter pa.color 1 pa.image @image end def on_data_update (e) @outdated = true super end private def create_text_image () str, size = string, content_size return nil unless str && size.all? {|n| n > 0} Image.new Bitmap.new(*size, :GRAY).draw_string(str), true end end# TextView end# Reflex
Version data entries
7 entries across 7 versions & 1 rubygems