Mercurial > dwindows
comparison 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 |
comparison
equal
deleted
inserted
replaced
2581:9dea42f27b0a | 2582:01fca1937806 |
---|---|
737 var notificationID: Int = 0 | 737 var notificationID: Int = 0 |
738 var darkMode: Int = -1 | 738 var darkMode: Int = -1 |
739 private var paint = Paint() | 739 private var paint = Paint() |
740 private var bgcolor: Int = 0 | 740 private var bgcolor: Int = 0 |
741 private var menuBar: DWMenu? = null | 741 private var menuBar: DWMenu? = null |
742 private var defaultItem: View? = null | |
742 | 743 |
743 // Our version of runOnUiThread that waits for execution | 744 // Our version of runOnUiThread that waits for execution |
744 fun waitOnUiThread(runnable: Runnable) | 745 fun waitOnUiThread(runnable: Runnable) |
745 { | 746 { |
746 if(Looper.myLooper() == Looper.getMainLooper()) { | 747 if(Looper.myLooper() == Looper.getMainLooper()) { |
937 return windowLayout | 938 return windowLayout |
938 } | 939 } |
939 return null | 940 return null |
940 } | 941 } |
941 | 942 |
943 fun windowSetFocus(window: View) | |
944 { | |
945 waitOnUiThread { | |
946 window.requestFocus() | |
947 } | |
948 } | |
949 | |
950 fun windowDefault(window: View, default: View) | |
951 { | |
952 // TODO: Verify this is the correct activity... | |
953 defaultItem = default | |
954 } | |
955 | |
942 fun windowSetStyle(window: View, style: Int, mask: Int) | 956 fun windowSetStyle(window: View, style: Int, mask: Int) |
943 { | 957 { |
944 waitOnUiThread { | 958 waitOnUiThread { |
945 if (window is TextView && window !is EditText) { | 959 if (window is TextView && window !is EditText) { |
946 val text = window | 960 val text = window |
1050 render.fontsize = size | 1064 render.fontsize = size |
1051 } | 1065 } |
1052 } | 1066 } |
1053 } | 1067 } |
1054 } | 1068 } |
1069 } | |
1070 | |
1071 fun windowGetFont(window: View): String? | |
1072 { | |
1073 var fontname: String? = null | |
1074 | |
1075 waitOnUiThread { | |
1076 var typeface: Typeface? = null | |
1077 var fontsize: Float? = null | |
1078 | |
1079 if(window is DWRender) { | |
1080 typeface = window.typeface | |
1081 fontsize = window.fontsize | |
1082 } else if(window is TextView) { | |
1083 typeface = window.typeface | |
1084 fontsize = window.textSize | |
1085 } else if(window is Button) { | |
1086 typeface = window.typeface | |
1087 fontsize = window.textSize | |
1088 } | |
1089 | |
1090 if(typeface != null && fontsize != null) { | |
1091 val isize = fontsize.toInt() | |
1092 val name = typeface.toString() | |
1093 | |
1094 fontname = "$isize.$name" | |
1095 } | |
1096 } | |
1097 return null | |
1055 } | 1098 } |
1056 | 1099 |
1057 fun windowSetColor(window: View, fore: Int, falpha: Int, fred: Int, fgreen: Int, fblue: Int, | 1100 fun windowSetColor(window: View, fore: Int, falpha: Int, fred: Int, fgreen: Int, fblue: Int, |
1058 back: Int, balpha: Int, bred: Int, bgreen: Int, bblue: Int) { | 1101 back: Int, balpha: Int, bred: Int, bgreen: Int, bblue: Int) { |
1059 var colorfore: Int = Color.rgb(fred, fgreen, fblue) | 1102 var colorfore: Int = Color.rgb(fred, fgreen, fblue) |
1134 waitOnUiThread { | 1177 waitOnUiThread { |
1135 if(state == 0) { | 1178 if(state == 0) { |
1136 window.visibility = View.GONE | 1179 window.visibility = View.GONE |
1137 } else { | 1180 } else { |
1138 window.visibility = View.VISIBLE | 1181 window.visibility = View.VISIBLE |
1182 defaultItem?.requestFocus() | |
1139 } | 1183 } |
1140 } | 1184 } |
1141 } | 1185 } |
1142 | 1186 |
1143 fun clipboardGetText(): String { | 1187 fun clipboardGetText(): String { |