1# 2# BLT support 3# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) 4# 5 6require 'tk' 7require 'tk/variable' 8 9# call setup script for general 'tkextlib' libraries 10require 'tkextlib/setup.rb' 11 12# call setup script 13require 'tkextlib/blt/setup.rb' 14 15# load all image format handlers 16#TkPackage.require('BLT', '2.4') 17TkPackage.require('BLT') 18 19module Tk 20 module BLT 21 TkComm::TkExtlibAutoloadModule.unshift(self) 22 # Require autoload-symbols which is a same name as widget classname. 23 # Those are used at TkComm._genobj_for_tkwidget method. 24 25 extend TkCore 26 27 VERSION = tk_call('set', 'blt_version') 28 PATCH_LEVEL = tk_call('set', 'blt_patchLevel') 29 30 begin 31 lib = TkCore::INTERP._invoke('set', 'blt_library') 32 rescue 33 lib = '' 34 end 35 LIBRARY = TkVarAccess.new('blt_library', lib) 36 37 begin 38 lib = TkCore::INTERP._invoke('set', 'blt_libPath') 39 rescue 40 lib = '' 41 end 42 LIB_PATH = TkVarAccess.new('blt_libPath', lib) 43 44 PACKAGE_NAME = 'BLT'.freeze 45 def self.package_name 46 PACKAGE_NAME 47 end 48 49 def self.package_version 50 begin 51 TkPackage.require('BLT') 52 rescue 53 '' 54 end 55 end 56 57 #################################################### 58 59 def self.beep(percent = 50) 60 tk_call('::blt::beep', percent) 61 end 62 63 def self.bgexec(*args) 64 if args[0].kind_of?(TkVariable) 65 var = args.shift 66 else 67 var = TkVariable.new 68 end 69 params = [var] 70 71 params.concat(hash_kv(args.shift, true)) if args[0].kind_of?(Hash) 72 73 params << '--' if args[0] =~ /^\s*-[^-]/ 74 params.concat(args) 75 76 tk_call('::blt::bgexec', *params) 77 var 78 end 79 80 def self.detach_bgexec(*args) 81 if args[0].kind_of?(TkVariable) 82 var = args.shift 83 else 84 var = TkVariable.new 85 end 86 params = [var] 87 88 params.concat(hash_kv(args.shift, true)) if args[0].kind_of?(Hash) 89 90 params << '--' if args[0] =~ /^\s*-[^-]/ 91 params.concat(args) 92 params << '&' 93 94 [var, tk_split_list(tk_call('::blt::bgexec', *params))] 95 end 96 97 def self.bltdebug(lvl = nil) 98 if lvl 99 tk_call('::blt::bltdebug', lvl) 100 else 101 number(tk_call('::blt::bltdebug')) 102 end 103 end 104 105 def self.crc32_file(name) 106 tk_call_without_enc('::blt::crc32', name) 107 end 108 def self.crc32_data(dat) 109 tk_call_without_enc('::blt::crc32', '-data', dat) 110 end 111 112 #################################################### 113 114 def self.active_legend(graph) 115 tk_call_without_enc('Blt_ActiveLegend', graph) 116 end 117 def self.crosshairs(graph) 118 tk_call_without_enc('Blt_Crosshairs', graph) 119 end 120 def self.zoom_stack(graph) 121 tk_call_without_enc('Blt_ZoomStack', graph) 122 end 123 def self.print_key(graph) 124 tk_call_without_enc('Blt_PrintKey', graph) 125 end 126 def self.closest_point(graph) 127 tk_call_without_enc('Blt_ClosestPoint', graph) 128 end 129 130 module GraphCommand 131 def active_legend 132 tk_call_without_enc('Blt_ActiveLegend', @path) 133 self 134 end 135 def crosshairs 136 tk_call_without_enc('Blt_Crosshairs', @path) 137 self 138 end 139 def zoom_stack 140 tk_call_without_enc('Blt_ZoomStack', @path) 141 self 142 end 143 def print_key 144 tk_call_without_enc('Blt_PrintKey', @path) 145 self 146 end 147 def closest_point 148 tk_call_without_enc('Blt_ClosestPoint', @path) 149 self 150 end 151 end 152 153 #################################################### 154 155 autoload :PlotComponent,'tkextlib/blt/component.rb' 156 157 autoload :Barchart, 'tkextlib/blt/barchart.rb' 158 autoload :Bitmap, 'tkextlib/blt/bitmap.rb' 159 autoload :Busy, 'tkextlib/blt/busy.rb' 160 autoload :Container, 'tkextlib/blt/container.rb' 161 autoload :CutBuffer, 'tkextlib/blt/cutbuffer.rb' 162 autoload :DragDrop, 'tkextlib/blt/dragdrop.rb' 163 autoload :EPS, 'tkextlib/blt/eps.rb' 164 autoload :Htext, 'tkextlib/blt/htext.rb' 165 autoload :Graph, 'tkextlib/blt/graph.rb' 166 autoload :Spline, 'tkextlib/blt/spline.rb' 167 autoload :Stripchart, 'tkextlib/blt/stripchart.rb' 168 autoload :Table, 'tkextlib/blt/table.rb' 169 autoload :Tabnotebook, 'tkextlib/blt/tabnotebook.rb' 170 autoload :Tabset, 'tkextlib/blt/tabset.rb' 171 autoload :Ted, 'tkextlib/blt/ted.rb' 172 autoload :Tile, 'tkextlib/blt/tile.rb' 173 autoload :Tree, 'tkextlib/blt/tree.rb' 174 autoload :TreeView, 'tkextlib/blt/treeview.rb' 175 autoload :Hiertable, 'tkextlib/blt/treeview.rb' 176 # Hierbox is obsolete 177 autoload :Vector, 'tkextlib/blt/vector.rb' 178 autoload :VectorAccess, 'tkextlib/blt/vector.rb' 179 autoload :Watch, 'tkextlib/blt/watch.rb' 180 autoload :Winop, 'tkextlib/blt/winop.rb' 181 autoload :WinOp, 'tkextlib/blt/winop.rb' 182 183 # Unix only 184 autoload :DnD, 'tkextlib/blt/unix_dnd.rb' 185 186 # Windows only 187 autoload :Printer, 'tkextlib/blt/win_printer.rb' 188 end 189end 190