1# 2# tkextlib/tcllib/cursor.rb 3# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) 4# 5# * Part of tcllib extension 6# * Procedures to handle CURSOR data 7# 8 9require 'tk' 10require 'tkextlib/tcllib.rb' 11 12module Tk 13 module Tcllib 14 module Cursor 15 PACKAGE_NAME = 'cursor'.freeze 16 def self.package_name 17 PACKAGE_NAME 18 end 19 20 def self.package_version 21 begin 22 TkPackage.require('cursor') 23 rescue 24 '' 25 end 26 end 27 28 def self.not_available 29 fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment." 30 end 31 32 def self.cursor_display(win=None) 33 Tk::Tcllib::Cursor.not_available 34 end 35 36 def self.cursor_propagate(win, cursor) 37 Tk::Tcllib::Cursor.not_available 38 end 39 40 def self.cursor_restore(win, cursor = None) 41 Tk::Tcllib::Cursor.not_available 42 end 43 end 44 end 45 46 def self.cursor_display(parent=None) 47 # Pops up a dialog with a listbox containing all the cursor names. 48 # Selecting a cursor name will display it in that dialog. 49 # This is simply for viewing any available cursors on the platform . 50 #tk_call_without_enc('::cursor::display', parent) 51 Tk::Tcllib::Cursor.cursor_display(parent) 52 end 53end 54 55class TkWindow 56 def cursor_propagate(cursor) 57 # Sets the cursor for self and all its descendants to cursor. 58 #tk_call_without_enc('::cursor::propagate', @path, cursor) 59 Tk::Tcllib::Cursor.cursor_propagate(self, cursor) 60 end 61 def cursor_restore(cursor = None) 62 # Restore the original or previously set cursor for self and all its 63 # descendants. If cursor is specified, that will be used if on any 64 # widget that did not have a preset cursor (set by a previous call 65 # to TkWindow#cursor_propagate). 66 #tk_call_without_enc('::cursor::restore', @path, cursor) 67 Tk::Tcllib::Cursor.cursor_restore(self, cursor) 68 end 69end 70 71# TkPackage.require('cursor', '0.1') 72TkPackage.require('cursor') 73 74module Tk 75 module Tcllib 76 class << Cursor 77 undef not_available 78 end 79 80 module Cursor 81 extend TkCore 82 def self.cursor_display(win=None) 83 tk_call_without_enc('::cursor::display', _epath(win)) 84 end 85 86 def self.cursor_propagate(win, cursor) 87 #tk_call_without_enc('::cursor::propagate', win.path, cursor) 88 tk_call_without_enc('::cursor::propagate', _epath(win), cursor) 89 end 90 91 def self.cursor_restore(win, cursor = None) 92 #tk_call_without_enc('::cursor::restore', win.path, cursor) 93 tk_call_without_enc('::cursor::restore', _epath(win), cursor) 94 end 95 end 96 end 97end 98