Mercurial > dwindows
diff android/DWindows.kt @ 2582:01fca1937806
Android: Implement dw_window_set_focus(), dw_window_default() and dw_window_get_font().
dw_window_get_font() is untested... will test it shortly in another app.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 23 May 2021 07:30:52 +0000 |
parents | 9dea42f27b0a |
children | 8352c38bc20b |
line wrap: on
line diff
--- a/android/DWindows.kt Sun May 23 02:41:06 2021 +0000 +++ b/android/DWindows.kt Sun May 23 07:30:52 2021 +0000 @@ -739,6 +739,7 @@ private var paint = Paint() private var bgcolor: Int = 0 private var menuBar: DWMenu? = null + private var defaultItem: View? = null // Our version of runOnUiThread that waits for execution fun waitOnUiThread(runnable: Runnable) @@ -939,6 +940,19 @@ return null } + fun windowSetFocus(window: View) + { + waitOnUiThread { + window.requestFocus() + } + } + + fun windowDefault(window: View, default: View) + { + // TODO: Verify this is the correct activity... + defaultItem = default + } + fun windowSetStyle(window: View, style: Int, mask: Int) { waitOnUiThread { @@ -1054,6 +1068,35 @@ } } + fun windowGetFont(window: View): String? + { + var fontname: String? = null + + waitOnUiThread { + var typeface: Typeface? = null + var fontsize: Float? = null + + if(window is DWRender) { + typeface = window.typeface + fontsize = window.fontsize + } else if(window is TextView) { + typeface = window.typeface + fontsize = window.textSize + } else if(window is Button) { + typeface = window.typeface + fontsize = window.textSize + } + + if(typeface != null && fontsize != null) { + val isize = fontsize.toInt() + val name = typeface.toString() + + fontname = "$isize.$name" + } + } + return null + } + fun windowSetColor(window: View, fore: Int, falpha: Int, fred: Int, fgreen: Int, fblue: Int, back: Int, balpha: Int, bred: Int, bgreen: Int, bblue: Int) { var colorfore: Int = Color.rgb(fred, fgreen, fblue) @@ -1136,6 +1179,7 @@ window.visibility = View.GONE } else { window.visibility = View.VISIBLE + defaultItem?.requestFocus() } } }