Mercurial > dwindows
diff android/DWindows.kt @ 2476:20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
dw_text_new(), dw_status_text_new(), dw_checkbox_new() and dw_radiobutton_new().
Fix the signatures used in GetMethodID(), Android Studio can apparently do it autoamtically.
Add a LinearLayout to the DWindows activity, use it as the content view so we don't need XML.
dw_dwindow_new() will now return the LinearLayout instead of the Activity object... so the
handle can be used with dw_box_pack*().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 22 Apr 2021 00:04:01 +0000 |
parents | 16d195d46f2a |
children | 3fbf8783122d |
line wrap: on
line diff
--- a/android/DWindows.kt Wed Apr 21 11:15:26 2021 +0000 +++ b/android/DWindows.kt Thu Apr 22 00:04:01 2021 +0000 @@ -1,36 +1,39 @@ package org.dbsoft.dwindows.dwtest import android.os.Bundle +import android.text.method.PasswordTransformationMethod import android.view.View -import android.widget.LinearLayout -import android.widget.TextView +import android.widget.* import androidx.appcompat.app.AppCompatActivity class DWindows : AppCompatActivity() { + public var windowLayout: LinearLayout = LinearLayout(this) + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.dwindows_main) + setContentView(windowLayout) val m = packageManager var s = packageName val p = m.getPackageInfo(s!!, 0) s = p.applicationInfo.dataDir - // Example of a call to a native method - findViewById<TextView>(R.id.sample_text).text = dwindowsInit(s) + // Initialize the Dynamic Windows code... + // This will start a new thread that calls the app's dwmain() + dwindowsInit(s) } /* * These are the Android calls to actually create the UI... * forwarded from the C Dynamic Windows API */ - fun windowNew(title: String, style: Int): DWindows + fun windowNew(title: String, style: Int): LinearLayout { - // For now we just return our DWindows activity... + // For now we just return our DWindows' main activity layout... // in the future, later calls should create new activities - return this + return windowLayout } fun boxNew(type: Int, pad: Int): LinearLayout @@ -52,12 +55,12 @@ var h: Int = height; if(hsize > 0) { - w = LinearLayout.LayoutParams.FILL_PARENT + w = LinearLayout.LayoutParams.MATCH_PARENT } else if(w < 1) { w = LinearLayout.LayoutParams.WRAP_CONTENT } if(vsize > 0) { - h = LinearLayout.LayoutParams.FILL_PARENT + h = LinearLayout.LayoutParams.MATCH_PARENT } else if(h < 1) { h = LinearLayout.LayoutParams.WRAP_CONTENT } @@ -65,6 +68,44 @@ box.addView(item) } + fun buttonNew(text: String, cid: Int): Button + { + val button = Button(this) + button.text = text + return button + } + + fun entryfieldNew(text: String, cid: Int, password: Int): EditText + { + val entryfield = EditText(this) + if(password > 0) { + entryfield.transformationMethod = PasswordTransformationMethod.getInstance() + } + entryfield.setText(text) + return entryfield + } + + fun radioButtonNew(text: String, cid: Int): RadioButton + { + val radiobutton = RadioButton(this) + radiobutton.text = text + return radiobutton + } + + fun checkboxNew(text: String, cid: Int): CheckBox + { + val checkbox = CheckBox(this) + checkbox.text = text + return checkbox + } + + fun textNew(text: String, cid: Int, status: Int): TextView + { + val textview = TextView(this) + textview.text = text + return textview + } + /* * Native methods that are implemented by the 'dwindows' native library, * which is packaged with this application.