Mercurial > dwindows
comparison android/DWindows.kt @ 2482:4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
Make eventHandler() second View and string parameters nullable.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 26 Apr 2021 18:34:51 +0000 |
parents | 94f0d61d6953 |
children | 9f7af6d8c6a4 |
comparison
equal
deleted
inserted
replaced
2481:94f0d61d6953 | 2482:4888503c3e3e |
---|---|
2 | 2 |
3 import android.content.pm.ActivityInfo | 3 import android.content.pm.ActivityInfo |
4 import android.os.Bundle | 4 import android.os.Bundle |
5 import android.text.method.PasswordTransformationMethod | 5 import android.text.method.PasswordTransformationMethod |
6 import android.util.Half.toFloat | 6 import android.util.Half.toFloat |
7 import android.util.Log | |
7 import android.view.Gravity | 8 import android.view.Gravity |
8 import android.view.View | 9 import android.view.View |
9 import android.widget.* | 10 import android.widget.* |
10 import androidx.appcompat.app.AppCompatActivity | 11 import androidx.appcompat.app.AppCompatActivity |
11 | 12 |
127 | 128 |
128 fun buttonNew(text: String, cid: Int): Button | 129 fun buttonNew(text: String, cid: Int): Button |
129 { | 130 { |
130 val button = Button(this) | 131 val button = Button(this) |
131 button.text = text | 132 button.text = text |
132 button.setOnClickListener { eventHandler(button, button, 8, "", "", 0, 0, 0, 0) } | 133 button.setOnClickListener { |
134 eventHandler(button, null, 8, null, null, 0, 0, 0, 0) | |
135 } | |
133 return button | 136 return button |
134 } | 137 } |
135 | 138 |
136 fun entryfieldNew(text: String, cid: Int, password: Int): EditText | 139 fun entryfieldNew(text: String, cid: Int, password: Int): EditText |
137 { | 140 { |
145 | 148 |
146 fun radioButtonNew(text: String, cid: Int): RadioButton | 149 fun radioButtonNew(text: String, cid: Int): RadioButton |
147 { | 150 { |
148 val radiobutton = RadioButton(this) | 151 val radiobutton = RadioButton(this) |
149 radiobutton.text = text | 152 radiobutton.text = text |
150 radiobutton.setOnClickListener { eventHandler(radiobutton, radiobutton, 8, "", "", 0, 0, 0, 0) } | 153 radiobutton.setOnClickListener { |
154 eventHandler(radiobutton, null, 8, null, null, 0, 0, 0, 0) | |
155 } | |
151 return radiobutton | 156 return radiobutton |
152 } | 157 } |
153 | 158 |
154 fun checkboxNew(text: String, cid: Int): CheckBox | 159 fun checkboxNew(text: String, cid: Int): CheckBox |
155 { | 160 { |
156 val checkbox = CheckBox(this) | 161 val checkbox = CheckBox(this) |
157 checkbox.text = text | 162 checkbox.text = text |
163 checkbox.setOnClickListener { | |
164 eventHandler(checkbox, null, 8, null, null, 0, 0, 0, 0) | |
165 } | |
158 return checkbox | 166 return checkbox |
159 } | 167 } |
160 | 168 |
161 fun textNew(text: String, cid: Int, status: Int): TextView | 169 fun textNew(text: String, cid: Int, status: Int): TextView |
162 { | 170 { |
163 val textview = TextView(this) | 171 val textview = TextView(this) |
164 textview.text = text | 172 textview.text = text |
165 return textview | 173 return textview |
166 } | 174 } |
167 | 175 |
176 fun debugMessage(text: String) | |
177 { | |
178 Log.d(null, text) | |
179 } | |
180 | |
168 /* | 181 /* |
169 * Native methods that are implemented by the 'dwindows' native library, | 182 * Native methods that are implemented by the 'dwindows' native library, |
170 * which is packaged with this application. | 183 * which is packaged with this application. |
171 */ | 184 */ |
172 external fun dwindowsInit(dataDir: String): String | 185 external fun dwindowsInit(dataDir: String): String |
173 external fun eventHandler(obj1: Any, obj2: Any, message: Int, str1: String, str2: String, int1: Int, int2: Int, int3: Int, int4: Int): Int | 186 external fun eventHandler(obj1: View, obj2: View?, message: Int, str1: String?, str2: String?, int1: Int, int2: Int, int3: Int, int4: Int): Int |
174 | 187 |
175 companion object | 188 companion object |
176 { | 189 { |
177 // Used to load the 'dwindows' library on application startup. | 190 // Used to load the 'dwindows' library on application startup. |
178 init | 191 init |