Mercurial > dwindows
annotate android/DWindows.kt @ 2481:94f0d61d6953
Android: Initial commit of signal handlers, connecting buttons to the new
system.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 26 Apr 2021 11:01:58 +0000 |
parents | 878d36588aaa |
children | 4888503c3e3e |
rev | line source |
---|---|
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1 package org.dbsoft.dwindows.dwtest |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2 |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
3 import android.content.pm.ActivityInfo |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4 import android.os.Bundle |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
5 import android.text.method.PasswordTransformationMethod |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
6 import android.util.Half.toFloat |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
7 import android.view.Gravity |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
8 import android.view.View |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
9 import android.widget.* |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
10 import androidx.appcompat.app.AppCompatActivity |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
11 |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
12 |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
13 class DWindows : AppCompatActivity() |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
14 { |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
15 override fun onCreate(savedInstanceState: Bundle?) |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
16 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
17 super.onCreate(savedInstanceState) |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
18 |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
19 // Turn on rotation |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
20 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
|
21 |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
22 // Get the Android app path |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
23 val m = packageManager |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
24 var s = packageName |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
25 val p = m.getPackageInfo(s!!, 0) |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
26 s = p.applicationInfo.dataDir |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
27 |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
28 // Initialize the Dynamic Windows code... |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
29 // This will start a new thread that calls the app's dwmain() |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
30 dwindowsInit(s) |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
31 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
32 /* |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
33 * These are the Android calls to actually create the UI... |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
34 * forwarded from the C Dynamic Windows API |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
35 */ |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
36 fun windowNew(title: String, style: Int): LinearLayout |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
37 { |
2477
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
38 var windowLayout: LinearLayout = LinearLayout(this) |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
39 setContentView(windowLayout) |
2479
54b0008a0569
Android: Set the window text on the activity in dw_window_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2478
diff
changeset
|
40 this.title = title |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
41 // For now we just return our DWindows' main activity layout... |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
42 // in the future, later calls should create new activities |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
43 return windowLayout |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
44 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
45 |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
46 fun boxNew(type: Int, pad: Int): LinearLayout |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
47 { |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
48 val box = LinearLayout(this) |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
49 box.layoutParams = |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
50 LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
51 if (type > 0) { |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
52 box.orientation = LinearLayout.VERTICAL |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
53 } else { |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
54 box.orientation = LinearLayout.HORIZONTAL |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
55 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
56 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
|
57 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
58 |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
59 fun boxPack(box: LinearLayout, item: View, index: Int, width: Int, height: Int, hsize: Int, vsize: Int, pad: Int) |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
60 { |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
61 var w: Int = LinearLayout.LayoutParams.WRAP_CONTENT |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
62 var h: Int = LinearLayout.LayoutParams.WRAP_CONTENT |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
63 |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
64 if(item is LinearLayout) { |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
65 if(box.orientation == LinearLayout.VERTICAL) { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
66 if (hsize > 0) { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
67 w = LinearLayout.LayoutParams.MATCH_PARENT |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
68 } |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
69 } else { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
70 if (vsize > 0) { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
71 h = LinearLayout.LayoutParams.MATCH_PARENT |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
72 } |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
73 } |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
74 } |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
75 var params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h) |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
76 |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
77 if(item !is LinearLayout && (width != -1 || height != -1)) { |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
78 item.measure(0,0) |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
79 if (width > 0) { |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
80 w = width |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
81 } else if(width == -1) { |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
82 w = item.getMeasuredWidth() |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
83 } |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
84 if (height > 0) { |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
85 h = height |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
86 } else if(height == -1) { |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
87 h = item.getMeasuredHeight() |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
88 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
89 } |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
90 if(box.orientation == LinearLayout.VERTICAL) { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
91 if (vsize > 0) { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
92 if (w > 0) { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
93 params.weight = w.toFloat() |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
94 } else { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
95 params.weight = 1F |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
96 } |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
97 } |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
98 } else { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
99 if (hsize > 0) { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
100 if (h > 0) { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
101 params.weight = h.toFloat() |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
102 } else { |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
103 params.weight = 1F |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
104 } |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
105 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
106 } |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
107 if(pad > 0) { |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
108 params.setMargins(pad, pad, pad, pad) |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
109 } |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
110 var grav: Int = Gravity.CLIP_HORIZONTAL or Gravity.CLIP_VERTICAL |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
111 if(hsize > 0 && vsize > 0) { |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
112 params.gravity = Gravity.FILL or grav |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
113 } else if(hsize > 0) { |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
114 params.gravity = Gravity.FILL_HORIZONTAL or grav |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
115 } else if(vsize > 0) { |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
116 params.gravity = Gravity.FILL_VERTICAL or grav |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
117 } |
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
118 item.layoutParams = params |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
119 box.addView(item) |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
120 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
121 |
2477
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
122 fun boxUnpack(item: View) |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
123 { |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
124 var box: LinearLayout = item.parent as LinearLayout |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
125 box.removeView(item) |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
126 } |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
127 |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
128 fun buttonNew(text: String, cid: Int): Button |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
129 { |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
130 val button = Button(this) |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
131 button.text = text |
2481
94f0d61d6953
Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2480
diff
changeset
|
132 button.setOnClickListener { eventHandler(button, button, 8, "", "", 0, 0, 0, 0) } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
133 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
|
134 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
135 |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
136 fun entryfieldNew(text: String, cid: Int, password: Int): EditText |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
137 { |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
138 val entryfield = EditText(this) |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
139 if(password > 0) { |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
140 entryfield.transformationMethod = PasswordTransformationMethod.getInstance() |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
141 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
142 entryfield.setText(text) |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
143 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
|
144 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
145 |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
146 fun radioButtonNew(text: String, cid: Int): RadioButton |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
147 { |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
148 val radiobutton = RadioButton(this) |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
149 radiobutton.text = text |
2481
94f0d61d6953
Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2480
diff
changeset
|
150 radiobutton.setOnClickListener { eventHandler(radiobutton, radiobutton, 8, "", "", 0, 0, 0, 0) } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
151 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
|
152 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
153 |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
154 fun checkboxNew(text: String, cid: Int): CheckBox |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
155 { |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
156 val checkbox = CheckBox(this) |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
157 checkbox.text = text |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
158 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
|
159 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
160 |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
161 fun textNew(text: String, cid: Int, status: Int): TextView |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
162 { |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
163 val textview = TextView(this) |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
164 textview.text = text |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
165 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
|
166 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
167 |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
168 /* |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
169 * 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
|
170 * 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
|
171 */ |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
172 external fun dwindowsInit(dataDir: String): String |
2481
94f0d61d6953
Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2480
diff
changeset
|
173 external fun eventHandler(obj1: Any, obj2: Any, message: Int, str1: String, str2: String, int1: Int, int2: Int, int3: Int, int4: Int): Int |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
174 |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
175 companion object |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
176 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
177 // 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
|
178 init |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
179 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
180 System.loadLibrary("dwindows") |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
181 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
182 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
183 } |