# File lib/rabbit/cursor-manager.rb, line 10 def initialize @stocks = {} @current = nil @blank_cursor = blank_cursor @pencil_cursor = Gdk::Cursor.new(Gdk::Cursor::PENCIL) @hand_cursor = Gdk::Cursor.new(Gdk::Cursor::HAND1) end
# File lib/rabbit/cursor-manager.rb, line 18 def keep(name) @stocks[name] ||= [] @stocks[name].push(@current) end
# File lib/rabbit/cursor-manager.rb, line 23 def restore(drawable, name) if name.nil? type = @current else type = @stocks[name].pop end drawable.cursor = type_to_cursor(type) end
# File lib/rabbit/cursor-manager.rb, line 32 def update(drawable, type) drawable.cursor = type_to_cursor(type) end
# File lib/rabbit/cursor-manager.rb, line 49 def blank_cursor if @@blank_cursor.nil? source = Gdk::Pixmap.new(nil, 1, 1, 1) mask = Gdk::Pixmap.new(nil, 1, 1, 1) gc = Gdk::GC.new(source) fg = gc.foreground bg = gc.background @@blank_cursor = Gdk::Cursor.new(source, mask, fg, bg, 1, 1) end @@blank_cursor end
# File lib/rabbit/cursor-manager.rb, line 37 def type_to_cursor(type) if type.nil? nil else name = "@#{type}_cursor" unless instance_variable_defined?(name) raise UnknownCursorTypeError.new(type) end instance_variable_get(name) end end