bakkdoor-rswing 0.1.5 → 0.2.0
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/README +1 -1
- data/Rakefile +21 -6
- data/lib/rswing/components/button.rb +1 -1
- data/lib/rswing/components/component.rb +36 -0
- data/lib/rswing/components/container.rb +17 -4
- data/lib/rswing/components/dialog.rb +1 -2
- data/lib/rswing/components/events/component_events.rb +33 -0
- data/lib/rswing/components/events/container_events.rb +31 -0
- data/lib/rswing/components/events/event.rb +1 -1
- data/lib/rswing/components/events/focus_events.rb +1 -1
- data/lib/rswing/components/events/hierarchy_bounds_events.rb +31 -0
- data/lib/rswing/components/events/hierarchy_changed.rb +30 -0
- data/lib/rswing/components/events/input_method_events.rb +31 -0
- data/lib/rswing/components/events/key_events.rb +1 -1
- data/lib/rswing/components/events/mouse_events.rb +1 -1
- data/lib/rswing/components/events/mouse_motion_events.rb +31 -0
- data/lib/rswing/components/events/mouse_wheel_events.rb +30 -0
- data/lib/rswing/components/events/property_changed.rb +30 -0
- data/lib/rswing/components/events/window_events.rb +36 -0
- data/lib/rswing/components/events/window_focus.rb +31 -0
- data/lib/rswing/components/events/window_state.rb +30 -0
- data/lib/rswing/components/frame.rb +1 -2
- data/lib/rswing/components/listener.rb +6 -7
- data/lib/rswing/components/options.rb +3 -3
- data/lib/rswing/components/panel.rb +2 -5
- data/lib/rswing/components/text_field.rb +1 -1
- data/lib/rswing/components/window.rb +8 -1
- data/lib/rswing.rb +13 -1
- data/test/test_button.rb +17 -0
- data/test/test_container.rb +55 -0
- data/test/test_helper.rb +9 -0
- metadata +26 -8
data/README
CHANGED
@@ -38,7 +38,7 @@ Some examples:
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# accessing components of frame via :name attribute given to button:
|
41
|
-
puts "text property of : #{frame[:okButton].text}"
|
41
|
+
puts "text property of okButton: #{frame[:okButton].text}"
|
42
42
|
|
43
43
|
# options-dialog
|
44
44
|
options = ["Yes", "No", "Cancel"]
|
data/Rakefile
CHANGED
@@ -1,8 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require "rake"
|
2
|
+
require "rake/testtask"
|
3
|
+
require "rake/rdoctask"
|
4
|
+
require "rake/clean"
|
5
|
+
require "rake/gempackagetask"
|
4
6
|
|
7
|
+
task :default => [ :test ]
|
8
|
+
task :test => [ :test_units ]
|
9
|
+
|
10
|
+
desc "run unit tests in test/unit"
|
11
|
+
rt = Rake::TestTask.new("test_units") do |t|
|
12
|
+
t.libs << "test/unit"
|
13
|
+
t.pattern = "test/test_*.rb"
|
14
|
+
t.verbose = true
|
15
|
+
end
|
5
16
|
|
6
|
-
|
7
|
-
|
8
|
-
|
17
|
+
desc "create rdoc in /doc"
|
18
|
+
rd = Rake::RDocTask.new("doc") do |rd|
|
19
|
+
rd.main = "README"
|
20
|
+
rd.rdoc_files.include("README", "lib/*.rb")
|
21
|
+
rd.options << "--all"
|
22
|
+
rd.rdoc_dir = "rdoc"
|
23
|
+
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -0,0 +1,36 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Component
|
23
|
+
|
24
|
+
include Events::ComponentEvents
|
25
|
+
include Events::MouseEvents
|
26
|
+
include Events::MouseMotionEvents
|
27
|
+
include Events::MouseWheelEvents
|
28
|
+
include Events::KeyEvents
|
29
|
+
include Events::HierarchyBoundsEvents
|
30
|
+
include Events::InputMethodEvents
|
31
|
+
include Events::PropertyChanged
|
32
|
+
include Events::FocusEvents
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -21,12 +21,15 @@ module RSwing
|
|
21
21
|
module Components
|
22
22
|
module Container
|
23
23
|
|
24
|
+
include Component
|
25
|
+
|
26
|
+
include Events::ContainerEvents
|
27
|
+
|
24
28
|
# Adds a component with a set of options to this container.
|
25
29
|
def add(component, options = {})
|
26
30
|
if(self.respond_to?(:getContentPane))
|
27
31
|
self.add_to_content_pane(component, options)
|
28
32
|
else
|
29
|
-
# this should be handled somehow later on:
|
30
33
|
if(layout = Options.value_for(options => :layout))
|
31
34
|
super(component, layout)
|
32
35
|
else
|
@@ -46,7 +49,7 @@ module RSwing
|
|
46
49
|
# Raises an exception if name already taken.
|
47
50
|
def add_with_name(component, name_symbol)
|
48
51
|
if self.component_hash.has_key?(name_symbol)
|
49
|
-
raise "Name in
|
52
|
+
raise "Name in component already taken!"
|
50
53
|
else
|
51
54
|
self.component_hash[name_symbol] = component
|
52
55
|
end
|
@@ -55,7 +58,7 @@ module RSwing
|
|
55
58
|
# Removes a component from this container.
|
56
59
|
# Also removes it from the component_hash
|
57
60
|
def remove(component)
|
58
|
-
super
|
61
|
+
super(component)
|
59
62
|
# delete all entries with component as value in component_hash
|
60
63
|
self.component_hash.delete_if { |key,value| value == component }
|
61
64
|
end
|
@@ -70,6 +73,16 @@ module RSwing
|
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
76
|
+
# Returns the components of a container.
|
77
|
+
# If the container uses a content_pane, its components are returned.
|
78
|
+
def components
|
79
|
+
if self.respond_to?(:getContentPane)
|
80
|
+
self.content_pane.components
|
81
|
+
else
|
82
|
+
super
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
73
86
|
# Adds a component to a container, if specified via :belongs_to in options.
|
74
87
|
def self.add_if_requested(component, options)
|
75
88
|
if(container = Options.value_for(options => :belongs_to))
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -28,7 +28,6 @@ module RSwing
|
|
28
28
|
# Can also be used to create custom dialogs by extending from this class.
|
29
29
|
class Dialog < JDialog
|
30
30
|
include Window
|
31
|
-
include Container
|
32
31
|
|
33
32
|
def initialize(title, options = {}, &block)
|
34
33
|
super(Options.value_for(options => :belongs_to), title, Options.value_for(options => :modal))
|
@@ -0,0 +1,33 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module ComponentEvents
|
24
|
+
ComponentListener = java.awt.event.ComponentListener
|
25
|
+
|
26
|
+
event_for self => :on_component_hidden, ComponentListener => :componentHidden
|
27
|
+
event_for self => :on_component_moved, ComponentListener => :componentMoved
|
28
|
+
event_for self => :on_component_resized, ComponentListener => :componentResized
|
29
|
+
event_for self => :on_component_shown, ComponentListener => :componentShown
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module ContainerEvents
|
24
|
+
ContainerListener = java.awt.event.ContainerListener
|
25
|
+
|
26
|
+
event_for self => :on_component_added, ContainerListener => :componentAdded
|
27
|
+
event_for self => :on_component_removed, ContainerListener => :componentRemoved
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -0,0 +1,31 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module HierarchyBoundsEvents
|
24
|
+
HierarchyBoundsListener = java.awt.event.HierarchyBoundsListener
|
25
|
+
|
26
|
+
event_for self => :on_ancestor_moved, HierarchyBoundsListener => :ancestorMoved
|
27
|
+
event_for self => :on_ancestor_resized, HierarchyBoundsListener => :ancestorResized
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module HierarchyChanged
|
24
|
+
HierarchyListener = java.awt.event.HierarchyListener
|
25
|
+
|
26
|
+
event_for self => :on_hierarchy_changed, HierarchyListener => :hierarchyChanged
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module InputMethodEvents
|
24
|
+
InputMethodListener = java.awt.event.InputMethodListener
|
25
|
+
|
26
|
+
event_for self => :on_input_method_text_changed, InputMethodListener => :inputMethodTextChanged
|
27
|
+
event_for self => :on_caret_position_changed, InputMethodListener => :caretPositionChanged
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -0,0 +1,31 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module MouseMotionEvents
|
24
|
+
MouseMotionListener = java.awt.event.MouseMotionListener
|
25
|
+
|
26
|
+
event_for self => :on_mouse_dragged, MouseMotionListener => :mouseDragged
|
27
|
+
event_for self => :on_mouse_moved, MouseMotionListener => :mouseMoved
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module MouseWheelEvents
|
24
|
+
MouseWheelListener = java.awt.event.MouseWheelListener
|
25
|
+
|
26
|
+
event_for self => :on_mouse_wheel_moved, MouseWheelListener => :mouseWheelMoved
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module PropertyChanged
|
24
|
+
PropertyChangeListener = java.beans.PropertyChangeListener
|
25
|
+
|
26
|
+
event_for self => :on_property_changed, PropertyChangeListener => :propertyChange
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module WindowEvents
|
24
|
+
WindowListener = java.awt.event.WindowListener
|
25
|
+
|
26
|
+
event_for self => :on_window_activated, WindowListener => :windowActivated
|
27
|
+
event_for self => :on_window_closed, WindowListener => :windowClosed
|
28
|
+
event_for self => :on_window_closing, WindowListener => :windowClosing
|
29
|
+
event_for self => :on_window_deactivated, WindowListener => :windowDeactivated
|
30
|
+
event_for self => :on_window_deiconified, WindowListener => :windowDeiconified
|
31
|
+
event_for self => :on_window_iconified, WindowListener => :windowIconified
|
32
|
+
event_for self => :on_window_opened, WindowListener => :windowOpened
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module WindowFocus
|
24
|
+
WindowFocusListener = java.awt.event.WindowFocusListener
|
25
|
+
|
26
|
+
event_for self => :on_window_focus, WindowFocusListener => :windowGainedFocus
|
27
|
+
event_for self => :on_window_focus_lost, WindowFocusListener => :windowLostFocus
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file is part of RSwing. #
|
3
|
+
# RSwing - Swing wrapper for JRuby #
|
4
|
+
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
|
5
|
+
# #
|
6
|
+
# RSwing is free software: you can redistribute it and/or modify #
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by #
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
9
|
+
# (at your option) any later version. #
|
10
|
+
# #
|
11
|
+
# RSwing is distributed in the hope that it will be useful, #
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
|
+
# #
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
17
|
+
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
18
|
+
###############################################################################
|
19
|
+
|
20
|
+
module RSwing
|
21
|
+
module Components
|
22
|
+
module Events
|
23
|
+
module WindowState
|
24
|
+
WindowStateListener = java.awt.event.WindowStateListener
|
25
|
+
|
26
|
+
event_for self => :on_window_state_changed, WindowStateListener => :windowStateChanged
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -23,7 +23,6 @@ module RSwing
|
|
23
23
|
|
24
24
|
class Frame < JFrame
|
25
25
|
include Window
|
26
|
-
include Container
|
27
26
|
|
28
27
|
# valid options are:
|
29
28
|
# 1. <tt>:size => [800, 600]</tt> 800x600 pixels (default: nil)
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -20,11 +20,10 @@
|
|
20
20
|
module RSwing
|
21
21
|
module Components
|
22
22
|
class Listener
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# Gibt anschließend eine neue Instanz dieser Listener-Klasse zurück
|
23
|
+
# Creates a Listener-Class of the given listener_interface (Java Listener Interface)
|
24
|
+
# which has all interface methods implemented empty exceptt the one
|
25
|
+
# specified by <tt>methodname</tt>. Its method-body gets filled by the given <tt>block</tt>.
|
26
|
+
# Finally returns a new instance of this dynamically created Listener-Class.
|
28
27
|
def self.create(listener_interface, methodname, &block)
|
29
28
|
listener_class = Class.new() do
|
30
29
|
include listener_interface
|
@@ -35,7 +34,7 @@ module RSwing
|
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
38
|
-
#
|
37
|
+
# return new instance of listener_class
|
39
38
|
listener_class.new(methodname, &block)
|
40
39
|
end
|
41
40
|
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -56,8 +56,8 @@ module RSwing
|
|
56
56
|
def self.value_for(hash)
|
57
57
|
raise "Value must be a hash!" unless hash.kind_of? Hash
|
58
58
|
hash.each_pair do |options_hash, option_key|
|
59
|
-
#
|
60
|
-
#
|
59
|
+
# it should only be one pair specified,
|
60
|
+
# so we can simply take the first and return the appropriate value
|
61
61
|
return options_hash[option_key].nil? ? gui_options[option_key] : options_hash[option_key]
|
62
62
|
end
|
63
63
|
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -23,9 +23,6 @@ module RSwing
|
|
23
23
|
|
24
24
|
class Panel < JPanel
|
25
25
|
include Container
|
26
|
-
include Events::KeyEvents
|
27
|
-
include Events::MouseEvents
|
28
|
-
include Events::FocusEvents
|
29
26
|
|
30
27
|
def initialize(options = {}, &block)
|
31
28
|
super(Options.value_for(options => :layout_manager), Options.value_for(options => :double_buffer))
|
@@ -36,7 +33,7 @@ module RSwing
|
|
36
33
|
self.border = border
|
37
34
|
end
|
38
35
|
|
39
|
-
# block
|
36
|
+
# call block with current object, if given
|
40
37
|
if block_given?
|
41
38
|
yield self
|
42
39
|
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -20,6 +20,13 @@
|
|
20
20
|
module RSwing
|
21
21
|
module Components
|
22
22
|
module Window
|
23
|
+
|
24
|
+
include Container
|
25
|
+
|
26
|
+
include Events::PropertyChanged
|
27
|
+
include Events::WindowState
|
28
|
+
include Events::WindowFocus
|
29
|
+
|
23
30
|
# Initializes a given Window object with some options.
|
24
31
|
# Valid options include:
|
25
32
|
# 1. <tt>:size => [100,200] # 100x200 pixels</tt> (default: nil)
|
data/lib/rswing.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
# RSwing is distributed in the hope that it will be useful, #
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
14
|
-
# GNU General Public License for more details.
|
14
|
+
# GNU Lesser General Public License for more details. #
|
15
15
|
# #
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License #
|
17
17
|
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
|
@@ -31,12 +31,24 @@ class Module
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# event-modules
|
34
|
+
require "events/component_events"
|
35
|
+
require "events/container_events"
|
34
36
|
require "events/focus_events"
|
37
|
+
require "events/hierarchy_bounds_events"
|
38
|
+
require "events/hierarchy_changed"
|
39
|
+
require "events/input_method_events"
|
35
40
|
require "events/key_events"
|
36
41
|
require "events/mouse_events"
|
42
|
+
require "events/mouse_motion_events"
|
43
|
+
require "events/mouse_wheel_events"
|
44
|
+
require "events/property_changed"
|
45
|
+
require "events/window_events"
|
46
|
+
require "events/window_focus"
|
47
|
+
require "events/window_state"
|
37
48
|
|
38
49
|
|
39
50
|
# containers
|
51
|
+
require "component"
|
40
52
|
require "container"
|
41
53
|
require "window"
|
42
54
|
|
data/test/test_button.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
|
3
|
+
require "rswing"
|
4
|
+
require "test/test_helper"
|
5
|
+
|
6
|
+
class TestButton < Test::Unit::TestCase
|
7
|
+
include RSwing::Components
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@button = Button.new "hello world"
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_events
|
15
|
+
should_have_events @button => [:on_click, :on_focus, :on_focus_lost]
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
|
3
|
+
require "rswing"
|
4
|
+
require "test/test_helper"
|
5
|
+
|
6
|
+
class TestContainer < Test::Unit::TestCase
|
7
|
+
include RSwing::Components
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@container = Frame.new "my frame"
|
12
|
+
@button = Button.new "by button"
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_indexer
|
16
|
+
btn = Button.new "my button", :belongs_to => @container, :name => :button
|
17
|
+
assert_equal(@container[:button], btn)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_add
|
21
|
+
@container.add @button
|
22
|
+
assert(@container.components.include?(@button), "container should have button!")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_remove
|
26
|
+
test_add
|
27
|
+
@container.remove @button
|
28
|
+
assert(! @container.components.include?(@button), "container should not have button!")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_add_if_requested
|
32
|
+
Container.add_if_requested @button, {}
|
33
|
+
assert(! @container.components.include?(@button), "container should not have button!")
|
34
|
+
|
35
|
+
Container.add_if_requested @button, :belongs_to => @container, :name => :new_button
|
36
|
+
assert(@container.components.include?(@button), "container now should have button!")
|
37
|
+
assert_not_nil(@container[:new_button], "container now should have button!")
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_components
|
41
|
+
frame = Frame.new "my frame"
|
42
|
+
panel = Panel.new
|
43
|
+
|
44
|
+
frame.add @button
|
45
|
+
assert(frame.components.include?(@button), "frame should have button!")
|
46
|
+
|
47
|
+
panel.add @button
|
48
|
+
assert(panel.components.include?(@button), "panel should have button!")
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_events
|
52
|
+
frame = Frame.new "my frame"
|
53
|
+
should_have_events frame => [:on_focus, :on_focus_lost, :on_property_changed]
|
54
|
+
end
|
55
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
module TestHelper
|
2
|
+
def should_have_events(component_events_hash)
|
3
|
+
component = component_events_hash.keys.first
|
4
|
+
events = component_events_hash[component]
|
5
|
+
events.each do |event|
|
6
|
+
assert(component.respond_to?(event), "no #{event} event-method available!")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bakkdoor-rswing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Bertels
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-03 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -27,18 +27,34 @@ files:
|
|
27
27
|
- Rakefile
|
28
28
|
- lib/rswing.rb
|
29
29
|
- lib/rswing/components/button.rb
|
30
|
+
- lib/rswing/components/component.rb
|
30
31
|
- lib/rswing/components/container.rb
|
31
32
|
- lib/rswing/components/dialog.rb
|
33
|
+
- lib/rswing/components/events
|
34
|
+
- lib/rswing/components/events/component_events.rb
|
35
|
+
- lib/rswing/components/events/container_events.rb
|
36
|
+
- lib/rswing/components/events/event.rb
|
37
|
+
- lib/rswing/components/events/focus_events.rb
|
38
|
+
- lib/rswing/components/events/hierarchy_bounds_events.rb
|
39
|
+
- lib/rswing/components/events/hierarchy_changed.rb
|
40
|
+
- lib/rswing/components/events/input_method_events.rb
|
41
|
+
- lib/rswing/components/events/key_events.rb
|
42
|
+
- lib/rswing/components/events/mouse_events.rb
|
43
|
+
- lib/rswing/components/events/mouse_motion_events.rb
|
44
|
+
- lib/rswing/components/events/mouse_wheel_events.rb
|
45
|
+
- lib/rswing/components/events/property_changed.rb
|
46
|
+
- lib/rswing/components/events/window_events.rb
|
47
|
+
- lib/rswing/components/events/window_focus.rb
|
48
|
+
- lib/rswing/components/events/window_state.rb
|
32
49
|
- lib/rswing/components/frame.rb
|
33
50
|
- lib/rswing/components/listener.rb
|
34
51
|
- lib/rswing/components/options.rb
|
35
52
|
- lib/rswing/components/panel.rb
|
36
53
|
- lib/rswing/components/text_field.rb
|
37
54
|
- lib/rswing/components/window.rb
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
- lib/rswing/components/events/mouse_events.rb
|
55
|
+
- test/test_button.rb
|
56
|
+
- test/test_container.rb
|
57
|
+
- test/test_helper.rb
|
42
58
|
has_rdoc: true
|
43
59
|
homepage: http://github.com/bakkdoor/rswing
|
44
60
|
post_install_message:
|
@@ -66,5 +82,7 @@ rubygems_version: 1.2.0
|
|
66
82
|
signing_key:
|
67
83
|
specification_version: 2
|
68
84
|
summary: RSwing - Ruby-ish wrapper of Swing GUI-Framework for JRuby
|
69
|
-
test_files:
|
70
|
-
|
85
|
+
test_files:
|
86
|
+
- test/test_button.rb
|
87
|
+
- test/test_container.rb
|
88
|
+
- test/test_helper.rb
|