bakkdoor-rswing 0.1.4 → 0.1.5

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.
@@ -1,3 +1,22 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  ActionListener = java.awt.event.ActionListener
@@ -32,9 +51,7 @@ module RSwing
32
51
 
33
52
  # Eventhandler for clicked (actionPerformed) event.
34
53
  # Takes a block, which will be executed if this event occurs.
35
- def on_click(&block)
36
- self.add_action_listener(Listener.create(ActionListener, :actionPerformed, &block))
37
- end
54
+ event_for self => :on_click, ActionListener => :actionPerformed
38
55
  end
39
56
  end
40
57
  end
@@ -1,3 +1,22 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  module Container
@@ -1,3 +1,22 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  JOptionPane = javax.swing.JOptionPane
@@ -0,0 +1,52 @@
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 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 Event
24
+ def event_for(listener_class_method_hash)
25
+ module_with_event = listener_class_method_hash.keys.first
26
+ event_name = listener_class_method_hash.values.first
27
+
28
+ event_listener_class = listener_class_method_hash.keys.last
29
+ java_method_name = listener_class_method_hash.values.last
30
+
31
+ module_with_event.module_eval do
32
+ define_method("__real_#{event_name}") do |block, *args|
33
+ self.send("add#{event_listener_class.java_class.name.split(".").last}",
34
+ Listener.create(event_listener_class, java_method_name, &block))
35
+ end
36
+
37
+ # some funky code here, since we need do define the interface-method
38
+ # which will itself call our 'real' method. this is a workaround for ruby 1.8 since
39
+ # it isn't possible to define_method a method with a &block via define_method. should work in 1.9
40
+ # but for now, we keep it this (obviously ugly) way, since it works.
41
+ eval <<-EOM
42
+ def #{event_name}(*args, &block)
43
+ __real_#{event_name}(block, args)
44
+ end
45
+ EOM
46
+
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,20 +1,35 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  module Events
4
23
  module FocusEvents
5
24
  FocusListener = java.awt.event.FocusListener
6
25
 
7
- # Eventhandler für focus (focusGained) Event.
8
- # Nimmt einen block, welcher dann bei diesem Event ausgeführt wird.
9
- def on_focus(&block)
10
- self.add_focus_listener(Listener.create(FocusListener, :focusGained ,&block))
11
- end
12
-
13
- # Eventhandler für focus_lost (focusLost) Event.
14
- # Nimmt einen block, welcher dann bei diesem Event ausgeführt wird.
15
- def on_focus_lost(&block)
16
- self.add_focus_listener(Listener.create(FocusListener, :focusLost ,&block))
17
- end
26
+ # Eventhandler for on_focus (focusGained) event.
27
+ # Takes a block, which will get executed, when this event is fired.
28
+ event_for self => :on_focus, FocusListener => :focusGained
29
+
30
+ # Eventhandler for focus_lost (focusLost) event.
31
+ # Takes a block, which will get executed, when this event is fired.
32
+ event_for self => :on_focus_lost, FocusListener => :focusLost
18
33
  end
19
34
  end
20
35
  end
@@ -1,20 +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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  module Events
4
23
  module KeyEvents
5
24
  KeyListener = java.awt.event.KeyListener
6
25
 
7
- def on_key_pressed(&block)
8
- self.add_key_listener(Listener.create(KeyListener, :keyPressed, &block))
9
- end
10
-
11
- def on_key_released(&block)
12
- self.add_key_listener(Listener.create(KeyListener, :keyReleased, &block))
13
- end
14
-
15
- def on_key_typed(&block)
16
- self.add_key_listener(Listener.create(KeyListener, :keyTyped, &block))
17
- end
26
+ event_for self => :on_key_pressed, KeyListener => :keyPressed
27
+ event_for self => :on_key_released, KeyListener => :keyReleased
28
+ event_for self => :on_key_typed, KeyListener => :keyTyped
18
29
  end
19
30
  end
20
31
  end
@@ -1,28 +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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  module Events
4
23
  module MouseEvents
5
24
  MouseListener = java.awt.event.MouseListener
6
25
 
7
- def on_mouse_clicked(&block)
8
- self.add_key_listener(Listener.create(MouseListener, :mouseClicked, &block))
9
- end
10
-
11
- def on_mouse_entered(&block)
12
- self.add_key_listener(Listener.create(MouseListener, :mouseEntered, &block))
13
- end
14
-
15
- def on_mouse_exited(&block)
16
- self.add_key_listener(Listener.create(MouseListener, :mouseExited, &block))
17
- end
18
-
19
- def on_mouse_pressed(&block)
20
- self.add_key_listener(Listener.create(MouseListener, :mousePressed, &block))
21
- end
22
-
23
- def on_mouse_released(&block)
24
- self.add_key_listener(Listener.create(MouseListener, :mouseReleased, &block))
25
- end
26
+ event_for self => :on_mouse_clicked, MouseListener => :mouseClicked
27
+ event_for self => :on_mouse_entered, MouseListener => :mouseEntered
28
+ event_for self => :on_mouse_exited, MouseListener => :mouseExited
29
+ event_for self => :on_mouse_pressed, MouseListener => :mousePressed
30
+ event_for self => :on_mouse_released, MouseListener => :mouseReleased
26
31
  end
27
32
  end
28
33
  end
@@ -1,3 +1,22 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  JFrame = javax.swing.JFrame
@@ -1,3 +1,22 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  class Listener
@@ -1,3 +1,22 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  class Options
@@ -1,3 +1,22 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  JPanel = javax.swing.JPanel
@@ -1,3 +1,22 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  JTextField = javax.swing.JTextField
@@ -1,3 +1,22 @@
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 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
+
1
20
  module RSwing
2
21
  module Components
3
22
  module Window
data/lib/rswing.rb CHANGED
@@ -1,14 +1,41 @@
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 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
+
1
20
  # needed for swing classes
2
21
  require "java"
3
22
 
4
23
  # expand search path to components subdir.
5
24
  $: << File.expand_path(File.dirname(__FILE__) + "/rswing/components")
6
25
 
26
+ require "events/event"
27
+
28
+ # add "has_event"-method to Module-class for easy access in event-modules.
29
+ class Module
30
+ include RSwing::Components::Events::Event
31
+ end
32
+
7
33
  # event-modules
8
34
  require "events/focus_events"
9
35
  require "events/key_events"
10
36
  require "events/mouse_events"
11
37
 
38
+
12
39
  # containers
13
40
  require "container"
14
41
  require "window"
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.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Bertels
@@ -35,6 +35,7 @@ files:
35
35
  - lib/rswing/components/panel.rb
36
36
  - lib/rswing/components/text_field.rb
37
37
  - lib/rswing/components/window.rb
38
+ - lib/rswing/components/events/event.rb
38
39
  - lib/rswing/components/events/focus_events.rb
39
40
  - lib/rswing/components/events/key_events.rb
40
41
  - lib/rswing/components/events/mouse_events.rb