#--
-# $Id: part.rb 18 2005-04-02 21:45:24Z tilman $
+# $Id: part.rb 21 2005-04-02 22:26:40Z tilman $
#
# Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
#
end
def clip=(part)
- if self == part
+ if part == self
raise(ArgumentError, "cannot clip part to itself")
- elsif part.nil?
- @clip = nil
- elsif part.collection != @collection
- raise(ArgumentError, "parts' collections not identical")
+ elsif !part.nil? && part.collection != @collection
+ raise(ArgumentError, "items not in the same collection")
else
@clip = part
end
end
class TextPart < Part
- EFFECT_NONE = 0
- EFFECT_PLAIN = 1
- EFFECT_OUTLINE = 2
- EFFECT_SOFT_OUTLINE = 3
- EFFECT_SHADOW = 4
- EFFECT_SOFT_SHADOW = 5
- EFFECT_OUTLINE_SHADOW = 6
- EFFECT_OUTLINE_SOFT_SHADOW = 7
-
attr_accessor :effect
def initialize(collection, id, name)
super
@type = TYPE_TEXT
- @effect = EFFECT_NONE
+ @effect = :none
end
protected
end
def to_eet_properties
- super.merge!({"effect" => [@effect, :char]})
+ effect = case @effect
+ when :none: 0
+ when :plain: 1
+ when :outline: 2
+ when :soft_outline: 3
+ when :shadow: 4
+ when :soft_shadow: 5
+ when :outline_shadow: 6
+ when :outline_soft_shadow: 7
+ else
+ raise(RedactError, "invalid effect value - #{@effect}")
+ end
+
+ super.merge!({"effect" => [effect, :char]})
end
end
end
def confine=(part)
- if part == self
+ if part == @part
raise(ArgumentError, "cannot confine part to itself")
elsif !part.nil? && part.collection != @part.collection
- raise(ArgumentError, "parts' collections not identical")
+ raise(ArgumentError, "items not in the same collection")
else
@confine = part
end
class Description
attr_reader :rel, :aspect, :step
- attr_accessor :visible, :aspect_preference
+ attr_accessor :visible, :aspect_preference, :color_class
def initialize(name = "default", value = 0.0)
@name = name.to_str.dup.freeze
class TextDescription < Description
attr_reader :font
- attr_accessor :text, :font_size
+ attr_accessor :text, :font_size, :text_class
def initialize(name = "default", value = 0.0)
super