glimmer-dsl-tk 0.0.18 → 0.0.23
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 +36 -0
- data/README.md +429 -21
- data/VERSION +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/dsl/tk/message_box_expression.rb +4 -1
- data/lib/glimmer/dsl/tk/on_expression.rb +35 -0
- data/lib/glimmer/dsl/tk/widget_expression.rb +0 -7
- data/lib/glimmer/tk/button_proxy.rb +2 -3
- data/lib/glimmer/tk/checkbutton_proxy.rb +36 -0
- data/lib/glimmer/tk/combobox_proxy.rb +34 -0
- data/lib/glimmer/tk/commandable.rb +42 -0
- data/lib/glimmer/tk/entry_proxy.rb +3 -0
- data/lib/glimmer/tk/frame_proxy.rb +1 -0
- data/lib/glimmer/tk/label_proxy.rb +3 -0
- data/lib/glimmer/tk/notebook_proxy.rb +3 -8
- data/lib/glimmer/tk/radiobutton_proxy.rb +46 -0
- data/lib/glimmer/tk/root_proxy.rb +122 -2
- data/lib/glimmer/tk/text_variable_owner.rb +31 -0
- data/lib/glimmer/tk/variable_owner.rb +31 -0
- data/lib/glimmer/tk/widget_proxy.rb +102 -23
- data/lib/glimmer-dsl-tk.rb +1 -0
- data/samples/hello/hello_checkbutton.rb +131 -0
- data/samples/hello/hello_notebook.rb +1 -1
- data/samples/hello/hello_radiobutton.rb +87 -0
- data/samples/hello/hello_root.rb +48 -0
- metadata +45 -15
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright (c) 2021 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/tk/widget_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module DSL
|
27
|
+
module Tk
|
28
|
+
class OnExpression < StaticExpression
|
29
|
+
def interpret(parent, keyword, *args, &block)
|
30
|
+
parent.handle_listener(args.first, &block)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -52,10 +52,3 @@ module Glimmer
|
|
52
52
|
end
|
53
53
|
|
54
54
|
require 'glimmer/tk/widget_proxy'
|
55
|
-
require 'glimmer/tk/notebook_proxy'
|
56
|
-
require 'glimmer/tk/frame_proxy'
|
57
|
-
require 'glimmer/tk/button_proxy'
|
58
|
-
require 'glimmer/tk/label_proxy'
|
59
|
-
require 'glimmer/tk/list_proxy'
|
60
|
-
require 'glimmer/tk/entry_proxy'
|
61
|
-
require 'glimmer/tk/treeview_proxy'
|
@@ -20,6 +20,7 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/tk/widget_proxy'
|
23
|
+
require 'glimmer/tk/commandable'
|
23
24
|
|
24
25
|
module Glimmer
|
25
26
|
module Tk
|
@@ -27,9 +28,7 @@ module Glimmer
|
|
27
28
|
#
|
28
29
|
# Follows the Proxy Design Pattern
|
29
30
|
class ButtonProxy < WidgetProxy
|
30
|
-
|
31
|
-
tk.command(proc)
|
32
|
-
end
|
31
|
+
include Commandable
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Copyright (c) 2020-2021 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/tk/widget_proxy'
|
23
|
+
require 'glimmer/tk/commandable'
|
24
|
+
require 'glimmer/tk/variable_owner'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module Tk
|
28
|
+
# Proxy for Tk::Tile::Checkbutton
|
29
|
+
#
|
30
|
+
# Follows the Proxy Design Pattern
|
31
|
+
class CheckbuttonProxy < WidgetProxy
|
32
|
+
include Commandable
|
33
|
+
include VariableOwner
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Copyright (c) 2020-2021 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/tk/widget_proxy'
|
23
|
+
require 'glimmer/tk/text_variable_owner'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module Tk
|
27
|
+
# Proxy for Tk::Tile::Combobox
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class ComboboxProxy < WidgetProxy
|
31
|
+
include TextVariableOwner
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Copyright (c) 2020-2021 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/tk/widget_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module Tk
|
26
|
+
# Represents widgets that can invoke a command
|
27
|
+
module Commandable
|
28
|
+
def command_block=(proc)
|
29
|
+
tk.command(proc)
|
30
|
+
end
|
31
|
+
|
32
|
+
def handle_listener(listener_name, &listener)
|
33
|
+
case listener_name.to_s.downcase
|
34
|
+
when 'command'
|
35
|
+
command(listener)
|
36
|
+
else
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -20,6 +20,7 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/tk/widget_proxy'
|
23
|
+
require 'glimmer/tk/text_variable_owner'
|
23
24
|
|
24
25
|
module Glimmer
|
25
26
|
module Tk
|
@@ -27,6 +28,8 @@ module Glimmer
|
|
27
28
|
#
|
28
29
|
# Follows the Proxy Design Pattern
|
29
30
|
class EntryProxy < WidgetProxy
|
31
|
+
include TextVariableOwner
|
32
|
+
|
30
33
|
def validatecommand_block=(proc)
|
31
34
|
tk.validatecommand(proc)
|
32
35
|
end
|
@@ -33,6 +33,7 @@ module Glimmer
|
|
33
33
|
if parent_proxy.is_a?(NotebookProxy)
|
34
34
|
@tab_options, args[0] = args[0].to_h.partition {|key, value| NotebookProxy::TAB_OPTIONS.include?(key.to_s)}
|
35
35
|
@tab_options = Hash[@tab_options]
|
36
|
+
@tab_options[:text] = @tab_options.delete(:title) if @tab_options.keys.include?(:title)
|
36
37
|
args.delete_at(0) if args[0].to_a.empty?
|
37
38
|
end
|
38
39
|
super
|
@@ -20,6 +20,7 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/tk/widget_proxy'
|
23
|
+
require 'glimmer/tk/text_variable_owner'
|
23
24
|
|
24
25
|
module Glimmer
|
25
26
|
module Tk
|
@@ -27,6 +28,8 @@ module Glimmer
|
|
27
28
|
#
|
28
29
|
# Follows the Proxy Design Pattern
|
29
30
|
class LabelProxy < WidgetProxy
|
31
|
+
include TextVariableOwner
|
32
|
+
|
30
33
|
def set_attribute(attribute, *args)
|
31
34
|
if attribute.to_s == 'font'
|
32
35
|
args[0] = "tk_#{args[0]}_font".camelcase(:upper) if (args[0].is_a?(Symbol) || args[0].is_a?(String)) && args[0].to_s == args[0].to_s.downcase
|
@@ -27,17 +27,12 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class NotebookProxy < WidgetProxy
|
30
|
-
TAB_OPTIONS = ['state', 'sticky', 'padding', 'text', 'image', 'compound', 'underline']
|
30
|
+
TAB_OPTIONS = ['state', 'sticky', 'padding', 'text', 'title', 'image', 'compound', 'underline']
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
def initialize(*args)
|
35
|
-
@tab_proxies = []
|
36
|
-
super
|
37
|
-
end
|
32
|
+
alias tab_proxies children
|
38
33
|
|
39
34
|
def post_initialize_child(child)
|
40
|
-
|
35
|
+
super
|
41
36
|
@tk.add child.tk, child.tab_options
|
42
37
|
end
|
43
38
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright (c) 2020-2021 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/tk/widget_proxy'
|
23
|
+
require 'glimmer/tk/commandable'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module Tk
|
27
|
+
# Proxy for Tk::Tile::Radiobutton
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class RadiobuttonProxy < WidgetProxy
|
31
|
+
include Commandable
|
32
|
+
|
33
|
+
def sibling_radio_buttons
|
34
|
+
@parent_proxy.children.select {|child| child.is_a?(RadiobuttonProxy)}
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def initialize_defaults
|
40
|
+
super
|
41
|
+
sibling_variable = sibling_radio_buttons.map(&:tk).map(&:variable).compact.first
|
42
|
+
tk.variable = sibling_variable.nil? ? ::TkVariable.new : sibling_variable
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -27,8 +27,13 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class RootProxy < WidgetProxy
|
30
|
+
REGEX_GEOMETRY = /[x+-]/
|
31
|
+
DEFAULT_WIDTH = 190
|
32
|
+
DEFAULT_HEIGHT = 95
|
33
|
+
|
30
34
|
def initialize(*args)
|
31
35
|
@tk = ::TkRoot.new
|
36
|
+
@tk.minsize = DEFAULT_WIDTH, DEFAULT_HEIGHT
|
32
37
|
end
|
33
38
|
|
34
39
|
def post_add_content
|
@@ -43,19 +48,134 @@ module Glimmer
|
|
43
48
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::RootExpression.new, keyword, *args, &block)
|
44
49
|
end
|
45
50
|
|
51
|
+
def has_attribute?(attribute, *args)
|
52
|
+
%w[width height x y].include?(attribute.to_s) || super
|
53
|
+
end
|
54
|
+
|
46
55
|
def set_attribute(attribute, *args)
|
47
|
-
|
56
|
+
case attribute.to_s
|
57
|
+
when 'iconphoto'
|
48
58
|
args[0..-1] = [image_argument(args)]
|
49
59
|
super
|
60
|
+
when 'width'
|
61
|
+
@width = args.first.to_i
|
62
|
+
self.geometry = "#{args.first.to_i}x#{@height || DEFAULT_HEIGHT}#{x_sign}#{abs_x}#{y_sign}#{abs_y}"
|
63
|
+
when 'height'
|
64
|
+
@height = args.first.to_i
|
65
|
+
self.geometry = "#{@width || DEFAULT_WIDTH}x#{args.first.to_i}#{x_sign}#{abs_x}#{y_sign}#{abs_y}"
|
66
|
+
when 'x'
|
67
|
+
self.geometry = "#{@width || DEFAULT_WIDTH}x#{@height || DEFAULT_HEIGHT}#{args.first.to_i > 0 ? '+' : '-'}#{args.first.to_i.abs}#{y_sign}#{abs_y}"
|
68
|
+
when 'y'
|
69
|
+
self.geometry = "#{@width || DEFAULT_WIDTH}x#{@height || DEFAULT_HEIGHT}#{x_sign}#{abs_x}#{args.first.to_i > 0 ? '+' : '-'}#{args.first.to_i.abs}"
|
70
|
+
when 'resizable'
|
71
|
+
if args.size == 1 && !args.first.is_a?(Array)
|
72
|
+
self.resizable = [args.first]*2
|
73
|
+
else
|
74
|
+
super
|
75
|
+
end
|
50
76
|
else
|
51
77
|
super
|
52
78
|
end
|
53
79
|
end
|
54
|
-
|
80
|
+
|
81
|
+
def get_attribute(attribute)
|
82
|
+
attribute = attribute.to_s
|
83
|
+
case attribute
|
84
|
+
when 'width'
|
85
|
+
geometry.split(REGEX_GEOMETRY)[0].to_i
|
86
|
+
when 'height'
|
87
|
+
geometry.split(REGEX_GEOMETRY)[1].to_i
|
88
|
+
when 'x'
|
89
|
+
sign_number(x_sign, geometry.split(REGEX_GEOMETRY)[2].to_i)
|
90
|
+
when 'y'
|
91
|
+
sign_number(y_sign, geometry.split(REGEX_GEOMETRY)[3].to_i)
|
92
|
+
else
|
93
|
+
super
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def width
|
98
|
+
get_attribute(:width)
|
99
|
+
end
|
100
|
+
|
101
|
+
def height
|
102
|
+
get_attribute(:height)
|
103
|
+
end
|
104
|
+
|
105
|
+
def x
|
106
|
+
get_attribute(:x)
|
107
|
+
end
|
108
|
+
|
109
|
+
def y
|
110
|
+
get_attribute(:y)
|
111
|
+
end
|
112
|
+
|
113
|
+
def width=(value)
|
114
|
+
set_attribute(:width, value)
|
115
|
+
end
|
116
|
+
|
117
|
+
def height=(value)
|
118
|
+
set_attribute(:height, value)
|
119
|
+
end
|
120
|
+
|
121
|
+
def x=(value)
|
122
|
+
set_attribute(:x, value)
|
123
|
+
end
|
124
|
+
|
125
|
+
def y=(value)
|
126
|
+
set_attribute(:y, value)
|
127
|
+
end
|
128
|
+
|
129
|
+
def handle_listener(listener_name, &listener)
|
130
|
+
case listener_name.to_s.upcase
|
131
|
+
when 'WM_DELETE_WINDOW', 'DELETE_WINDOW'
|
132
|
+
listener_name = 'WM_DELETE_WINDOW'
|
133
|
+
@tk.protocol(listener_name, &listener)
|
134
|
+
when 'WM_OPEN_WINDOW', 'OPEN_WINDOW'
|
135
|
+
@on_open_window_procs ||= []
|
136
|
+
@on_open_window_procs << listener
|
137
|
+
else
|
138
|
+
super
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
55
142
|
# Starts Tk mainloop
|
56
143
|
def start_event_loop
|
144
|
+
if @on_open_window_procs.to_a.any?
|
145
|
+
::Tk.after(100) do # ensure root window showed up first
|
146
|
+
@on_open_window_procs.to_a.each do |on_open_window|
|
147
|
+
::Tk.after(0, on_open_window)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
57
151
|
::Tk.mainloop
|
58
152
|
end
|
153
|
+
|
154
|
+
private
|
155
|
+
|
156
|
+
def sign_number(sign, number)
|
157
|
+
"#{sign}1".to_i * number
|
158
|
+
end
|
159
|
+
|
160
|
+
def abs_x
|
161
|
+
geometry.split(REGEX_GEOMETRY)[2].to_i
|
162
|
+
end
|
163
|
+
|
164
|
+
def abs_y
|
165
|
+
geometry.split(REGEX_GEOMETRY)[3].to_i
|
166
|
+
end
|
167
|
+
|
168
|
+
def x_sign
|
169
|
+
geometry_signs[0]
|
170
|
+
end
|
171
|
+
|
172
|
+
def y_sign
|
173
|
+
geometry_signs[1]
|
174
|
+
end
|
175
|
+
|
176
|
+
def geometry_signs
|
177
|
+
geometry.chars.select {|char| char.match(/[+-]/)}
|
178
|
+
end
|
59
179
|
end
|
60
180
|
end
|
61
181
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright (c) 2020-2021 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
|
+
module Glimmer
|
23
|
+
module Tk
|
24
|
+
module TextVariableOwner
|
25
|
+
def initialize_defaults
|
26
|
+
super
|
27
|
+
tk.textvariable = ::TkVariable.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright (c) 2020-2021 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
|
+
module Glimmer
|
23
|
+
module Tk
|
24
|
+
module VariableOwner
|
25
|
+
def initialize_defaults
|
26
|
+
super
|
27
|
+
tk.variable = ::TkVariable.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|