033585fd5d193b2f5ad3cd7f7cf543cd224c1b07
[nit.git] / examples / calculator / src / scientific / scientific.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Extends the portable calculator app with scientific operations
16 module scientific
17
18 import calculator
19
20 redef class CalculatorWindow
21 init
22 do
23 # All the button labels, row by row
24 var rows = [["√", "x²", "xⁿ", "e" ],
25 ["log","ln", "%", "x!" ],
26 ["π", "sin","cos","tan"]]
27
28 for row in rows do
29 var row_layout = new HorizontalLayout(parent=layout)
30
31 for op in row do
32 var but = new Button(parent=row_layout, text=op)
33 buttons[op] = but
34 end
35 end
36
37 super
38 end
39 end