Methods
- F
- G
- L
- M
- N
- R
Constants
USAGE | = | <<EOT --- WHAT IS --- You can write comments on the loaded image, and save it as a Postscipt file (original image file is not modified). Each comment is drawn as a set of an indicator circle, an arrow, and a memo text. See the following how to write comments. This can save the list of memo texts to another file. It may useful to search the saved Postscript file by the comments on them. This may not support multibyte characters (multibyte texts are broken on a Postscript file). It depends on features of canvas widgets of Tcl/Tk libraries linked your Ruby/Tk. If you use Tcl/Tk8.0-jp (Japanized Tcl/Tk), you can (possibly) get a Japanese Postscript file. --- BINDINGS --- * Button-1 : draw comments by following steps 1st - Set center of a indicator circle. 2nd - Set head position of an arrow. 3rd - Set tail position of an arrow, and show an entry box. Input a memo text and hit 'Enter' key to entry the comment. * Button-2-drag : scroll the canvas * Button-3 : when drawing, cancel current drawing * Double-Button-3 : delete the clicked comment (text, arrow, and circle) EOT |
Class Public methods
new(*args)
Link
# File ext/tk/sample/figmemo_sample.rb, line 83 def initialize(*args) super(*args) self.highlightthickness = 0 self.selectborderwidth = 0 @photo = TkPhotoImage.new @img = TkcImage.new(self, 0, 0, :image=>@photo) width = self.width height = self.height @scr_region = [-width, -height, width, height] self.scrollregion(@scr_region) self.xview_moveto(0.25) self.yview_moveto(0.25) @col = 'red' @font = 'Helvetica -12' @memo_id_num = -1 @memo_id_head = 'memo_' @memo_id_tag = nil @overlap_d = 2 @state = TkVariable.new @border = 2 @selectborder = 1 @delta = @border + @selectborder @entry = TkEntry.new(self, :relief=>:ridge, :borderwidth=>@border, :selectborderwidth=>@selectborder, :highlightthickness=>0) @entry.bind('Return'){@state.value = 0} @mode = old_mode = 0 _state0() bind('2', :x, :y){|x,y| scan_mark(x,y)} bind('B2-Motion', :x, :y){|x,y| scan_dragto(x,y)} bind('3'){ next if (old_mode = @mode) == 0 @items.each{|item| item.delete } _state0() } bind('Double-3', :widget, :x, :y){|w, x, y| next if old_mode != 0 x = w.canvasx(x) y = w.canvasy(y) tag = nil w.find_overlapping(x - @overlap_d, y - @overlap_d, x + @overlap_d, y + @overlap_d).find{|item| ! (item.tags.find{|name| if name =~ /^(#{@memo_id_head}\d+)$/ tag = $1 end }.empty?) } w.delete(tag) if tag } end
Instance Public methods
fig_erase()
Link
get_texts()
Link
load_photo(filename)
Link
modified?()
Link
reset_region()
Link
# File ext/tk/sample/figmemo_sample.rb, line 268 def reset_region width = @photo.width height = @photo.height if width > @scr_region[2] @scr_region[0] = -width @scr_region[2] = width end if height > @scr_region[3] @scr_region[1] = -height @scr_region[3] = height end self.scrollregion(@scr_region) self.xview_moveto(0.25) self.yview_moveto(0.25) end