annotate android/DWindows.kt @ 2580:473eb9ff3f04

Android: Implement dw_container_set_stripe() and center the images in the rows. Also switch to using jlong (Long) types for passing the colors internally.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 23 May 2021 02:27:12 +0000
parents 68ee9a89e0f0
children 9dea42f27b0a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2484
cb5b67154399 Android: The DWindows class should be org.dbsoft.dwindows, remove dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2483
diff changeset
1 package org.dbsoft.dwindows
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3 import android.R
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
4 import android.app.Activity
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
5 import android.app.Dialog
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6 import android.app.NotificationChannel
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
7 import android.app.NotificationManager
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
8 import android.content.ClipData
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
9 import android.content.ClipboardManager
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
10 import android.content.Context
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
11 import android.content.DialogInterface
2480
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
12 import android.content.pm.ActivityInfo
2496
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
13 import android.content.res.Configuration
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
14 import android.graphics.*
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
15 import android.graphics.drawable.BitmapDrawable
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
16 import android.graphics.drawable.Drawable
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
17 import android.graphics.drawable.GradientDrawable
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
18 import android.media.AudioManager
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
19 import android.media.ToneGenerator
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
20 import android.os.*
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
21 import android.text.InputFilter
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
22 import android.text.InputFilter.LengthFilter
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
23 import android.text.InputType
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
24 import android.text.method.PasswordTransformationMethod
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
25 import android.util.Base64
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
26 import android.util.Log
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
27 import android.util.SparseBooleanArray
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
28 import android.util.TypedValue
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
29 import android.view.*
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
30 import android.view.View.OnTouchListener
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
31 import android.view.ViewGroup
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
32 import android.view.inputmethod.EditorInfo
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
33 import android.webkit.WebView
2505
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
34 import android.webkit.WebViewClient
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
35 import android.widget.*
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
36 import android.widget.AdapterView.OnItemClickListener
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
37 import android.widget.SeekBar.OnSeekBarChangeListener
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
38 import androidx.appcompat.app.AlertDialog
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
39 import androidx.appcompat.app.AppCompatActivity
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
40 import androidx.appcompat.widget.AppCompatEditText
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
41 import androidx.collection.SimpleArrayMap
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
42 import androidx.core.app.NotificationCompat
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
43 import androidx.core.app.NotificationManagerCompat
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
44 import androidx.core.content.res.ResourcesCompat
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
45 import androidx.core.view.MenuCompat
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
46 import androidx.recyclerview.widget.RecyclerView
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
47 import androidx.viewpager2.widget.ViewPager2
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
48 import com.google.android.material.tabs.TabLayout
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
49 import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
50 import com.google.android.material.tabs.TabLayoutMediator
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
51 import java.io.File
2564
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
52 import java.io.IOException
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
53 import java.util.*
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
54 import java.util.concurrent.locks.ReentrantLock
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
55
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
56
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
57 class DWTabViewPagerAdapter : RecyclerView.Adapter<DWTabViewPagerAdapter.DWEventViewHolder>() {
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
58 val viewList = mutableListOf<LinearLayout>()
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
59 val pageList = mutableListOf<Long>()
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
60 var currentPageID = 0L
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
61
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
62 override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
63 DWEventViewHolder(viewList.get(viewType))
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
64
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
65 override fun getItemCount() = viewList.count()
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
66 override fun getItemViewType(position: Int): Int {
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
67 return position
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
68 }
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
69 override fun onBindViewHolder(holder: DWEventViewHolder, position: Int) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
70 holder.setIsRecyclable(false)
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
71 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
72
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
73 class DWEventViewHolder(var view: View) : RecyclerView.ViewHolder(view)
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
74 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
75
2505
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
76 private class DWWebViewClient : WebViewClient() {
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
77 //Implement shouldOverrideUrlLoading//
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
78 override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
79 // We always want to load in our own WebView,
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
80 // to match the behavior on the other platforms
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
81 return false
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
82 }
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
83 override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
84 // Handle the DW_HTML_CHANGE_STARTED event
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
85 eventHandlerHTMLChanged(view, 19, url, 1)
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
86 }
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
87
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
88 override fun onPageFinished(view: WebView, url: String) {
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
89 // Handle the DW_HTML_CHANGE_COMPLETE event
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
90 eventHandlerHTMLChanged(view, 19, url, 4)
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
91 }
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
92
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
93 external fun eventHandlerHTMLChanged(obj1: View, message: Int, URI: String, status: Int)
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
94 }
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
95
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
96 class DWSpinButton(context: Context) : AppCompatEditText(context), OnTouchListener {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
97 var value: Long = 0
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
98 var minimum: Long = 0
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
99 var maximum: Long = 65535
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
100
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
101 init {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
102 setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_media_previous, 0, R.drawable.ic_media_next, 0)
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
103 setOnTouchListener(this)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
104 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
105
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
106 override fun onTouch(v: View, event: MotionEvent): Boolean {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
107 val DRAWABLE_RIGHT = 2
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
108 val DRAWABLE_LEFT = 0
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
109
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
110 if (event.action == MotionEvent.ACTION_UP) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
111 if (event.x >= v.width - (v as EditText)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
112 .compoundDrawables[DRAWABLE_RIGHT].bounds.width()
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
113 ) {
2527
eec926265888 Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
114 val newvalue = this.text.toString().toLongOrNull()
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
115
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
116 if(newvalue != null) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
117 value = newvalue + 1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
118 } else {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
119 value += 1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
120 }
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
121 if(value > maximum) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
122 value = maximum
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
123 }
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
124 if(value < minimum) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
125 value = minimum
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
126 }
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
127 setText(value.toString())
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
128 eventHandlerInt(14, value.toInt(), 0, 0, 0)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
129 return true
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
130 } else if (event.x <= v.compoundDrawables[DRAWABLE_LEFT].bounds.width()) {
2527
eec926265888 Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
131 val newvalue = this.text.toString().toLongOrNull()
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
132
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
133 if(newvalue != null) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
134 value = newvalue - 1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
135 } else {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
136 value -= 1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
137 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
138 if(value > maximum) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
139 value = maximum
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
140 }
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
141 if(value < minimum) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
142 value = minimum
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
143 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
144 setText(value.toString())
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
145 eventHandlerInt(14, value.toInt(), 0, 0, 0)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
146 return true
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
147 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
148 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
149 return false
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
150 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
151
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
152 external fun eventHandlerInt(
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
153 message: Int,
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
154 inta: Int,
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
155 intb: Int,
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
156 intc: Int,
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
157 intd: Int
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
158 )
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
159 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
160
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
161 class DWComboBox(context: Context) : AppCompatEditText(context), OnTouchListener, OnItemClickListener {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
162 var lpw: ListPopupWindow? = null
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
163 var list = mutableListOf<String>()
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
164 var selected: Int = -1
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
165
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
166 init {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
167 setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.arrow_down_float, 0)
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
168 setOnTouchListener(this)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
169 lpw = ListPopupWindow(context)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
170 lpw!!.setAdapter(
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
171 ArrayAdapter(
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
172 context,
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
173 R.layout.simple_list_item_1, list
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
174 )
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
175 )
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
176 lpw!!.anchorView = this
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
177 lpw!!.isModal = true
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
178 lpw!!.setOnItemClickListener(this)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
179 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
180
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
181 override fun onItemClick(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
182 val item = list[position]
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
183 selected = position
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
184 setText(item)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
185 lpw!!.dismiss()
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
186 eventHandlerInt(11, position, 0, 0, 0)
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
187 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
188
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
189 override fun onTouch(v: View, event: MotionEvent): Boolean {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
190 val DRAWABLE_RIGHT = 2
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
191
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
192 if (event.action == MotionEvent.ACTION_UP) {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
193 if (event.x >= v.width - (v as EditText)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
194 .compoundDrawables[DRAWABLE_RIGHT].bounds.width()
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
195 ) {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
196 lpw!!.show()
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
197 return true
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
198 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
199 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
200 return false
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
201 }
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
202
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
203 external fun eventHandlerInt(
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
204 message: Int,
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
205 inta: Int,
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
206 intb: Int,
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
207 intc: Int,
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
208 intd: Int
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
209 )
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
210 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
211
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
212 class DWListBox(context: Context) : ListView(context), OnItemClickListener {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
213 var list = mutableListOf<String>()
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
214 var selected: Int = -1
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
215
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
216 init {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
217 setAdapter(
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
218 ArrayAdapter(
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
219 context,
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
220 R.layout.simple_list_item_1, list
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
221 )
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
222 )
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
223 onItemClickListener = this
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
224 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
225
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
226 override fun onItemClick(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
227 selected = position
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
228 eventHandlerInt(11, position, 0, 0, 0)
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
229 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
230
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
231 external fun eventHandlerInt(
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
232 message: Int,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
233 inta: Int,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
234 intb: Int,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
235 intc: Int,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
236 intd: Int
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
237 )
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
238 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
239
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
240 class DWRender(context: Context) : View(context) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
241 var cachedCanvas: Canvas? = null
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
242 var typeface: Typeface? = null
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
243 var fontsize: Float? = null
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
244
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
245 override fun onSizeChanged(width: Int, height: Int, oldWidth: Int, oldHeight: Int) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
246 super.onSizeChanged(width, height, oldWidth, oldHeight)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
247 // Send DW_SIGNAL_CONFIGURE
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
248 eventHandlerInt(1, width, height, 0, 0)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
249 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
250
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
251 override fun onDraw(canvas: Canvas) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
252 super.onDraw(canvas)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
253 cachedCanvas = canvas
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
254 // Send DW_SIGNAL_EXPOSE
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
255 eventHandlerInt(7, 0, 0, this.width, this.height)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
256 cachedCanvas = null
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
257 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
258
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
259 external fun eventHandlerInt(
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
260 message: Int,
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
261 inta: Int,
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
262 intb: Int,
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
263 intc: Int,
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
264 intd: Int
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
265 )
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
266 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
267
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
268 class DWFileChooser(private val activity: Activity) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
269 private val list: ListView = ListView(activity)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
270 private val dialog: Dialog = Dialog(activity)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
271 private var currentPath: File? = null
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
272
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
273 // filter on file extension
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
274 private var extension: String? = null
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
275 fun setExtension(extension: String?) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
276 this.extension = extension?.toLowerCase(Locale.ROOT)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
277 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
278
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
279 // file selection event handling
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
280 interface FileSelectedListener {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
281 fun fileSelected(file: File?)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
282 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
283
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
284 fun setFileListener(fileListener: FileSelectedListener?): DWFileChooser {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
285 this.fileListener = fileListener
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
286 return this
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
287 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
288
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
289 private var fileListener: FileSelectedListener? = null
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
290 fun showDialog() {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
291 dialog.show()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
292 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
293
2527
eec926265888 Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
294 /*
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
295 * Sort, filter and display the files for the given path.
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
296 */
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
297 private fun refresh(path: File?) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
298 currentPath = path
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
299 if (path != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
300 if (path.exists()) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
301 val dirs = path.listFiles { file -> file.isDirectory && file.canRead() }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
302 val files = path.listFiles { file ->
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
303 if (!file.isDirectory) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
304 if (!file.canRead()) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
305 false
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
306 } else if (extension == null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
307 true
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
308 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
309 file.name.toLowerCase(Locale.ROOT).endsWith(extension!!)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
310 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
311 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
312 false
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
313 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
314 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
315
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
316 // convert to an array
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
317 var i = 0
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
318 val fileList: Array<String?>
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
319 var filecount = 0
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
320 var dircount = 0
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
321 if(files != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
322 filecount = files.size
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
323 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
324 if(dirs != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
325 dircount = dirs.size
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
326 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
327 if (path.parentFile == null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
328 fileList = arrayOfNulls(dircount + filecount)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
329 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
330 fileList = arrayOfNulls(dircount + filecount + 1)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
331 fileList[i++] = PARENT_DIR
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
332 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
333 if(dirs != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
334 Arrays.sort(dirs)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
335 for (dir in dirs) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
336 fileList[i++] = dir.name
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
337 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
338 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
339 if(files != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
340 Arrays.sort(files)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
341 for (file in files) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
342 fileList[i++] = file.name
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
343 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
344 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
345
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
346 // refresh the user interface
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
347 dialog.setTitle(currentPath!!.path)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
348 list.adapter = object : ArrayAdapter<Any?>(
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
349 activity,
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
350 R.layout.simple_list_item_1, fileList
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
351 ) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
352 override fun getView(pos: Int, view: View?, parent: ViewGroup): View {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
353 val thisview = super.getView(pos, view, parent)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
354 (thisview as TextView).isSingleLine = true
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
355 return thisview
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
356 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
357 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
358 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
359 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
360 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
361
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
362 /**
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
363 * Convert a relative filename into an actual File object.
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
364 */
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
365 private fun getChosenFile(fileChosen: String): File? {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
366 return if (fileChosen == PARENT_DIR) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
367 currentPath!!.parentFile
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
368 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
369 File(currentPath, fileChosen)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
370 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
371 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
372
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
373 companion object {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
374 private const val PARENT_DIR = ".."
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
375 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
376
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
377 init {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
378 list.onItemClickListener =
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
379 OnItemClickListener { parent, view, which, id ->
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
380 val fileChosen = list.getItemAtPosition(which) as String
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
381 val chosenFile: File? = getChosenFile(fileChosen)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
382 if (chosenFile != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
383 if (chosenFile.isDirectory) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
384 refresh(chosenFile)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
385 } else {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
386 if (fileListener != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
387 fileListener!!.fileSelected(chosenFile)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
388 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
389 dialog.dismiss()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
390 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
391 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
392 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
393 dialog.setContentView(list)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
394 dialog.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
395 refresh(Environment.getExternalStorageDirectory())
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
396 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
397 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
398
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
399 // On Android we can't pre-create submenus...
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
400 // So create our own placeholder classes, and create the actual menus
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
401 // on demand when required by Android
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
402 class DWMenuItem
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
403 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
404 var title: String? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
405 var menu: DWMenu? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
406 var submenu: DWMenu? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
407 var checked: Boolean = false
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
408 var check: Boolean = false
2546
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
409 var enabled: Boolean = true
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
410 var menuitem: MenuItem? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
411 var submenuitem: SubMenu? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
412 var id: Int = 0
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
413 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
414
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
415 class DWMenu {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
416 var menu: Menu? = null
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
417 var children = mutableListOf<DWMenuItem>()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
418 var id: Int = 0
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
419
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
420 fun createMenu(newmenu: Menu?) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
421 if(menu == null) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
422 menu = newmenu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
423 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
424 if(menu != null) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
425 var group = 0
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
426
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
427 // Enable group dividers for separators
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
428 MenuCompat.setGroupDividerEnabled(menu, true)
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
429
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
430 for (menuitem in children) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
431 // Submenus on Android can't have submenus, so stop at depth 1
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
432 if (menuitem.submenu != null && menu !is SubMenu) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
433 if(menuitem.submenuitem == null) {
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
434 menuitem.submenuitem = menu?.addSubMenu(group, menuitem.id, 0, menuitem.title)
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
435 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
436 menuitem.submenu!!.createMenu(menuitem.submenuitem)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
437 } else if(menuitem.submenu == null) {
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
438 if(menuitem.title!!.isEmpty()) {
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
439 group += 1
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
440 } else if(menuitem.menuitem == null) {
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
441 menuitem.menuitem = menu?.add(group, menuitem.id, 0, menuitem.title)
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
442 menuitem.menuitem!!.isCheckable = menuitem.check
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
443 menuitem.menuitem!!.isChecked = menuitem.checked
2546
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
444 menuitem.menuitem!!.isEnabled = menuitem.enabled
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
445 menuitem.menuitem!!.setOnMenuItemClickListener { item: MenuItem? ->
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
446 eventHandlerSimple(menuitem, 8)
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
447 true
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
448 }
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
449 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
450 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
451 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
452 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
453 }
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
454
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
455 external fun eventHandlerSimple(item: DWMenuItem, message: Int)
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
456 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
457
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
458 // Class for storing container data
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
459 class DWContainerModel {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
460 var columns = mutableListOf<String?>()
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
461 var types = mutableListOf<Int>()
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
462 var data = mutableListOf<Any?>()
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
463 var rowdata = mutableListOf<Long>()
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
464 var rowtitle = mutableListOf<String?>()
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
465 var querypos: Int = -1
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
466
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
467 fun numberOfColumns(): Int
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
468 {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
469 return columns.size
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
470 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
471
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
472 fun numberOfRows(): Int
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
473 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
474 if(columns.size > 0) {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
475 return data.size / columns.size
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
476 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
477 return 0
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
478 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
479
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
480 fun getColumnType(column: Int): Int
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
481 {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
482 if(column < types.size) {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
483 return types[column]
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
484 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
485 return -1
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
486 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
487
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
488 fun getRowAndColumn(row: Int, column: Int): Any?
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
489 {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
490 val index: Int = (row * columns.size) + column
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
491
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
492 if(index > -1 && index < data.size) {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
493 return data[index]
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
494 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
495 return null
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
496 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
497
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
498 fun setRowAndColumn(row: Int, column: Int, obj: Any?)
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
499 {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
500 val index: Int = (row * columns.size) + column
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
501
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
502 if(index > -1 && index < data.size && column < types.size) {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
503 // Verify the data matches the column type
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
504 if((((types[column] and 1) != 0) && (obj is Drawable)) ||
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
505 (((types[column] and (1 shl 1)) != 0) && (obj is String)) ||
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
506 (((types[column] and (1 shl 2)) != 0) && (obj is Int))) {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
507 data[index] = obj
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
508 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
509 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
510 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
511
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
512 fun changeRowData(row: Int, rdata: Long)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
513 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
514 if(row > -1 && row < rowdata.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
515 rowdata[row] = rdata
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
516 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
517 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
518
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
519 fun getRowData(row: Int): Long
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
520 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
521 if(row > -1 && row < rowdata.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
522 return rowdata[row]
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
523 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
524 return 0
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
525 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
526
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
527 fun changeRowTitle(row: Int, title: String?)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
528 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
529 if(row > -1 && row < rowtitle.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
530 rowtitle[row] = title
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
531 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
532 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
533
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
534 fun getRowTitle(row: Int): String?
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
535 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
536 if(row > -1 && row < rowtitle.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
537 return rowtitle[row]
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
538 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
539 return null
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
540 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
541
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
542 fun addColumn(title: String?, type: Int)
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
543 {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
544 columns.add(title)
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
545 types.add(type)
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
546 // If we change the columns we have to invalidate the data
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
547 data.clear()
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
548 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
549
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
550 fun deleteRows(count: Int)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
551 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
552 if(count < rowdata.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
553 for(i in 0 until count) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
554 for(j in 0 until columns.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
555 data.removeAt(0)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
556 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
557 rowdata.removeAt(0)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
558 rowtitle.removeAt(0)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
559 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
560 } else {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
561 data.clear()
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
562 rowdata.clear()
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
563 rowtitle.clear()
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
564 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
565 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
566
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
567 fun deleteRowByTitle(title: String?)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
568 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
569 for(i in 0 until rowtitle.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
570 if(rowtitle[i] != null && rowtitle[i] == title) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
571 for(j in 0 until columns.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
572 data.removeAt(i * columns.size)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
573 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
574 rowdata.removeAt(i)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
575 rowtitle.removeAt(i)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
576 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
577 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
578 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
579
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
580 fun deleteRowByData(rdata: Long)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
581 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
582 for(i in 0 until rowdata.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
583 if(rowdata[i] == rdata) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
584 for(j in 0 until columns.size) {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
585 data.removeAt(i * columns.size)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
586 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
587 rowdata.removeAt(i)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
588 rowtitle.removeAt(i)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
589 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
590 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
591 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
592
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
593 fun addRows(count: Int): Long
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
594 {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
595 val startRow: Long = numberOfRows().toLong()
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
596
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
597 for(i in 0 until count)
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
598 {
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
599 for(j in 0 until columns.size)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
600 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
601 // Fill in with nulls to be set later
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
602 data.add(null)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
603 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
604 rowdata.add(0)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
605 rowtitle.add(null)
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
606 }
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
607 return startRow
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
608 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
609
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
610 fun clear()
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
611 {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
612 data.clear()
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
613 rowdata.clear()
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
614 rowtitle.clear()
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
615 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
616 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
617
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
618 class DWContainerAdapter(c: Context) : BaseAdapter()
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
619 {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
620 private var context = c
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
621 var model = DWContainerModel()
2563
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
622 var selectedItem: Int = -1
2565
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
623 var simpleMode: Boolean = true
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
624 var oddColor: Int? = null
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
625 var evenColor: Int? = null
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
626
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
627 override fun getCount(): Int {
2567
19d82c1f135f Android: Fix incorrect display of first container entry with the new layout code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2565
diff changeset
628 return model.numberOfRows()
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
629 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
630
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
631 override fun getItem(position: Int): Any? {
2565
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
632 return model.getRowAndColumn(position, 0)
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
633 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
634
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
635 override fun getItemId(position: Int): Long {
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
636 return position.toLong()
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
637 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
638
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
639 override fun getView(position: Int, view: View?, parent: ViewGroup): View {
2568
b536b7b21682 Android: Switch to using LinearLayout for Container row layout...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2567
diff changeset
640 var rowView: LinearLayout? = view as LinearLayout?
2565
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
641 var displayColumns = model.numberOfColumns()
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
642
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
643 // In simple mode, limit the columns to 1 or 2
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
644 if(simpleMode == true) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
645 // If column 1 is bitmap and column 2 is text...
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
646 if(displayColumns > 1 && (model.getColumnType(0) and 1) != 0 &&
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
647 (model.getColumnType(1) and (1 shl 1)) != 0) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
648 displayColumns = 2
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
649 } else {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
650 displayColumns = 1
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
651 }
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
652 }
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
653
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
654 // If the view passed in is null we need to create the layout
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
655 if(rowView == null) {
2568
b536b7b21682 Android: Switch to using LinearLayout for Container row layout...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2567
diff changeset
656 rowView = LinearLayout(context)
b536b7b21682 Android: Switch to using LinearLayout for Container row layout...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2567
diff changeset
657 rowView.orientation = LinearLayout.HORIZONTAL
2565
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
658
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
659 for(i in 0 until displayColumns) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
660 val content = model.getRowAndColumn(position, i)
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
661
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
662 // Image
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
663 if((model.getColumnType(i) and 1) != 0) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
664 val imageview = ImageView(context)
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
665 val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
666 LinearLayout.LayoutParams.WRAP_CONTENT)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
667 params.gravity = Gravity.CENTER
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
668 imageview.layoutParams = params
2565
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
669 imageview.id = View.generateViewId()
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
670 if (content is Drawable) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
671 imageview.setImageDrawable(content)
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
672 }
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
673 rowView.addView(imageview)
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
674 } else {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
675 // Everything else id displayed as text
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
676 val textview = TextView(context)
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
677 val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
678 LinearLayout.LayoutParams.WRAP_CONTENT)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
679 params.gravity = Gravity.CENTER
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
680 textview.layoutParams = params
2565
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
681 textview.id = View.generateViewId()
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
682 if (content is String) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
683 textview.text = content
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
684 } else if(content is Int) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
685 textview.text = content.toString()
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
686 }
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
687 rowView.addView(textview)
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
688 }
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
689 }
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
690 // TODO: Add code to optionally add other columns
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
691 } else {
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
692 // Otherwise we just need to update the existing layout
2565
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
693
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
694 for(i in 0 until displayColumns) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
695 val content = model.getRowAndColumn(position, i)
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
696
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
697 // Image
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
698 if((model.getColumnType(i) and 1) != 0) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
699 val imageview = rowView.getChildAt(i)
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
700
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
701 if (imageview is ImageView && content is Drawable) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
702 imageview.setImageDrawable(content)
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
703 }
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
704 } else {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
705 // Text
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
706 val textview = rowView.getChildAt(i)
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
707
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
708 if (textview is TextView) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
709 if (content is String) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
710 textview.text = content
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
711 } else if (content is Int) {
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
712 textview.text = content.toString()
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
713 }
5463801a888f Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2564
diff changeset
714 }
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
715 }
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
716 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
717 }
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
718 // Handle row stripe
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
719 if (position % 2 == 0) {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
720 if(evenColor != null) {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
721 rowView.setBackgroundColor(evenColor!!)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
722 }
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
723 } else {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
724 if(oddColor != null) {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
725 rowView.setBackgroundColor(oddColor!!)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
726 }
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
727 }
2555
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
728 return rowView
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
729 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
730 }
d7d163d70763 Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2554
diff changeset
731
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
732 class DWindows : AppCompatActivity() {
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
733 var firstWindow: Boolean = true
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
734 var windowLayout: LinearLayout? = null
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
735 var threadLock = ReentrantLock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
736 var threadCond = threadLock.newCondition()
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
737 var notificationID: Int = 0
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
738 var darkMode: Int = -1
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
739 private var paint = Paint()
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
740 private var bgcolor: Int = 0
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
741 private var menuBar: DWMenu? = null
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
742
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
743 // Our version of runOnUiThread that waits for execution
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
744 fun waitOnUiThread(runnable: Runnable)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
745 {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
746 if(Looper.myLooper() == Looper.getMainLooper()) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
747 runnable.run()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
748 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
749 threadLock.lock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
750 val ourRunnable = Runnable {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
751 threadLock.lock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
752 runnable.run()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
753 threadCond.signal()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
754 threadLock.unlock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
755 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
756 runOnUiThread(ourRunnable)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
757 threadCond.await()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
758 threadLock.unlock()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
759 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
760 }
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
761
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
762 // We only want to call this once when the app starts up
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
763 // By default Android will call onCreate for rotation and other
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
764 // changes. This is incompatible with Dynamic Windows...
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
765 // Make sure the following is in your AndroidManifest.xml
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
766 // android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
767 override fun onCreate(savedInstanceState: Bundle?) {
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
768 super.onCreate(savedInstanceState)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
769
2480
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
770 // Turn on rotation
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
771 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR)
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
772
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
773 // Get the Android app path
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
774 val m = packageManager
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
775 var s = packageName
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
776 val p = m.getPackageInfo(s!!, 0)
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
777 s = p.applicationInfo.dataDir
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
778
2498
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
779 // Initialize the Dynamic Windows code...
4ae2b3b77f25 Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2497
diff changeset
780 // This will start a new thread that calls the app's dwmain()
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
781 dwindowsInit(s, this.getPackageName())
2496
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
782 }
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
783
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
784 override fun onConfigurationChanged(newConfig: Configuration) {
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
785 super.onConfigurationChanged(newConfig)
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
786
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
787 val currentNightMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
788 when (currentNightMode) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
789 Configuration.UI_MODE_NIGHT_NO -> { darkMode = 0 } // Night mode is not active, we're using the light theme
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
790 Configuration.UI_MODE_NIGHT_YES -> { darkMode = 1 } // Night mode is active, we're using dark theme
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
791 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
792
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
793 // Send a DW_SIGNAL_CONFIGURE on orientation change
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
794 if(windowLayout != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
795 val width: Int = windowLayout!!.width
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
796 val height: Int = windowLayout!!.height
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
797
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
798 eventHandlerInt(windowLayout as View, 1, width, height, 0, 0)
2496
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
799 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
800 }
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
801
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
802 override fun onCreateOptionsMenu(menu: Menu?): Boolean {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
803 if(menuBar == null) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
804 menuBar = DWMenu()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
805 menuBar!!.menu = menu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
806 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
807 return super.onCreateOptionsMenu(menu)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
808 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
809
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
810 override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
811 if(menuBar != null) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
812 menuBar!!.createMenu(menu)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
813 } else {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
814 menuBar = DWMenu()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
815 menuBar!!.createMenu(menu)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
816 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
817 return super.onPrepareOptionsMenu(menu)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
818 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
819
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
820 // These are the Android calls to actually create the UI...
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
821 // forwarded from the C Dynamic Windows API
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
822
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
823 fun darkModeDetected(): Int
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
824 {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
825 return darkMode
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
826 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
827
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
828 fun menuBarNew(location: View): DWMenu?
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
829 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
830 // TODO: Make sure location is this activity
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
831 return menuBar
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
832 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
833
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
834 fun menuNew(cid: Int): DWMenu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
835 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
836 val menu = DWMenu()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
837 menu.id = cid
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
838 return menu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
839 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
840
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
841 fun menuAppendItem(menu: DWMenu, title: String, cid: Int, flags: Int, end: Int, check: Int, submenu: DWMenu?): DWMenuItem
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
842 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
843 val menuitem = DWMenuItem()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
844 menuitem.id = cid
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
845 menuitem.title = title
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
846 menuitem.check = check != 0
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
847 if(submenu != null) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
848 menuitem.submenu = submenu
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
849 }
2546
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
850 if((flags and (1 shl 1)) != 0) {
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
851 menuitem.enabled = false
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
852 }
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
853 if((flags and (1 shl 2)) != 0) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
854 menuitem.checked = true
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
855 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
856 if(end == 0) {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
857 menu.children.add(0, menuitem)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
858 } else {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
859 menu.children.add(menuitem)
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
860 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
861 return menuitem
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
862 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
863
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
864 fun menuDestroy(menu: DWMenu)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
865 {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
866 menu.children.clear()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
867 runOnUiThread {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
868 menu.menu!!.clear()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
869 invalidateOptionsMenu()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
870 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
871 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
872
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
873 fun menuDeleteItem(menu: DWMenu, cid: Int)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
874 {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
875 for(menuitem in menu.children) {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
876 if(menuitem.id == cid) {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
877 menu.children.remove(menuitem)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
878 runOnUiThread {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
879 menu.menu!!.removeItem(menuitem.id)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
880 invalidateOptionsMenu()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
881 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
882 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
883 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
884 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
885
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
886 fun menuSetState(menu: DWMenu, cid: Int, state: Int)
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
887 {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
888 for(menuitem in menu.children) {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
889 if(menuitem.id == cid) {
2546
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
890 // Handle DW_MIS_ENABLED/DISABLED
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
891 if((state and (1 or (1 shl 1))) != 0) {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
892 var enabled = false
2546
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
893
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
894 // Handle DW_MIS_ENABLED
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
895 if ((state and 1) != 0) {
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
896 enabled = true
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
897 }
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
898 menuitem.enabled = enabled
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
899 runOnUiThread {
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
900 menuitem.menuitem!!.isEnabled = enabled
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
901 invalidateOptionsMenu()
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
902 }
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
903 }
897d94c20365 Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
904
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
905 // Handle DW_MIS_CHECKED/UNCHECKED
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
906 if((state and ((1 shl 2) or (1 shl 3))) != 0) {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
907 var checked = false
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
908
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
909 // Handle DW_MIS_CHECKED
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
910 if ((state and (1 shl 2)) != 0) {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
911 checked = true
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
912 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
913 menuitem.checked = checked
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
914 runOnUiThread {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
915 menuitem.menuitem!!.isChecked = checked
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
916 invalidateOptionsMenu()
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
917 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
918 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
919 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
920 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
921 }
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
922
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
923 fun windowNew(title: String, style: Int): LinearLayout? {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
924 if (firstWindow) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
925 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
926 val dataArrayMap = SimpleArrayMap<String, Long>()
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
927 windowLayout = LinearLayout(this)
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
928
2503
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
929 windowLayout!!.visibility = View.GONE
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
930 windowLayout!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
931 setContentView(windowLayout)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
932 this.title = title
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
933 // For now we just return our DWindows' main activity layout...
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
934 // in the future, later calls should create new activities
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
935 firstWindow = false
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
936 }
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
937 return windowLayout
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
938 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
939 return null
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
940 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
941
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
942 fun windowSetStyle(window: View, style: Int, mask: Int)
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
943 {
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
944 waitOnUiThread {
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
945 if (window is TextView && window !is EditText) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
946 val text = window
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
947 val ourmask = (Gravity.HORIZONTAL_GRAVITY_MASK or Gravity.VERTICAL_GRAVITY_MASK) and mask
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
948
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
949 if (ourmask != 0) {
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
950 // Gravity with the masked parts zeroed out
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
951 val newgravity = style and ourmask
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
952
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
953 text.gravity = newgravity
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
954 }
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
955 }
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
956 }
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
957 }
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
958
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
959 fun windowFromId(window: View, cid: Int): View {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
960 return window.findViewById(cid)
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
961 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
962
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
963 fun windowSetData(window: View, name: String, data: Long) {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
964 if (window.tag != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
965 val dataArrayMap: SimpleArrayMap<String, Long> = window.tag as SimpleArrayMap<String, Long>
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
966
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
967 if (data != 0L) {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
968 dataArrayMap.put(name, data)
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
969 } else {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
970 dataArrayMap.remove(name)
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
971 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
972 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
973 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
974
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
975 fun windowGetData(window: View, name: String): Long {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
976 var retval = 0L
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
977
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
978 if (window.tag != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
979 val dataArrayMap: SimpleArrayMap<String, Long> = window.tag as SimpleArrayMap<String, Long>
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
980
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
981 if(dataArrayMap.containsKey(name)) {
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
982 retval = dataArrayMap.get(name)!!
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
983 }
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
984 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
985 return retval
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
986 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
987
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
988 fun windowSetEnabled(window: View, state: Boolean) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
989 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
990 window.setEnabled(state)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
991 }
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
992 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
993
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
994 fun typefaceFromFontName(fontname: String?): Typeface?
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
995 {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
996 if(fontname != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
997 val bold: Boolean = fontname.contains(" Bold")
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
998 val italic: Boolean = fontname.contains(" Italic")
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
999 val font = fontname.substringAfter('.')
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1000 var fontFamily = font
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
1001 val typeface: Typeface?
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1002
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1003 if (bold) {
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1004 fontFamily = font.substringBefore(" Bold")
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1005 } else if (italic) {
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1006 fontFamily = font.substringBefore(" Italic")
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1007 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1008
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1009 var style: Int = Typeface.NORMAL
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1010 if (bold && italic) {
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1011 style = Typeface.BOLD_ITALIC
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1012 } else if (bold) {
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1013 style = Typeface.BOLD
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1014 } else if (italic) {
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1015 style = Typeface.ITALIC
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1016 }
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1017 typeface = Typeface.create(fontFamily, style)
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1018
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1019 return typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1020 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1021 return Typeface.DEFAULT
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1022 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1023
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1024 fun windowSetFont(window: View, fontname: String?) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
1025 val typeface: Typeface? = typefaceFromFontName(fontname)
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1026 var size: Float? = null
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1027
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1028 if(fontname != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1029 size = fontname.substringBefore('.').toFloatOrNull()
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1030 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1031
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1032 if(typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1033 waitOnUiThread {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1034 if (window is TextView) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1035 val textview: TextView = window
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1036 textview.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1037 if(size != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1038 textview.textSize = size
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1039 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1040 } else if (window is Button) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1041 val button: Button = window
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1042 button.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1043 if(size != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1044 button.textSize = size
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1045 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1046 } else if(window is DWRender) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1047 val render: DWRender = window
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1048 render.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1049 if(size != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1050 render.fontsize = size
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1051 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1052 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1053 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1054 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1055 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1056
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1057 fun windowSetColor(window: View, fore: Int, falpha: Int, fred: Int, fgreen: Int, fblue: Int,
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1058 back: Int, balpha: Int, bred: Int, bgreen: Int, bblue: Int) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1059 var colorfore: Int = Color.rgb(fred, fgreen, fblue)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1060 var colorback: Int = Color.rgb(bred, bgreen, bblue)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1061
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1062 // DW_CLR_DEFAULT on background sets it transparent...
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1063 // so the background drawable shows through
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1064 if(back == 16) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1065 colorback = Color.TRANSPARENT
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1066 }
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1067
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1068 waitOnUiThread {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1069 if (window is TextView) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1070 val textview: TextView = window
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1071
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1072 // Handle DW_CLR_DEFAULT
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1073 if(fore == 16) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1074 val value = TypedValue()
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1075 this.theme.resolveAttribute(R.attr.editTextColor, value, true)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1076 colorfore = value.data
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1077 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1078 textview.setTextColor(colorfore)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1079 textview.setBackgroundColor(colorback)
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1080 } else if (window is Button) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1081 val button: Button = window
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1082
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1083 // Handle DW_CLR_DEFAULT
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1084 if(fore == 16) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1085 val value = TypedValue()
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1086 this.theme.resolveAttribute(R.attr.colorButtonNormal, value, true)
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1087 colorfore = value.data
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1088 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1089 button.setTextColor(colorfore)
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1090 button.setBackgroundColor(colorback)
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1091 } else if(window is LinearLayout) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1092 val box: LinearLayout = window
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1093
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2550
diff changeset
1094 box.setBackgroundColor(colorback)
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1095 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1096 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1097 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
1098
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1099 fun windowSetText(window: View, text: String) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1100 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1101 if (window is TextView) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1102 val textview: TextView = window
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1103 textview.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1104 } else if (window is Button) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1105 val button: Button = window
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1106 button.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1107 } else if (window is LinearLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1108 // TODO: Make sure this is actually the top-level layout, not just a box
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1109 this.title = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1110 }
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1111 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1112 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1113
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1114 fun windowGetText(window: View): String? {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1115 var text: String? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1116
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1117 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1118 if (window is TextView) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1119 val textview: TextView = window
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1120 text = textview.text.toString()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1121 } else if (window is Button) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1122 val button: Button = window
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1123 text = button.text.toString()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1124 } else if (window is LinearLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1125 // TODO: Make sure this is actually the top-level layout, not just a box
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1126 text = this.title.toString()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1127 }
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1128 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1129 return text
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1130 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1131
2503
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1132 fun windowHideShow(window: View, state: Int)
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1133 {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1134 waitOnUiThread {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1135 if(state == 0) {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1136 window.visibility = View.GONE
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1137 } else {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1138 window.visibility = View.VISIBLE
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1139 }
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1140 }
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1141 }
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
1142
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1143 fun clipboardGetText(): String {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1144 val cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1145 val clipdata = cm.primaryClip
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1146
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1147 if (clipdata != null && clipdata.itemCount > 0) {
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1148 return clipdata.getItemAt(0).coerceToText(this).toString()
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1149 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1150 return ""
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1151 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1152
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1153 fun clipboardSetText(text: String) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1154 val cm: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1155 val clipdata = ClipData.newPlainText("text", text)
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1156
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1157 cm.setPrimaryClip(clipdata)
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1158 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1159
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1160 fun boxNew(type: Int, pad: Int): LinearLayout? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1161 var box: LinearLayout? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1162 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1163 box = LinearLayout(this)
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1164 val dataArrayMap = SimpleArrayMap<String, Long>()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1165
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1166 box!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1167 box!!.layoutParams =
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1168 LinearLayout.LayoutParams(
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1169 LinearLayout.LayoutParams.WRAP_CONTENT,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1170 LinearLayout.LayoutParams.WRAP_CONTENT
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1171 )
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1172 if (type > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1173 box!!.orientation = LinearLayout.VERTICAL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1174 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1175 box!!.orientation = LinearLayout.HORIZONTAL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1176 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1177 box!!.setPadding(pad, pad, pad, pad)
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1178 }
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1179 return box
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1180 }
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1181
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1182 fun scrollBoxNew(type: Int, pad: Int) : ScrollView? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1183 var scrollBox: ScrollView? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1184
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1185 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1186 val box = LinearLayout(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1187 scrollBox = ScrollView(this)
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1188 val dataArrayMap = SimpleArrayMap<String, Long>()
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1189
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1190 scrollBox!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1191 box.layoutParams =
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1192 LinearLayout.LayoutParams(
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1193 LinearLayout.LayoutParams.MATCH_PARENT,
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1194 LinearLayout.LayoutParams.MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1195 )
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1196 if (type > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1197 box.orientation = LinearLayout.VERTICAL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1198 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1199 box.orientation = LinearLayout.HORIZONTAL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1200 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1201 box.setPadding(pad, pad, pad, pad)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1202 // Add a pointer back to the ScrollView
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1203 box.tag = scrollBox
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1204 scrollBox!!.addView(box)
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1205 }
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1206 return scrollBox
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1207 }
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1208
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1209 fun boxPack(
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1210 boxview: View,
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1211 item: View,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1212 index: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1213 width: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1214 height: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1215 hsize: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1216 vsize: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1217 pad: Int
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1218 ) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1219 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1220 var w: Int = LinearLayout.LayoutParams.WRAP_CONTENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1221 var h: Int = LinearLayout.LayoutParams.WRAP_CONTENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1222 var box: LinearLayout? = null
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1223
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1224 // Handle scrollboxes by pulling the LinearLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1225 // out of the ScrollView to pack into
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1226 if (boxview is LinearLayout) {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1227 box = boxview
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1228 } else if (boxview is ScrollView) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1229 val sv: ScrollView = boxview
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1230
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1231 if (sv.getChildAt(0) is LinearLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1232 box = sv.getChildAt(0) as LinearLayout
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1233 }
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1234 }
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1235
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1236 if (box != null) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
1237 var weight = 1F
2553
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1238
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1239 // If it is a box, match parent based on direction
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1240 if ((item is LinearLayout) || (item is ScrollView)) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1241 if (box.orientation == LinearLayout.VERTICAL) {
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1242 if (hsize != 0) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1243 w = LinearLayout.LayoutParams.MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1244 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1245 } else {
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1246 if (vsize != 0) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1247 h = LinearLayout.LayoutParams.MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1248 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1249 }
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1250 // If it isn't a box... set or calculate the size as needed
2553
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1251 } else {
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1252 if(width != -1 || height != -1) {
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1253 item.measure(0, 0)
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1254 }
2553
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1255 if(hsize == 0) {
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1256 if (width > 0) {
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1257 w = width
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1258 }
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1259 } else {
2575
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1260 if (box.orientation == LinearLayout.VERTICAL) {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1261 w = LinearLayout.LayoutParams.MATCH_PARENT
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1262 } else {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1263 if (width > 0) {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1264 weight = width.toFloat()
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1265 } else if (width == -1) {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1266 val newwidth = item.getMeasuredWidth()
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1267
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1268 if (newwidth > 0) {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1269 weight = newwidth.toFloat()
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1270 }
2553
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1271 }
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1272 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1273 }
2553
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1274 if(vsize == 0) {
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1275 if (height > 0) {
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1276 h = height
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1277 }
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1278 } else {
2575
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1279 if (box.orientation == LinearLayout.HORIZONTAL) {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1280 h = LinearLayout.LayoutParams.MATCH_PARENT
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1281 } else {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1282 if (height > 0) {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1283 weight = height.toFloat()
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1284 } else if (height == -1) {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1285 val newheight = item.getMeasuredHeight()
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1286
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1287 if (newheight > 0) {
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1288 weight = newheight.toFloat()
5beaaa4e9b03 Android: Improve the layout, if an item expands in the opposite direction of the box...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2574
diff changeset
1289 }
2553
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1290 }
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1291 }
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1292 }
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1293 }
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1294
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1295 val params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h)
2553
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1296
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1297 // Handle expandable items by giving them a weight...
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1298 // in the direction of the box.
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1299 if (box.orientation == LinearLayout.VERTICAL) {
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1300 if (vsize != 0) {
2553
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1301 params.weight = weight
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1302 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1303 } else {
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1304 if (hsize != 0) {
2553
2b4f2929408e Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2552
diff changeset
1305 params.weight = weight
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1306 }
2480
878d36588aaa Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2479
diff changeset
1307 }
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1308 // Gravity needs to match the expandable settings
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1309 val grav: Int = Gravity.CLIP_HORIZONTAL or Gravity.CLIP_VERTICAL
2552
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1310 if (hsize != 0 && vsize != 0) {
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1311 params.gravity = Gravity.FILL or grav
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1312 } else if (hsize != 0) {
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1313 params.gravity = Gravity.FILL_HORIZONTAL or grav
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1314 } else if (vsize != 0) {
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1315 params.gravity = Gravity.FILL_VERTICAL or grav
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1316 }
303f544d14fa Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
1317 // Finally add the padding
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1318 if (pad > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1319 params.setMargins(pad, pad, pad, pad)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1320 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1321 item.layoutParams = params
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1322 box.addView(item, index)
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1323 }
2478
b0230e378667 Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
1324 }
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1325 }
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1326
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1327 fun boxUnpack(item: View) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1328 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1329 val box: LinearLayout = item.parent as LinearLayout
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1330 box.removeView(item)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1331 }
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1332 }
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1333
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1334 fun boxUnpackAtIndex(box: LinearLayout, index: Int): View? {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1335 var item: View? = null
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1336
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1337 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1338 item = box.getChildAt(index)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1339
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1340 box.removeView(item)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1341 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1342 return item
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1343 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1344
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1345 fun buttonNew(text: String, cid: Int): Button? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1346 var button: Button? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1347 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1348 button = Button(this)
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1349 val dataArrayMap = SimpleArrayMap<String, Long>()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1350
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1351 button!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1352 button!!.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1353 button!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1354 button!!.setOnClickListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1355 eventHandlerSimple(button!!, 8)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1356 }
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
1357 }
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1358 return button
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1359 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1360
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1361 fun bitmapButtonNew(text: String, resid: Int): ImageButton? {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1362 var button: ImageButton? = null
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1363 waitOnUiThread {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1364 button = ImageButton(this)
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1365 val dataArrayMap = SimpleArrayMap<String, Long>()
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1366
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1367 button!!.tag = dataArrayMap
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1368 button!!.id = resid
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1369 button!!.setImageResource(resid)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1370 button!!.setOnClickListener {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1371 eventHandlerSimple(button!!, 8)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1372 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1373 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1374 return button
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1375 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1376
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1377 fun bitmapButtonNewFromFile(text: String, cid: Int, filename: String): ImageButton? {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1378 var button: ImageButton? = null
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1379 waitOnUiThread {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1380 button = ImageButton(this)
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1381 val dataArrayMap = SimpleArrayMap<String, Long>()
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1382 val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif")
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1383
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1384 button!!.tag = dataArrayMap
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1385 button!!.id = cid
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1386 button!!.setOnClickListener {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1387 eventHandlerSimple(button!!, 8)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1388 }
2564
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1389
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1390 for (ext in exts) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1391 // Try to load the image, and protect against exceptions
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1392 try {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1393 val f = this.assets.open(filename + ext)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1394 val b = BitmapFactory.decodeStream(f)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1395
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1396 if(b != null) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1397 button!!.setImageBitmap(b)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1398 break
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1399 }
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1400 } catch (e: IOException) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
1401 }
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1402 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1403 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1404 return button
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1405 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1406
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1407 fun bitmapButtonNewFromData(text: String, cid: Int, data: ByteArray, length: Int): ImageButton? {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1408 var button: ImageButton? = null
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1409 waitOnUiThread {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1410 button = ImageButton(this)
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1411 val dataArrayMap = SimpleArrayMap<String, Long>()
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1412 val b = BitmapFactory.decodeByteArray(data,0, length)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1413
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1414 button!!.tag = dataArrayMap
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1415 button!!.id = cid
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1416 button!!.setOnClickListener {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1417 eventHandlerSimple(button!!, 8)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1418 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1419 button!!.setImageBitmap(b)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1420 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1421 return button
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1422 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1423
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1424 fun entryfieldNew(text: String, cid: Int, password: Int): EditText? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1425 var entryfield: EditText? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1426
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1427 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1428 val dataArrayMap = SimpleArrayMap<String, Long>()
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1429 entryfield = EditText(this)
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1430
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1431 entryfield!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1432 entryfield!!.id = cid
2554
4c75fb6089a9 Android: Need to set isSingleLine for entryfields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2553
diff changeset
1433 entryfield!!.isSingleLine = true
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1434 if (password > 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1435 entryfield!!.transformationMethod = PasswordTransformationMethod.getInstance()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1436 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1437 entryfield!!.setText(text)
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1438 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1439 return entryfield
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1440 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1441
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1442 fun entryfieldSetLimit(entryfield: EditText, limit: Long) {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1443 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1444 entryfield.filters = arrayOf<InputFilter>(LengthFilter(limit.toInt()))
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1445 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1446 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1447
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1448 fun radioButtonNew(text: String, cid: Int): RadioButton? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1449 var radiobutton: RadioButton? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1450
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1451 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1452 val dataArrayMap = SimpleArrayMap<String, Long>()
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1453 radiobutton = RadioButton(this)
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1454
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1455 radiobutton!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1456 radiobutton!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1457 radiobutton!!.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1458 radiobutton!!.setOnClickListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1459 eventHandlerSimple(radiobutton!!, 8)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1460 }
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
1461 }
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1462 return radiobutton
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1463 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1464
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1465 fun checkboxNew(text: String, cid: Int): CheckBox? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1466 var checkbox: CheckBox? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1467
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1468 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1469 val dataArrayMap = SimpleArrayMap<String, Long>()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1470
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1471 checkbox = CheckBox(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1472 checkbox!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1473 checkbox!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1474 checkbox!!.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1475 checkbox!!.setOnClickListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1476 eventHandlerSimple(checkbox!!, 8)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1477 }
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
1478 }
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1479 return checkbox
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1480 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1481
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1482 fun checkOrRadioSetChecked(control: View, state: Int)
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1483 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1484 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1485 if (control is CheckBox) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1486 val checkbox: CheckBox = control
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1487 checkbox.isChecked = state != 0
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1488 } else if (control is RadioButton) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1489 val radiobutton: RadioButton = control
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1490 radiobutton.isChecked = state != 0
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1491 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1492 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1493 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1494
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1495 fun checkOrRadioGetChecked(control: View): Boolean
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1496 {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
1497 var retval = false
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1498
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1499 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1500 if (control is CheckBox) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1501 val checkbox: CheckBox = control
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1502 retval = checkbox.isChecked
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1503 } else if (control is RadioButton) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1504 val radiobutton: RadioButton = control
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1505 retval = radiobutton.isChecked
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1506 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1507 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1508 return retval
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1509 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1510
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1511 fun textNew(text: String, cid: Int, status: Int): TextView? {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1512 var textview: TextView? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1513
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1514 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1515 val dataArrayMap = SimpleArrayMap<String, Long>()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1516
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1517 textview = TextView(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1518 textview!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1519 textview!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1520 textview!!.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1521 if (status != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1522 val border = GradientDrawable()
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1523
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1524 // Set a black border on white background...
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1525 // might need to change this to invisible...
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1526 // or the color from windowSetColor
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1527 border.setColor(-0x1)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1528 border.setStroke(1, -0x1000000)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1529 textview!!.background = border
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1530 }
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1531 }
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1532 return textview
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1533 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1534
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1535 fun mleNew(cid: Int): EditText?
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1536 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1537 var mle: EditText? = null
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1538
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1539 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1540 val dataArrayMap = SimpleArrayMap<String, Long>()
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1541
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1542 mle = EditText(this)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1543 mle!!.tag = dataArrayMap
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1544 mle!!.id = cid
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1545 mle!!.isSingleLine = false
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1546 mle!!.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1547 mle!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1548 mle!!.isVerticalScrollBarEnabled = true
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1549 mle!!.scrollBarStyle = View.SCROLLBARS_INSIDE_INSET
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1550 mle!!.setHorizontallyScrolling(true)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1551 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1552 return mle
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1553 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1554
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1555 fun mleSetWordWrap(mle: EditText, state: Int)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1556 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1557 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1558 if (state != 0) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1559 mle.setHorizontallyScrolling(false)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1560 } else {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1561 mle.setHorizontallyScrolling(true)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1562 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1563 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1564 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1565
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1566 fun mleSetEditable(mle: EditText, state: Int)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1567 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1568 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1569 if (state != 0) {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1570 mle.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE)
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1571 } else {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
1572 mle.inputType = InputType.TYPE_NULL
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1573 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1574 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1575 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1576
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1577 fun mleSetCursor(mle: EditText, point: Int)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1578 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1579 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1580 mle.setSelection(point)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1581 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1582 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1583
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1584 fun mleClear(mle: EditText)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1585 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1586 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1587 mle.setText("")
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1588 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1589 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1590
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1591 fun mleImport(mle: EditText, text: String, startpoint: Int): Int
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1592 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1593 var retval: Int = startpoint
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1594
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1595 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1596 val origtext = mle.text
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1597 val origlen = origtext.toString().length
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1598
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1599 if(startpoint < 1) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1600 val newtext = text + origtext.toString()
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1601
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1602 mle.setText(newtext)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1603 retval = origlen + text.length
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1604 } else if(startpoint >= origlen) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1605 val newtext = origtext.toString() + text
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1606
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1607 mle.setText(newtext)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1608 retval = origlen + text.length
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1609 } else {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1610 val newtext = origtext.substring(0, startpoint) + text + origtext.substring(startpoint)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1611
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1612 mle.setText(newtext)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1613 retval = startpoint + text.length
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1614 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1615 mle.setSelection(retval)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1616 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1617 return retval
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1618 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1619
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1620 fun mleDelete(mle: EditText, startpoint: Int, length: Int)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1621 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1622 waitOnUiThread {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1623 val origtext = mle.text
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1624 val newtext = origtext.substring(0, startpoint) + origtext.substring(startpoint + length)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1625
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1626 mle.setText(newtext)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1627 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1628 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1629
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1630 fun notebookNew(cid: Int, top: Int): RelativeLayout?
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1631 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1632 var notebook: RelativeLayout? = null
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1633
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1634 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1635 val pager = ViewPager2(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1636 val tabs = TabLayout(this)
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1637 val w: Int = RelativeLayout.LayoutParams.MATCH_PARENT
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1638 val h: Int = RelativeLayout.LayoutParams.WRAP_CONTENT
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1639 val dataArrayMap = SimpleArrayMap<String, Long>()
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1640
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1641 notebook = RelativeLayout(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1642 notebook!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1643 notebook!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1644 tabs.id = View.generateViewId()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1645 pager.id = View.generateViewId()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1646 pager.adapter = DWTabViewPagerAdapter()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1647 TabLayoutMediator(tabs, pager) { tab, position ->
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1648 // This code never gets called?
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1649 }.attach()
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1650
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1651 var params: RelativeLayout.LayoutParams = RelativeLayout.LayoutParams(w, h)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1652 if (top != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1653 params.addRule(RelativeLayout.ALIGN_PARENT_TOP)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1654 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1655 params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1656 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1657 tabs.tabGravity = TabLayout.GRAVITY_FILL
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1658 tabs.tabMode = TabLayout.MODE_FIXED
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1659 notebook!!.addView(tabs, params)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1660 params = RelativeLayout.LayoutParams(w, w)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1661 if (top != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1662 params.addRule(RelativeLayout.BELOW, tabs.id)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1663 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1664 params.addRule(RelativeLayout.ABOVE, tabs.id)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1665 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1666 notebook!!.addView(pager, params)
2550
a8d90e2896bc Android: For the moment disable swiping to change notebook pages.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2547
diff changeset
1667 // TODO: Not sure if we want this all the time...
a8d90e2896bc Android: For the moment disable swiping to change notebook pages.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2547
diff changeset
1668 // Might want to make a flag for this
a8d90e2896bc Android: For the moment disable swiping to change notebook pages.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2547
diff changeset
1669 pager.isUserInputEnabled = false
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1670 tabs.addOnTabSelectedListener(object : OnTabSelectedListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1671 override fun onTabSelected(tab: TabLayout.Tab) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1672 val adapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1673
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1674 pager.currentItem = tab.position
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1675 eventHandlerNotebook(notebook!!, 15, adapter.pageList[tab.position])
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1676 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1677
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1678 override fun onTabUnselected(tab: TabLayout.Tab) {}
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1679 override fun onTabReselected(tab: TabLayout.Tab) {}
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1680 })
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1681 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1682 return notebook
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1683 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1684
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1685 fun notebookPageNew(notebook: RelativeLayout, flags: Long, front: Int): Long
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1686 {
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1687 var pageID = 0L
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1688
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1689 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1690 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1691 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1692
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1693 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1694 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1695 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1696 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1697 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1698 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1699 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1700
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1701 if (pager != null && tabs != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1702 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1703 val tab = tabs.newTab()
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1704
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1705 // Increment our page ID... making sure no duplicates exist
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1706 do {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1707 adapter.currentPageID += 1
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1708 } while (adapter.currentPageID == 0L || adapter.pageList.contains(adapter.currentPageID))
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1709 pageID = adapter.currentPageID
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1710 // Temporarily add a black tab with an empty layout/box
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1711 if (front != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1712 adapter.viewList.add(0, LinearLayout(this))
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1713 adapter.pageList.add(0, pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1714 tabs.addTab(tab, 0)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1715 } else {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1716 adapter.viewList.add(LinearLayout(this))
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1717 adapter.pageList.add(pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1718 tabs.addTab(tab)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1719 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1720 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1721 }
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1722 return pageID
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1723 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1724
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1725 fun notebookPageDestroy(notebook: RelativeLayout, pageID: Long)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1726 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1727 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1728 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1729 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1730
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1731 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1732 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1733 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1734 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1735 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1736 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1737 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1738
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1739 if (pager != null && tabs != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1740 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1741 val index = adapter.pageList.indexOf(pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1742 val tab = tabs.getTabAt(index)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1743
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1744 if (tab != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1745 adapter.viewList.removeAt(index)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1746 adapter.pageList.removeAt(index)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1747 tabs.removeTab(tab)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1748 }
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1749 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1750 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1751 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1752
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1753 fun notebookPageSetText(notebook: RelativeLayout, pageID: Long, text: String)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1754 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1755 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1756 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1757 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1758
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1759 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1760 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1761 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1762 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1763 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1764 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1765 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1766
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1767 if (pager != null && tabs != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1768 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1769 val index = adapter.pageList.indexOf(pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1770 val tab = tabs.getTabAt(index)
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1771
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1772 if (tab != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1773 tab.text = text
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1774 }
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1775 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1776 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1777 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1778
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1779 fun notebookPagePack(notebook: RelativeLayout, pageID: Long, box: LinearLayout)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1780 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1781 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1782 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1783 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1784
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1785 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1786 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1787 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1788 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1789 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1790 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1791 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1792
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1793 if (pager != null && tabs != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1794 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1795 val index = adapter.pageList.indexOf(pageID)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1796
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1797 // Make sure the box is MATCH_PARENT
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1798 box.layoutParams = LinearLayout.LayoutParams(
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1799 LinearLayout.LayoutParams.MATCH_PARENT,
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1800 LinearLayout.LayoutParams.MATCH_PARENT
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
1801 )
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1802
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1803 adapter.viewList[index] = box
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1804 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1805 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1806 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1807
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1808 fun notebookPageGet(notebook: RelativeLayout): Long
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1809 {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
1810 var retval = 0L
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1811
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1812 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1813 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1814 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1815
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1816 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1817 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1818 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1819 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1820 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1821 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1822 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1823
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1824 if (pager != null && tabs != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1825 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1826 retval = adapter.pageList.get(tabs.selectedTabPosition)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1827 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1828 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1829 return retval
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1830 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1831
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1832 fun notebookPageSet(notebook: RelativeLayout, pageID: Long)
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1833 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1834 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1835 var pager: ViewPager2? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1836 var tabs: TabLayout? = null
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1837
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1838 if (notebook.getChildAt(0) is ViewPager2 && notebook.getChildAt(1) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1839 pager = notebook.getChildAt(0) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1840 tabs = notebook.getChildAt(1) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1841 } else if (notebook.getChildAt(1) is ViewPager2 && notebook.getChildAt(0) is TabLayout) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1842 pager = notebook.getChildAt(1) as ViewPager2
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1843 tabs = notebook.getChildAt(0) as TabLayout
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1844 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1845
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1846 if (pager != null && tabs != null) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1847 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1848 val index = adapter.pageList.indexOf(pageID)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1849 val tab = tabs.getTabAt(index)
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
1850
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1851 tabs.selectTab(tab)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1852 }
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
1853 }
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1854 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
1855
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1856 fun sliderNew(vertical: Int, increments: Int, cid: Int): SeekBar?
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1857 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1858 var slider: SeekBar? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1859
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1860 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1861 val dataArrayMap = SimpleArrayMap<String, Long>()
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1862
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1863 slider = SeekBar(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1864 slider!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1865 slider!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1866 slider!!.max = increments
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1867 if (vertical != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1868 slider!!.rotation = 270F
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1869 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1870 slider!!.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1871 override fun onStopTrackingTouch(seekBar: SeekBar) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1872 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1873
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1874 override fun onStartTrackingTouch(seekBar: SeekBar) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1875 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1876
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1877 override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1878 eventHandlerInt(slider as View, 14, slider!!.progress, 0, 0, 0)
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1879 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1880 })
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1881 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1882 return slider
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1883 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1884
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1885 fun percentNew(cid: Int): ProgressBar?
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1886 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1887 var percent: ProgressBar? = null
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1888
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1889 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1890 val dataArrayMap = SimpleArrayMap<String, Long>()
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1891
2574
5b13bb267364 Android: Percent widget should be using horizontal ProgressBar.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2573
diff changeset
1892 percent = ProgressBar(this,null, R.attr.progressBarStyleHorizontal)
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1893 percent!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1894 percent!!.id = cid
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1895 percent!!.max = 100
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1896 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1897 return percent
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1898 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1899
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1900 fun percentGetPos(percent: ProgressBar): Int
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1901 {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
1902 var retval = 0
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1903
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1904 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1905 retval = percent.progress
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1906 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1907 return retval
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1908 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1909
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1910 fun percentSetPos(percent: ProgressBar, position: Int)
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1911 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1912 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1913 percent.progress = position
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1914 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1915 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1916
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1917 fun percentSetRange(percent: ProgressBar, range: Int)
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1918 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1919 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1920 percent.max = range
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1921 }
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1922 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2491
diff changeset
1923
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1924 fun htmlNew(cid: Int): WebView?
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1925 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1926 var html: WebView? = null
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1927
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1928 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
1929 val dataArrayMap = SimpleArrayMap<String, Long>()
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1930
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1931 html = WebView(this)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1932 html!!.tag = dataArrayMap
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1933 html!!.id = cid
2505
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
1934 // Configure a few settings to make it behave as we expect
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
1935 html!!.webViewClient = DWWebViewClient()
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
1936 html!!.settings.javaScriptEnabled = true
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1937 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1938 return html
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1939 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1940
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1941 fun htmlLoadURL(html: WebView, url: String)
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1942 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1943 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1944 html.loadUrl(url)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1945 }
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1946 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1947
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1948 fun htmlRaw(html: WebView, data: String)
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1949 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1950 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1951 val encodedHtml: String = Base64.encodeToString(data.toByteArray(), Base64.NO_PADDING)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1952 html.loadData(encodedHtml, "text/html", "base64")
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1953 }
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1954 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1955
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1956 fun htmlJavascriptRun(html: WebView, javascript: String, data: Long)
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1957 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1958 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1959 html.evaluateJavascript(javascript) { value ->
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1960 // Execute onReceiveValue's code
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1961 eventHandlerHTMLResult(html, 18, value, data)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1962 }
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1963 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1964 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1965
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1966 fun htmlAction(html: WebView, action: Int)
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1967 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1968 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1969 when (action) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1970 0 -> html.goBack()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1971 1 -> html.goForward()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1972 2 -> html.loadUrl("http://dwindows.netlabs.org")
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1973 4 -> html.reload()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1974 5 -> html.stopLoading()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
1975 }
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1976 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1977 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1978
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1979 fun spinButtonNew(text: String, cid: Int): DWSpinButton?
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1980 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1981 var spinbutton: DWSpinButton? = null
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1982
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1983 waitOnUiThread {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
1984 val dataArrayMap = SimpleArrayMap<String, Long>()
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1985 val newval = text.toLongOrNull()
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1986
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1987 spinbutton = DWSpinButton(this)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1988 spinbutton!!.tag = dataArrayMap
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1989 spinbutton!!.id = cid
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1990 spinbutton!!.setText(text)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1991 if(newval != null) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1992 spinbutton!!.value = newval
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1993 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1994 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1995 return spinbutton
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1996 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1997
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1998 fun spinButtonSetPos(spinbutton: DWSpinButton, position: Long)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1999 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2000 waitOnUiThread {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2001 spinbutton.value = position
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2002 spinbutton.setText(position.toString())
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2003 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2004 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2005
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2006 fun spinButtonSetLimits(spinbutton: DWSpinButton, upper: Long, lower: Long)
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2007 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2008 waitOnUiThread {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2009 spinbutton.maximum = upper
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2010 spinbutton.minimum = lower
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2011 if(spinbutton.value > upper) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2012 spinbutton.value = upper
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2013 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2014 if(spinbutton.value < lower) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2015 spinbutton.value = lower
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2016 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2017 spinbutton.setText(spinbutton.value.toString())
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2018 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2019 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2020
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2021 fun spinButtonGetPos(spinbutton: DWSpinButton): Long
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2022 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2023 var retval: Long = 0
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2024
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2025 waitOnUiThread {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2026 val newvalue = spinbutton.text.toString().toLongOrNull()
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2027
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2028 if(newvalue == null) {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2029 retval = spinbutton.value
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2030 } else {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2031 retval = newvalue
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2032 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2033 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2034 return retval
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2035 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
2036
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2037 fun comboBoxNew(text: String, cid: Int): DWComboBox?
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2038 {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2039 var combobox: DWComboBox? = null
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2040
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2041 waitOnUiThread {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2042 val dataArrayMap = SimpleArrayMap<String, Long>()
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2043
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2044 combobox = DWComboBox(this)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2045 combobox!!.tag = dataArrayMap
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2046 combobox!!.id = cid
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2047 combobox!!.setText(text)
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2048 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2049 return combobox
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2050 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2051
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2052 fun containerNew(cid: Int, multi: Int): ListView?
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2053 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2054 var cont: ListView? = null
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2055
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2056 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2057 val dataArrayMap = SimpleArrayMap<String, Long>()
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2058 val adapter = DWContainerAdapter(this)
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2059
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2060 cont = ListView(this)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2061 cont!!.tag = dataArrayMap
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2062 cont!!.id = cid
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2063 cont!!.adapter = adapter
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2064 if(multi != 0) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2065 cont!!.choiceMode = ListView.CHOICE_MODE_MULTIPLE
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2066 }
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2067 cont!!.setOnItemClickListener { parent, view, position, id ->
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2068 val title = adapter.model.getRowTitle(position)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2069 val data = adapter.model.getRowData(position)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2070
2563
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2071 view.isSelected = !view.isSelected
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2072 adapter.selectedItem = position
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2073 eventHandlerContainer(cont!!, 12, title, 0, 0, data)
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2074 }
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2075 cont!!.setOnContextClickListener {
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2076 if(adapter.selectedItem > -1 && adapter.selectedItem < adapter.model.numberOfRows()) {
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2077 val title = adapter.model.getRowTitle(adapter.selectedItem)
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2078 val data = adapter.model.getRowData(adapter.selectedItem)
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2079
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2080 eventHandlerContainer(cont!!, 10, title, 0, 0, data)
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2081 }
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2082 true
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2083 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2084 cont!!.setOnItemLongClickListener { parent, view, position, id ->
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2085 val title = adapter.model.getRowTitle(position)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2086 val data = adapter.model.getRowData(position)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2087
2563
56183bef6793 Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2562
diff changeset
2088 eventHandlerContainer(cont!!, 9, title, 0, 0, data)
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2089 true
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2090 }
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2091 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2092 return cont
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2093 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2094
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2095 fun containerSetStripe(cont: ListView, oddcolor: Long, evencolor: Long)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2096 {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2097 waitOnUiThread {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2098 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2099
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2100 if(oddcolor == -1L) {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2101 adapter.oddColor = null
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2102 } else if(evencolor == -2L) {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2103 if(darkMode == 1) {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2104 adapter.oddColor = Color.rgb(100, 100, 100)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2105 } else {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2106 adapter.oddColor = Color.rgb(230, 230, 230)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2107 }
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2108 } else {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2109 adapter.oddColor = colorFromDW(oddcolor)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2110 }
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2111 if(evencolor == -1L || evencolor == -2L) {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2112 adapter.evenColor = null
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2113 } else {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2114 adapter.evenColor = colorFromDW(evencolor)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2115 }
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2116 }
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2117 }
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2118
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2119 fun containerGetTitleStart(cont: ListView, flags: Int): String?
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2120 {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2121 var retval: String? = null
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2122
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2123 waitOnUiThread {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2124 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2125
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2126 // Handle DW_CRA_SELECTED
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2127 if((flags and 1) != 0) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2128 val checked: SparseBooleanArray = cont.getCheckedItemPositions()
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2129 val position = checked.keyAt(0)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2130
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2131 adapter.model.querypos = position
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2132 retval = adapter.model.getRowTitle(position)
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2133 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2134 if(adapter.model.rowdata.size == 0) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2135 adapter.model.querypos = -1
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2136 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2137 retval = adapter.model.getRowTitle(0)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2138 adapter.model.querypos = 0
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2139 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2140 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2141 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2142 return retval
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2143 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2144
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2145 fun containerGetTitleNext(cont: ListView, flags: Int): String?
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2146 {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2147 var retval: String? = null
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2148
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2149 waitOnUiThread {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2150 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2151
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2152 if(adapter.model.querypos != -1) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2153 // Handle DW_CRA_SELECTED
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2154 if ((flags and 1) != 0) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2155 val checked: SparseBooleanArray = cont.getCheckedItemPositions()
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2156
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2157 // Otherwise loop until we find our current place
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2158 for (i in 0 until checked.size()) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2159 // Item position in adapter
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2160 val position: Int = checked.keyAt(i)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2161
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2162 if (adapter.model.querypos == position && (i + 1) < checked.size()) {
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2163 val newpos = checked.keyAt(i + 1)
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2164
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2165 adapter.model.querypos = newpos
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2166 retval = adapter.model.getRowTitle(newpos)
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2167 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2168 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2169 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2170 if (adapter.model.rowtitle.size > adapter.model.querypos) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2171 adapter.model.querypos += 1
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2172 retval = adapter.model.getRowTitle(adapter.model.querypos)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2173 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2174 adapter.model.querypos = -1
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2175 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2176 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2177 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2178 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2179 return retval
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2180 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2181
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2182 fun containerGetDataStart(cont: ListView, flags: Int): Long
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2183 {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2184 var retval: Long = 0
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2185
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2186 waitOnUiThread {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2187 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2188
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2189 // Handle DW_CRA_SELECTED
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2190 if((flags and 1) != 0) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2191 val checked: SparseBooleanArray = cont.getCheckedItemPositions()
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2192 val position = checked.keyAt(0)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2193
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2194 adapter.model.querypos = position
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2195 retval = adapter.model.getRowData(position)
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2196 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2197 if(adapter.model.rowdata.size == 0) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2198 adapter.model.querypos = -1
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2199 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2200 retval = adapter.model.getRowData(0)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2201 adapter.model.querypos = 0
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2202 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2203 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2204 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2205 return retval
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2206 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2207
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2208 fun containerGetDataNext(cont: ListView, flags: Int): Long
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2209 {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2210 var retval: Long = 0
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2211
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2212 waitOnUiThread {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2213 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2214
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2215 if(adapter.model.querypos != -1) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2216 // Handle DW_CRA_SELECTED
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2217 if ((flags and 1) != 0) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2218 val checked: SparseBooleanArray = cont.getCheckedItemPositions()
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2219
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2220 // Otherwise loop until we find our current place
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2221 for (i in 0 until checked.size()) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2222 // Item position in adapter
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2223 val position: Int = checked.keyAt(i)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2224
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2225 if (adapter.model.querypos == position && (i + 1) < checked.size()) {
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2226 val newpos = checked.keyAt(i + 1)
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2227
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2228 adapter.model.querypos = newpos
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2229 retval = adapter.model.getRowData(newpos)
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2230 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2231 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2232 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2233 if (adapter.model.rowdata.size > adapter.model.querypos) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2234 adapter.model.querypos += 1
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2235 retval = adapter.model.getRowData(adapter.model.querypos)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2236 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2237 adapter.model.querypos = -1
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2238 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2239 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2240 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2241 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2242 return retval
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2243 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
2244
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2245 fun containerAddColumn(cont: ListView, title: String, flags: Int)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2246 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2247 waitOnUiThread {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2248 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2249
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2250 adapter.model.addColumn(title, flags)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2251 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2252 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2253
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2254 fun containerAlloc(cont: ListView, rowcount: Int): ListView
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2255 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2256 waitOnUiThread {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2257 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2258 val rowStart = adapter.model.addRows(rowcount)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2259
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2260 windowSetData(cont, "_dw_rowstart", rowStart)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2261 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2262 return cont
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2263 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2264
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2265 fun containerChangeItemString(cont: ListView, column: Int, row: Int, text: String)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2266 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2267 waitOnUiThread {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2268 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2269
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2270 adapter.model.setRowAndColumn(row, column, text)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2271 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2272 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2273
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2274 fun containerChangeItemIcon(cont: ListView, column: Int, row: Int, icon: Drawable)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2275 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2276 waitOnUiThread {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2277 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2278
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2279 adapter.model.setRowAndColumn(row, column, icon)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2280 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2281 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2282
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2283 fun containerChangeItemInt(cont: ListView, column: Int, row: Int, num: Int)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2284 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2285 waitOnUiThread {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2286 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2287
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2288 adapter.model.setRowAndColumn(row, column, num)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2289 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2290 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2291
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2292 fun containerChangeRowData(cont: ListView, row: Int, data: Long)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2293 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2294 waitOnUiThread {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2295 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2296
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2297 adapter.model.changeRowData(row, data)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2298 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2299 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2300
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2301 fun containerChangeRowTitle(cont: ListView, row: Int, title: String?)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2302 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2303 waitOnUiThread {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2304 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2305
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2306 adapter.model.changeRowTitle(row, title)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2307 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2308 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2309
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
2310 fun containerRefresh(cont: ListView)
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
2311 {
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
2312 waitOnUiThread {
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
2313 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
2314
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
2315 adapter.notifyDataSetChanged()
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
2316 }
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
2317 }
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
2318
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2319 fun containerGetColumnType(cont: ListView, column: Int): Int
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2320 {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2321 var type = 0
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2322
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2323 waitOnUiThread {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2324 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2325
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2326 type = adapter.model.getColumnType(column)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2327 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2328 return type
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2329 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2330
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2331 fun containerDelete(cont: ListView, rowcount: Int)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2332 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2333 waitOnUiThread {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2334 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2335
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2336 adapter.model.deleteRows(rowcount)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2337 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2338 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2339
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2340 fun containerRowDeleteByTitle(cont: ListView, title: String?)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2341 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2342 waitOnUiThread {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2343 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2344
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2345 adapter.model.deleteRowByTitle(title)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2346 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2347 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2348
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2349 fun containerRowDeleteByData(cont: ListView, data: Long)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2350 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2351 waitOnUiThread {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2352 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2353
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2354 adapter.model.deleteRowByData(data)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2355 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2356 }
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
2357
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2358 fun containerClear(cont: ListView)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2359 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2360 waitOnUiThread {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2361 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2362
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2363 adapter.model.clear()
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2364 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2365 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2555
diff changeset
2366
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2367 fun listBoxNew(cid: Int, multi: Int): DWListBox?
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2368 {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2369 var listbox: DWListBox? = null
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2370
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2371 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2372 val dataArrayMap = SimpleArrayMap<String, Long>()
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2373
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2374 listbox = DWListBox(this)
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2375 listbox!!.tag = dataArrayMap
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2376 listbox!!.id = cid
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2377 if(multi != 0) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2378 listbox!!.choiceMode = ListView.CHOICE_MODE_MULTIPLE
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2379 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2380 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2381 return listbox
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2382 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2383
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2384 fun listOrComboBoxAppend(window: View, text: String)
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2385 {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2386 waitOnUiThread {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2387 if(window is DWComboBox) {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2388 val combobox = window
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2389
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2390 combobox.list.add(text)
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2391 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2392 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2393
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2394 listbox.list.add(text)
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2395 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2396 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2397 }
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2398
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2399 fun listOrComboBoxInsert(window: View, text: String, pos: Int)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2400 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2401 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2402 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2403 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2404
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2405 combobox.list.add(pos, text)
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2406 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2407 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2408
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2409 listbox.list.add(pos, text)
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2410 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2411 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2412 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2413
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2414 fun listOrComboBoxClear(window: View)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2415 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2416 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2417 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2418 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2419
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2420 combobox.list.clear()
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2421 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2422 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2423
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2424 listbox.list.clear()
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2425 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2426 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2427 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2428
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2429 fun listOrComboBoxCount(window: View): Int
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2430 {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2431 var retval = 0
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2432
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2433 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2434 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2435 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2436
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2437 retval = combobox.list.count()
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2438 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2439 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2440
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2441 retval = listbox.list.count()
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2442 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2443 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2444 return retval
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2445 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2446
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2447 fun listOrComboBoxSetText(window: View, index: Int, text: String)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2448 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2449 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2450 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2451 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2452
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2453 if(index > -1 && index < combobox.list.count())
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2454 combobox.list[index] = text
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2455 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2456 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2457
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2458 if(index > -1 && index < listbox.list.count())
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2459 listbox.list[index] = text
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2460 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2461 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2462 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2463
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2464 fun listOrComboBoxGetText(window: View, index: Int): String?
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2465 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2466 var retval: String? = null
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2467
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2468 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2469 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2470 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2471
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2472 if(index > -1 && index < combobox.list.count())
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2473 retval = combobox.list[index]
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2474 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2475 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2476
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2477 if(index > -1 && index < listbox.list.count())
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2478 retval = listbox.list[index]
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2479 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2480 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2481 return retval
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2482 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2483
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2484 fun listOrComboBoxGetSelected(window: View): Int
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2485 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2486 var retval: Int = -1
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2487
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2488 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2489 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2490 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2491
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2492 retval = combobox.selected
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2493 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2494 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2495
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2496 retval = listbox.selected
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2497 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2498 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2499 return retval
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2500 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2501
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2502 fun listOrComboBoxSelect(window: View, index: Int, state: Int)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2503 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2504 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2505 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2506 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2507
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2508 if(index < combobox.list.count() && state != 0) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2509 combobox.selected = index
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2510 combobox.setText(combobox.list[index])
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2511 }
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2512 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2513 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2514
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2515 if(index < listbox.list.count()) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2516 if(state != 0) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2517 listbox.selected = index
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2518 listbox.setItemChecked(index, true)
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2519 } else {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2520 listbox.setItemChecked(index, false)
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2521 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2522 }
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2523 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2524 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2525 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2526
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2527 fun listOrComboBoxDelete(window: View, index: Int)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2528 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2529 waitOnUiThread {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2530 if(window is DWComboBox) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2531 val combobox = window
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2532
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2533 if(index < combobox.list.count()) {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2534 combobox.list.removeAt(index)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2535 }
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2536 } else if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2537 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2538
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2539 if(index < listbox.list.count()) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2540 listbox.list.removeAt(index)
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2541 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2542 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2543 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2544 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2545
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2546 fun listBoxSetTop(window: View, top: Int)
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2547 {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2548 waitOnUiThread {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2549 if(window is DWListBox) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2550 val listbox = window
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2551
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2552 if(top < listbox.list.count()) {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2553 listbox.smoothScrollToPosition(top)
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
2554 }
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2555 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2556 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2557 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2516
diff changeset
2558
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2559 fun listBoxSelectedMulti(window: View, where: Int): Int
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2560 {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2561 var retval: Int = -1
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2562
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2563 waitOnUiThread {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2564 if(window is DWListBox) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2565 val listbox = window
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2566 val checked: SparseBooleanArray = listbox.getCheckedItemPositions()
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2567
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2568 // If we are starting over....
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2569 if(where == -1 && checked.size() > 0) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2570 retval = checked.keyAt(0)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2571 } else {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2572 // Otherwise loop until we find our current place
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2573 for (i in 0 until checked.size()) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2574 // Item position in adapter
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2575 val position: Int = checked.keyAt(i)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2576 // If we are at our current point... check to see
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2577 // if there is another one, and return it...
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2578 // otherwise we will return -1 to indicated we are done.
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2579 if (where == position && (i+1) < checked.size()) {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2580 retval = checked.keyAt(i+1)
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2581 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2582 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2583 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2584 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2585 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2586 return retval
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2587 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2588
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2589 fun calendarNew(cid: Int): CalendarView?
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2590 {
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2591 var calendar: CalendarView? = null
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2592
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2593 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2594 val dataArrayMap = SimpleArrayMap<String, Long>()
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2595
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2596 calendar = CalendarView(this)
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2597 calendar!!.tag = dataArrayMap
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2598 calendar!!.id = cid
2524
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2599 calendar!!.setOnDateChangeListener { calendar, year, month, day ->
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2600 val c: Calendar = Calendar.getInstance()
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2601 c.set(year, month, day)
2524
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2602 calendar.date = c.timeInMillis
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2603 }
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2604 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2605
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2606 return calendar
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2607 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2608
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2609 fun calendarSetDate(calendar: CalendarView, date: Long)
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2610 {
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2611 waitOnUiThread {
2524
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2612 // Convert from seconds to milliseconds
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2613 calendar.setDate(date * 1000, true, true)
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2614 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2615 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2616
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2617 fun calendarGetDate(calendar: CalendarView): Long
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2618 {
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2619 var date: Long = 0
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2620
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2621 waitOnUiThread {
2524
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2622 // Convert from milliseconds to seconds
d5c3c573c74e Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2623 date = calendar.date / 1000
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2624 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2625 return date
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2626 }
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
2627
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2628 fun bitmapNew(cid: Int): ImageView?
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2629 {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2630 var imageview: ImageView? = null
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2631
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2632 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2633 val dataArrayMap = SimpleArrayMap<String, Long>()
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2634
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2635 imageview = ImageView(this)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2636 imageview!!.tag = dataArrayMap
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2637 imageview!!.id = cid
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2638 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2639
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2640 return imageview
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2641 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2642
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2643 fun windowSetBitmap(window: View, resID: Int, filename: String?)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2644 {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2645 waitOnUiThread {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2646 if(resID != 0) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2647 if(window is ImageButton) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2648 val button = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2649
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2650 button.setImageResource(resID)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2651 } else if(window is ImageView) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2652 val imageview = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2653
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2654 imageview.setImageResource(resID)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2655 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2656 } else if(filename != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2657 val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif")
2564
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2658
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2659 for (ext in exts) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2660 // Try to load the image, and protect against exceptions
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2661 try {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2662 val f = this.assets.open(filename + ext)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2663 val b = BitmapFactory.decodeStream(f)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2664
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2665 if(b != null) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2666 if (window is ImageButton) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2667 val button = window
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2668
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2669 button.setImageBitmap(b)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2670 } else if (window is ImageView) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2671 val imageview = window
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2672
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2673 imageview.setImageBitmap(b)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2674 }
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2675 break
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2676 }
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2677 } catch (e: IOException) {
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2678 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2679 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2680 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2681 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2682 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2683
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2684 fun windowSetBitmapFromData(window: View, resID: Int, data: ByteArray?, length: Int)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2685 {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2686 waitOnUiThread {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2687 if(resID != 0) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2688 if (window is ImageButton) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2689 val button = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2690
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2691 button.setImageResource(resID)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2692 } else if (window is ImageView) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2693 val imageview = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2694
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2695 imageview.setImageResource(resID)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2696 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2697 } else if(data != null) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2698 val b = BitmapFactory.decodeByteArray(data, 0, length)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2699
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2700 if (window is ImageButton) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2701 val button = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2702
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2703 button.setImageBitmap(b)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2704 } else if (window is ImageView) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2705 val imageview = window
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2706
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2707 imageview.setImageBitmap(b)
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2708 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2709 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2710 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2711 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2527
diff changeset
2712
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2713 fun iconNew(filename: String?, data: ByteArray?, length: Int, resID: Int): Drawable?
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2714 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2715 var icon: Drawable? = null
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2716
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2717 waitOnUiThread {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2718 if(resID != 0) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2719 icon = ResourcesCompat.getDrawable(resources, resID, null)
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2720 } else if(filename != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2721 val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif")
2564
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2722
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2723 for (ext in exts) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2724 // Try to load the image, and protect against exceptions
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2725 try {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2726 val f = this.assets.open(filename + ext)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2727 icon = Drawable.createFromStream(f, null)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2728 } catch (e: IOException) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2729 }
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2730 if(icon != null) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2731 break
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2732 }
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2733
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2734 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2735 } else if(data != null) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2736 icon = BitmapDrawable(resources, BitmapFactory.decodeByteArray(data, 0, length))
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2737 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2738 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2739 return icon
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2740 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2741
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2742 fun pixmapNew(width: Int, height: Int, filename: String?, data: ByteArray?, length: Int, resID: Int): Bitmap?
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2743 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2744 var pixmap: Bitmap? = null
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2745
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2746 waitOnUiThread {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2747 if(width > 0 && height > 0) {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2748 pixmap = Bitmap.createBitmap(null, width, height, Bitmap.Config.ARGB_8888)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2749 } else if(resID != 0) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2750 pixmap = BitmapFactory.decodeResource(resources, resID)
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2751 } else if(filename != null) {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2752 val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif")
2564
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2753
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2754 for (ext in exts) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2755 // Try to load the image, and protect against exceptions
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2756 try {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2757 val f = this.assets.open(filename + ext)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2758 pixmap = BitmapFactory.decodeStream(f)
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2759 } catch (e: IOException) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2760 }
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2761 if(pixmap != null) {
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2762 break
607acfe2c504 Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2563
diff changeset
2763 }
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2764 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2765 } else if(data != null) {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2766 pixmap = BitmapFactory.decodeByteArray(data, 0, length)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2767 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2768 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2769 return pixmap
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2770 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2771
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2772 fun pixmapGetDimensions(pixmap: Bitmap): Long
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2773 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2774 var dimensions: Long = 0
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2775
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2776 waitOnUiThread {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2777 dimensions = pixmap.width.toLong() or (pixmap.height.toLong() shl 32)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2778 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2779 return dimensions
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2780 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2781
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2782 fun screenGetDimensions(): Long
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2783 {
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2784 val dm = resources.displayMetrics
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2785 return dm.widthPixels.toLong() or (dm.heightPixels.toLong() shl 32)
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2786 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
2787
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2788 fun renderNew(cid: Int): DWRender?
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2789 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2790 var render: DWRender? = null
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2791
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2792 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2793 val dataArrayMap = SimpleArrayMap<String, Long>()
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2794
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2795 render = DWRender(this)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2796 render!!.tag = dataArrayMap
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2797 render!!.id = cid
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2798 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2799 return render
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2800 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2801
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2802 fun renderRedraw(render: DWRender)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2803 {
2539
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2538
diff changeset
2804 runOnUiThread {
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2538
diff changeset
2805 render.invalidate()
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2538
diff changeset
2806 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2807 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2808
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2809 fun pixmapBitBlt(dstr: DWRender?, dstp: Bitmap?, dstx: Int, dsty: Int, dstw: Int, dsth: Int,
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2810 srcr: DWRender?, srcp: Bitmap?, srcy: Int, srcx: Int, srcw: Int, srch: Int): Int
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2811 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2812 val dst = Rect(dstx, dsty, dstx + dstw, dsty + dsth)
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2813 val src = Rect(srcx, srcy, srcx + srcw, srcy + srch)
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2814 var retval = 1
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2815
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2816 if(srcw == -1) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2817 src.right = srcx + dstw
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2818 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2819 if(srch == -1) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2820 src.bottom = srcy + dsth
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2821 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2822
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2823 waitOnUiThread {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2824 var canvas: Canvas? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2825 var bitmap: Bitmap? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2826
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2827 if(dstr != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2828 canvas = dstr.cachedCanvas
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2829 } else if(dstp != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2830 canvas = Canvas(dstp)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2831 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2832
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2833 if(srcp != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2834 bitmap = srcp
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2835 } else if(srcr != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2836 bitmap = Bitmap.createBitmap(srcr.layoutParams.width,
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2837 srcr.layoutParams.height, Bitmap.Config.ARGB_8888)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2838 val c = Canvas(bitmap)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2839 srcr.layout(srcr.left, srcr.top, srcr.right, srcr.bottom)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2840 srcr.draw(c)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2841 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2842
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2843 if(canvas != null && bitmap != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2844 canvas.drawBitmap(bitmap, src, dst, null)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2845 retval = 0
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2846 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2847 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2848 return retval
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2849 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2850
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2851 fun drawPoint(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, fgColor: Long, bgColor: Long)
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2852 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2853 waitOnUiThread {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2854 var canvas: Canvas? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2855
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2856 if(render != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2857 canvas = render.cachedCanvas
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2858 } else if(bitmap != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2859 canvas = Canvas(bitmap)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2860 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2861
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2862 if(canvas != null) {
2572
bbe693293be5 Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2568
diff changeset
2863 colorsSet(fgColor, bgColor)
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2864 canvas.drawPoint(x.toFloat(), y.toFloat(), Paint())
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2865 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2866 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2867 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2868
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2869 fun drawLine(render: DWRender?, bitmap: Bitmap?, x1: Int, y1: Int, x2: Int, y2: Int, fgColor: Long, bgColor: Long)
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2870 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2871 waitOnUiThread {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2872 var canvas: Canvas? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2873
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2874 if(render != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2875 canvas = render.cachedCanvas
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2876 } else if(bitmap != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2877 canvas = Canvas(bitmap)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2878 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2879
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2880 if(canvas != null) {
2572
bbe693293be5 Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2568
diff changeset
2881 colorsSet(fgColor, bgColor)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2882 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2883 paint.style = Paint.Style.STROKE
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2884 canvas.drawLine(x1.toFloat(), y1.toFloat(), x2.toFloat(), y2.toFloat(), paint)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2885 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2886 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2887 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2888
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2889 fun fontTextExtentsGet(render: DWRender?, bitmap: Bitmap?, text:String, typeface: Typeface?, fontsize: Int, window: View?): Long
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2890 {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2891 var dimensions: Long = 0
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2892
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2893 waitOnUiThread {
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2894 val rect = Rect()
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2895
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2896 if (render != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2897 if (render.typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2898 paint.typeface = render.typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2899 if (render.fontsize != null && render.fontsize!! > 0F) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2900 paint.textSize = render.fontsize!!
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2901 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2902 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2903 } else if (bitmap != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2904 if (typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2905 paint.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2906 if (fontsize > 0) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2907 paint.textSize = fontsize.toFloat()
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2908 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2909 } else if (window != null && window is DWRender) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2910 val secondary: DWRender = window
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2911
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2912 if (secondary.typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2913 paint.typeface = secondary.typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2914 if (secondary.fontsize != null && secondary.fontsize!! > 0F) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2915 paint.textSize = secondary.fontsize!!
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2916 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2917 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2918 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2919 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2920 paint.getTextBounds(text, 0, text.length, rect)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2921 val textheight = rect.bottom - rect.top
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2922 val textwidth = rect.right - rect.left
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2923 dimensions = textwidth.toLong() or (textheight.toLong() shl 32)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2924 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2925 return dimensions
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2926 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2927
2572
bbe693293be5 Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2568
diff changeset
2928 fun drawText(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, text:String, typeface: Typeface?,
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2929 fontsize: Int, window: View?, fgColor: Long, bgColor: Long)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2930 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2931 waitOnUiThread {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2932 var canvas: Canvas? = null
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2933
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2934 if(render != null && render.cachedCanvas != null) {
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2935 canvas = render.cachedCanvas
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2936 if(render.typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2937 paint.typeface = render.typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2938 if(render.fontsize != null && render.fontsize!! > 0F) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2939 paint.textSize = render.fontsize!!
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2940 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2941 }
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2942 } else if(bitmap != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2943 canvas = Canvas(bitmap)
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2944 if(typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2945 paint.typeface = typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2946 if(fontsize > 0) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2947 paint.textSize = fontsize.toFloat()
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2948 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2949 } else if(window != null && window is DWRender) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
2950 val secondary: DWRender = window
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2951
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2952 if(secondary.typeface != null) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2953 paint.typeface = secondary.typeface
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2954 if(secondary.fontsize != null && secondary.fontsize!! > 0F) {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2955 paint.textSize = secondary.fontsize!!
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2956 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2957 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2546
diff changeset
2958 }
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2959 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2960
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2961 if(canvas != null) {
2572
bbe693293be5 Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2568
diff changeset
2962 colorsSet(fgColor, bgColor)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2963 // Save the old color for later...
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
2964 val rect = Rect()
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2965 val oldcolor = paint.color
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2966 // Prepare to draw the background rect
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2967 paint.color = bgcolor
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2968 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2969 paint.style = Paint.Style.FILL_AND_STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2970 paint.textAlign = Paint.Align.LEFT
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2971 paint.getTextBounds(text, 0, text.length, rect)
2538
1b3b40c89cd0 Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
2972 val textheight = rect.bottom - rect.top
1b3b40c89cd0 Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
2973 rect.top += y + textheight
1b3b40c89cd0 Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
2974 rect.bottom += y + textheight
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2975 rect.left += x
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2976 rect.right += x
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2977 canvas.drawRect(rect, paint)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2978 // Restore the color and prepare to draw text
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2979 paint.color = oldcolor
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2980 paint.style = Paint.Style.STROKE
2538
1b3b40c89cd0 Android: Move the text to below the point, not above it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
2981 canvas.drawText(text, x.toFloat(), y.toFloat() + textheight.toFloat(), paint)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2982 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2983 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2984 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2985
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
2986 fun drawRect(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, width: Int, height: Int, fgColor: Long, bgColor: Long)
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2987 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2988 waitOnUiThread {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2989 var canvas: Canvas? = null
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2990
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2991 if(render != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2992 canvas = render.cachedCanvas
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2993 } else if(bitmap != null) {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2994 canvas = Canvas(bitmap)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2995 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2996
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2997 if(canvas != null) {
2572
bbe693293be5 Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2568
diff changeset
2998 colorsSet(fgColor, bgColor)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
2999 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3000 paint.style = Paint.Style.FILL_AND_STROKE
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3001 canvas.drawRect(x.toFloat(), y.toFloat(), x.toFloat() + width.toFloat(), y.toFloat() + height.toFloat(), paint)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3002 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3003 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3004 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3005
2572
bbe693293be5 Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2568
diff changeset
3006 fun drawPolygon(render: DWRender?, bitmap: Bitmap?, flags: Int, npoints: Int,
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3007 x: IntArray, y: IntArray, fgColor: Long, bgColor: Long)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3008 {
2537
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
3009 // Create a path with all our points
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
3010 val path = Path()
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3011
2537
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
3012 path.moveTo(x[0].toFloat(), y[0].toFloat())
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
3013 for (i in 1 until npoints) {
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
3014 path.lineTo(x[i].toFloat(), y[i].toFloat())
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3015 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3016
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3017 waitOnUiThread {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3018 var canvas: Canvas? = null
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3019
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3020 if(render != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3021 canvas = render.cachedCanvas
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3022 } else if(bitmap != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3023 canvas = Canvas(bitmap)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3024 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3025
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3026 if(canvas != null) {
2572
bbe693293be5 Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2568
diff changeset
3027 colorsSet(fgColor, bgColor)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3028 // Handle the DW_DRAW_NOAA flag
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3029 if((flags and (1 shl 2)) == 0) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3030 paint.flags = Paint.ANTI_ALIAS_FLAG
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3031 } else {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3032 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3033 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3034 // Handle the DW_DRAW_FILL flag
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3035 if((flags and 1) == 1) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3036 paint.style = Paint.Style.FILL_AND_STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3037 } else {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3038 paint.style = Paint.Style.STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3039 }
2537
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2536
diff changeset
3040 canvas.drawPath(path, paint)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3041 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3042 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3043 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3044
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3045 fun drawArc(render: DWRender?, bitmap: Bitmap?, flags: Int, xorigin: Int, yorigin: Int,
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3046 x1: Int, y1: Int, x2: Int, y2: Int, fgColor: Long, bgColor: Long)
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3047 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3048 waitOnUiThread {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3049 var canvas: Canvas? = null
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3050
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3051 if(render != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3052 canvas = render.cachedCanvas
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3053 } else if(bitmap != null) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3054 canvas = Canvas(bitmap)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3055 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3056
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3057 if(canvas != null) {
2572
bbe693293be5 Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2568
diff changeset
3058 colorsSet(fgColor, bgColor)
bbe693293be5 Android: New color handling system, save the color in the C API and pass
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2568
diff changeset
3059
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3060 // Handle the DW_DRAW_NOAA flag
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3061 if((flags and (1 shl 2)) == 0) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3062 paint.flags = Paint.ANTI_ALIAS_FLAG
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3063 } else {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3064 paint.flags = 0
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3065 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3066 // Handle the DW_DRAW_FILL flag
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3067 if((flags and 1) == 1) {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3068 paint.style = Paint.Style.FILL_AND_STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3069 } else {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3070 paint.style = Paint.Style.STROKE
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3071 }
2536
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
3072 // Handle the DW_DRAW_FULL flag
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
3073 if((flags and (1 shl 1)) != 0) {
2576
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3074 var left: Float = x1.toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3075 var top: Float = y1.toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3076 var right: Float = x2.toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3077 var bottom: Float = y2.toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3078
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3079 if(x2 < x1) {
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3080 left = x2.toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3081 right = x1.toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3082 }
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3083 if(y2 < y1) {
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3084 top = y2.toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3085 bottom = y1.toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3086 }
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3087
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3088 canvas.drawOval(left, top, right, bottom, paint)
2536
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
3089 } else {
2576
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3090 var a1: Double = Math.atan2((y1 - yorigin).toDouble(), (x1 - xorigin).toDouble())
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3091 var a2: Double = Math.atan2((y2 - yorigin).toDouble(), (x2 - xorigin).toDouble())
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3092 val dx = (xorigin - x1).toDouble()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3093 val dy = (yorigin - y1).toDouble()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3094 val r: Double = Math.sqrt(dx * dx + dy * dy)
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3095 val left = (xorigin-r).toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3096 val top = (yorigin-r).toFloat()
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3097 val rect = RectF(left, top, (left + (r*2)).toFloat(), (top + (r*2)).toFloat())
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3098
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3099 // Convert to degrees
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3100 a1 *= 180.0 / Math.PI
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3101 a2 *= 180.0 / Math.PI
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3102 val sweep = Math.abs(a1 - a2)
db097ec28c90 Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2575
diff changeset
3103
2536
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
3104 canvas.drawArc(rect, a1.toFloat(), sweep.toFloat(), false, paint)
d172ab2eddb6 Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
3105 }
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3106 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3107 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3108 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
3109
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3110 fun colorFromDW(color: Long): Int
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3111 {
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3112 val red: Int = (color and 0x000000FF).toInt()
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3113 val green: Int = ((color and 0x0000FF00) shr 8).toInt()
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3114 val blue: Int = ((color and 0x00FF0000) shr 16).toInt()
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3115
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3116 return Color.rgb(red, green, blue)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3117 }
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3118
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3119 fun colorsSet(fgColor: Long, bgColor: Long)
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3120 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3121 waitOnUiThread {
2580
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3122 paint.color = colorFromDW(fgColor)
473eb9ff3f04 Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2579
diff changeset
3123 this.bgcolor = colorFromDW(bgColor)
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3124 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3125 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
3126
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3127 fun timerConnect(interval: Long, sigfunc: Long, data: Long): Timer
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3128 {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3129 // creating timer task, timer
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3130 val t = Timer()
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3131 val tt: TimerTask = object : TimerTask() {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3132 override fun run() {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3133 if(eventHandlerTimer(sigfunc, data) == 0) {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3134 t.cancel()
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3135 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3136 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3137 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3138 t.scheduleAtFixedRate(tt, interval, interval)
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3139 return t
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3140 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3141
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3142 fun timerDisconnect(timer: Timer)
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3143 {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3144 timer.cancel()
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3145 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3146
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3147 fun doBeep(duration: Int)
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3148 {
2491
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
3149 val toneGen = ToneGenerator(AudioManager.STREAM_ALARM, 100)
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3150 toneGen.startTone(ToneGenerator.TONE_CDMA_PIP, duration)
2491
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
3151 val handler = Handler(Looper.getMainLooper())
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
3152 handler.postDelayed({
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
3153 toneGen.release()
bf4fe6bb512b Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
3154 }, (duration + 50).toLong())
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
3155 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
3156
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
3157 fun debugMessage(text: String)
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
3158 {
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
3159 Log.d(null, text)
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
3160 }
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
3161
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3162 fun fileBrowse(title: String, defpath: String?, ext: String?, flags: Int): String?
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3163 {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3164 var retval: String? = null
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3165
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3166 waitOnUiThread {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3167 val fc = DWFileChooser(this)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3168 fc.setFileListener(object: DWFileChooser.FileSelectedListener {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3169 override fun fileSelected(file: File?) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3170 // do something with the file
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3171 retval = file!!.absolutePath
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3172 throw java.lang.RuntimeException()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3173 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3174 })
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3175 if(ext != null) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3176 fc.setExtension(ext)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3177 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3178 fc.showDialog()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3179 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3180
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3181 // loop till a runtime exception is triggered.
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3182 try {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3183 Looper.loop()
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3184 } catch (e2: RuntimeException) {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3185 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3186
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3187 return retval
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3188 }
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2524
diff changeset
3189
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
3190 fun messageBox(title: String, body: String, flags: Int): Int
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
3191 {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3192 var retval = 0
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
3193
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3194 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3195 // make a text input dialog and show it
2578
a36448beb7f7 Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2576
diff changeset
3196 val alert = AlertDialog.Builder(this)
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
3197
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3198 alert.setTitle(title)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3199 alert.setMessage(body)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3200 if ((flags and (1 shl 3)) != 0) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3201 alert.setPositiveButton("Yes"
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3202 )
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3203 //R.string.yes,
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3204 { _: DialogInterface, _: Int ->
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3205 retval = 1
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3206 throw java.lang.RuntimeException()
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3207 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3208 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3209 if ((flags and ((1 shl 1) or (1 shl 2))) != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3210 alert.setNegativeButton(
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3211 R.string.ok
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3212 ) { _: DialogInterface, _: Int ->
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3213 retval = 0
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3214 throw java.lang.RuntimeException()
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3215 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3216 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3217 if ((flags and ((1 shl 3) or (1 shl 4))) != 0) {
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3218 alert.setNegativeButton("No"
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3219 )
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3220 //R.string.no,
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3221 { _: DialogInterface, _: Int ->
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3222 retval = 0
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3223 throw java.lang.RuntimeException()
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3224 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3225 }
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3226 if ((flags and ((1 shl 2) or (1 shl 4))) != 0) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3227 alert.setNeutralButton(
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3228 R.string.cancel
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3229 ) { _: DialogInterface, _: Int ->
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3230 retval = 2
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3231 throw java.lang.RuntimeException()
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3232 }
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3233 }
2573
ea75e295025b Android: Make message boxes modal (not cancelable).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2572
diff changeset
3234 alert.setCancelable(false)
2579
68ee9a89e0f0 Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2578
diff changeset
3235 alert.show()
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3236
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3237 // loop till a runtime exception is triggered.
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3238 try {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3239 Looper.loop()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3240 } catch (e2: RuntimeException) {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3241 }
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
3242 }
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
3243 return retval
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
3244 }
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
3245
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3246 fun isUIThread(): Boolean
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3247 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3248 if(Looper.getMainLooper() == Looper.myLooper()) {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3249 return true
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3250 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3251 return false
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3252 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3253
2514
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3254 fun mainSleep(milliseconds: Int)
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3255 {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3256 // If we are on the main UI thread... add an idle handler
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3257 // Then loop until we throw an exception when the time expires
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3258 // in the idle handler, if we are already thrown... remove the handler
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3259 if(Looper.getMainLooper() == Looper.myLooper()) {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3260 val starttime = System.currentTimeMillis()
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3261
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3262 // Waiting for Idle to make sure Toast gets rendered.
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3263 Looper.myQueue().addIdleHandler(object : MessageQueue.IdleHandler {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3264 var thrown: Boolean = false
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3265
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3266 override fun queueIdle(): Boolean {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3267 if(System.currentTimeMillis() - starttime >= milliseconds) {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3268 if (thrown == false) {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3269 thrown = true
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3270 throw java.lang.RuntimeException()
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3271 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3272 return false
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3273 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3274 return true
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3275 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3276 })
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3277
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3278 // loop till a runtime exception is triggered.
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3279 try {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3280 Looper.loop()
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3281 } catch (e2: RuntimeException) {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3282 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3283 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3284 else
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3285 {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3286 // If we are in a different thread just sleep
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3287 Thread.sleep(milliseconds.toLong())
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3288 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3289 }
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
3290
2487
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
3291 fun dwindowsExit(exitcode: Int)
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
3292 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3293 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3294 this.finishAffinity()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3295 System.exit(exitcode)
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3296 }
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
3297 }
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
3298
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
3299 fun dwindowsShutdown()
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
3300 {
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3301 waitOnUiThread {
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3302 this.finishAffinity()
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
3303 }
2487
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
3304 }
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
3305
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
3306 fun dwInit(appid: String, appname: String): Int
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3307 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3308 waitOnUiThread {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3309 // Create the notification channel in dw_init()
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3310 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3311 // Create the NotificationChannel
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3312 val importance = NotificationManager.IMPORTANCE_DEFAULT
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3313 val mChannel = NotificationChannel(appid, appname, importance)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3314 // Register the channel with the system; you can't change the importance
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3315 // or other notification behaviors after this
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3316 val notificationManager =
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3317 getSystemService(NOTIFICATION_SERVICE) as NotificationManager
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3318 notificationManager.createNotificationChannel(mChannel)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3319 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3320 }
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
3321 return Build.VERSION.SDK_INT
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
3322 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
3323
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
3324 fun dwMain()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
3325 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
3326 runOnUiThread {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
3327 // Trigger the options menu to update when dw_main() is called
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
3328 invalidateOptionsMenu()
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
3329 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
3330 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
3331
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
3332 fun androidGetRelease(): String
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
3333 {
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
3334 return Build.VERSION.RELEASE
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3335 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3336
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3337 fun notificationNew(title: String, imagepath: String, text: String, appid: String): NotificationCompat.Builder?
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3338 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3339 var builder: NotificationCompat.Builder? = null
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3340
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3341 waitOnUiThread {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3342 builder = NotificationCompat.Builder(this, appid)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3343 .setContentTitle(title)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3344 .setContentText(text)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3345 .setPriority(NotificationCompat.PRIORITY_DEFAULT)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3346 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3347 return builder
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3348 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3349
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3350 fun notificationSend(builder: NotificationCompat.Builder)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3351 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3352 waitOnUiThread {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3353 notificationID += 1
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3354 with(NotificationManagerCompat.from(this)) {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3355 // notificationId is a unique int for each notification that you must define
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3356 notify(notificationID, builder.build())
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3357 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3358 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3359 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3360
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
3361 /*
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
3362 * Native methods that are implemented by the 'dwindows' native library,
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3363 * which is packaged with this application.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3364 */
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
3365 external fun dwindowsInit(dataDir: String, appid: String)
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
3366 external fun eventHandler(
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3367 obj1: View?,
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
3368 obj2: View?,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
3369 message: Int,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
3370 str1: String?,
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
3371 str2: String?,
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3372 inta: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3373 intb: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3374 intc: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3375 intd: Int
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
3376 ): Int
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3377 external fun eventHandlerInt(
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3378 obj1: View,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3379 message: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3380 inta: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3381 intb: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3382 intc: Int,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3383 intd: Int
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
3384 )
2483
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
3385 external fun eventHandlerSimple(obj1: View, message: Int)
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
3386 external fun eventHandlerNotebook(obj1: View, message: Int, pageID: Long)
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
3387 external fun eventHandlerTimer(sigfunc: Long, data: Long): Int
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
3388 external fun eventHandlerHTMLResult(obj1: View, message: Int, result: String, data: Long)
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
3389 external fun eventHandlerContainer(obj1: View, message: Int, title: String?, x: Int, y: Int, data: Long)
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3390
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
3391 companion object
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
3392 {
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 // Used to load the 'dwindows' library on application startup.
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
3394 init
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
3395 {
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 System.loadLibrary("dwindows")
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 }