glimmer-dsl-wx 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +102 -25
- data/VERSION +1 -1
- data/glimmer-dsl-wx.gemspec +0 -0
- data/lib/glimmer/dsl/wx/control_expression.rb +1 -0
- data/lib/glimmer/dsl/wx/dsl.rb +2 -0
- data/lib/glimmer/dsl/wx/sizer_args_expression.rb +43 -0
- data/lib/glimmer/dsl/wx/sizer_expression.rb +53 -0
- data/lib/glimmer/wx/control_proxy.rb +14 -11
- data/lib/glimmer/wx/sizer_proxy.rb +150 -0
- data/samples/{glimmer_new → hello}/hello_button.rb +14 -10
- data/samples/{glimmer_new → hello}/hello_button2.rb +15 -12
- data/samples/hello/hello_sizer.rb +69 -0
- metadata +10 -6
- /data/samples/{glimmer_new → hello}/hello_world.rb +0 -0
- /data/samples/{glimmer_new → hello}/hello_world2.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf55c367fb4ec68158af5d891e0247aeb504438f094b454658440eb6d1089758
|
4
|
+
data.tar.gz: 8c1e5efaf64398f4daecf1b784ed4a5a42b0cc172748398d24d00f16c2a5cf9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c3a8d1510fb4887b4395fad8105145ad229beb0e4d954577abea4db2527093563bbd1cb4900b5d06dff5a3b431626a14a098559314de32e769ba7c53ae89059
|
7
|
+
data.tar.gz: e59f34e898c4b4e7c3b979ad112bf34d916efac91e3d7a6a66bda068896a2a9a51025a67534380f451aa11db093eae0931de40187e819a89a3ed0297877117bb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
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
|
+
|
3
10
|
## 0.0.5
|
4
11
|
|
5
12
|
- Nested child control support
|
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.
|
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
|
[](http://badge.fury.io/rb/glimmer-dsl-wx)
|
4
4
|
[](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -51,16 +51,20 @@ require 'glimmer-dsl-wx'
|
|
51
51
|
|
52
52
|
include Glimmer
|
53
53
|
|
54
|
-
frame(title: 'Hello, Button!') { |
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
+
}
|
64
68
|
}
|
65
69
|
}
|
66
70
|
```
|
@@ -72,20 +76,76 @@ require 'glimmer-dsl-wx'
|
|
72
76
|
|
73
77
|
include Glimmer
|
74
78
|
|
75
|
-
frame { |
|
79
|
+
frame { |main_frame|
|
76
80
|
title 'Hello, Button!'
|
77
81
|
|
78
|
-
|
79
|
-
|
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!**
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
require 'glimmer-dsl-wx'
|
104
|
+
|
105
|
+
include Glimmer
|
106
|
+
|
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
|
+
}
|
80
136
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
+
}
|
89
149
|
}
|
90
150
|
}
|
91
151
|
```
|
@@ -109,6 +169,8 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
|
|
109
169
|
|
110
170
|
- [Glimmer DSL for WX](#)
|
111
171
|
- [Usage](#usage)
|
172
|
+
- [GIRB (Glimmer IRB)](#girb-glimmer-irb)
|
173
|
+
- [Smart Defaults and Conventions](#smart-defaults-and-conventions)
|
112
174
|
- [Process](#process)
|
113
175
|
- [Resources](#resources)
|
114
176
|
- [Help](#help)
|
@@ -134,21 +196,36 @@ gem install glimmer-dsl-wx
|
|
134
196
|
Or install via Bundler `Gemfile`:
|
135
197
|
|
136
198
|
```ruby
|
137
|
-
gem 'glimmer-dsl-wx', '~> 0.0.
|
199
|
+
gem 'glimmer-dsl-wx', '~> 0.0.6'
|
138
200
|
```
|
139
201
|
|
140
202
|
Test that installation worked by running a sample:
|
141
203
|
|
142
204
|
```
|
143
|
-
ruby -r glimmer-dsl-wx -e "require 'samples/
|
205
|
+
ruby -r glimmer-dsl-wx -e "require 'samples/hello/hello_world'"
|
144
206
|
```
|
145
207
|
|
146
208
|
If you cloned project, test by running a sample locally:
|
147
209
|
|
148
210
|
```
|
149
|
-
ruby -r ./lib/glimmer-dsl-wx.rb samples/
|
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
|
150
220
|
```
|
151
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
|
+
|
152
229
|
## Process
|
153
230
|
|
154
231
|
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/glimmer-dsl-wx.gemspec
CHANGED
Binary file
|
data/lib/glimmer/dsl/wx/dsl.rb
CHANGED
@@ -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
|
@@ -116,9 +116,19 @@ module Glimmer
|
|
116
116
|
# No Op by default
|
117
117
|
end
|
118
118
|
|
119
|
+
# Returns closest frame ancestor or self if it is a frame
|
119
120
|
def frame_proxy
|
120
121
|
found_proxy = self
|
121
|
-
until found_proxy.nil? || found_proxy.is_a?(
|
122
|
+
until found_proxy.nil? || found_proxy.is_a?(FrameProxy)
|
123
|
+
found_proxy = found_proxy.parent_proxy
|
124
|
+
end
|
125
|
+
found_proxy
|
126
|
+
end
|
127
|
+
|
128
|
+
# Returns closest control ancestor
|
129
|
+
def control_proxy
|
130
|
+
found_proxy = parent_proxy
|
131
|
+
until found_proxy.nil? || found_proxy.is_a?(ControlProxy)
|
122
132
|
found_proxy = found_proxy.parent_proxy
|
123
133
|
end
|
124
134
|
found_proxy
|
@@ -132,7 +142,7 @@ module Glimmer
|
|
132
142
|
|
133
143
|
def handle_listener(listener_name, &listener)
|
134
144
|
event = listener_name.to_s.sub('on_', '')
|
135
|
-
|
145
|
+
frame_proxy.wx.send("evt_#{event}", @wx, &listener)
|
136
146
|
# elsif has_custom_listener?(listener_name)
|
137
147
|
# handle_custom_listener(listener_name, &listener)
|
138
148
|
# end
|
@@ -210,15 +220,8 @@ module Glimmer
|
|
210
220
|
private
|
211
221
|
|
212
222
|
def build_control
|
213
|
-
|
214
|
-
|
215
|
-
else
|
216
|
-
sizer = ::Wx::HBoxSizer.new
|
217
|
-
@parent_proxy.sizer = sizer
|
218
|
-
@wx = ControlProxy.new_control(@keyword, @parent_proxy&.wx, @args)
|
219
|
-
sizer.add @wx, 0, ::Wx::RIGHT, 8
|
220
|
-
end
|
221
|
-
@wx
|
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)
|
222
225
|
end
|
223
226
|
end
|
224
227
|
end
|
@@ -0,0 +1,150 @@
|
|
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/wx/data_bindable'
|
23
|
+
require 'glimmer/wx/parent'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module Wx
|
27
|
+
# Proxy for Wx sizer objects
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class SizerProxy
|
31
|
+
class << self
|
32
|
+
def exists?(keyword)
|
33
|
+
keyword.end_with?('_sizer') and
|
34
|
+
(
|
35
|
+
::Wx.constants.include?(wx_constant_symbol(keyword)) or
|
36
|
+
descendant_keyword_constant_map.keys.include?(keyword)
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def create(keyword, parent, args, &block)
|
41
|
+
sizer_proxy_class(keyword).new(keyword, parent, args, &block)
|
42
|
+
end
|
43
|
+
|
44
|
+
def sizer_proxy_class(keyword)
|
45
|
+
descendant_keyword_constant_map[keyword] || SizerProxy
|
46
|
+
end
|
47
|
+
|
48
|
+
def new_sizer(keyword, parent, args)
|
49
|
+
args = args.clone || []
|
50
|
+
if args.last.is_a?(Hash)
|
51
|
+
args[-1] = args[-1].clone
|
52
|
+
end
|
53
|
+
::Wx.const_get(wx_constant_symbol(keyword)).new(*args)
|
54
|
+
end
|
55
|
+
|
56
|
+
def wx_constant_symbol(keyword)
|
57
|
+
keyword.to_s.camelcase(:upper).to_sym
|
58
|
+
end
|
59
|
+
|
60
|
+
def constant_symbol(keyword)
|
61
|
+
"#{keyword.to_s.camelcase(:upper)}Proxy".to_sym
|
62
|
+
end
|
63
|
+
|
64
|
+
def keyword(constant_symbol)
|
65
|
+
constant_symbol.to_s.underscore.sub(/_proxy$/, '')
|
66
|
+
end
|
67
|
+
|
68
|
+
def descendant_keyword_constant_map
|
69
|
+
@descendant_keyword_constant_map ||= map_descendant_keyword_constants_for(self)
|
70
|
+
end
|
71
|
+
|
72
|
+
def reset_descendant_keyword_constant_map
|
73
|
+
@descendant_keyword_constant_map = nil
|
74
|
+
descendant_keyword_constant_map
|
75
|
+
end
|
76
|
+
|
77
|
+
def map_descendant_keyword_constants_for(klass, accumulator: {})
|
78
|
+
klass.constants.map do |constant_symbol|
|
79
|
+
[constant_symbol, klass.const_get(constant_symbol)]
|
80
|
+
end.select do |constant_symbol, constant|
|
81
|
+
constant.is_a?(Module) && !accumulator.values.include?(constant)
|
82
|
+
end.each do |constant_symbol, constant|
|
83
|
+
accumulator[keyword(constant_symbol)] = constant
|
84
|
+
map_descendant_keyword_constants_for(constant, accumulator: accumulator)
|
85
|
+
end
|
86
|
+
accumulator
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
include DataBindable
|
91
|
+
|
92
|
+
# wx returns the contained LibUI object
|
93
|
+
attr_reader :parent_proxy, :wx, :args, :keyword, :block, :content_added
|
94
|
+
alias content_added? content_added
|
95
|
+
|
96
|
+
def initialize(keyword, parent, args, &block)
|
97
|
+
@keyword = keyword
|
98
|
+
@parent_proxy = parent
|
99
|
+
@args = args
|
100
|
+
@block = block
|
101
|
+
build_sizer
|
102
|
+
post_add_content if @block.nil?
|
103
|
+
end
|
104
|
+
|
105
|
+
# Subclasses may override to perform post add_content work (normally must call super)
|
106
|
+
def post_add_content
|
107
|
+
unless @content_added
|
108
|
+
@parent_proxy&.post_initialize_child(self)
|
109
|
+
@content_added = true
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Subclasses may override to perform post initialization work on an added child
|
114
|
+
def post_initialize_child(child)
|
115
|
+
# No Op by default
|
116
|
+
end
|
117
|
+
|
118
|
+
def respond_to?(method_name, *args, &block)
|
119
|
+
@wx.respond_to?(method_name, true) ||
|
120
|
+
super(method_name, true)
|
121
|
+
end
|
122
|
+
|
123
|
+
def method_missing(method_name, *args, &block)
|
124
|
+
if @wx.respond_to?(method_name, true)
|
125
|
+
@wx.send(method_name, *args, &block)
|
126
|
+
else
|
127
|
+
super
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def content(&block)
|
132
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::SizerExpression.new, @keyword, {post_add_content: @content_added}, &block)
|
133
|
+
end
|
134
|
+
|
135
|
+
def add(control_proxy, *args, &block)
|
136
|
+
@wx.add(control_proxy.wx, *args)
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def build_sizer
|
142
|
+
@wx = SizerProxy.new_sizer(@keyword, @parent_proxy.wx, @args)
|
143
|
+
parent_proxy.sizer = @wx if parent_proxy.is_a?(Glimmer::Wx::ControlProxy)
|
144
|
+
@wx
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
Dir[File.expand_path("./#{File.basename(__FILE__, '.rb')}/*.rb", __dir__)].each {|f| require f}
|
@@ -23,15 +23,19 @@ require 'glimmer-dsl-wx'
|
|
23
23
|
|
24
24
|
include Glimmer
|
25
25
|
|
26
|
-
frame(title: 'Hello, Button!') { |
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
frame(title: 'Hello, Button!') { |main_frame|
|
27
|
+
h_box_sizer {
|
28
|
+
button(label: 'Click To Find Who Built This!') {
|
29
|
+
sizer_args 0, Wx::RIGHT, 10
|
30
|
+
|
31
|
+
on_button do
|
32
|
+
about_box(
|
33
|
+
name: main_frame.title,
|
34
|
+
version: Wx::WXRUBY_VERSION,
|
35
|
+
description: "This is the Hello, Button! sample",
|
36
|
+
developers: ['The Glimmer DSL for WX Development Team']
|
37
|
+
)
|
38
|
+
end
|
39
|
+
}
|
36
40
|
}
|
37
41
|
}
|
@@ -23,19 +23,22 @@ require 'glimmer-dsl-wx'
|
|
23
23
|
|
24
24
|
include Glimmer
|
25
25
|
|
26
|
-
frame { |
|
26
|
+
frame { |main_frame|
|
27
27
|
title 'Hello, Button!'
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
29
|
+
h_box_sizer {
|
30
|
+
button {
|
31
|
+
sizer_args 0, Wx::RIGHT, 10
|
32
|
+
label 'Click To Find Who Built This!'
|
33
|
+
|
34
|
+
on_button do
|
35
|
+
about_box(
|
36
|
+
name: main_frame.title,
|
37
|
+
version: Wx::WXRUBY_VERSION,
|
38
|
+
description: "This is the Hello, Button! sample",
|
39
|
+
developers: ['The Glimmer DSL for WX Development Team']
|
40
|
+
)
|
41
|
+
end
|
42
|
+
}
|
40
43
|
}
|
41
44
|
}
|
@@ -0,0 +1,69 @@
|
|
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-wx'
|
23
|
+
|
24
|
+
include Glimmer
|
25
|
+
|
26
|
+
frame { |main_frame|
|
27
|
+
title 'Hello, Sizer!'
|
28
|
+
|
29
|
+
v_box_sizer {
|
30
|
+
button {
|
31
|
+
sizer_args 0, Wx::DOWN, 10
|
32
|
+
label 'Greeting 1'
|
33
|
+
|
34
|
+
on_button do
|
35
|
+
message_dialog(
|
36
|
+
"Hello",
|
37
|
+
"Greeting",
|
38
|
+
Wx::OK | Wx::ICON_INFORMATION
|
39
|
+
).show_modal
|
40
|
+
end
|
41
|
+
}
|
42
|
+
|
43
|
+
button {
|
44
|
+
sizer_args 0, Wx::DOWN, 10
|
45
|
+
label 'Greeting 2'
|
46
|
+
|
47
|
+
on_button do
|
48
|
+
message_dialog(
|
49
|
+
"Howdy",
|
50
|
+
"Greeting",
|
51
|
+
Wx::OK | Wx::ICON_INFORMATION
|
52
|
+
).show_modal
|
53
|
+
end
|
54
|
+
}
|
55
|
+
|
56
|
+
button {
|
57
|
+
sizer_args 0, Wx::DOWN, 10
|
58
|
+
label 'Greeting 3'
|
59
|
+
|
60
|
+
on_button do
|
61
|
+
message_dialog(
|
62
|
+
"Aloha",
|
63
|
+
"Greeting",
|
64
|
+
Wx::OK | Wx::ICON_INFORMATION
|
65
|
+
).show_modal
|
66
|
+
end
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-wx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -240,20 +240,24 @@ files:
|
|
240
240
|
- lib/glimmer/dsl/wx/operation_expression.rb
|
241
241
|
- lib/glimmer/dsl/wx/property_expression.rb
|
242
242
|
- lib/glimmer/dsl/wx/shine_data_binding_expression.rb
|
243
|
+
- lib/glimmer/dsl/wx/sizer_args_expression.rb
|
244
|
+
- lib/glimmer/dsl/wx/sizer_expression.rb
|
243
245
|
- lib/glimmer/proc_tracker.rb
|
244
246
|
- lib/glimmer/wx/control_proxy.rb
|
245
247
|
- lib/glimmer/wx/control_proxy/frame_proxy.rb
|
246
248
|
- lib/glimmer/wx/data_bindable.rb
|
247
249
|
- lib/glimmer/wx/parent.rb
|
250
|
+
- lib/glimmer/wx/sizer_proxy.rb
|
248
251
|
- samples/art/wxruby-128x128.png
|
249
252
|
- samples/art/wxruby-256x256.png
|
250
253
|
- samples/art/wxruby-64x64.png
|
251
254
|
- samples/art/wxruby.ico
|
252
255
|
- samples/art/wxruby.png
|
253
|
-
- samples/
|
254
|
-
- samples/
|
255
|
-
- samples/
|
256
|
-
- samples/
|
256
|
+
- samples/hello/hello_button.rb
|
257
|
+
- samples/hello/hello_button2.rb
|
258
|
+
- samples/hello/hello_sizer.rb
|
259
|
+
- samples/hello/hello_world.rb
|
260
|
+
- samples/hello/hello_world2.rb
|
257
261
|
- samples/minimal/mondrian.ico
|
258
262
|
- samples/minimal/mondrian.png
|
259
263
|
- samples/minimal/nothing.rb
|
File without changes
|
File without changes
|