glimmer-dsl-wx 0.0.7 → 0.1.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +309 -35
  5. data/VERSION +1 -1
  6. data/bin/girb +1 -1
  7. data/bin/girb_runner.rb +1 -1
  8. data/glimmer-dsl-wx.gemspec +0 -0
  9. data/lib/glimmer/dsl/wx/about_box_expression.rb +1 -1
  10. data/lib/glimmer/dsl/wx/bind_expression.rb +16 -16
  11. data/lib/glimmer/dsl/wx/control_expression.rb +1 -1
  12. data/lib/glimmer/dsl/wx/data_binding_expression.rb +25 -25
  13. data/lib/glimmer/dsl/wx/dsl.rb +4 -7
  14. data/lib/glimmer/dsl/wx/listener_expression.rb +1 -1
  15. data/lib/glimmer/dsl/wx/observe_expression.rb +1 -1
  16. data/lib/glimmer/dsl/wx/operation_expression.rb +23 -27
  17. data/lib/glimmer/dsl/wx/property_expression.rb +10 -3
  18. data/lib/glimmer/dsl/wx/shine_data_binding_expression.rb +23 -22
  19. data/lib/glimmer/dsl/wx/sizer_addable_expression.rb +1 -1
  20. data/lib/glimmer/dsl/wx/sizer_args_expression.rb +1 -1
  21. data/lib/glimmer/dsl/wx/sizer_expression.rb +1 -1
  22. data/lib/glimmer/wx/control_proxy/frame_proxy.rb +1 -1
  23. data/lib/glimmer/wx/control_proxy/slider_proxy.rb +55 -0
  24. data/lib/glimmer/wx/control_proxy/spin_ctrl_double_proxy.rb +41 -0
  25. data/lib/glimmer/wx/control_proxy/spin_ctrl_proxy.rb +41 -0
  26. data/lib/glimmer/wx/control_proxy/text_ctrl_proxy.rb +39 -0
  27. data/lib/glimmer/wx/control_proxy.rb +3 -3
  28. data/lib/glimmer/wx/data_bindable.rb +1 -1
  29. data/lib/glimmer/wx/parent.rb +1 -1
  30. data/lib/glimmer/wx/sizer_proxy.rb +1 -1
  31. data/lib/glimmer-dsl-wx.rb +1 -1
  32. data/samples/hello/hello_button.rb +1 -1
  33. data/samples/hello/hello_button2.rb +1 -1
  34. data/samples/hello/hello_data_binding.rb +126 -0
  35. data/samples/hello/hello_sizer.rb +7 -7
  36. data/samples/hello/hello_world.rb +1 -1
  37. data/samples/hello/hello_world2.rb +1 -1
  38. data/samples/minimal/nothing.rb +1 -1
  39. metadata +19 -10
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -19,29 +19,25 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- # require 'glimmer/dsl/expression'
23
- # require 'glimmer/libui/control_proxy'
24
- # require 'glimmer/libui/shape'
25
- # require 'glimmer/libui/attributed_string'
26
- #
27
- # module Glimmer
28
- # module DSL
29
- # module Libui
30
- # class OperationExpression < Expression
31
- # def can_interpret?(parent, keyword, *args, &block)
32
- # (
33
- # parent.is_a?(Glimmer::LibUI::ControlProxy) or
34
- # parent.is_a?(Glimmer::LibUI::Shape) or
35
- # parent.is_a?(Glimmer::LibUI::AttributedString)
36
- # ) and
37
- # block.nil? and
38
- # parent.respond_to?(keyword, *args)
39
- # end
40
- #
41
- # def interpret(parent, keyword, *args, &block)
42
- # parent.send(keyword, *args)
43
- # end
44
- # end
45
- # end
46
- # end
47
- # end
22
+ require 'glimmer/dsl/expression'
23
+ require 'glimmer/wx/control_proxy'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module Wx
28
+ class OperationExpression < Expression
29
+ def can_interpret?(parent, keyword, *args, &block)
30
+ (
31
+ parent.is_a?(Glimmer::Wx::ControlProxy)
32
+ ) and
33
+ block.nil? and
34
+ parent.respond_to?(keyword, *args)
35
+ end
36
+
37
+ def interpret(parent, keyword, *args, &block)
38
+ parent.send(keyword, *args)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -29,11 +29,18 @@ module Glimmer
29
29
  def can_interpret?(parent, keyword, *args, &block)
30
30
  parent.is_a?(Glimmer::Wx::ControlProxy) and
31
31
  block.nil? and
32
- parent.respond_to?("#{keyword}=", *args)
32
+ (
33
+ parent.respond_to?("#{keyword}=", *args) or
34
+ parent.respond_to?("set_#{keyword}", *args)
35
+ )
33
36
  end
34
37
 
35
38
  def interpret(parent, keyword, *args, &block)
36
- parent.send("#{keyword}=", *args)
39
+ if parent.respond_to?("#{keyword}=", *args)
40
+ parent.send("#{keyword}=", *args)
41
+ else
42
+ parent.send("set_#{keyword}", *args)
43
+ end
37
44
  end
38
45
  end
39
46
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -19,24 +19,25 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- # require 'glimmer/dsl/expression'
23
- # require 'glimmer/data_binding/model_binding'
24
- # require 'glimmer/data_binding/shine'
25
- #
26
- # module Glimmer
27
- # module DSL
28
- # module Libui
29
- # class ShineDataBindingExpression < Expression
30
- # def can_interpret?(parent, keyword, *args, &block)
31
- # args.size == 0 and
32
- # block.nil? and
33
- # parent.respond_to?(keyword, *args, &block)
34
- # end
35
- #
36
- # def interpret(parent, keyword, *args, &block)
37
- # Glimmer::DataBinding::Shine.new(parent, keyword)
38
- # end
39
- # end
40
- # end
41
- # end
42
- # end
22
+ require 'glimmer/dsl/expression'
23
+ require 'glimmer/data_binding/model_binding'
24
+ require 'glimmer/data_binding/shine'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module Wx
29
+ class ShineDataBindingExpression < Expression
30
+ def can_interpret?(parent, keyword, *args, &block)
31
+ keyword != 'content' and
32
+ args.size == 0 and
33
+ block.nil? and
34
+ parent.respond_to?(keyword, *args, &block)
35
+ end
36
+
37
+ def interpret(parent, keyword, *args, &block)
38
+ Glimmer::DataBinding::Shine.new(parent, keyword)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -0,0 +1,55 @@
1
+ # Copyright (c) 2021-2024 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/wx/control_proxy'
23
+
24
+ module Glimmer
25
+ module Wx
26
+ class ControlProxy
27
+ # Proxy for Wx slider double objects
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class SliderProxy < ControlProxy
31
+ include ::Wx::IDHelper
32
+
33
+ class << self
34
+ def new_control(keyword, parent, args)
35
+ args = args.clone || []
36
+ if args.last.is_a?(Hash)
37
+ args[-1] = args[-1].clone
38
+ end
39
+ value = 0
40
+ min = 0
41
+ max = 100
42
+ style = 0
43
+ ::Wx.const_get(wx_constant_symbol(keyword)).new(parent, next_id, value, min, max, style: style)
44
+ end
45
+ end
46
+
47
+ def data_bind_write(property, model_binding)
48
+ handle_listener('on_slider') { model_binding.call(value) } if property == 'value'
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ Dir[File.expand_path("./#{File.basename(__FILE__, '.rb')}/*.rb", __dir__)].each {|f| require f}
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2021-2024 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/wx/control_proxy'
23
+
24
+ module Glimmer
25
+ module Wx
26
+ class ControlProxy
27
+ # Proxy for Wx spin ctrl double objects
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class SpinCtrlDoubleProxy < ControlProxy
31
+ def data_bind_write(property, model_binding)
32
+ if property == 'value'
33
+ handle_listener('on_spinctrldouble') { model_binding.call(value) }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ Dir[File.expand_path("./#{File.basename(__FILE__, '.rb')}/*.rb", __dir__)].each {|f| require f}
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2021-2024 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/wx/control_proxy'
23
+
24
+ module Glimmer
25
+ module Wx
26
+ class ControlProxy
27
+ # Proxy for Wx spin ctrl objects
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class SpinCtrlProxy < ControlProxy
31
+ def data_bind_write(property, model_binding)
32
+ if property == 'value'
33
+ handle_listener('on_spinctrl') { model_binding.call(value) }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ Dir[File.expand_path("./#{File.basename(__FILE__, '.rb')}/*.rb", __dir__)].each {|f| require f}
@@ -0,0 +1,39 @@
1
+ # Copyright (c) 2021-2024 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/wx/control_proxy'
23
+
24
+ module Glimmer
25
+ module Wx
26
+ class ControlProxy
27
+ # Proxy for Wx text ctrl objects
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class TextCtrlProxy < ControlProxy
31
+ def data_bind_write(property, model_binding)
32
+ handle_listener('on_text') { model_binding.call(value) } if property == 'value'
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ Dir[File.expand_path("./#{File.basename(__FILE__, '.rb')}/*.rb", __dir__)].each {|f| require f}
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -214,14 +214,14 @@ module Glimmer
214
214
  end
215
215
 
216
216
  def content(&block)
217
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::ControlExpression.new, @keyword, {post_add_content: @content_added}, &block)
217
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Wx::ControlExpression.new, @keyword, {post_add_content: @content_added}, &block)
218
218
  end
219
219
 
220
220
  private
221
221
 
222
222
  def build_control
223
223
  # must pass control_proxy.wx as parent because the direct parent might be a sizer
224
- @wx = ControlProxy.new_control(@keyword, control_proxy&.wx, @args)
224
+ @wx = self.class.control_proxy_class(keyword).new_control(@keyword, control_proxy&.wx, @args)
225
225
  end
226
226
  end
227
227
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -0,0 +1,126 @@
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer-dsl-wx'
23
+
24
+ class Donor
25
+ DONATION_AMOUNT_MIN = 0
26
+ DONATION_AMOUNT_MAX = 100
27
+ DONATION_AMOUNT_DEFAULT = 50
28
+
29
+ attr_accessor :first_name, :last_name, :donation_amount
30
+
31
+ def initialize
32
+ @last_name = @first_name = ''
33
+ @donation_amount = DONATION_AMOUNT_DEFAULT
34
+ end
35
+
36
+ def full_name
37
+ full_name_parts = [first_name, last_name]
38
+ full_name_string = full_name_parts.join(' ').strip
39
+ if full_name_string.empty?
40
+ 'Anonymous'
41
+ else
42
+ full_name_string
43
+ end
44
+ end
45
+
46
+ def summary
47
+ "#{full_name} donated $#{donation_amount}"
48
+ end
49
+ end
50
+
51
+ donor = Donor.new
52
+
53
+ include Glimmer
54
+
55
+ frame(title: 'Hello, Data-Binding!') { |window|
56
+ panel {
57
+ v_box_sizer {
58
+ h_box_sizer {
59
+ sizer_args 0, Wx::DOWN, 10
60
+
61
+ static_text(label: 'First Name:') {
62
+ sizer_args 0, Wx::RIGHT, 10
63
+ }
64
+ text_ctrl {
65
+ sizer_args 0, Wx::RIGHT, 10
66
+ # data-bind donor.first_name to text_ctrl.value bidirectionally,
67
+ # ensuring changes to either attribute update the other attribute
68
+ value <=> [donor, :first_name]
69
+ }
70
+ }
71
+
72
+ h_box_sizer {
73
+ sizer_args 0, Wx::DOWN, 10
74
+
75
+ static_text(label: 'Last Name:') {
76
+ sizer_args 0, Wx::RIGHT, 10
77
+ }
78
+ text_ctrl {
79
+ sizer_args 0, Wx::RIGHT, 10
80
+ # data-bind donor.last_name to text_ctrl.value bidirectionally,
81
+ # ensuring changes to either attribute update the other attribute
82
+ value <=> [donor, :last_name]
83
+ }
84
+ }
85
+
86
+ h_box_sizer {
87
+ sizer_args 0, Wx::DOWN, 10
88
+
89
+ static_text(label: 'Donation Amount: $') {
90
+ sizer_args 0, Wx::RIGHT, 1
91
+ }
92
+ spin_ctrl {
93
+ sizer_args 0, Wx::RIGHT, 10
94
+ range Donor::DONATION_AMOUNT_MIN, Donor::DONATION_AMOUNT_MAX
95
+ # data-bind donor.donation_amount to spin_ctrl.value bidirectionally,
96
+ # ensuring changes to either attribute update the other attribute
97
+ value <=> [donor, :donation_amount]
98
+ }
99
+ }
100
+
101
+ h_box_sizer {
102
+ sizer_args 0, Wx::DOWN, 10
103
+
104
+ slider {
105
+ sizer_args 0, Wx::RIGHT, 10
106
+ range Donor::DONATION_AMOUNT_MIN, Donor::DONATION_AMOUNT_MAX
107
+ # data-bind donor.first_name to spinner.value bidirectionally,
108
+ # ensuring changes to either attribute update the other attribute
109
+ value <=> [donor, :donation_amount]
110
+ }
111
+ }
112
+
113
+ h_box_sizer {
114
+ sizer_args 0, Wx::DOWN, 10
115
+
116
+ static_text(label: '') {
117
+ sizer_args 0, Wx::RIGHT, 10
118
+ # data-bind donor.summary to static_text.label unidirectionally,
119
+ # with computed data-binding from donor summary dependencies: first_name, last_name, and donation_amount
120
+ # ensuring changes to donor.summary or any of its dependencies update static_text.label
121
+ label <= [donor, :summary, computed_by: [:first_name, :last_name, :donation_amount]]
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -37,7 +37,7 @@ frame { |main_frame|
37
37
  on_button do
38
38
  message_dialog(
39
39
  "Hello",
40
- "Greeting",
40
+ "Greeting 1",
41
41
  Wx::OK | Wx::ICON_INFORMATION
42
42
  ).show_modal
43
43
  end
@@ -52,7 +52,7 @@ frame { |main_frame|
52
52
  on_button do
53
53
  message_dialog(
54
54
  "Howdy",
55
- "Greeting",
55
+ "Greeting 2",
56
56
  Wx::OK | Wx::ICON_INFORMATION
57
57
  ).show_modal
58
58
  end
@@ -67,7 +67,7 @@ frame { |main_frame|
67
67
  on_button do
68
68
  message_dialog(
69
69
  "Hi",
70
- "Greeting",
70
+ "Greeting 3",
71
71
  Wx::OK | Wx::ICON_INFORMATION
72
72
  ).show_modal
73
73
  end
@@ -84,7 +84,7 @@ frame { |main_frame|
84
84
  on_button do
85
85
  message_dialog(
86
86
  "Ciao",
87
- "Greeting",
87
+ "Greeting 4",
88
88
  Wx::OK | Wx::ICON_INFORMATION
89
89
  ).show_modal
90
90
  end
@@ -99,7 +99,7 @@ frame { |main_frame|
99
99
  on_button do
100
100
  message_dialog(
101
101
  "Aloha",
102
- "Greeting",
102
+ "Greeting 5",
103
103
  Wx::OK | Wx::ICON_INFORMATION
104
104
  ).show_modal
105
105
  end
@@ -114,7 +114,7 @@ frame { |main_frame|
114
114
  on_button do
115
115
  message_dialog(
116
116
  "Salut",
117
- "Greeting",
117
+ "Greeting 6",
118
118
  Wx::OK | Wx::ICON_INFORMATION
119
119
  ).show_modal
120
120
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the