reactive-wx 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/LICENSE +20 -0
  2. data/Manifest +45 -0
  3. data/README +22 -0
  4. data/Rakefile +5 -0
  5. data/lib/reactive-wx.rb +19 -0
  6. data/lib/reactive-wx/accessors.rb +15 -0
  7. data/lib/reactive-wx/accessors/control_with_items.rb +22 -0
  8. data/lib/reactive-wx/accessors/date_picker_ctrl.rb +17 -0
  9. data/lib/reactive-wx/accessors/text_ctrl.rb +17 -0
  10. data/lib/reactive-wx/binder.rb +49 -0
  11. data/lib/reactive-wx/default_handler.rb +50 -0
  12. data/lib/reactive-wx/helpers.rb +10 -0
  13. data/lib/reactive-wx/helpers/asset_helper.rb +21 -0
  14. data/lib/reactive-wx/helpers/exception_helper.rb +82 -0
  15. data/lib/reactive-wx/helpers/forms.rb +40 -0
  16. data/lib/reactive-wx/request.rb +13 -0
  17. data/lib/reactive-wx/wx_ext.rb +42 -0
  18. data/lib/reactive-wx/wx_ext/arranger.rb +33 -0
  19. data/lib/reactive-wx/wx_ext/aui_toolbar.rb +22 -0
  20. data/lib/reactive-wx/wx_ext/event_binder.rb +11 -0
  21. data/lib/reactive-wx/wx_ext/form_grid_sizer.rb +54 -0
  22. data/lib/reactive-wx/wx_ext/message_dialog.rb +62 -0
  23. data/lib/reactive-wx/wx_ext/panel_dialog.rb +14 -0
  24. data/lib/reactive-wx/wx_ext/semi_modal.rb +233 -0
  25. data/lib/reactive-wx/wx_ext/toolbar.rb +29 -0
  26. data/lib/reactive-wx/wx_ext/window.rb +16 -0
  27. data/reactive_app_generators/wx/USAGE +6 -0
  28. data/reactive_app_generators/wx/templates/application_helper.wx.rb +8 -0
  29. data/reactive_app_generators/wx/templates/layout.wx.erb +2 -0
  30. data/reactive_app_generators/wx/templates/main_controller.rb +10 -0
  31. data/reactive_app_generators/wx/templates/main_helper.wx.rb +9 -0
  32. data/reactive_app_generators/wx/templates/run.wx.erb +22 -0
  33. data/reactive_app_generators/wx/templates/show.wx.erb +2 -0
  34. data/reactive_app_generators/wx/wx_generator.rb +54 -0
  35. data/reactive_generators/view/USAGE +11 -0
  36. data/reactive_generators/view/templates/create.wx.rb +0 -0
  37. data/reactive_generators/view/templates/delete.wx.rb +0 -0
  38. data/reactive_generators/view/templates/destroy.wx.rb +0 -0
  39. data/reactive_generators/view/templates/edit.wx.rb +0 -0
  40. data/reactive_generators/view/templates/index.wx.rb +0 -0
  41. data/reactive_generators/view/templates/layout.wx.rb +0 -0
  42. data/reactive_generators/view/templates/new.wx.rb +0 -0
  43. data/reactive_generators/view/templates/show.wx.rb +0 -0
  44. data/reactive_generators/view/templates/update.wx.rb +0 -0
  45. data/reactive_generators/view/view_generator.rb +25 -0
  46. metadata +134 -0
@@ -0,0 +1,29 @@
1
+ module WxExtensions
2
+ module ToolBar
3
+ def self.included(base) #:nodoc:
4
+ base.send :alias_method_chain, :initialize, :extension
5
+ base.send :alias_method_chain, :add_tool, :extension
6
+ base.send :alias_method_chain, :add_check_tool, :extension
7
+ end
8
+
9
+ def initialize_with_extension(*args)
10
+ initialize_without_extension(*args)
11
+ if block_given?
12
+ yield self
13
+ realize
14
+ end
15
+ end
16
+
17
+ def add_tool_with_extension(*args, &block)
18
+ id = add_tool_without_extension(*args)
19
+ evt_tool(id, &block) if block
20
+ id
21
+ end
22
+
23
+ def add_check_tool_with_extension(*args, &block)
24
+ id = add_check_tool_without_extension(*args)
25
+ evt_tool(id, &block) if block
26
+ id
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ module WxExtensions
2
+ module Window
3
+ # Access to Window children the ruby way
4
+ include Enumerable
5
+
6
+ # ruby way to iterate over children
7
+ def each
8
+ get_children.each {|item| yield item}
9
+ end
10
+
11
+ # access children window by name directly as attribute reader
12
+ def method_missing(name, *args)
13
+ Wx::Window.find_window_by_name(name.to_s, self) || super
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ Description:
2
+ Creates the main controller and the related views with the actions needed
3
+ to create a main window.
4
+ It also adds the related helpers and layouts.
5
+
6
+ Modifies the config file to add the initial request statment.
@@ -0,0 +1,8 @@
1
+ module ApplicationHelper
2
+
3
+ # get the main frame
4
+ def main_frame
5
+ Wx::get_app.top_window
6
+ end
7
+
8
+ end
@@ -0,0 +1,2 @@
1
+ <%= inject_output_helpers %>
2
+ <%= yield %>
@@ -0,0 +1,10 @@
1
+ class MainController < ApplicationController
2
+ layout 'main', :except => :run
3
+
4
+ def run
5
+ end
6
+
7
+ def show
8
+ end
9
+
10
+ end
@@ -0,0 +1,9 @@
1
+ module MainHelper
2
+
3
+ class MainFrame < Wx::Frame
4
+ def initialize(*args)
5
+ super
6
+ end
7
+ end
8
+
9
+ end
@@ -0,0 +1,22 @@
1
+ app_class = Class.new(App)
2
+ app_class.class_eval do
3
+ attr_accessor :handler
4
+ def on_init
5
+ # We do not < %= render :partial => 'show' %> because we want the handler to catch exceptions.
6
+ # So we run a new request for the main frame.
7
+ do_request(:controller => 'main', :action => 'show')
8
+ true
9
+ rescue Exception => e
10
+ handler.show_exception_dialog(e)
11
+ false
12
+ end
13
+ def on_run
14
+ super
15
+ rescue Exception => e
16
+ handler.show_exception_dialog(e)
17
+ retry
18
+ end
19
+ end
20
+ app = app_class.new
21
+ app.handler = self
22
+ app.main_loop
@@ -0,0 +1,2 @@
1
+ frame = MainFrame.new(nil, :title => "Reactive Application")
2
+ frame.show
@@ -0,0 +1,54 @@
1
+ class WxGenerator < RubiGen::Base
2
+ attr_reader :app_name
3
+
4
+ def initialize(runtime_args, runtime_options = {})
5
+ super
6
+ @destination_root = runtime_args.shift || '.'
7
+ @app_name = File.basename(File.expand_path(@destination_root))
8
+ extract_options
9
+ end
10
+
11
+ def manifest
12
+ record do |m|
13
+ m.directory(Reactive.relative_path_for(:views, 'main'))
14
+ m.directory(Reactive.relative_path_for(:views, 'layouts'))
15
+
16
+ m.file "main_controller.rb", Reactive.relative_path_for(:controller, "main_controller.rb")
17
+ m.file "main_helper.wx.rb", Reactive.relative_path_for(:helper, "main_helper.wx.rb")
18
+ m.file "application_helper.wx.rb", Reactive.relative_path_for(:helper, "application_helper.wx.rb")
19
+
20
+ m.file "layout.wx.erb", Reactive.relative_path_for(:views, "layouts", "application.wx.erb")
21
+ m.file "layout.wx.erb", Reactive.relative_path_for(:views, "layouts", "main.wx.erb")
22
+ m.file "run.wx.erb", Reactive.relative_path_for(:views, "main", "run.wx.erb")
23
+ m.file "show.wx.erb", Reactive.relative_path_for(:views, "main", "show.wx.erb")
24
+
25
+ unless options[:pretend]
26
+ # Find the beginning of the config block, then skip all gems statments, insert here.
27
+ m.gsub_file Reactive.relative_path_for(:config, "config.rb"), /with Reactive\.configuration do \|config\|.*config.gem.*?$/mi do |match|
28
+ "#{match}\n\n config.initial_request = {:controller => 'main', :action => 'run', :format => :wx}\n"
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+ protected
36
+
37
+ def add_options!(opts)
38
+ # opts.separator ''
39
+ # opts.separator 'Options:'
40
+ # # For each option below, place the default
41
+ # # at the top of the file next to "default_options"
42
+ # opts.on("-r", "--ruby=path", String,
43
+ # "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
44
+ # "Default: #{DEFAULT_SHEBANG}") { |options[:shebang]| }
45
+ end
46
+
47
+ def extract_options
48
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
49
+ # Templates can access these value via the attr_reader-generated methods, but not the
50
+ # raw instance variable value.
51
+ # @author = options[:author]
52
+ end
53
+
54
+ end
@@ -0,0 +1,11 @@
1
+ Description:
2
+ Generate the views for a given resource. Views for all CRUD operations
3
+ are done, respecting the following action names:
4
+ index, show, new, create, edit, update, delete, destroy
5
+ Note that you have to fill the views yourself.
6
+
7
+ Pass the name of the resource, either CamelCased or under_scored, as the
8
+ first argument.
9
+
10
+ Example:
11
+ `./script/generate view product`
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,25 @@
1
+ class ViewGenerator < Reactive::NamedBaseGenerator
2
+ def manifest
3
+ record do |m|
4
+ m.directory(Reactive.relative_path_for(:views, path, plural_name))
5
+
6
+ for action in actions
7
+ m.template(
8
+ "#{action}.wx.rb",
9
+ Reactive.relative_path_for(:views, path, plural_name, "#{action}.wx.rb")
10
+ )
11
+ end
12
+
13
+ end
14
+ end
15
+
16
+ protected
17
+ # Override with your own usage banner.
18
+ def banner
19
+ "Usage: #{$0} view ModelName"
20
+ end
21
+
22
+ def actions
23
+ %w[ index show new create edit update delete destroy ]
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reactive-wx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Pascal Hurni
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-12 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: reactive-core
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.2.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: wxruby
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.9.6
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: wx_sugar
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.1.19
44
+ version:
45
+ description: Adds
46
+ email: phi@ruby-reactive.org
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - README
53
+ - LICENSE
54
+ files:
55
+ - README
56
+ - LICENSE
57
+ - Manifest
58
+ - Rakefile
59
+ - lib/reactive-wx.rb
60
+ - lib/reactive-wx/accessors.rb
61
+ - lib/reactive-wx/accessors/control_with_items.rb
62
+ - lib/reactive-wx/accessors/date_picker_ctrl.rb
63
+ - lib/reactive-wx/accessors/text_ctrl.rb
64
+ - lib/reactive-wx/binder.rb
65
+ - lib/reactive-wx/default_handler.rb
66
+ - lib/reactive-wx/helpers.rb
67
+ - lib/reactive-wx/helpers/asset_helper.rb
68
+ - lib/reactive-wx/helpers/exception_helper.rb
69
+ - lib/reactive-wx/helpers/forms.rb
70
+ - lib/reactive-wx/request.rb
71
+ - lib/reactive-wx/wx_ext.rb
72
+ - lib/reactive-wx/wx_ext/arranger.rb
73
+ - lib/reactive-wx/wx_ext/aui_toolbar.rb
74
+ - lib/reactive-wx/wx_ext/event_binder.rb
75
+ - lib/reactive-wx/wx_ext/form_grid_sizer.rb
76
+ - lib/reactive-wx/wx_ext/message_dialog.rb
77
+ - lib/reactive-wx/wx_ext/panel_dialog.rb
78
+ - lib/reactive-wx/wx_ext/semi_modal.rb
79
+ - lib/reactive-wx/wx_ext/toolbar.rb
80
+ - lib/reactive-wx/wx_ext/window.rb
81
+ - reactive_app_generators/wx/USAGE
82
+ - reactive_app_generators/wx/templates/application_helper.wx.rb
83
+ - reactive_app_generators/wx/templates/layout.wx.erb
84
+ - reactive_app_generators/wx/templates/main_controller.rb
85
+ - reactive_app_generators/wx/templates/main_helper.wx.rb
86
+ - reactive_app_generators/wx/templates/run.wx.erb
87
+ - reactive_app_generators/wx/templates/show.wx.erb
88
+ - reactive_app_generators/wx/wx_generator.rb
89
+ - reactive_generators/view/USAGE
90
+ - reactive_generators/view/templates/create.wx.rb
91
+ - reactive_generators/view/templates/delete.wx.rb
92
+ - reactive_generators/view/templates/destroy.wx.rb
93
+ - reactive_generators/view/templates/edit.wx.rb
94
+ - reactive_generators/view/templates/index.wx.rb
95
+ - reactive_generators/view/templates/layout.wx.rb
96
+ - reactive_generators/view/templates/new.wx.rb
97
+ - reactive_generators/view/templates/show.wx.rb
98
+ - reactive_generators/view/templates/update.wx.rb
99
+ - reactive_generators/view/view_generator.rb
100
+ has_rdoc: true
101
+ homepage: http://www.ruby-reactive.org
102
+ post_install_message:
103
+ rdoc_options:
104
+ - -x
105
+ - Manifest
106
+ - -x
107
+ - Rakefile
108
+ - -x
109
+ - .*\.rake
110
+ - -m
111
+ - README
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: "0"
119
+ version:
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: "0"
125
+ version:
126
+ requirements: []
127
+
128
+ rubyforge_project: reactive-wx
129
+ rubygems_version: 1.3.1
130
+ signing_key:
131
+ specification_version: 2
132
+ summary: This plugin is an output handler for wx code. It therefore runs code targeted for the wxWidgets toolkit using its ruby port named wxRuby. It is required to run on the client-side of the Reactive application.
133
+ test_files: []
134
+