glimmer-dsl-wx 0.0.2 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a58eca665a94827505984c32aca6e70f41b74227adefc3847d6c36272ccd0125
4
- data.tar.gz: c92afe6e99a78d32b07df6f6e30a70cbd73a65f136dc4f20cdac02a591bc099c
3
+ metadata.gz: cf55c367fb4ec68158af5d891e0247aeb504438f094b454658440eb6d1089758
4
+ data.tar.gz: 8c1e5efaf64398f4daecf1b784ed4a5a42b0cc172748398d24d00f16c2a5cf9b
5
5
  SHA512:
6
- metadata.gz: 4720d808e123c3a67baf8e0fc99b4a5c12c5d1929ba1279cc4ac47fdc24d7fffb61c1aa11d9d303bbbfcd2ad71cf5742b5073e36717ea31bda97b54776ef9b10
7
- data.tar.gz: eed7d3e70d290ac90fe36a2a8502c516febccc4a09f8fc9667cd15886d250a3b3683c245cc72930fe99fe578e48588b7612bdb86a026e38226d3b61fd6667e79
6
+ metadata.gz: 1c3a8d1510fb4887b4395fad8105145ad229beb0e4d954577abea4db2527093563bbd1cb4900b5d06dff5a3b431626a14a098559314de32e769ba7c53ae89059
7
+ data.tar.gz: e59f34e898c4b4e7c3b979ad112bf34d916efac91e3d7a6a66bda068896a2a9a51025a67534380f451aa11db093eae0931de40187e819a89a3ed0297877117bb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.6
4
+
5
+ - Sizer (layout) support
6
+ - samples/glimmer_new/hello_sizer.rb
7
+ - Refactor/move `glimmer_new` samples to `hello` directory
8
+ - Fix `ControlProxy#frame_proxy` method, which grabs the parent frame (going all the way to the top of the hierarchy)
9
+
10
+ ## 0.0.5
11
+
12
+ - Nested child control support
13
+ - Listener support
14
+ - `about_box` keyword for displaying an about dialog box
15
+ - samples/glimmer_new/hello_button.rb
16
+ - samples/glimmer_new/hello_button2.rb
17
+ - Fix again the issue with complaining about not finding `frame` `app_name` when not specified despite it being optional
18
+
19
+ ## 0.0.4
20
+
21
+ - Fix issue with complaining about not finding `frame` `app_name` when not specified despite it being optional
22
+
23
+ ## 0.0.3
24
+
25
+ - Support control arguments and properties
26
+ - girb (Glimmer IRB)
27
+ - Use frame title argument in samples/minimal/nothing.rb
28
+ - Support `app_name` argument/property on `frame`
29
+ - Automatically set `app_name` to `frame` `title` if `frame` `app_name` is not specified
30
+ - samples/glimmer_new/hello_world.rb
31
+ - samples/glimmer_new/hello_world2.rb
32
+
3
33
  ## 0.0.2
4
34
 
5
35
  - Remove forgotten occurrences of pd (puts_debuggerer) from code
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for WX 0.0.2
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for WX 0.0.6
2
2
  ## wxWidgets Ruby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-wx.svg)](http://badge.fury.io/rb/glimmer-dsl-wx)
4
4
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -14,14 +14,140 @@
14
14
  - Scaffolding for new custom controls, apps, and gems
15
15
  - Native-Executable packaging on Mac, Windows, and Linux.
16
16
 
17
- Nothing Sample:
17
+ **Hello, World!**
18
+
19
+ ![Hello, World!](https://github.com/AndyObtiva/glimmer-dsl-wx/blob/master/screenshots/glimmer-dsl-wx-sample-hello-world.png?raw=true)
20
+
21
+ ```ruby
22
+ require 'glimmer-dsl-wx'
23
+
24
+ include Glimmer
25
+
26
+ frame(title: 'Hello, World!')
27
+ ```
28
+
29
+ Alternate Syntax:
30
+
31
+ ```ruby
32
+ require 'glimmer-dsl-wx'
33
+
34
+ include Glimmer
35
+
36
+ frame {
37
+ title 'Hello, World!'
38
+ }
39
+ ```
40
+
41
+ **Hello Button!**
42
+
43
+
44
+ ![Hello, Button!](https://github.com/AndyObtiva/glimmer-dsl-wx/blob/master/screenshots/glimmer-dsl-wx-sample-hello-button.png?raw=true)
45
+
46
+ ![Hello, Button! Clicked](https://github.com/AndyObtiva/glimmer-dsl-wx/blob/master/screenshots/glimmer-dsl-wx-sample-hello-button-clicked.png?raw=true)
47
+
48
+
49
+ ```ruby
50
+ require 'glimmer-dsl-wx'
51
+
52
+ include Glimmer
53
+
54
+ frame(title: 'Hello, Button!') { |main_frame|
55
+ h_box_sizer {
56
+ button(label: 'Click To Find Who Built This!') {
57
+ sizer_args 0, Wx::RIGHT, 10
58
+
59
+ on_button do
60
+ about_box(
61
+ name: main_frame.title,
62
+ version: Wx::WXRUBY_VERSION,
63
+ description: "This is the Hello, Button! sample",
64
+ developers: ['The Glimmer DSL for WX Development Team']
65
+ )
66
+ end
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ Alternate Syntax:
73
+
74
+ ```ruby
75
+ require 'glimmer-dsl-wx'
76
+
77
+ include Glimmer
78
+
79
+ frame { |main_frame|
80
+ title 'Hello, Button!'
81
+
82
+ h_box_sizer {
83
+ button {
84
+ sizer_args 0, Wx::RIGHT, 10
85
+ label 'Click To Find Who Built This!'
86
+
87
+ on_button do
88
+ about_box(
89
+ name: main_frame.title,
90
+ version: Wx::WXRUBY_VERSION,
91
+ description: "This is the Hello, Button! sample",
92
+ developers: ['The Glimmer DSL for WX Development Team']
93
+ )
94
+ end
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ **Hello Sizer!**
18
101
 
19
102
  ```ruby
20
103
  require 'glimmer-dsl-wx'
21
104
 
22
105
  include Glimmer
23
106
 
24
- frame
107
+ frame { |main_frame|
108
+ title 'Hello, Sizer!'
109
+
110
+ v_box_sizer {
111
+ button {
112
+ sizer_args 0, Wx::DOWN, 10
113
+ label 'Greeting 1'
114
+
115
+ on_button do
116
+ message_dialog(
117
+ "Hello",
118
+ "Greeting",
119
+ Wx::OK | Wx::ICON_INFORMATION
120
+ ).show_modal
121
+ end
122
+ }
123
+
124
+ button {
125
+ sizer_args 0, Wx::DOWN, 10
126
+ label 'Greeting 2'
127
+
128
+ on_button do
129
+ message_dialog(
130
+ "Howdy",
131
+ "Greeting",
132
+ Wx::OK | Wx::ICON_INFORMATION
133
+ ).show_modal
134
+ end
135
+ }
136
+
137
+ button {
138
+ sizer_args 0, Wx::DOWN, 10
139
+ label 'Greeting 3'
140
+
141
+ on_button do
142
+ message_dialog(
143
+ "Aloha",
144
+ "Greeting",
145
+ Wx::OK | Wx::ICON_INFORMATION
146
+ ).show_modal
147
+ end
148
+ }
149
+ }
150
+ }
25
151
  ```
26
152
 
27
153
  **[Glimmer](https://rubygems.org/gems/glimmer) DSL Comparison Table:**
@@ -42,6 +168,9 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
42
168
  ## Table of Contents
43
169
 
44
170
  - [Glimmer DSL for WX](#)
171
+ - [Usage](#usage)
172
+ - [GIRB (Glimmer IRB)](#girb-glimmer-irb)
173
+ - [Smart Defaults and Conventions](#smart-defaults-and-conventions)
45
174
  - [Process](#process)
46
175
  - [Resources](#resources)
47
176
  - [Help](#help)
@@ -53,6 +182,50 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
53
182
  - [Contributors](#contributors)
54
183
  - [License](#license)
55
184
 
185
+ ## Usage
186
+
187
+ Follow instructions for installing [wxruby3](https://github.com/mcorino/wxRuby3) on a supported platform (Linux or Windows):
188
+ https://github.com/mcorino/wxRuby3/blob/master/INSTALL.md
189
+
190
+ Install [glimmer-dsl-wx](https://rubygems.org/gems/glimmer-dsl-wx) gem directly into a [maintained Ruby version](https://www.ruby-lang.org/en/downloads/):
191
+
192
+ ```
193
+ gem install glimmer-dsl-wx
194
+ ```
195
+
196
+ Or install via Bundler `Gemfile`:
197
+
198
+ ```ruby
199
+ gem 'glimmer-dsl-wx', '~> 0.0.6'
200
+ ```
201
+
202
+ Test that installation worked by running a sample:
203
+
204
+ ```
205
+ ruby -r glimmer-dsl-wx -e "require 'samples/hello/hello_world'"
206
+ ```
207
+
208
+ If you cloned project, test by running a sample locally:
209
+
210
+ ```
211
+ ruby -r ./lib/glimmer-dsl-wx.rb samples/hello/hello_world.rb
212
+ ```
213
+
214
+ ## GIRB (Glimmer IRB)
215
+
216
+ You can run the `girb` command (`bin/girb` if you cloned the project locally) to do some quick and dirty experimentation and learning:
217
+
218
+ ```
219
+ girb
220
+ ```
221
+
222
+ This gives you `irb` with the `glimmer-dsl-wx` gem loaded and the `Glimmer` module mixed into the main object for easy experimentation with GUI.
223
+
224
+ ## Smart Defaults and Conventions
225
+
226
+ - Instantiate any wxWidgets control by using its underscored name (e.g. `Button` becomes `button`)
227
+ - `frame` will automatically execute within a `Wx::App.run` block and `show` the Frame
228
+
56
229
  ## Process
57
230
 
58
231
  [Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.6
data/bin/girb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Copyright (c) 2020-2021 Andy Maleh
3
+ # Copyright (c) 2023 Andy Maleh
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining
6
6
  # a copy of this software and associated documentation files (the
data/bin/girb_runner.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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
@@ -23,7 +23,7 @@
23
23
  require 'fileutils'
24
24
  require 'etc'
25
25
 
26
- require_relative '../lib/glimmer-dsl-libui'
26
+ require_relative '../lib/glimmer-dsl-wx'
27
27
 
28
28
  include Glimmer
29
29
 
Binary file
@@ -0,0 +1,34 @@
1
+ # Copyright (c) 2023 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/static_expression'
23
+
24
+ module Glimmer
25
+ module DSL
26
+ module Wx
27
+ class AboutBoxExpression < StaticExpression
28
+ def interpret(parent, keyword, *args, &block)
29
+ ::Wx.about_box(*args)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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,35 +29,35 @@ module Glimmer
29
29
  include ParentExpression
30
30
 
31
31
  def can_interpret?(parent, keyword, *args, &block)
32
- # Glimmer::Wx::ControlProxy.exists?(keyword)
33
- ::Wx.constants.include?(keyword.capitalize.to_sym)
32
+ Glimmer::Wx::ControlProxy.exists?(keyword)
34
33
  end
35
34
 
36
35
  def interpret(parent, keyword, *args, &block)
37
- # Glimmer::Wx::ControlProxy.create(keyword, parent, args, &block)
38
- control = ::Wx.const_get(keyword.capitalize.to_sym).new(nil)
39
- control.show if keyword == 'frame'
40
- control
36
+ Glimmer::Wx::ControlProxy.create(keyword, parent, args, &block)
41
37
  end
42
38
 
43
39
  def around(parent, keyword, args, block, &interpret_and_add_content)
40
+ # TODO refactor/extract this logic to a FrameExpression
44
41
  if keyword == 'frame'
45
42
  ::Wx::App.run do
46
- interpret_and_add_content.call
43
+ frame_proxy = interpret_and_add_content.call
44
+ app_name = frame_proxy.app_name || frame_proxy.title
45
+ self.app_name = app_name unless app_name.nil?
47
46
  end
48
47
  else
49
48
  interpret_and_add_content.call
50
49
  end
51
50
  end
52
51
 
53
- # def add_content(parent, keyword, *args, &block)
54
- # options = args.last.is_a?(Hash) ? args.last : {post_add_content: true}
55
- # super
56
- # parent&.post_add_content if options[:post_add_content]
57
- # end
52
+ def add_content(parent, keyword, *args, &block)
53
+ options = args.last.is_a?(Hash) ? args.last : {post_add_content: true}
54
+ options[:post_add_content] = true if options[:post_add_content].nil?
55
+ super
56
+ parent&.post_add_content if options[:post_add_content]
57
+ end
58
58
  end
59
59
  end
60
60
  end
61
61
  end
62
62
 
63
- # require 'glimmer/wx/control_proxy'
63
+ require 'glimmer/wx/control_proxy'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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
@@ -20,8 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/dsl/engine'
23
- # Dir[File.expand_path('*_expression.rb', __dir__)].each {|f| require f}
24
- require 'glimmer/dsl/wx/control_expression'
23
+ Dir[File.expand_path('*_expression.rb', __dir__)].each {|f| require f}
25
24
 
26
25
  # Glimmer DSL expression configuration module
27
26
  #
@@ -41,7 +40,12 @@ module Glimmer
41
40
  # shine_data_binding
42
41
  # property
43
42
  # operation
43
+ # control
44
44
  %w[
45
+ listener
46
+ sizer_args
47
+ sizer
48
+ property
45
49
  control
46
50
  ]
47
51
  )
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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,23 +19,23 @@
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
- #
25
- # module Glimmer
26
- # module DSL
27
- # module Libui
28
- # class ListenerExpression < Expression
29
- # def can_interpret?(parent, keyword, *args, &block)
30
- # (parent.is_a?(Glimmer::LibUI::ControlProxy) or parent.is_a?(Glimmer::LibUI::Shape)) and
31
- # block_given? and
32
- # parent.can_handle_listener?(keyword)
33
- # end
34
- #
35
- # def interpret(parent, keyword, *args, &block)
36
- # parent.handle_listener(keyword, &block)
37
- # end
38
- # end
39
- # end
40
- # end
41
- # end
22
+ require 'glimmer/dsl/expression'
23
+ require 'glimmer/wx/control_proxy'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module Wx
28
+ class ListenerExpression < Expression
29
+ def can_interpret?(parent, keyword, *args, &block)
30
+ parent.is_a?(Glimmer::Wx::ControlProxy) and
31
+ block_given? and
32
+ parent&.can_handle_listener?(keyword)
33
+ end
34
+
35
+ def interpret(parent, keyword, *args, &block)
36
+ parent.handle_listener(keyword, &block)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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,30 +19,23 @@
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 PropertyExpression < 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) or
36
- # parent.is_a?(Glimmer::LibUI::CustomControl)
37
- # ) and
38
- # block.nil? and
39
- # parent.respond_to?("#{keyword}=", *args)
40
- # end
41
- #
42
- # def interpret(parent, keyword, *args, &block)
43
- # parent.send("#{keyword}=", *args)
44
- # end
45
- # end
46
- # end
47
- # end
48
- # end
22
+ require 'glimmer/dsl/expression'
23
+ require 'glimmer/wx/control_proxy'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module Wx
28
+ class PropertyExpression < Expression
29
+ def can_interpret?(parent, keyword, *args, &block)
30
+ parent.is_a?(Glimmer::Wx::ControlProxy) and
31
+ block.nil? and
32
+ parent.respond_to?("#{keyword}=", *args)
33
+ end
34
+
35
+ def interpret(parent, keyword, *args, &block)
36
+ parent.send("#{keyword}=", *args)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021-2023 Andy Maleh
1
+ # Copyright (c) 2023 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,43 @@
1
+ # Copyright (c) 2023 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/static_expression'
23
+ require 'glimmer/wx/control_proxy'
24
+ require 'glimmer/wx/sizer_proxy'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module Wx
29
+ class SizerArgsExpression < StaticExpression
30
+ def can_interpret?(parent, keyword, *args, &block)
31
+ keyword == 'sizer_args' and
32
+ parent.is_a?(Glimmer::Wx::ControlProxy) and
33
+ parent&.parent_proxy&.is_a?(Glimmer::Wx::SizerProxy)
34
+ end
35
+
36
+ def interpret(parent, keyword, *args, &block)
37
+ parent.parent_proxy.add(parent, *args, &block)
38
+ end
39
+ end
40
+ SizerArgumentsExpression = SizerArgsExpression
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,53 @@
1
+ # Copyright (c) 2023 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/expression'
23
+ require 'glimmer/wx/control_proxy'
24
+ require 'glimmer/wx/sizer_proxy'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module Wx
29
+ class SizerExpression < Expression
30
+ include ParentExpression
31
+
32
+ def can_interpret?(parent, keyword, *args, &block)
33
+ (
34
+ parent.is_a?(Glimmer::Wx::ControlProxy) or
35
+ parent.is_a?(Glimmer::Wx::SizerProxy)
36
+ ) and
37
+ Glimmer::Wx::SizerProxy.exists?(keyword)
38
+ end
39
+
40
+ def interpret(parent, keyword, *args, &block)
41
+ Glimmer::Wx::SizerProxy.create(keyword, parent, args, &block)
42
+ end
43
+
44
+ def add_content(parent, keyword, *args, &block)
45
+ options = args.last.is_a?(Hash) ? args.last : {post_add_content: true}
46
+ options[:post_add_content] = true if options[:post_add_content].nil?
47
+ super
48
+ parent&.post_add_content if options[:post_add_content]
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end