ffi-tk 2010.01.02 → 2010.02

Sign up to get free protection for your applications and to get access to all the features.
@@ -201,18 +201,22 @@ module Tk
201
201
  indices = [given_index]
202
202
 
203
203
  while arg = arguments.shift
204
- case arg.to_tcl
205
- when '-command'
206
- command = arguments.shift
207
- invocation << ['-command', command]
208
- when /^-(all|image|mark|tag|text|window)$/
209
- invocation << tcl_option(arg)
204
+ if arg.respond_to?(:to_tcl_option)
205
+ case tcl_option = arg.to_tcl_option
206
+ when '-command'
207
+ command = arguments.shift
208
+ invocation << ['-command', command]
209
+ when /^-(?:all|image|mark|tag|text|window)$/
210
+ invocation << tcl_option
211
+ else
212
+ indices.unshift(arg)
213
+ end
210
214
  else
211
215
  indices.unshift(arg)
212
216
  end
213
217
  end
214
218
 
215
- execute('dump', *invocation, *indices)
219
+ execute('dump', *invocation, *indices).to_a.each_slice(3).to_a
216
220
  end
217
221
 
218
222
  # If boolean is not specified, returns the modified flag of the widget.
@@ -655,7 +659,7 @@ module Tk
655
659
  # and the substitutions performed on script before invoking it.
656
660
  # If all arguments are specified then a new binding is created, replacing
657
661
  # any existing binding for the same sequence and tagName (if the first
658
- # character of script is “+” then script augments an existing binding
662
+ # character of script is "+" then script augments an existing binding
659
663
  # rather than replacing it).
660
664
  # In this case the return value is an empty string.
661
665
  # If script is omitted then the command returns the script associated
@@ -765,8 +769,8 @@ module Tk
765
769
  # active at the character position given by index.
766
770
  # If index is omitted, then the return value will describe all of the tags
767
771
  # that exist for the text (this includes all tags that have been named in a
768
- # pathName tag widget command but have not been deleted by a pathName
769
- # tag delete widget command, even if no characters are currently marked
772
+ # "pathName tag" widget command but have not been deleted by a "pathName
773
+ # tag delete" widget command, even if no characters are currently marked
770
774
  # with the tag).
771
775
  # The list will be sorted in order from lowest priority to highest
772
776
  # priority.
@@ -889,5 +893,33 @@ module Tk
889
893
  def paste
890
894
  Tk.execute(:tk_textPaste, self)
891
895
  end
896
+
897
+ def tk_prev_word_pos(start)
898
+ Tk.execute('tk::TextPrevPos', self, start, 'tcl_startOfPreviousWord').to_s
899
+ end
900
+
901
+ def tk_next_word_pos(start)
902
+ Tk.execute('tk::TextNextPos', self, start, 'tcl_startOfNextWord').to_s
903
+ end
904
+
905
+ def tk_next_word_pos_end(start)
906
+ Tk.execute('tk::TextNextWord', self, start).to_s
907
+ end
908
+
909
+ def tk_prev_line_pos(count)
910
+ Tk.execute('tk::TextUpDownLine', self, -count.abs).to_s
911
+ end
912
+
913
+ def tk_next_line_pos(count)
914
+ Tk.execute('tk::TextUpDownLine', self, count).to_s
915
+ end
916
+
917
+ def tk_prev_page_pos(count)
918
+ Tk.execute('tk::TextScrollPages', self, -count.abs).to_s
919
+ end
920
+
921
+ def tk_next_page_pos(count)
922
+ Tk.execute('tk::TextScrollPages', self, count).to_s
923
+ end
892
924
  end
893
925
  end
@@ -38,17 +38,20 @@ module Tk
38
38
  # the string end, an integer index, or the name of a managed subwindow.
39
39
  # If subwindow is already managed by the notebook, moves it to
40
40
  # the specified position.
41
- def insert(pos, window, options)
42
- execute_only(:insert, pos, window, options.to_tcl_options)
41
+ def insert(pos, window, options = {})
42
+ execute_only(:insert, pos, window, options.to_tcl_options)
43
43
  end
44
44
 
45
45
  # Selects the specified tab. The associated slave window
46
46
  # will be displayed, and the previously-selected window
47
47
  # (if different) is unmapped. If tabid is omitted, returns
48
48
  # the widget name of the currently selected pane.
49
- def select(window)
50
- execute_only(:select, window)
51
- window.tk_pathname
49
+ def select(window = None)
50
+ if None == window
51
+ execute(:select)
52
+ else
53
+ execute_only(:select, window)
54
+ end
52
55
  end
53
56
 
54
57
  # Remove the pane containing window from the panedwindow.
@@ -57,14 +60,18 @@ module Tk
57
60
  execute_only(:forget, window, *windows)
58
61
  end
59
62
 
60
- def hide(window)
61
- execute_only(:hide, window)
63
+ # Hides the tab specified by +tabid+.
64
+ # The tab will not be displayed, but the associated window remains managed
65
+ # by the notebook and its configuration remembered.
66
+ # Hidden tabs may be restored with the add command.
67
+ def hide(tabid)
68
+ execute_only(:hide, tabid)
62
69
  end
63
70
 
64
- # Returns the numeric index of the tab specified by tabid,
71
+ # Returns the numeric index of the tab specified by +tabid+,
65
72
  # or the total number of tabs if tabid is the string 'end'.
66
- def index(window)
67
- execute(:index, window).to_i
73
+ def index(tabid)
74
+ execute(:index, tabid).to_i
68
75
  end
69
76
 
70
77
  def identify(x, y)
@@ -3,7 +3,59 @@ module Tk
3
3
  class PanedWindow < Tk::PanedWindow
4
4
  def self.tk_command; 'ttk::panedwindow'; end
5
5
  include TileWidget
6
+
7
+ # pathname add subwindow options...
8
+ # Adds a new pane to the window.
9
+ # subwindow must be a direct child of the paned window pathname.
10
+ # See PANE OPTIONS for the list of available options.
11
+ def add(subwindow, options = {})
12
+ execute_only(:add, subwindow, options.to_tcl_options)
13
+ end
14
+
15
+ # pathname forget pane
16
+ # Removes the specified subpane from the widget.
17
+ # pane is either an integer index or the name of a managed subwindow.
18
+ def forget(pane)
19
+ execute_only(:forget, pane)
20
+ end
21
+
22
+ # pathname identify x y
23
+ # Returns the index of the sash at point x,y, or the empty string if x,y
24
+ # is not over a sash.
25
+ def identify(x, y)
26
+ execute(:identify, x, y)
27
+ end
28
+
29
+ # pathname insert pos subwindow options...
30
+ # Inserts a pane at the specified position.
31
+ # pos is either the string end, an integer index, or the name of a managed
32
+ # subwindow. If subwindow is already managed by the paned window, moves it
33
+ # to the specified position.
34
+ # See PANE OPTIONS for the list of available options.
35
+ def insert(pos, subwindow, options = {})
36
+ execute_only(:insert, pos, subwindow, options.to_tcl_options)
37
+ end
38
+
39
+ # pathname pane pane -option ?value ?-option value...
40
+ # Query or modify the options of the specified pane, where pane is either
41
+ # an integer index or the name of a managed subwindow.
42
+ # If no -option is specified, returns a dictionary of the pane option
43
+ # values. If one -option is specified, returns the value of that option.
44
+ # Otherwise, sets the -options to the corresponding values.
45
+ def pane(pane, options = {})
46
+ common_configure([:pane, pane], options)
47
+ end
48
+
49
+ # pathname sashpos index ?newpos?
50
+ # If newpos is specified, sets the position of sash number index.
51
+ # May adjust the positions of adjacent sashes to ensure that positions are
52
+ # monotonically increasing.
53
+ # Sash positions are further constrained to be between 0 and the total
54
+ # size of the widget.
55
+ # Returns the new position of sash number index.
56
+ def sashpos(index, newpos = None)
57
+ execute(:sashpos, index, newpos)
58
+ end
6
59
  end
7
60
  end
8
61
  end
9
-
@@ -22,8 +22,6 @@ module Tk
22
22
  def command(&block)
23
23
  configure(:command => block) if block
24
24
  end
25
-
26
- def scrollbar_default; end
27
25
  end
28
26
 
29
27
  class YScrollbar < Tk::Tile::Scrollbar
@@ -17,8 +17,8 @@ module Tk
17
17
  # BUG: http://tcl.activestate.com/man/tcl8.5/TkCmd/ttk_sizegrip.htm
18
18
  # If the containing toplevel's position was specified relative to the
19
19
  # right or bottom of the screen (e.g., 'wm geometry ... wxh-x-y' instead
20
- # of wm geometry ... wxh+x+y), the sizegrip widget will not resize the
21
- # window. ttk::sizegrip widgets only support southeast resizing.
20
+ # of "wm geometry ... wxh+x+y"), the sizegrip widget will not resize the
21
+ # window. ttk::sizegrip widgets only support "southeast" resizing.
22
22
  end
23
23
  end
24
24
  end
@@ -103,7 +103,7 @@ module Tk
103
103
  # Returns the value specified for -option in style style in state
104
104
  # state, using the standard lookup rules for element options.
105
105
  # state is a list of state names; if omitted, it defaults to all
106
- # bits off (the normal state). If the default argument is present,
106
+ # bits off (the "normal" state). If the default argument is present,
107
107
  # it is used as a fallback value in case no specification
108
108
  # for -option is found.
109
109
  def self.lookup(style, option, state=Tk::None, default=Tk::None)
@@ -19,7 +19,7 @@ module Tk
19
19
  # Treeview widgets support horizontal and vertical scrolling with the
20
20
  # standard -[xy]scrollcommand options and [xy]view widget commands.
21
21
  class Treeview < Tk::Widget
22
- include Tk::Tile::TileWidget, Cget, Configure
22
+ include Tk::Tile::TileWidget, Scrollable, Cget, Configure
23
23
 
24
24
  def self.tk_command; 'ttk::treeview'; end
25
25
 
@@ -217,6 +217,10 @@ module Tk
217
217
  tk_parent.children(id, *new_children)
218
218
  end
219
219
 
220
+ def selection_set
221
+ tk_parent.selection_set(id)
222
+ end
223
+
220
224
  def selection_add
221
225
  tk_parent.selection_add(id)
222
226
  end
@@ -322,12 +326,12 @@ module Tk
322
326
 
323
327
  # Returns the list of selected items.
324
328
  def selection
325
- execute(:selection).to_a
329
+ execute(:selection).to_a.map{|id| Item.new(self, id) }
326
330
  end
327
331
 
328
332
  # +items+ becomes the new selection.
329
333
  def selection_set(*items)
330
- execute(:selection, set, *items.flatten)
334
+ execute(:selection, :set, *items.flatten)
331
335
  end
332
336
 
333
337
  # Add +items+ to the selection
@@ -0,0 +1,25 @@
1
+ require_relative '../../helper'
2
+
3
+ describe Tk::Bind do
4
+ entry = Tk::Entry.new
5
+ entry.pack
6
+ entry.focus
7
+
8
+ it 'should bind a block' do
9
+ foo = false
10
+ entry.bind('f'){ foo = true }
11
+ Tk.interp.do_events_until{
12
+ Tk::Event.generate(entry, 'f')
13
+ foo
14
+ }
15
+ foo.should == true
16
+ end
17
+
18
+ it 'should return the bound proc' do
19
+ entry.bind('f').should == ' ::RubyFFI::event 0 f %# %b %c %d %f %h %i %k %m %o %p %s %t %w %x %y %A %B %D %E %K %N %P %R %S %T %W %X %Y '
20
+ end
21
+
22
+ it 'should list the sequences bound' do
23
+ entry.bind.should == ['f']
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2010.01.02
4
+ version: "2010.02"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael 'manveru' Fellinger
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-02 00:00:00 +09:00
12
+ date: 2010-02-15 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -41,6 +41,7 @@ extensions: []
41
41
  extra_rdoc_files: []
42
42
 
43
43
  files:
44
+ - .gitignore
44
45
  - AUTHORS
45
46
  - CHANGELOG
46
47
  - MANIFEST
@@ -63,6 +64,7 @@ files:
63
64
  - example/tile/kroc_rb_demo.rb
64
65
  - example/tile/notebook.rb
65
66
  - example/tile/theme_hello.rb
67
+ - example/tile/themes.rb
66
68
  - example/tile/treeview.rb
67
69
  - example/tkgo.rb
68
70
  - example/various.rb
@@ -169,6 +171,7 @@ files:
169
171
  - lib/ffi-tk/widget/tile/style.rb
170
172
  - lib/ffi-tk/widget/tile/treeview.rb
171
173
  - lib/ffi-tk/widget/toplevel.rb
174
+ - spec/ffi-tk/command/bind.rb
172
175
  - spec/ffi-tk/command/bindtags.rb
173
176
  - spec/ffi-tk/command/clipboard.rb
174
177
  - spec/ffi-tk/command/font.rb