glimmer-cs-calculator 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +70 -0
- data/VERSION +1 -0
- data/bin/calculator +7 -0
- data/bin/glimmer-cs-calculator +7 -0
- data/lib/glimmer-cs-calculator.rb +4 -0
- data/lib/models/glimmer/calculator/command.rb +89 -0
- data/lib/models/glimmer/calculator/command/all_clear.rb +17 -0
- data/lib/models/glimmer/calculator/command/equals.rb +18 -0
- data/lib/models/glimmer/calculator/command/number.rb +20 -0
- data/lib/models/glimmer/calculator/command/operation.rb +12 -0
- data/lib/models/glimmer/calculator/command/operation/add.rb +26 -0
- data/lib/models/glimmer/calculator/command/operation/divide.rb +26 -0
- data/lib/models/glimmer/calculator/command/operation/multiply.rb +26 -0
- data/lib/models/glimmer/calculator/command/operation/subtract.rb +26 -0
- data/lib/models/glimmer/calculator/command/point.rb +20 -0
- data/lib/models/glimmer/calculator/presenter.rb +18 -0
- data/lib/views/glimmer/calculator.rb +258 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1181ebd61993301957b214666f187c7ecf1be2aea7bb288aa6abb67ddc664225
|
4
|
+
data.tar.gz: 170e6809beb9a4b6dca428a8cd83f9772d496e54ab1a8a92a15982704ffcfa14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 38d88bed477197cfd91b52eeac642ae31ccecdcf56df7324f1e6bbd009c15db28038486df02921ddbdcb36cf0f3858799b09dee26691c601995283e5a131c7f8
|
7
|
+
data.tar.gz: 7680cbdd1555d5db2e55a2724807ad7812ca943a879bd873115150bf342d4e5d88b0845ac5dbf8ff4ac2e1d2273bc777336b0e12322c6143da73b8a207ae5aac
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2020 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.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# <img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" width="60" /> Calculator - Glimmer Custom Shell
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/glimmer-cs-calculator.svg)](http://badge.fury.io/rb/glimmer-cs-calculator)
|
3
|
+
|
4
|
+
![Calculator](glimmer-cs-calculator-screenshot.png)
|
5
|
+
|
6
|
+
Calculator sample desktop GUI application built with [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development Library).
|
7
|
+
|
8
|
+
It is developed test-first following TDD (Test Driven Development).
|
9
|
+
Design Patterns discovered in the process were Presenter/Facade and Command Pattern.
|
10
|
+
|
11
|
+
Follows the MVP architectural pattern (Model View Presenter) thanks to [Glimmer data-binding](https://github.com/AndyObtiva/glimmer#data-binding) support.
|
12
|
+
|
13
|
+
## Platforms
|
14
|
+
|
15
|
+
- Mac: Tested and [packaged](https://github.com/AndyObtiva/glimmer#packaging--distribution) for the Mac. ([Download Here<img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" width="30" />](https://www.dropbox.com/s/tdgwt2vfxfh13ro/Glimmer%20Calculator-1.0.0.dmg?dl=1))
|
16
|
+
- Linux: Not tested/packaged for Linux, but should work by following setup instructions below.
|
17
|
+
- Windows: Not tested/packaged for Windows, but should work by following setup instructions below.
|
18
|
+
|
19
|
+
## Development Environment Pre-requisites
|
20
|
+
|
21
|
+
- JRuby 9.2.11.1 (supporting Ruby 2.5.x syntax) (find at https://www.jruby.org/download)
|
22
|
+
- Java SE Runtime Environment 7 or higher (find at https://www.oracle.com/java/technologies/javase-downloads.html)
|
23
|
+
|
24
|
+
## Setup Instructions
|
25
|
+
|
26
|
+
Install Calculator gem by running (`jgem`, `jruby -S gem`, or `gem` directly if you have RVM):
|
27
|
+
|
28
|
+
```
|
29
|
+
jgem install glimmer-cs-calculator
|
30
|
+
```
|
31
|
+
|
32
|
+
Afterwards, you may run `calculator` to bring up the calculator:
|
33
|
+
|
34
|
+
```
|
35
|
+
calculator
|
36
|
+
```
|
37
|
+
|
38
|
+
Note: If you cloned this project and bundle installed, you may invoke via `bin/calculator` instead.
|
39
|
+
|
40
|
+
### Glimmer Custom Shell Reuse
|
41
|
+
|
42
|
+
To reuse Calculator as a Glimmer Custom Shell inside another Glimmer application, add the
|
43
|
+
following to the application's `Gemfile`:
|
44
|
+
|
45
|
+
```
|
46
|
+
gem 'glimmer-cs-calculator', '1.0.0'
|
47
|
+
```
|
48
|
+
|
49
|
+
Run:
|
50
|
+
|
51
|
+
```
|
52
|
+
jruby -S bundle
|
53
|
+
```
|
54
|
+
|
55
|
+
And, then instantiate the Calculator custom shell in your Glimmer application via the `calculator` Glimmer DSL keyword.
|
56
|
+
|
57
|
+
## Contributing to glimmer-cs-calculator
|
58
|
+
|
59
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
60
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
61
|
+
* Fork the project.
|
62
|
+
* Start a feature/bugfix branch.
|
63
|
+
* Commit and push until you are happy with your contribution.
|
64
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
65
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
66
|
+
|
67
|
+
## Copyright
|
68
|
+
|
69
|
+
Copyright (c) 2020 Andy Maleh. See LICENSE.txt for
|
70
|
+
further details.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/bin/calculator
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
include EasilyTypable
|
5
|
+
class << self
|
6
|
+
attr_accessor :number1, :number2, :operation
|
7
|
+
|
8
|
+
# Keyword string representing calculator command (e.g. '+' for Add command)
|
9
|
+
# Subclasses must call to define a single keyword
|
10
|
+
def keyword(keyword_text)
|
11
|
+
Command.keyword_to_command_class_mapping[keyword_text] = self
|
12
|
+
end
|
13
|
+
|
14
|
+
# Keyword string array representing calculator command (e.g. ('0'..'9').to_a)
|
15
|
+
# Subclasses must call to define multiple keywords
|
16
|
+
def keywords(*keyword_text_array)
|
17
|
+
keyword_text_array.flatten.each do |keyword_text|
|
18
|
+
keyword(keyword_text)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def keyword_to_command_class_mapping
|
23
|
+
@keyword_to_command_class_mapping ||= {}
|
24
|
+
end
|
25
|
+
|
26
|
+
def command_history
|
27
|
+
@command_history ||= []
|
28
|
+
end
|
29
|
+
|
30
|
+
def for(button)
|
31
|
+
command_class = keyword_to_command_class_mapping[button]
|
32
|
+
command_class&.new(button)&.tap do |command|
|
33
|
+
command.execute
|
34
|
+
command_history << command
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_reader :button
|
40
|
+
attr_accessor :result
|
41
|
+
|
42
|
+
def initialize(button)
|
43
|
+
@button = button
|
44
|
+
end
|
45
|
+
|
46
|
+
def number1
|
47
|
+
Command.number1
|
48
|
+
end
|
49
|
+
|
50
|
+
def number1=(value)
|
51
|
+
Command.number1 = value.to_f
|
52
|
+
end
|
53
|
+
|
54
|
+
def number2
|
55
|
+
Command.number2
|
56
|
+
end
|
57
|
+
|
58
|
+
def number2=(value)
|
59
|
+
Command.number2 = value.to_f
|
60
|
+
end
|
61
|
+
|
62
|
+
def operation
|
63
|
+
Command.operation
|
64
|
+
end
|
65
|
+
|
66
|
+
def operation=(op)
|
67
|
+
Command.operation = op
|
68
|
+
end
|
69
|
+
|
70
|
+
def last_result
|
71
|
+
last_command&.result
|
72
|
+
end
|
73
|
+
|
74
|
+
def last_command
|
75
|
+
command_history.last
|
76
|
+
end
|
77
|
+
|
78
|
+
def command_history
|
79
|
+
Command.command_history
|
80
|
+
end
|
81
|
+
|
82
|
+
def execute
|
83
|
+
raise 'Not implemented! Please override in a subclass.'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
Dir[File.join(File.dirname(__FILE__), 'command', '**', '*.rb')].each {|f| require(f)}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
class AllClear < Command
|
5
|
+
keywords 'AC', 'c', 'C', 27.chr
|
6
|
+
|
7
|
+
def execute
|
8
|
+
self.result = '0'
|
9
|
+
self.number1 = nil
|
10
|
+
self.number2 = nil
|
11
|
+
self.operation = nil
|
12
|
+
command_history.clear
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
class Equals < Command
|
5
|
+
keywords '=', "\r"
|
6
|
+
|
7
|
+
def execute
|
8
|
+
if operation
|
9
|
+
self.result = operation.calculate.to_s
|
10
|
+
self.number1 = self.result
|
11
|
+
else
|
12
|
+
self.result = last_result
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
class Number < Command
|
5
|
+
keywords ('0'..'9').to_a
|
6
|
+
|
7
|
+
def execute
|
8
|
+
self.result = last_result.nil? || (!last_command.number? && !last_command.point?) ? button : last_result + button
|
9
|
+
if operation.nil? || last_command.equals?
|
10
|
+
self.number1 = self.result
|
11
|
+
self.number2 = nil
|
12
|
+
self.operation = nil
|
13
|
+
else
|
14
|
+
self.number2 = self.result
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
class Operation < Command
|
5
|
+
# Calculate operation result using number1 and number2 attributes
|
6
|
+
def calculate
|
7
|
+
raise 'Not implemented! A subclass must implement to calculate operation using number1 and number2 attributes'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
class Operation < Command
|
5
|
+
class Add < Operation
|
6
|
+
keyword '+'
|
7
|
+
|
8
|
+
def execute
|
9
|
+
if number2 && operation && !last_command.equals?
|
10
|
+
self.result = operation.calculate.to_s
|
11
|
+
self.number1 = self.result
|
12
|
+
else
|
13
|
+
self.result = last_result
|
14
|
+
self.operation = self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def calculate
|
19
|
+
calculation_result = number1 + number2
|
20
|
+
calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
class Operation < Command
|
5
|
+
class Divide < Operation
|
6
|
+
keywords '÷', '/'
|
7
|
+
|
8
|
+
def execute
|
9
|
+
if number2 && operation && !last_command.equals?
|
10
|
+
self.result = operation.calculate.to_s
|
11
|
+
self.number1 = self.result
|
12
|
+
else
|
13
|
+
self.result = last_result
|
14
|
+
self.operation = self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def calculate
|
19
|
+
calculation_result = number1 / number2
|
20
|
+
calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result #TODO consider moving this to result= method in Command
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
class Operation < Command
|
5
|
+
class Multiply < Operation
|
6
|
+
keywords '×', '*'
|
7
|
+
|
8
|
+
def execute
|
9
|
+
if number2 && operation && !last_command.equals?
|
10
|
+
self.result = operation.calculate.to_s
|
11
|
+
self.number1 = self.result
|
12
|
+
else
|
13
|
+
self.result = last_result
|
14
|
+
self.operation = self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def calculate
|
19
|
+
calculation_result = number1 * number2
|
20
|
+
calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
class Operation < Command
|
5
|
+
class Subtract < Operation
|
6
|
+
keywords '−', '-'
|
7
|
+
|
8
|
+
def execute
|
9
|
+
if number2 && operation && !last_command.equals?
|
10
|
+
self.result = operation.calculate.to_s
|
11
|
+
self.number1 = self.result
|
12
|
+
else
|
13
|
+
self.result = last_result
|
14
|
+
self.operation = self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def calculate
|
19
|
+
calculation_result = number1 - number2
|
20
|
+
calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Calculator
|
3
|
+
class Command
|
4
|
+
class Point < Command
|
5
|
+
keyword '.'
|
6
|
+
|
7
|
+
def execute
|
8
|
+
self.result = last_result.nil? || !last_command.number? ? '0.' : "#{last_result}."
|
9
|
+
if operation.nil? || last_command.equals?
|
10
|
+
self.number1 = self.result
|
11
|
+
self.number2 = nil
|
12
|
+
self.operation = nil
|
13
|
+
else
|
14
|
+
self.number2 = self.result
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'models/glimmer/calculator/command'
|
2
|
+
|
3
|
+
module Glimmer
|
4
|
+
class Calculator
|
5
|
+
class Presenter
|
6
|
+
attr_accessor :result
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
self.result = '0'
|
10
|
+
end
|
11
|
+
|
12
|
+
def press(button)
|
13
|
+
command = Command.for(button)
|
14
|
+
self.result = command.result if command
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,258 @@
|
|
1
|
+
require 'easily_typable'
|
2
|
+
|
3
|
+
require 'models/glimmer/calculator/presenter'
|
4
|
+
|
5
|
+
module Glimmer
|
6
|
+
class Calculator
|
7
|
+
include Glimmer::UI::CustomShell
|
8
|
+
|
9
|
+
VERSION = File.read(File.expand_path(File.join('..', '..', '..', '..', 'VERSION'), __FILE__))
|
10
|
+
LICENSE = File.read(File.expand_path(File.join('..', '..', '..', '..', 'LICENSE.txt'), __FILE__))
|
11
|
+
|
12
|
+
## Add options like the following to configure CustomShell by outside consumers
|
13
|
+
#
|
14
|
+
# options :title, :background_color
|
15
|
+
# option :width, 320
|
16
|
+
# option :height, 240
|
17
|
+
|
18
|
+
## Uncomment before_body block to pre-initialize variables to use in body
|
19
|
+
#
|
20
|
+
#
|
21
|
+
before_body {
|
22
|
+
@presenter = Presenter.new
|
23
|
+
@button_font = {height: 14}
|
24
|
+
@button_font_operation = {height: 18}
|
25
|
+
@button_font_big = {height: 28}
|
26
|
+
Display.setAppName('Glimmer Calculator')
|
27
|
+
@display = display {
|
28
|
+
on_event_keydown { |key_event|
|
29
|
+
char = key_event.character.chr rescue nil
|
30
|
+
@presenter.press(char)
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
## Uncomment after_body block to setup observers for widgets in body
|
36
|
+
#
|
37
|
+
# after_body {
|
38
|
+
#
|
39
|
+
# }
|
40
|
+
|
41
|
+
## Add widget content inside custom shell body
|
42
|
+
## Top-most widget must be a shell or another custom shell
|
43
|
+
#
|
44
|
+
body {
|
45
|
+
shell {
|
46
|
+
# Replace example content below with custom shell content
|
47
|
+
minimum_size 320, 240
|
48
|
+
text "Glimmer - Calculator"
|
49
|
+
grid_layout 4, true
|
50
|
+
on_about {
|
51
|
+
display_about_dialog
|
52
|
+
}
|
53
|
+
on_preferences {
|
54
|
+
# No need for preferences. Just display about dialog.
|
55
|
+
display_about_dialog
|
56
|
+
}
|
57
|
+
# Setting styled_text to multi in order for alignment options to activate
|
58
|
+
styled_text(:multi, :wrap, :border) {
|
59
|
+
text bind(@presenter, :result)
|
60
|
+
alignment swt(:right)
|
61
|
+
right_margin 5
|
62
|
+
font height: 40
|
63
|
+
layout_data(:fill, :fill, true, true) {
|
64
|
+
horizontal_span 4
|
65
|
+
}
|
66
|
+
editable false
|
67
|
+
caret nil
|
68
|
+
}
|
69
|
+
button {
|
70
|
+
text 'AC'
|
71
|
+
font @button_font
|
72
|
+
|
73
|
+
layout_data(:fill, :fill, true, true)
|
74
|
+
|
75
|
+
on_widget_selected {
|
76
|
+
@presenter.press('AC')
|
77
|
+
}
|
78
|
+
}
|
79
|
+
button {
|
80
|
+
text '÷'
|
81
|
+
font @button_font_operation
|
82
|
+
|
83
|
+
layout_data(:fill, :fill, true, true)
|
84
|
+
|
85
|
+
on_widget_selected {
|
86
|
+
@presenter.press('/')
|
87
|
+
}
|
88
|
+
}
|
89
|
+
button {
|
90
|
+
text '×'
|
91
|
+
font @button_font_operation
|
92
|
+
|
93
|
+
layout_data(:fill, :fill, true, true)
|
94
|
+
|
95
|
+
on_widget_selected {
|
96
|
+
@presenter.press('*')
|
97
|
+
}
|
98
|
+
}
|
99
|
+
button {
|
100
|
+
text '−'
|
101
|
+
font @button_font_operation
|
102
|
+
|
103
|
+
layout_data(:fill, :fill, true, true)
|
104
|
+
|
105
|
+
on_widget_selected {
|
106
|
+
@presenter.press('-')
|
107
|
+
}
|
108
|
+
}
|
109
|
+
button {
|
110
|
+
text '7'
|
111
|
+
font @button_font
|
112
|
+
|
113
|
+
layout_data(:fill, :fill, true, true)
|
114
|
+
|
115
|
+
on_widget_selected {
|
116
|
+
@presenter.press('7')
|
117
|
+
}
|
118
|
+
}
|
119
|
+
button {
|
120
|
+
text '8'
|
121
|
+
font @button_font
|
122
|
+
|
123
|
+
layout_data(:fill, :fill, true, true)
|
124
|
+
|
125
|
+
on_widget_selected {
|
126
|
+
@presenter.press('8')
|
127
|
+
}
|
128
|
+
}
|
129
|
+
button {
|
130
|
+
text '9'
|
131
|
+
font @button_font
|
132
|
+
|
133
|
+
layout_data(:fill, :fill, true, true)
|
134
|
+
|
135
|
+
on_widget_selected {
|
136
|
+
@presenter.press('9')
|
137
|
+
}
|
138
|
+
}
|
139
|
+
button {
|
140
|
+
text '+'
|
141
|
+
font @button_font_big
|
142
|
+
|
143
|
+
layout_data(:fill, :fill, true, true) {
|
144
|
+
vertical_span 2
|
145
|
+
}
|
146
|
+
|
147
|
+
on_widget_selected {
|
148
|
+
@presenter.press('+')
|
149
|
+
}
|
150
|
+
}
|
151
|
+
button {
|
152
|
+
text '4'
|
153
|
+
font @button_font
|
154
|
+
|
155
|
+
layout_data(:fill, :fill, true, true)
|
156
|
+
|
157
|
+
on_widget_selected {
|
158
|
+
@presenter.press('4')
|
159
|
+
}
|
160
|
+
}
|
161
|
+
button {
|
162
|
+
text '5'
|
163
|
+
font @button_font
|
164
|
+
|
165
|
+
layout_data(:fill, :fill, true, true)
|
166
|
+
|
167
|
+
on_widget_selected {
|
168
|
+
@presenter.press('5')
|
169
|
+
}
|
170
|
+
}
|
171
|
+
button {
|
172
|
+
text '6'
|
173
|
+
font @button_font
|
174
|
+
|
175
|
+
layout_data(:fill, :fill, true, true)
|
176
|
+
|
177
|
+
on_widget_selected {
|
178
|
+
@presenter.press('6')
|
179
|
+
}
|
180
|
+
}
|
181
|
+
button {
|
182
|
+
text '1'
|
183
|
+
font @button_font
|
184
|
+
|
185
|
+
layout_data(:fill, :fill, true, true)
|
186
|
+
|
187
|
+
on_widget_selected {
|
188
|
+
@presenter.press('1')
|
189
|
+
}
|
190
|
+
}
|
191
|
+
button {
|
192
|
+
text '2'
|
193
|
+
font @button_font
|
194
|
+
|
195
|
+
layout_data(:fill, :fill, true, true)
|
196
|
+
|
197
|
+
on_widget_selected {
|
198
|
+
@presenter.press('2')
|
199
|
+
}
|
200
|
+
}
|
201
|
+
button {
|
202
|
+
text '3'
|
203
|
+
font @button_font
|
204
|
+
|
205
|
+
layout_data(:fill, :fill, true, true)
|
206
|
+
|
207
|
+
on_widget_selected {
|
208
|
+
@presenter.press('3')
|
209
|
+
}
|
210
|
+
}
|
211
|
+
button {
|
212
|
+
text '='
|
213
|
+
font @button_font_big
|
214
|
+
|
215
|
+
layout_data(:fill, :fill, true, true) {
|
216
|
+
vertical_span 2
|
217
|
+
}
|
218
|
+
|
219
|
+
on_widget_selected {
|
220
|
+
@presenter.press('=')
|
221
|
+
}
|
222
|
+
}
|
223
|
+
button {
|
224
|
+
text '0'
|
225
|
+
font @button_font
|
226
|
+
|
227
|
+
layout_data(:fill, :fill, true, true) {
|
228
|
+
horizontal_span 2
|
229
|
+
}
|
230
|
+
|
231
|
+
on_widget_selected {
|
232
|
+
@presenter.press('0')
|
233
|
+
}
|
234
|
+
}
|
235
|
+
button {
|
236
|
+
text '.'
|
237
|
+
font @button_font_operation
|
238
|
+
|
239
|
+
layout_data(:fill, :fill, true, true)
|
240
|
+
|
241
|
+
on_widget_selected {
|
242
|
+
@presenter.press('.')
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
def display_about_dialog
|
249
|
+
message_box = MessageBox.new(swt_widget)
|
250
|
+
message_box.setText("About")
|
251
|
+
message = "Glimmer - Calculator #{VERSION}\n"
|
252
|
+
message += LICENSE
|
253
|
+
message_box.setMessage(message)
|
254
|
+
message_box.open
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glimmer-cs-calculator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Maleh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 0.7.7
|
19
|
+
name: glimmer
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.7.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.2
|
33
|
+
name: easily_typable
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.5.0
|
47
|
+
name: rspec
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.5.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.3.9
|
61
|
+
name: jeweler
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.3.9
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
name: simplecov
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.1.6
|
89
|
+
name: glimmer-cs-gladiator
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.6
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.8.1
|
103
|
+
name: puts_debuggerer
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.8.1
|
111
|
+
description: Calculator - Glimmer Custom Shell
|
112
|
+
email: andy.am@gmail.com
|
113
|
+
executables:
|
114
|
+
- calculator
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files:
|
117
|
+
- LICENSE.txt
|
118
|
+
- README.md
|
119
|
+
files:
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- VERSION
|
123
|
+
- bin/calculator
|
124
|
+
- bin/glimmer-cs-calculator
|
125
|
+
- lib/glimmer-cs-calculator.rb
|
126
|
+
- lib/models/glimmer/calculator/command.rb
|
127
|
+
- lib/models/glimmer/calculator/command/all_clear.rb
|
128
|
+
- lib/models/glimmer/calculator/command/equals.rb
|
129
|
+
- lib/models/glimmer/calculator/command/number.rb
|
130
|
+
- lib/models/glimmer/calculator/command/operation.rb
|
131
|
+
- lib/models/glimmer/calculator/command/operation/add.rb
|
132
|
+
- lib/models/glimmer/calculator/command/operation/divide.rb
|
133
|
+
- lib/models/glimmer/calculator/command/operation/multiply.rb
|
134
|
+
- lib/models/glimmer/calculator/command/operation/subtract.rb
|
135
|
+
- lib/models/glimmer/calculator/command/point.rb
|
136
|
+
- lib/models/glimmer/calculator/presenter.rb
|
137
|
+
- lib/views/glimmer/calculator.rb
|
138
|
+
homepage: http://github.com/AndyObtiva/glimmer-cs-calculator
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubygems_version: 3.0.6
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Calculator - Glimmer Custom Shell
|
161
|
+
test_files: []
|