From b08f795fb495dc233336bc5fd0298a08c3508f58 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Wed, 10 Aug 2011 11:42:11 +0000 Subject: [PATCH] androidlcl: Minimal implementation of statictext, checkbox, edit and combobox git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1792 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../src/com/pascal/androidlcl/AndroidAll.java | 11 +++++++ .../pascal/androidlcl/AndroidPipesComm.java | 28 +++++++++++++++- examples/androidlcl/androidlcltest.lpi | 4 --- examples/androidlcl/mainform.lfm | 33 +++++++++++++++++++ examples/androidlcl/mainform.pas | 4 +++ 5 files changed, 75 insertions(+), 5 deletions(-) diff --git a/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidAll.java b/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidAll.java index c689d95bd..166281774 100644 --- a/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidAll.java +++ b/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidAll.java @@ -90,6 +90,10 @@ public class AndroidAll static final int amkUI_TCompoundButton_toggle = 0x00110003; // CheckBox static final int amkUI_TCheckBox_Create = 0x00111000; + // AdapterView + // AbsSpinner + // Spinner + static final int amkUI_TSpinner_Create = 0x00114000; public boolean ProcessCommand(int Buffer) { @@ -369,12 +373,14 @@ public class AndroidAll DebugOut("amkUI_TButton_Create"); ViewElements.add(new Button(activity)); MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1); + DebugOut("amkUI_TButton_Create Self=" + Integer.toString(ViewElements.size() - 1)); break; // method void setText(CharSequence AText); override; case amkUI_TButton_setText: DebugOut("amkUI_TButton_setText"); // Self lInt = MyAndroidPipesComm.GetInt(); + DebugOut("amkUI_TButton_setText Self=" + Integer.toString(lInt)); param_self_Button = (Button) ViewElements.get(lInt); // params lInt = MyAndroidPipesComm.GetInt(); @@ -516,6 +522,11 @@ public class AndroidAll ViewElements.add(new CheckBox(activity)); MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1); break; + case amkUI_TSpinner_Create: + DebugOut("amkUI_TSpinner_Create"); + ViewElements.add(new Spinner(activity)); + MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1); + break; default: return false; diff --git a/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidPipesComm.java b/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidPipesComm.java index 51d25e1f5..44f7a4a95 100644 --- a/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidPipesComm.java +++ b/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidPipesComm.java @@ -56,6 +56,27 @@ public class AndroidPipesComm Log.v("AndroidPipesComm:", Str); // tv.setText(tv.getText().toString() + Str); } + + public void TerminateApplication() + { + System.exit(0); + } + + public void PrintPascalException(byte Buffer) + { + String PascalMessage = "" + (char) Buffer; + try + { + while (true) + { + PascalMessage = PascalMessage + (char) reader.readByte(); + } + } + catch (IOException e) + { + ErrorOut(PascalMessage); + } + } // Waits for a particular Pascal message. // In the mean time processes any other incoming messages @@ -118,11 +139,16 @@ public class AndroidPipesComm else { ErrorOut("Unknown Pascal message!!! " + java.lang.Integer.toHexString(Buffer)); + + // If we get an Unknown Pascal message, it might be an error printed to the console, so lets print it and quit + PrintPascalException(Buffer); + TerminateApplication(); } } catch (EOFException e) { ErrorOut("[WaitAndProcessPascalMessage] EOFException=" + e.getMessage()); + TerminateApplication(); } catch (IOException e) { @@ -258,7 +284,7 @@ public class AndroidPipesComm catch (IOException e) { ErrorOut("[SendMessage] IOException=" + e.getMessage()); - System.exit(0); + TerminateApplication(); } } diff --git a/examples/androidlcl/androidlcltest.lpi b/examples/androidlcl/androidlcltest.lpi index 6e7c1dc2e..b51108f7e 100644 --- a/examples/androidlcl/androidlcltest.lpi +++ b/examples/androidlcl/androidlcltest.lpi @@ -60,10 +60,6 @@ - - - - diff --git a/examples/androidlcl/mainform.lfm b/examples/androidlcl/mainform.lfm index 2db36739e..659d7073b 100644 --- a/examples/androidlcl/mainform.lfm +++ b/examples/androidlcl/mainform.lfm @@ -15,4 +15,37 @@ object Form2: TForm2 Caption = 'Button1' TabOrder = 0 end + object CheckBox1: TCheckBox + Left = 32 + Height = 21 + Top = 91 + Width = 94 + Caption = 'CheckBox1' + TabOrder = 1 + end + object Edit1: TEdit + Left = 37 + Height = 25 + Top = 145 + Width = 99 + TabOrder = 2 + Text = 'Edit1' + end + object StaticText1: TStaticText + Left = 147 + Height = 17 + Top = 36 + Width = 65 + Caption = 'StaticText1' + TabOrder = 3 + end + object ComboBox1: TComboBox + Left = 151 + Height = 27 + Top = 84 + Width = 100 + ItemHeight = 0 + TabOrder = 4 + Text = 'ComboBox1' + end end diff --git a/examples/androidlcl/mainform.pas b/examples/androidlcl/mainform.pas index 5c6012897..cca3e23a3 100644 --- a/examples/androidlcl/mainform.pas +++ b/examples/androidlcl/mainform.pas @@ -14,6 +14,10 @@ type TForm2 = class(TForm) Button1: TButton; + CheckBox1: TCheckBox; + ComboBox1: TComboBox; + Edit1: TEdit; + StaticText1: TStaticText; private { private declarations } public