androidlcl: Advances to implementing reading text values

git-svn-id: trunk@32012 -
This commit is contained in:
sekelsenmat 2011-08-19 15:26:10 +00:00
parent 778c20af82
commit 2338d7ce64
4 changed files with 52 additions and 8 deletions

View File

@ -108,6 +108,7 @@ type
procedure callOnClickListener();
public
procedure setTextSize(unit_: Integer; size: Single);
function getText(): string;
end;
TEditText = class(TTextView)
@ -302,6 +303,7 @@ const
amkUI_TTextView_OnClickListener_Start = $0010A003;
amkUI_TTextView_OnClickListener_Finished = $0010A004;
amkUI_TTextView_setTextSize = $0010A005;
amkUI_TTextView_getText = $0010A006;
// TEditText
amkUI_TEditText_Create = $0010B000;
amkUI_TEditText_setText = $0010B001;
@ -536,6 +538,14 @@ begin
vAndroidPipesComm.WaitForReturn();
end;
function TTextView.getText(): string;
begin
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
vAndroidPipesComm.SendInt(amkUI_TTextView_getText);
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
Result := vAndroidPipesComm.WaitForStringReturn();
end;
constructor TEditText.Create();
begin
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
@ -721,7 +731,6 @@ end;
procedure TArrayAdapter_String_.clear();
begin
vAndroidPipesComm.Log(Format('[TArrayAdapter_String_.Clear] Self=%P Index=%X', [@Self, Index]));
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
vAndroidPipesComm.SendInt(amkUI_TArrayAdapter_String__clear);
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer

View File

@ -18,9 +18,10 @@ uses
const
// Android Message Kind
amkFloatResult = 103;
amkIntResult = 102;
amkResult = 101;
amkStringResult = 14;
amkFloatResult = 13;
amkIntResult = 12;
amkResult = 11;
amkActivityCallback = 0;
amkLog = 1;
amkUICommand = 2;
@ -62,6 +63,7 @@ type
function ReadByte: ShortInt;
function ReadInt: Integer;
function ReadFloat: Single;
function ReadString: string;
procedure SendMessage(AKind: ShortInt; ASubtype: DWord);
procedure SendByte(AData: ShortInt);
procedure SendInt(AData: Integer);
@ -70,6 +72,7 @@ type
procedure WaitForReturn();
function WaitForIntReturn(): Integer;
function WaitForFloatReturn(): Single;
function WaitForStringReturn(): string;
procedure CommError(AStr: string);
procedure Log(AStr: string);
end;
@ -187,6 +190,18 @@ begin
Move(lNum, Result, 4);
end;
function TAndroidPipesComm.ReadString: string;
var
lSize, i: Integer;
begin
Result := '';
lSize := ReadInt();
for i := 1 to lSize do
begin
Result := Result + Char(ReadByte());
end;
end;
procedure TAndroidPipesComm.SendMessage(AKind: ShortInt; ASubtype: DWord);
begin
OutputStream.WriteByte(AKind);
@ -256,6 +271,16 @@ begin
Result := ReadFloat();
end;
function TAndroidPipesComm.WaitForStringReturn: string;
var
lByte: ShortInt;
begin
{$ifdef ANDROID_NO_COMM}Exit(0.0);{$ENDIF}
lByte := ReadByte();
if lByte <> amkStringResult then CommError('[TAndroidPipesComm.WaitForStringReturn] expected amkStringResult but got: ' + IntToStr(lByte));
Result := ReadString();
end;
procedure TAndroidPipesComm.CommError(AStr: string);
begin
dataString1 := AStr;

View File

@ -60,6 +60,8 @@ type
params: TAbsoluteLayout_LayoutParams;
constructor Create(const AObject: TCustomEdit; const AParams: TCreateParams);
destructor Destroy; override;
function GetText: string;
procedure SetText(AText: string);
end;
{ TAndroidButton }
@ -405,6 +407,16 @@ begin
inherited Destroy;
end;
function TAndroidEdit.GetText: string;
begin
Result := edittext.GetText();
end;
procedure TAndroidEdit.SetText(AText: string);
begin
edittext.SetText(AText);
end;
{ TAndroidButton }
constructor TAndroidButton.Create(const AObject: TCustomButton;

View File

@ -329,10 +329,8 @@ end;
function RegisterCustomMemo: Boolean; alias : 'WSRegisterCustomMemo';
begin
Result := False;
// RegisterWSComponent(TCustomMemo, TGtk2WSCustomMemo, TGtkPrivateScrolling); { GTK1 }
// RegisterWSComponent(TCustomMemo, TGtk2WSCustomMemo);
// Result := True;
RegisterWSComponent(TCustomMemo, TAndroidWSCustomMemo);
Result := True;
end;
function RegisterButtonControl: Boolean; alias : 'WSRegisterButtonControl';