ffi-tk 2009.11.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +748 -0
- data/MANIFEST +188 -0
- data/README.md +85 -0
- data/Rakefile +47 -0
- data/TODO.md +62 -0
- data/bin/rwish +33 -0
- data/doc/MIT_LICENSE +18 -0
- data/doc/TCL_LICENSE +39 -0
- data/example/choose_color.rb +22 -0
- data/example/choose_directory.rb +22 -0
- data/example/dialog.rb +37 -0
- data/example/hello.rb +11 -0
- data/example/message_box.rb +26 -0
- data/example/option_menu.rb +17 -0
- data/example/popup.rb +24 -0
- data/example/set_palette.rb +32 -0
- data/example/text.rb +47 -0
- data/example/tile/kroc_demo_small.rb +123 -0
- data/example/tile/kroc_rb_demo.rb +135 -0
- data/example/tile/notebook.rb +48 -0
- data/example/tile/theme_hello.rb +38 -0
- data/example/tile/treeview.rb +71 -0
- data/example/various.rb +25 -0
- data/example/wait.rb +16 -0
- data/ffi-tk.gemspec +33 -0
- data/lib/ffi-tk.rb +76 -0
- data/lib/ffi-tk/command.rb +39 -0
- data/lib/ffi-tk/command/after.rb +36 -0
- data/lib/ffi-tk/command/bell.rb +34 -0
- data/lib/ffi-tk/command/bind.rb +11 -0
- data/lib/ffi-tk/command/bindtags.rb +69 -0
- data/lib/ffi-tk/command/cget.rb +92 -0
- data/lib/ffi-tk/command/choose_color.rb +29 -0
- data/lib/ffi-tk/command/choose_directory.rb +45 -0
- data/lib/ffi-tk/command/clipboard.rb +102 -0
- data/lib/ffi-tk/command/configure.rb +88 -0
- data/lib/ffi-tk/command/destroy.rb +12 -0
- data/lib/ffi-tk/command/dialog.rb +54 -0
- data/lib/ffi-tk/command/event.rb +79 -0
- data/lib/ffi-tk/command/focus.rb +70 -0
- data/lib/ffi-tk/command/font.rb +124 -0
- data/lib/ffi-tk/command/get_open_file.rb +85 -0
- data/lib/ffi-tk/command/get_save_file.rb +83 -0
- data/lib/ffi-tk/command/grab.rb +141 -0
- data/lib/ffi-tk/command/grid.rb +246 -0
- data/lib/ffi-tk/command/image.rb +79 -0
- data/lib/ffi-tk/command/lower.rb +23 -0
- data/lib/ffi-tk/command/message_box.rb +65 -0
- data/lib/ffi-tk/command/option_menu.rb +8 -0
- data/lib/ffi-tk/command/pack.rb +99 -0
- data/lib/ffi-tk/command/place.rb +91 -0
- data/lib/ffi-tk/command/popup.rb +14 -0
- data/lib/ffi-tk/command/raise.rb +25 -0
- data/lib/ffi-tk/command/scrollable.rb +151 -0
- data/lib/ffi-tk/command/selection.rb +132 -0
- data/lib/ffi-tk/command/set_palette.rb +9 -0
- data/lib/ffi-tk/command/tk_cmd.rb +155 -0
- data/lib/ffi-tk/command/vars.rb +82 -0
- data/lib/ffi-tk/command/wait.rb +39 -0
- data/lib/ffi-tk/command/winfo.rb +668 -0
- data/lib/ffi-tk/command/wm.rb +1025 -0
- data/lib/ffi-tk/core_extensions.rb +154 -0
- data/lib/ffi-tk/event/data.rb +60 -0
- data/lib/ffi-tk/event/handler.rb +44 -0
- data/lib/ffi-tk/ffi/tcl.rb +92 -0
- data/lib/ffi-tk/ffi/tcl/cmd_proc.rb +10 -0
- data/lib/ffi-tk/ffi/tcl/eval_result.rb +148 -0
- data/lib/ffi-tk/ffi/tcl/interp.rb +95 -0
- data/lib/ffi-tk/ffi/tcl/obj.rb +89 -0
- data/lib/ffi-tk/ffi/tcl/time.rb +36 -0
- data/lib/ffi-tk/ffi/tk.rb +35 -0
- data/lib/ffi-tk/geometry.rb +32 -0
- data/lib/ffi-tk/thread_sender.rb +26 -0
- data/lib/ffi-tk/tk.rb +222 -0
- data/lib/ffi-tk/variable.rb +46 -0
- data/lib/ffi-tk/widget.rb +68 -0
- data/lib/ffi-tk/widget/button.rb +41 -0
- data/lib/ffi-tk/widget/canvas.rb +806 -0
- data/lib/ffi-tk/widget/canvas/arc.rb +18 -0
- data/lib/ffi-tk/widget/canvas/bitmap.rb +13 -0
- data/lib/ffi-tk/widget/canvas/image.rb +10 -0
- data/lib/ffi-tk/widget/canvas/item.rb +170 -0
- data/lib/ffi-tk/widget/canvas/line.rb +16 -0
- data/lib/ffi-tk/widget/canvas/oval.rb +15 -0
- data/lib/ffi-tk/widget/canvas/polygon.rb +16 -0
- data/lib/ffi-tk/widget/canvas/rectangle.rb +15 -0
- data/lib/ffi-tk/widget/canvas/text.rb +15 -0
- data/lib/ffi-tk/widget/canvas/window.rb +11 -0
- data/lib/ffi-tk/widget/checkbutton.rb +63 -0
- data/lib/ffi-tk/widget/entry.rb +208 -0
- data/lib/ffi-tk/widget/frame.rb +12 -0
- data/lib/ffi-tk/widget/label.rb +26 -0
- data/lib/ffi-tk/widget/labelframe.rb +7 -0
- data/lib/ffi-tk/widget/listbox.rb +192 -0
- data/lib/ffi-tk/widget/menu.rb +318 -0
- data/lib/ffi-tk/widget/menubutton.rb +7 -0
- data/lib/ffi-tk/widget/message.rb +36 -0
- data/lib/ffi-tk/widget/panedwindow.rb +164 -0
- data/lib/ffi-tk/widget/radiobutton.rb +43 -0
- data/lib/ffi-tk/widget/root.rb +8 -0
- data/lib/ffi-tk/widget/scale.rb +44 -0
- data/lib/ffi-tk/widget/scrollbar.rb +114 -0
- data/lib/ffi-tk/widget/spinbox.rb +198 -0
- data/lib/ffi-tk/widget/text.rb +893 -0
- data/lib/ffi-tk/widget/text/peer.rb +10 -0
- data/lib/ffi-tk/widget/tile.rb +70 -0
- data/lib/ffi-tk/widget/tile/button.rb +8 -0
- data/lib/ffi-tk/widget/tile/checkbutton.rb +8 -0
- data/lib/ffi-tk/widget/tile/combobox.rb +43 -0
- data/lib/ffi-tk/widget/tile/entry.rb +8 -0
- data/lib/ffi-tk/widget/tile/frame.rb +13 -0
- data/lib/ffi-tk/widget/tile/label.rb +9 -0
- data/lib/ffi-tk/widget/tile/labelframe.rb +8 -0
- data/lib/ffi-tk/widget/tile/menubutton.rb +8 -0
- data/lib/ffi-tk/widget/tile/notebook.rb +93 -0
- data/lib/ffi-tk/widget/tile/panedwindow.rb +9 -0
- data/lib/ffi-tk/widget/tile/progressbar.rb +59 -0
- data/lib/ffi-tk/widget/tile/radiobutton.rb +8 -0
- data/lib/ffi-tk/widget/tile/scale.rb +8 -0
- data/lib/ffi-tk/widget/tile/scrollbar.rb +41 -0
- data/lib/ffi-tk/widget/tile/separator.rb +23 -0
- data/lib/ffi-tk/widget/tile/sizegrip.rb +24 -0
- data/lib/ffi-tk/widget/tile/style.rb +114 -0
- data/lib/ffi-tk/widget/tile/treeview.rb +414 -0
- data/lib/ffi-tk/widget/toplevel.rb +14 -0
- data/spec/ffi-tk/command/bindtags.rb +18 -0
- data/spec/ffi-tk/command/clipboard.rb +18 -0
- data/spec/ffi-tk/command/font.rb +67 -0
- data/spec/ffi-tk/command/grid.rb +6 -0
- data/spec/ffi-tk/command/image.rb +26 -0
- data/spec/ffi-tk/command/pack.rb +20 -0
- data/spec/ffi-tk/command/place.rb +20 -0
- data/spec/ffi-tk/command/selection.rb +13 -0
- data/spec/ffi-tk/command/vars.rb +32 -0
- data/spec/ffi-tk/command/winfo.rb +233 -0
- data/spec/ffi-tk/command/wm.rb +185 -0
- data/spec/ffi-tk/event.rb +95 -0
- data/spec/ffi-tk/tile/button.rb +51 -0
- data/spec/ffi-tk/tile/checkbutton.rb +13 -0
- data/spec/ffi-tk/tile/combobox.rb +65 -0
- data/spec/ffi-tk/tile/entry.rb +61 -0
- data/spec/ffi-tk/tile/frame.rb +65 -0
- data/spec/ffi-tk/tile/label.rb +17 -0
- data/spec/ffi-tk/tile/labelframe.rb +13 -0
- data/spec/ffi-tk/tile/menubutton.rb +13 -0
- data/spec/ffi-tk/tile/notebook.rb +103 -0
- data/spec/ffi-tk/tile/panedwindow.rb +13 -0
- data/spec/ffi-tk/tile/progressbar.rb +78 -0
- data/spec/ffi-tk/tile/radiobutton.rb +13 -0
- data/spec/ffi-tk/tile/scale.rb +13 -0
- data/spec/ffi-tk/tile/scrollbar.rb +43 -0
- data/spec/ffi-tk/tile/separator.rb +22 -0
- data/spec/ffi-tk/tile/sizegrip.rb +13 -0
- data/spec/ffi-tk/tile/style.rb +161 -0
- data/spec/ffi-tk/tile/treeview.rb +101 -0
- data/spec/ffi-tk/variable.rb +24 -0
- data/spec/ffi-tk/widget/button.rb +22 -0
- data/spec/ffi-tk/widget/canvas.rb +169 -0
- data/spec/ffi-tk/widget/checkbutton.rb +44 -0
- data/spec/ffi-tk/widget/entry.rb +155 -0
- data/spec/ffi-tk/widget/frame.rb +8 -0
- data/spec/ffi-tk/widget/label.rb +16 -0
- data/spec/ffi-tk/widget/labelframe.rb +12 -0
- data/spec/ffi-tk/widget/listbox.rb +19 -0
- data/spec/ffi-tk/widget/menu.rb +12 -0
- data/spec/ffi-tk/widget/menubutton.rb +12 -0
- data/spec/ffi-tk/widget/message.rb +12 -0
- data/spec/ffi-tk/widget/panedwindow.rb +12 -0
- data/spec/ffi-tk/widget/radiobutton.rb +12 -0
- data/spec/ffi-tk/widget/root.rb +9 -0
- data/spec/ffi-tk/widget/scale.rb +12 -0
- data/spec/ffi-tk/widget/scrollbar.rb +12 -0
- data/spec/ffi-tk/widget/spinbox.rb +12 -0
- data/spec/ffi-tk/widget/text.rb +246 -0
- data/spec/ffi-tk/widget/toplevel.rb +12 -0
- data/spec/helper.rb +3 -0
- data/tasks/authors.rake +21 -0
- data/tasks/bacon.rake +66 -0
- data/tasks/changelog.rake +18 -0
- data/tasks/gem.rake +22 -0
- data/tasks/gem_setup.rake +113 -0
- data/tasks/grancher.rake +12 -0
- data/tasks/manifest.rake +4 -0
- data/tasks/rcov.rake +17 -0
- data/tasks/release.rake +65 -0
- data/tasks/reversion.rake +8 -0
- data/tasks/setup.rake +12 -0
- data/tasks/ycov.rake +84 -0
- metadata +261 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Tk
|
|
2
|
+
# A toplevel is similar to a frame except that it is created as a top-level
|
|
3
|
+
# window: its X parent is the root window of a screen rather than the logical
|
|
4
|
+
# parent from its path name.
|
|
5
|
+
# The primary purpose of a toplevel is to serve as a container for dialog
|
|
6
|
+
# boxes and other collections of widgets.
|
|
7
|
+
# The only visible features of a toplevel are its background color and an
|
|
8
|
+
# optional 3-D border to make the toplevel appear raised or sunken.
|
|
9
|
+
class Toplevel < Widget
|
|
10
|
+
include Cget, Configure
|
|
11
|
+
|
|
12
|
+
def self.tk_command; 'toplevel'; end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require_relative '../../helper'
|
|
2
|
+
|
|
3
|
+
Tk.init
|
|
4
|
+
|
|
5
|
+
describe Tk::Bindtags do
|
|
6
|
+
@entry = Tk::Entry.new('.')
|
|
7
|
+
@entry.pack # only placed widgets have bindtags?
|
|
8
|
+
|
|
9
|
+
it 'lists bindtags of a widget' do
|
|
10
|
+
Tk::Bindtags.bindtags(@entry).should == [".entry0", "Entry", ".", "all"]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'reverses bindtags of a widget' do
|
|
14
|
+
tags = Tk::Bindtags.bindtags(@entry)
|
|
15
|
+
Tk::Bindtags.bindtags(@entry, tags.reverse)
|
|
16
|
+
Tk::Bindtags.bindtags(@entry).should == tags.reverse
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require_relative '../../helper'
|
|
2
|
+
|
|
3
|
+
Tk.init
|
|
4
|
+
|
|
5
|
+
describe Tk::Clipboard do
|
|
6
|
+
C = Tk::Clipboard
|
|
7
|
+
|
|
8
|
+
it 'should clear the clipboard' do
|
|
9
|
+
C.clear
|
|
10
|
+
lambda{ C.get }.should.raise.message.
|
|
11
|
+
should =~ /^CLIPBOARD selection doesn't exist or form "STRING" not defined/
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should append to the clipboard' do
|
|
15
|
+
C.append data: 'something'
|
|
16
|
+
C.get.should == 'something'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require_relative '../../helper'
|
|
2
|
+
|
|
3
|
+
Tk.init
|
|
4
|
+
|
|
5
|
+
describe Tk::Font do
|
|
6
|
+
it 'lists names of all named fonts' do
|
|
7
|
+
Tk::Font.names.sort.should == [
|
|
8
|
+
"TkCaptionFont", "TkDefaultFont", "TkFixedFont", "TkHeadingFont",
|
|
9
|
+
"TkIconFont", "TkMenuFont", "TkSmallCaptionFont", "TkTextFont",
|
|
10
|
+
"TkTooltipFont"
|
|
11
|
+
]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'measures a character' do
|
|
15
|
+
Tk::Font.measure('TkDefaultFont', '0').should >= 4
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'shows metrics of a font' do
|
|
19
|
+
Tk::Font.metrics('TkDefaultFont', :ascent).should == 12
|
|
20
|
+
Tk::Font.metrics('TkDefaultFont', :descent).should == 3
|
|
21
|
+
Tk::Font.metrics('TkDefaultFont', :linespace).should == 15
|
|
22
|
+
Tk::Font.metrics('TkDefaultFont', :fixed).should == 0
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'lists all font families on the system' do
|
|
26
|
+
Tk::Font.families.size.should > 0
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'creates a font' do
|
|
30
|
+
Tk::Font.create('Awesome Font').should == "Awesome Font"
|
|
31
|
+
Tk::Font.names.sort.should.include('Awesome Font')
|
|
32
|
+
|
|
33
|
+
lambda{
|
|
34
|
+
Tk::Font.create('Awesome Font')
|
|
35
|
+
}.should.raise.message =~ /^named font "Awesome Font" already exists/
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'show configuration for our font' do
|
|
39
|
+
conf = Tk::Font.configure('Awesome Font')
|
|
40
|
+
conf[:family].should == ''
|
|
41
|
+
conf[:size].should == 0
|
|
42
|
+
conf[:weight].should == :normal
|
|
43
|
+
conf[:slant].should == :roman
|
|
44
|
+
conf[:underline].should == false
|
|
45
|
+
conf[:overstrike].should == false
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'manipulates configuration of our font' do
|
|
49
|
+
Tk::Font.configure('Awesome Font', size: 10)
|
|
50
|
+
Tk::Font.configure('Awesome Font')[:size].should == 10
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'shows actual information about the font' do
|
|
54
|
+
conf = Tk::Font.actual('Awesome Font')
|
|
55
|
+
conf[:family].should.not == ''
|
|
56
|
+
conf[:size].should == 10
|
|
57
|
+
conf[:weight].should == :normal
|
|
58
|
+
conf[:slant].should == :roman
|
|
59
|
+
conf[:underline].should == false
|
|
60
|
+
conf[:overstrike].should == false
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'deletes the font' do
|
|
64
|
+
Tk::Font.delete('Awesome Font')
|
|
65
|
+
Tk::Font.names.should.not.include('Awesome Font')
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative '../../helper'
|
|
2
|
+
|
|
3
|
+
Tk.init
|
|
4
|
+
|
|
5
|
+
describe Tk::Image do
|
|
6
|
+
Image = Tk::Image
|
|
7
|
+
|
|
8
|
+
it 'creates photo image and return path' do
|
|
9
|
+
Image.names.size.should == 0
|
|
10
|
+
Image.create('photo').to_s.should == 'image1'
|
|
11
|
+
Image.create('photo').to_s.should == 'image2'
|
|
12
|
+
Image.names.should == ['image1', 'image2']
|
|
13
|
+
|
|
14
|
+
Image.delete('image1', 'image2')
|
|
15
|
+
Image.names.size.should == 0
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'creates bitmap image and return path' do
|
|
19
|
+
Image.create('bitmap').to_s.should == 'image3'
|
|
20
|
+
Image.names.should == ['image3']
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'raise RuntimeError if wrong type' do
|
|
24
|
+
lambda { Image.create('unkown-') }.should.raise RuntimeError
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative '../../helper'
|
|
2
|
+
|
|
3
|
+
Tk.init
|
|
4
|
+
|
|
5
|
+
describe Tk::Pack do
|
|
6
|
+
@button = Tk::Button.new('.')
|
|
7
|
+
|
|
8
|
+
it 'packs a widget' do
|
|
9
|
+
Tk::Pack.pack(@button)
|
|
10
|
+
Tk::Pack.info(@button).should == {
|
|
11
|
+
in: '.', anchor: 'center', expand: false, fill: :none, ipadx: 0, ipady: 0,
|
|
12
|
+
padx: 0, pady: 0, side: :top
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'forgets the packing' do
|
|
17
|
+
Tk::Pack.forget(@button)
|
|
18
|
+
lambda{ Tk::Pack.info(@button) }.should.raise
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative '../../helper'
|
|
2
|
+
|
|
3
|
+
Tk.init
|
|
4
|
+
|
|
5
|
+
describe Tk::Place do
|
|
6
|
+
@button = Tk::Button.new('.')
|
|
7
|
+
|
|
8
|
+
it 'places a widget' do
|
|
9
|
+
Tk::Place.place(@button, y: 42, x: 24)
|
|
10
|
+
Tk::Place.info(@button).should == {
|
|
11
|
+
in: ".", x: 24, relx: 0.0, y: 42, rely: 0.0, width: 0, relwidth: 0.0,
|
|
12
|
+
height: 0, relheight: 0.0, anchor: "nw", bordermode: :inside
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'forgets the placement' do
|
|
17
|
+
Tk::Place.forget(@button)
|
|
18
|
+
Tk::Place.info(@button).should == {}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative '../../helper'
|
|
2
|
+
|
|
3
|
+
Tk.init
|
|
4
|
+
|
|
5
|
+
describe Tk::Selection do
|
|
6
|
+
@entry = Tk::Entry.new('.')
|
|
7
|
+
@entry.insert :end, 'abc def ghi jkl mno pqr stu vwx yz'
|
|
8
|
+
@entry.selection_range(0, 3)
|
|
9
|
+
|
|
10
|
+
it 'gets selection' do
|
|
11
|
+
Tk::Selection.get.should == 'abc'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require_relative '../../helper'
|
|
2
|
+
|
|
3
|
+
Tk.init
|
|
4
|
+
|
|
5
|
+
describe 'tkvars' do
|
|
6
|
+
it 'has a library set' do
|
|
7
|
+
library = Tk.library
|
|
8
|
+
library.class.should == String
|
|
9
|
+
library.should.not.be.empty
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'has a patchlevel' do
|
|
13
|
+
Tk.patchlevel.should =~ /\A(\d+)\.(\d+)\.(\d+)\Z/
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'has a version' do
|
|
17
|
+
Tk.version.should =~ /\A(\d+)\.(\d+)\Z/
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'is not set to strict motif' do
|
|
21
|
+
Tk.strict_motif.should.be.false
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'sets to strict motif' do
|
|
25
|
+
Tk.strict_motif = true
|
|
26
|
+
Tk.strict_motif.should.be.true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'does not have text_relayout set' do
|
|
30
|
+
lambda{ Tk.text_relayout }.should.raise(NameError)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
require_relative '../../helper'
|
|
2
|
+
|
|
3
|
+
Tk.init
|
|
4
|
+
|
|
5
|
+
describe Tk::Winfo do
|
|
6
|
+
root = Tk.root
|
|
7
|
+
entry = Tk::Entry.new(root)
|
|
8
|
+
|
|
9
|
+
it 'gives info about an atom' do
|
|
10
|
+
root.winfo_atom('STRING').should == 31
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'gives name of an atom' do
|
|
14
|
+
root.winfo_atomname(31).should == 'STRING'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'gives info about cells' do
|
|
18
|
+
root.winfo_cells.should >= 2
|
|
19
|
+
root.winfo_cells.should.be.even?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'gives info about children' do
|
|
23
|
+
root.winfo_children.should.include?(entry.tk_pathname)
|
|
24
|
+
entry.winfo_children.should.be.empty
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'gives class name of window' do
|
|
28
|
+
root.winfo_class.should == 'Tk'
|
|
29
|
+
entry.winfo_class.should == 'Entry'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'tell us whether colormap is full' do
|
|
33
|
+
root.winfo_colormapfull.should == false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
should 'not contain any coordinates yet' do
|
|
37
|
+
root.winfo_containing(0, 0).should == nil
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'tells us the depth of the window' do
|
|
41
|
+
root.winfo_depth.should >= 8
|
|
42
|
+
root.winfo_depth.should.even?
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'tells us whether the window exists' do
|
|
46
|
+
root.winfo_exists.should == true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'gives us the amount of pixels for a given distance' do
|
|
50
|
+
@fpixels = root.winfo_fpixels('1c')
|
|
51
|
+
@fpixels.class.should == Float
|
|
52
|
+
@fpixels.should > 0
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'knows distance in pixels' do
|
|
56
|
+
root.winfo_pixels('1c').should == @fpixels.round
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'gives us the window geometry' do
|
|
60
|
+
@geometry = root.winfo_geometry
|
|
61
|
+
@geometry.width.should == 1
|
|
62
|
+
@geometry.height.should == 1
|
|
63
|
+
@geometry.x.should == 0
|
|
64
|
+
@geometry.y.should == 0
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'gives us the window height' do
|
|
68
|
+
root.winfo_height.should == @geometry.height
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'gives us the window id' do
|
|
72
|
+
root.winfo_id.should.not.be.empty?
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'lists interps' do
|
|
76
|
+
root.winfo_interps.should.include?('tk')
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "knows whether it's mapped" do
|
|
80
|
+
root.winfo_ismapped.should == false
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'knows the manager' do
|
|
84
|
+
root.winfo_manager.should == 'wm'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "knows its name" do
|
|
88
|
+
root.winfo_name.should =~ /^tk/
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'knows its parent' do
|
|
92
|
+
root.winfo_parent.should == nil
|
|
93
|
+
entry.winfo_parent.should == root.tk_pathname
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'knows pathname of given id' do
|
|
97
|
+
root.winfo_pathname(entry.winfo_id).should == entry.tk_pathname
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'knows location of pointer x coordinate' do
|
|
101
|
+
root.winfo_pointerx.class.should == Fixnum
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'knows location of pointer y coordinate' do
|
|
105
|
+
root.winfo_pointery.class.should == Fixnum
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# NOTE: hold still while the specs are running ;)
|
|
109
|
+
it 'lists location of pointer x/y coordinates' do
|
|
110
|
+
root.winfo_pointerxy.should == [root.winfo_pointerx, root.winfo_pointery]
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'shows requested height of window' do
|
|
114
|
+
root.winfo_reqheight.should == 200
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'shows requested width of window' do
|
|
118
|
+
root.winfo_reqwidth.should == 200
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'gives r,g,b values of a color' do
|
|
122
|
+
root.winfo_rgb('red').should == [65535, 0, 0]
|
|
123
|
+
root.winfo_rgb('green').should == [0, 65535, 0]
|
|
124
|
+
root.winfo_rgb('blue').should == [0, 0, 65535]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'knows x coordinate of root window' do
|
|
128
|
+
entry.winfo_rootx.should == 0
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it 'knows y coordinate of root window' do
|
|
132
|
+
entry.winfo_rooty.should == 0
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'knows which screen it is on' do
|
|
136
|
+
root.winfo_screen.should.match(/\:(.+)\.\d/) # :0.0
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it 'knows the number of cells in the default color map' do
|
|
140
|
+
root.winfo_screencells.should >= 2
|
|
141
|
+
root.winfo_screencells.should.be.even?
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it 'knows the depth of the screen' do
|
|
145
|
+
root.winfo_screendepth.should >= 2
|
|
146
|
+
root.winfo_screendepth.should.be.even?
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it 'knows the height of the screen' do
|
|
150
|
+
root.winfo_screenheight.should >= 200
|
|
151
|
+
root.winfo_screenheight.should.be.even?
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it 'knows the width of the screen' do
|
|
155
|
+
root.winfo_screenwidth.should >= 320
|
|
156
|
+
root.winfo_screenwidth.should.be.even?
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'knows the height of the screen in millimeter' do
|
|
160
|
+
root.winfo_screenmmheight.should >= 2
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it 'knows the width of the screen in millimeter' do
|
|
164
|
+
root.winfo_screenmmwidth.should >= 2
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it 'shows the default visual class for the screen' do
|
|
168
|
+
root.winfo_screenvisual.should == :truecolor
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it 'knows its server' do
|
|
172
|
+
root.winfo_server.should.not.be.empty?
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
it 'knows its toplevel window' do
|
|
176
|
+
root.winfo_toplevel.should == '.'
|
|
177
|
+
entry.winfo_toplevel.should == '.'
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it "knows whether it's viwable" do
|
|
181
|
+
root.winfo_viewable.should == false
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it 'knows the visual class of the window' do
|
|
185
|
+
root.winfo_visual.should == :truecolor
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it 'knows the visualid of the window' do
|
|
189
|
+
root.winfo_visualid.should.not.be.empty
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it 'knows some stuff about visualavailable' do
|
|
193
|
+
root.winfo_visualsavailable.should.not.be.empty
|
|
194
|
+
root.winfo_visualsavailable(:directcolor).should.not.be.empty
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
it 'knows the height of the virtual root window' do
|
|
199
|
+
root.winfo_vrootheight.should >= 200
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it 'knows the width of the virtual root window' do
|
|
203
|
+
root.winfo_vrootwidth.should >= 320
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it 'knows the x coordinate of the virtual root window' do
|
|
207
|
+
root.winfo_vrootx.should == 0
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it 'knows the y coordinate of the virtual root window' do
|
|
211
|
+
root.winfo_vrooty.should == 0
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it 'knows the height of the window' do
|
|
215
|
+
root.winfo_width.should == 1
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it 'knows the x coordinate of the window' do
|
|
219
|
+
root.winfo_x.should == 0
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it 'knows the y coordinate of the window' do
|
|
223
|
+
root.winfo_y.should == 0
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# TODO check real screen values? (xrandr only)
|
|
227
|
+
# For now it checks for a minimum of 320 x 200
|
|
228
|
+
#
|
|
229
|
+
# matcher = /Screen (.+?)\: (.+), current (.+) x (.+), /
|
|
230
|
+
# %x{xrandr -q}.scan(matcher).collect{|i|
|
|
231
|
+
# {name: i[0], width: i[2].to_i, height: i[3].to_i}
|
|
232
|
+
# }.first
|
|
233
|
+
end
|