File: tk/textimage.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  class: TkTextImage#7
includes
  IndexModMethods ( Tk::Text )
inherits from
  TkObject   
has properties
method: initialize / 3 #10
method: id #36
method: mark #39
method: [] / 1 #43
method: []= / 2 #46
method: cget / 1 #51
method: cget_strict / 1 #55
method: configure / 2 #59
method: configinfo / 1 #67
method: current_configinfo / 1 #71
method: image #75
method: image= / 1 #80

Class Hierarchy

Object ( Builtin-Module )
TkKernel
TkObject
  TkTextImage    #7

Code

   1  #
   2  # tk/textimage.rb - treat Tk text image object
   3  #
   4  require 'tk'
   5  require 'tk/text'
   6 
   7  class TkTextImage<TkObject
   8    include Tk::Text::IndexModMethods
   9 
  10    def initialize(parent, index, keys)
  11      #unless parent.kind_of?(Tk::Text)
  12      #  fail ArgumentError, "expect Tk::Text for 1st argument"
  13      #end
  14      @t = parent
  15      if index == 'end' || index == :end
  16        @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
  17      elsif index.kind_of? TkTextMark
  18        if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
  19          @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', 
  20                                                         'end - 1 chars'))
  21        else
  22          @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', 
  23                                                         index.path))
  24        end
  25      else
  26        @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', 
  27                                                       _get_eval_enc_str(index)))
  28      end
  29      @path.gravity = 'left'
  30      @index = @path.path
  31      @id = tk_call_without_enc(@t.path, 'image', 'create', @index, 
  32                                *hash_kv(keys, true)).freeze
  33      @path.gravity = 'right'
  34    end
  35 
  36    def id
  37      Tk::Text::IndexString.new(@id)
  38    end
  39    def mark
  40      @path
  41    end
  42 
  43    def [](slot)
  44      cget(slot)
  45    end
  46    def []=(slot, value)
  47      configure(slot, value)
  48      value
  49    end
  50 
  51    def cget(slot)
  52      @t.image_cget(@index, slot)
  53    end
  54 
  55    def cget_strict(slot)
  56      @t.image_cget_strict(@index, slot)
  57    end
  58 
  59    def configure(slot, value=None)
  60      @t.image_configure(@index, slot, value)
  61      self
  62    end
  63  #  def configure(slot, value)
  64  #    tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value
  65  #  end
  66 
  67    def configinfo(slot = nil)
  68      @t.image_configinfo(@index, slot)
  69    end
  70 
  71    def current_configinfo(slot = nil)
  72      @t.current_image_configinfo(@index, slot)
  73    end
  74 
  75    def image
  76      img = tk_call_without_enc(@t.path, 'image', 'cget', @index, '-image')
  77      TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
  78    end
  79 
  80    def image=(value)
  81      tk_call_without_enc(@t.path, 'image', 'configure', @index, '-image', 
  82                          _get_eval_enc_str(value))
  83      #self
  84      value
  85    end
  86  end
  87 
  88  TktImage = TkTextImage