mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 03:40:21 +02:00
android: Adds combobox itemindex, set/get text for various textedit based controls
git-svn-id: trunk@32033 -
This commit is contained in:
parent
41360bd47d
commit
88e27838e2
@ -125,13 +125,11 @@ type
|
||||
TEditText = class(TTextView)
|
||||
public
|
||||
constructor Create();
|
||||
procedure setText(AText: string);
|
||||
end;
|
||||
|
||||
TButton = class(TTextView)
|
||||
public
|
||||
constructor Create();
|
||||
procedure setText(AText: string);
|
||||
end;
|
||||
|
||||
TFrameLayout = class(TViewGroup)
|
||||
@ -169,12 +167,14 @@ type
|
||||
|
||||
TAdapterView = class(TViewGroup)
|
||||
public
|
||||
function getSelectedItemPosition(): Integer;
|
||||
end;
|
||||
|
||||
TAbsSpinner = class(TAdapterView)
|
||||
public
|
||||
function getCount(): Integer;
|
||||
procedure setAdapter(adapter: TSpinnerAdapter);
|
||||
procedure setSelection(position: Integer); overload;
|
||||
end;
|
||||
|
||||
TSpinner = class(TAbsSpinner)
|
||||
@ -328,10 +328,8 @@ const
|
||||
amkUI_TTextView_getText_6 = $0010B006;
|
||||
// TEditText
|
||||
amkUI_TEditText_Create_0 = $0010C000;
|
||||
amkUI_TEditText_setText_1 = $0010C001;
|
||||
// TButton
|
||||
amkUI_TButton_Create_0 = $0010D000;
|
||||
amkUI_TButton_setText_1 = $0010D001;
|
||||
// TFrameLayout
|
||||
// TTimePicker
|
||||
amkUI_TTimePicker_Create_0 = $0010F000;
|
||||
@ -351,9 +349,11 @@ const
|
||||
// TCheckBox
|
||||
amkUI_TCheckBox_Create_0 = $00112000;
|
||||
// TAdapterView
|
||||
amkUI_TAdapterView_getSelectedItemPosition_0 = $00113000;
|
||||
// TAbsSpinner
|
||||
amkUI_TAbsSpinner_getCount_0 = $00114000;
|
||||
amkUI_TAbsSpinner_setAdapter_1 = $00114001;
|
||||
amkUI_TAbsSpinner_setSelection_2 = $00114002;
|
||||
// TSpinner
|
||||
amkUI_TSpinner_Create_0 = $00115000;
|
||||
// TFilterable
|
||||
@ -634,38 +634,12 @@ begin
|
||||
vAndroidPipesComm.SendInt(amkUI_TEditText_Create_0);
|
||||
Index := vAndroidPipesComm.WaitForIntReturn();
|
||||
end;
|
||||
procedure TEditText.setText(AText: string);
|
||||
var
|
||||
lString_1: TString;
|
||||
begin
|
||||
lString_1 := TString.Create(AText);
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
vAndroidPipesComm.SendInt(amkUI_TEditText_setText_1);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
vAndroidPipesComm.SendInt(lString_1.Index); // text
|
||||
vAndroidPipesComm.WaitForReturn();
|
||||
lString_1.Free;
|
||||
end;
|
||||
|
||||
constructor TButton.Create();
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
vAndroidPipesComm.SendInt(amkUI_TButton_Create_0);
|
||||
Index := vAndroidPipesComm.WaitForIntReturn();
|
||||
end;
|
||||
procedure TButton.setText(AText: string);
|
||||
var
|
||||
lString_1: TString;
|
||||
begin
|
||||
lString_1 := TString.Create(AText);
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
vAndroidPipesComm.SendInt(amkUI_TButton_setText_1);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
vAndroidPipesComm.SendInt(lString_1.Index); // text
|
||||
vAndroidPipesComm.WaitForReturn();
|
||||
lString_1.Free;
|
||||
end;
|
||||
|
||||
constructor TTimePicker.Create();
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
@ -768,6 +742,14 @@ begin
|
||||
vAndroidPipesComm.SendInt(amkUI_TCheckBox_Create_0);
|
||||
Index := vAndroidPipesComm.WaitForIntReturn();
|
||||
end;
|
||||
function TAdapterView.getSelectedItemPosition(): Integer;
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
vAndroidPipesComm.SendInt(amkUI_TAdapterView_getSelectedItemPosition_0);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
Result := Integer(vAndroidPipesComm.WaitForIntReturn());
|
||||
end;
|
||||
|
||||
function TAbsSpinner.getCount(): Integer;
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
@ -785,6 +767,15 @@ begin
|
||||
vAndroidPipesComm.WaitForReturn();
|
||||
end;
|
||||
|
||||
procedure TAbsSpinner.setSelection(position: Integer);
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
vAndroidPipesComm.SendInt(amkUI_TAbsSpinner_setSelection_2);
|
||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||
vAndroidPipesComm.SendInt(Integer(position));
|
||||
vAndroidPipesComm.WaitForReturn();
|
||||
end;
|
||||
|
||||
constructor TSpinner.Create();
|
||||
begin
|
||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||
|
@ -50,24 +50,32 @@ type
|
||||
mainviewgroup: TViewGroup;
|
||||
end;
|
||||
|
||||
{ TAndroidEdit }
|
||||
{ TAndroidStaticText }
|
||||
|
||||
TAndroidEdit = class(TAndroidView)
|
||||
TAndroidStaticText = class(TAndroidView)
|
||||
public
|
||||
edittext: android_all.TEditText;
|
||||
textview: android_all.TTextView;
|
||||
params: TAbsoluteLayout_LayoutParams;
|
||||
constructor Create(const AObject: TCustomEdit; const AParams: TCreateParams);
|
||||
constructor Create(const AObject: TCustomStaticText; const AParams: TCreateParams);
|
||||
destructor Destroy; override;
|
||||
function GetText: string;
|
||||
procedure SetText(AText: string);
|
||||
end;
|
||||
|
||||
{ TAndroidEdit }
|
||||
|
||||
TAndroidEdit = class(TAndroidStaticText)
|
||||
public
|
||||
edittext: android_all.TEditText;
|
||||
constructor Create(const AObject: TCustomEdit; const AParams: TCreateParams);
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
{ TAndroidButton }
|
||||
|
||||
TAndroidButton = class(TAndroidView)
|
||||
TAndroidButton = class(TAndroidStaticText)
|
||||
public
|
||||
btn: android_all.TButton;
|
||||
params: TAbsoluteLayout_LayoutParams;
|
||||
constructor Create(const AObject: TCustomButton; const AParams: TCreateParams);
|
||||
destructor Destroy; override;
|
||||
procedure buttonClickCallback(v: TView);
|
||||
@ -85,16 +93,6 @@ type
|
||||
procedure SetState(const AState: TCheckBoxState);
|
||||
end;
|
||||
|
||||
{ TAndroidStaticText }
|
||||
|
||||
TAndroidStaticText = class(TAndroidView)
|
||||
public
|
||||
textview: android_all.TTextView;
|
||||
params: TAbsoluteLayout_LayoutParams;
|
||||
constructor Create(const AObject: TCustomStaticText; const AParams: TCreateParams);
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
{ TAndroidComboBox }
|
||||
|
||||
TAndroidComboBox = class(TAndroidView)
|
||||
@ -110,6 +108,9 @@ type
|
||||
procedure InsertItem(Index: Integer; const S: string);
|
||||
procedure Clear;
|
||||
procedure Delete(Index: Integer);
|
||||
//
|
||||
function GetItemIndex(): Integer;
|
||||
procedure SetItemIndex(NewIndex: integer);
|
||||
end;
|
||||
|
||||
{ TAndroidWindow }
|
||||
@ -224,6 +225,16 @@ begin
|
||||
Adapter.remove(lStr);
|
||||
end;
|
||||
|
||||
function TAndroidComboBox.GetItemIndex: Integer;
|
||||
begin
|
||||
Result := spinner.getSelectedItemPosition();
|
||||
end;
|
||||
|
||||
procedure TAndroidComboBox.SetItemIndex(NewIndex: integer);
|
||||
begin
|
||||
spinner.setSelection(NewIndex);
|
||||
end;
|
||||
|
||||
{ TAndroidStaticText }
|
||||
|
||||
constructor TAndroidStaticText.Create(const AObject: TCustomStaticText;
|
||||
@ -248,6 +259,16 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TAndroidStaticText.GetText: string;
|
||||
begin
|
||||
Result := textview.GetText();
|
||||
end;
|
||||
|
||||
procedure TAndroidStaticText.SetText(AText: string);
|
||||
begin
|
||||
textview.SetText(AText);
|
||||
end;
|
||||
|
||||
{ TAndroidCheckBox }
|
||||
|
||||
constructor TAndroidCheckBox.Create(const AObject: TCustomCheckBox;
|
||||
@ -298,6 +319,7 @@ begin
|
||||
ParentGroupView := TAndroidViewGroup(AObject.Parent.Handle).mainviewgroup;
|
||||
|
||||
edittext := android_all.TEditText.Create;
|
||||
textview := edittext;
|
||||
MainView := edittext;
|
||||
Str := AObject.Caption;
|
||||
edittext.setText(Str);
|
||||
@ -311,16 +333,6 @@ 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;
|
||||
@ -332,6 +344,7 @@ begin
|
||||
ParentGroupView := TAndroidViewGroup(AObject.Parent.Handle).mainviewgroup;
|
||||
|
||||
btn := android_all.TButton.Create;
|
||||
textview := btn;
|
||||
MainView := btn;
|
||||
Str := AObject.Caption;
|
||||
btn.setText(Str);
|
||||
|
Loading…
Reference in New Issue
Block a user