Mercurial > dwindows
comparison android/DWindows.kt @ 2475:16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
Initialize JNI when creating new threads.
Include jni.h from dw.h so we can type HWND as jobject.
Remove our own resize code, we are going to try to use LinearLayout.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 21 Apr 2021 11:15:26 +0000 |
parents | a13e6db064f4 |
children | 20c9e83cba2a |
comparison
equal
deleted
inserted
replaced
2474:a13e6db064f4 | 2475:16d195d46f2a |
---|---|
1 package org.dbsoft.dwindows.dwtest | 1 package org.dbsoft.dwindows.dwtest |
2 | 2 |
3 import android.os.Bundle | 3 import android.os.Bundle |
4 import android.view.View | |
5 import android.widget.LinearLayout | |
4 import android.widget.TextView | 6 import android.widget.TextView |
5 import androidx.appcompat.app.AppCompatActivity | 7 import androidx.appcompat.app.AppCompatActivity |
6 | 8 |
7 | 9 |
8 class DWindows : AppCompatActivity() | 10 class DWindows : AppCompatActivity() |
18 s = p.applicationInfo.dataDir | 20 s = p.applicationInfo.dataDir |
19 | 21 |
20 // Example of a call to a native method | 22 // Example of a call to a native method |
21 findViewById<TextView>(R.id.sample_text).text = dwindowsInit(s) | 23 findViewById<TextView>(R.id.sample_text).text = dwindowsInit(s) |
22 } | 24 } |
25 /* | |
26 * These are the Android calls to actually create the UI... | |
27 * forwarded from the C Dynamic Windows API | |
28 */ | |
29 fun windowNew(title: String, style: Int): DWindows | |
30 { | |
31 // For now we just return our DWindows activity... | |
32 // in the future, later calls should create new activities | |
33 return this | |
34 } | |
23 | 35 |
24 /** | 36 fun boxNew(type: Int, pad: Int): LinearLayout |
37 { | |
38 val box = LinearLayout(this) | |
39 box.layoutParams = | |
40 LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) | |
41 if (type > 0) { | |
42 box.orientation = LinearLayout.VERTICAL | |
43 } else { | |
44 box.orientation = LinearLayout.HORIZONTAL | |
45 } | |
46 return box | |
47 } | |
48 | |
49 fun boxPack(box: LinearLayout, item: View, index: Int, width: Int, height: Int, hsize: Int, vsize: Int, pad: Int) | |
50 { | |
51 var w: Int = width; | |
52 var h: Int = height; | |
53 | |
54 if(hsize > 0) { | |
55 w = LinearLayout.LayoutParams.FILL_PARENT | |
56 } else if(w < 1) { | |
57 w = LinearLayout.LayoutParams.WRAP_CONTENT | |
58 } | |
59 if(vsize > 0) { | |
60 h = LinearLayout.LayoutParams.FILL_PARENT | |
61 } else if(h < 1) { | |
62 h = LinearLayout.LayoutParams.WRAP_CONTENT | |
63 } | |
64 item.layoutParams = LinearLayout.LayoutParams(w, h) | |
65 box.addView(item) | |
66 } | |
67 | |
68 /* | |
25 * Native methods that are implemented by the 'dwindows' native library, | 69 * Native methods that are implemented by the 'dwindows' native library, |
26 * which is packaged with this application. | 70 * which is packaged with this application. |
27 */ | 71 */ |
28 external fun dwindowsInit(dataDir: String): String | 72 external fun dwindowsInit(dataDir: String): String |
29 | 73 |