mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 01:32:31 +02:00
Finishes basic SMS sending in Android and fixes TEdit.GetText in LCL-CustomDrawn, but in the process broke the initial text setting for TEdit
git-svn-id: trunk@34496 -
This commit is contained in:
parent
30e9088462
commit
b92e125ce3
@ -26,7 +26,7 @@ object Form2: TForm2
|
||||
OnKeyUp = textDestKeyUp
|
||||
OnUTF8KeyPress = textDestUTF8KeyPress
|
||||
TabOrder = 1
|
||||
Text = 'textDest'
|
||||
Text = '8284'
|
||||
end
|
||||
object Image1: TImage
|
||||
Left = 102
|
||||
|
@ -39,6 +39,8 @@ type
|
||||
{ public declarations }
|
||||
procedure HandleAccelerometerChanged(Sender: TObject);
|
||||
procedure HandlePositionRetrieved(Sender: TObject);
|
||||
procedure HandleMessagingStatus(AMessage: TLazDeviceMessage;
|
||||
AStatus: TLazMessagingStatus);
|
||||
end;
|
||||
|
||||
var
|
||||
@ -46,6 +48,8 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
uses TypInfo;
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm2 }
|
||||
@ -59,9 +63,11 @@ procedure TForm2.btnSendSMSClick(Sender: TObject);
|
||||
var
|
||||
lMessage: TLazDeviceMessage;
|
||||
begin
|
||||
Messaging.OnMessagingStatus := @HandleMessagingStatus;
|
||||
lMessage := Messaging.CreateMessage();
|
||||
lMessage.Body := textBody.Text;
|
||||
lMessage.destinationAddress.Text := textDest.Text;
|
||||
DebugLn('[TForm2.btnSendSMSClick] dest='+textDest.Text);
|
||||
Messaging.SendMessage(lMessage);
|
||||
end;
|
||||
|
||||
@ -117,5 +123,13 @@ begin
|
||||
DebugLn(labelSensorData.Caption);
|
||||
end;
|
||||
|
||||
procedure TForm2.HandleMessagingStatus(AMessage: TLazDeviceMessage;
|
||||
AStatus: TLazMessagingStatus);
|
||||
begin
|
||||
labelSensorData.Caption := '[HandleMessagingStatus] ' +
|
||||
GetEnumName(TypeInfo(TLazMessagingStatus), integer(AStatus));
|
||||
DebugLn(labelSensorData.Caption);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -256,6 +256,8 @@ var
|
||||
arraydata: PDouble;
|
||||
arraylen: jsize;
|
||||
lIsCopy: jboolean;
|
||||
lSensorDataInt: Integer;
|
||||
lMessagingStatus: TLazMessagingStatus;
|
||||
begin
|
||||
Result := 0;
|
||||
|
||||
@ -268,6 +270,23 @@ begin
|
||||
|
||||
// Send the data to the LCL
|
||||
case ASensorKind of
|
||||
-11: // Defined by ourselves for Messaging Status
|
||||
begin
|
||||
lSensorDataInt := Round(arraydata[0]);
|
||||
case lSensorDataInt of
|
||||
1: lMessagingStatus := mssSentSuccessfully;
|
||||
2: lMessagingStatus := mssSendingGeneralError;
|
||||
3: lMessagingStatus := mssNoService;
|
||||
5: lMessagingStatus := mssRadioOff;
|
||||
10:lMessagingStatus := mssReceivedSuccessfully;
|
||||
11:lMessagingStatus := mssReceivingGeneralError;
|
||||
else
|
||||
lMessagingStatus := mssSendingGeneralError;
|
||||
end;
|
||||
|
||||
if Assigned(Messaging.OnMessagingStatus) then
|
||||
Messaging.OnMessagingStatus(nil, lMessagingStatus);
|
||||
end;
|
||||
-10: // Defined by ourselves for PositionInfo
|
||||
begin
|
||||
PositionInfo.latitude := arraydata[0];
|
||||
|
@ -4077,10 +4077,10 @@ var
|
||||
lJavaString: jstring;
|
||||
lIsCopy: jboolean;
|
||||
begin
|
||||
{.$ifdef VerboseCDText}
|
||||
{$ifdef VerboseCDText}
|
||||
DebugLn(Format('[WinAPI GetTextExtentExPoint] DC=%x javaEnvRef=%x Str=%s MaxWidth=%d',
|
||||
[DC, PtrInt(javaEnvRef), StrPas(Str), MaxWidth]));
|
||||
{.$endif}
|
||||
{$endif}
|
||||
// Result := inherited GetTextExtentExPoint(DC, Str, Count, MaxWidth, MaxCount, PartialWidths, Size);
|
||||
|
||||
Result := False;
|
||||
@ -4106,9 +4106,9 @@ begin
|
||||
|
||||
// Read the output
|
||||
lMaxCount := javaEnvRef^^.GetIntField(javaEnvRef, javaActivityObject, javaField_lclmaxcount);
|
||||
{.$ifdef VerboseCDText}
|
||||
{$ifdef VerboseCDText}
|
||||
DebugLn(Format(':[WinAPI GetTextExtentExPoint] MaxCount=%d', [lMaxCount]));
|
||||
{.$endif}
|
||||
{$endif}
|
||||
|
||||
if MaxCount <> nil then MaxCount^ := lMaxCount;
|
||||
|
||||
@ -4123,10 +4123,10 @@ begin
|
||||
for i := 0 to lMaxCount-1 do
|
||||
begin
|
||||
PartialWidths[i] := Round(arraydata[i]);
|
||||
{.$ifdef VerboseCDText}
|
||||
{$ifdef VerboseCDText}
|
||||
DebugLn(Format(':[WinAPI GetTextExtentExPoint] i=%d PartialWidth=%d',
|
||||
[i, PartialWidths[i]]));
|
||||
{.$endif}
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
// Don't forget to release it
|
||||
|
@ -142,9 +142,44 @@ type
|
||||
public
|
||||
class procedure CreateCDControl(const AWinControl: TWinControl; var ACDControlField: TCDControl);
|
||||
published
|
||||
// TWSWinControl
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): HWND; override;
|
||||
class procedure ShowHide(const AWinControl: TWinControl); override;
|
||||
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
||||
|
||||
{ //class function CanFocus(const AWincontrol: TWinControl): Boolean; override;
|
||||
|
||||
class function GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean; override;
|
||||
class function GetClientRect(const AWincontrol: TWinControl; var ARect: TRect): Boolean; override;
|
||||
class procedure GetPreferredSize(const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||
class function GetDefaultClientRect(const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer; var aClientRect: TRect): boolean; override;
|
||||
class function GetDesignInteractive(const AWinControl: TWinControl; AClientPos: TPoint): Boolean; override;}
|
||||
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||
// class function GetTextLen(const AWinControl: TWinControl; var ALength: Integer): Boolean; override;
|
||||
|
||||
{ class procedure SetBiDiMode(const AWinControl: TWinControl; UseRightToLeftAlign, UseRightToLeftReading, UseRightToLeftScrollBar : Boolean); override;
|
||||
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
|
||||
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
|
||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||
class procedure SetChildZPosition(const AWinControl, AChild: TWinControl; const AOldPos, ANewPos: Integer; const AChildren: TFPList); override;
|
||||
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||
class procedure SetPos(const AWinControl: TWinControl; const ALeft, ATop: Integer); override;
|
||||
class procedure SetSize(const AWinControl: TWinControl; const AWidth, AHeight: Integer); override;}
|
||||
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||
{ class procedure SetCursor(const AWinControl: TWinControl; const ACursor: HCursor); override;
|
||||
class procedure SetShape(const AWinControl: TWinControl; const AShape: HBITMAP); override;}
|
||||
|
||||
{ class procedure AdaptBounds(const AWinControl: TWinControl;
|
||||
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;
|
||||
|
||||
class procedure ConstraintsChange(const AWinControl: TWinControl); override;
|
||||
class procedure DefaultWndHandler(const AWinControl: TWinControl; var AMessage); override;
|
||||
class procedure Invalidate(const AWinControl: TWinControl); override;
|
||||
class procedure PaintTo(const AWinControl: TWinControl; ADC: HDC; X, Y: Integer); override;}
|
||||
class procedure ShowHide(const AWinControl: TWinControl); override;
|
||||
|
||||
// TWSCustomEdit
|
||||
|
||||
{ class procedure SetAlignment(const ACustomEdit: TCustomEdit; const AAlignment: TAlignment); override;
|
||||
class function GetCaretPos(const ACustomEdit: TCustomEdit): TPoint; override;
|
||||
class function GetCanUndo(const ACustomEdit: TCustomEdit): Boolean; override;
|
||||
@ -820,6 +855,7 @@ begin
|
||||
ACDControlField.Caption := AWinControl.Caption;
|
||||
ACDControlField.Parent := AWinControl;
|
||||
ACDControlField.Align := alClient;
|
||||
TCDIntfEdit(ACDControlField).Text := TCustomEdit(AWinControl).Text;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -836,6 +872,37 @@ begin
|
||||
lCDWinControl := TCDWinControl(Result);
|
||||
end;
|
||||
|
||||
class procedure TCDWSCustomEdit.DestroyHandle(const AWinControl: TWinControl);
|
||||
var
|
||||
lCDWinControl: TCDWinControl;
|
||||
begin
|
||||
lCDWinControl := TCDWinControl(AWinControl.Handle);
|
||||
lCDWinControl.Free;
|
||||
end;
|
||||
|
||||
class function TCDWSCustomEdit.GetText(const AWinControl: TWinControl;
|
||||
var AText: String): Boolean;
|
||||
var
|
||||
lCDWinControl: TCDWinControl;
|
||||
begin
|
||||
Result := False;
|
||||
lCDWinControl := TCDWinControl(AWinControl.Handle);
|
||||
if lCDWinControl.CDControl = nil then Exit;
|
||||
AText := TCDIntfEdit(lCDWinControl.CDControl).Text;
|
||||
DebugLn('[TCDWSCustomEdit.GetText] AText='+AText);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
class procedure TCDWSCustomEdit.SetText(const AWinControl: TWinControl;
|
||||
const AText: String);
|
||||
var
|
||||
lCDWinControl: TCDWinControl;
|
||||
begin
|
||||
lCDWinControl := TCDWinControl(AWinControl.Handle);
|
||||
if lCDWinControl.CDControl = nil then Exit;
|
||||
TCDIntfEdit(lCDWinControl.CDControl).Text := AText;
|
||||
end;
|
||||
|
||||
class procedure TCDWSCustomEdit.ShowHide(const AWinControl: TWinControl);
|
||||
var
|
||||
lCDWinControl: TCDWinControl;
|
||||
|
@ -51,24 +51,30 @@ type
|
||||
|
||||
// TLazMessaging
|
||||
|
||||
TLazMessageSendingStatus = (mssSuccess, mssGeneralError);
|
||||
TLazMessagingStatus = (
|
||||
// Message sending status
|
||||
mssSentSuccessfully, mssSendingGeneralError, mssRadioOff, mssNoService,
|
||||
// Message receiving status (by the destination)
|
||||
mssReceivedSuccessfully, mssReceivingGeneralError
|
||||
);
|
||||
|
||||
TOnMessageSendingFinished = procedure (AMessage: TLazDeviceMessage;
|
||||
ASendingStatus: TLazMessageSendingStatus; AErrorMsg: string) of object;
|
||||
TOnMessagingStatus = procedure (AMessage: TLazDeviceMessage;
|
||||
AStatus: TLazMessagingStatus) of object;
|
||||
|
||||
{ TLazMessaging }
|
||||
|
||||
TLazMessaging = class
|
||||
private
|
||||
FTOnMessageSendingFinished: TOnMessageSendingFinished;
|
||||
FOnMessagingStatus: TOnMessagingStatus;
|
||||
FMessages: TFPList; // of TLazDeviceMessage
|
||||
public
|
||||
// Attempt to send the specified message.
|
||||
procedure SendMessage(AMsg: TLazDeviceMessage);
|
||||
//
|
||||
constructor Create; virtual;
|
||||
destructor Destroy; override;
|
||||
procedure SendMessage(AMsg: TLazDeviceMessage); // Attempt to send the specified message.
|
||||
function CreateMessage: TLazDeviceMessage;
|
||||
// Called asynchronously when the message sending is finished
|
||||
property OnMessageSendingFinished: TOnMessageSendingFinished read FTOnMessageSendingFinished
|
||||
write FTOnMessageSendingFinished;
|
||||
procedure FreeMessage(AMessage: TLazDeviceMessage);
|
||||
// Called asynchronously when there is a message sending status
|
||||
property OnMessagingStatus: TOnMessagingStatus read FOnMessagingStatus write FOnMessagingStatus;
|
||||
end;
|
||||
|
||||
// TLazPositionInfo
|
||||
@ -123,6 +129,22 @@ end;
|
||||
|
||||
{ TLazMessaging }
|
||||
|
||||
constructor TLazMessaging.Create;
|
||||
begin
|
||||
FMessages := TFPList.Create;
|
||||
end;
|
||||
|
||||
destructor TLazMessaging.Destroy;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
// Free all messages
|
||||
for i := 0 to FMessages.Count-1 do
|
||||
TLazDeviceMessage(FMessages.Items[i]).Free;
|
||||
FMessages.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TLazMessaging.SendMessage(AMsg: TLazDeviceMessage);
|
||||
begin
|
||||
LCLIntf.LazDeviceAPIs_SendMessage(AMsg);
|
||||
@ -131,6 +153,13 @@ end;
|
||||
function TLazMessaging.CreateMessage: TLazDeviceMessage;
|
||||
begin
|
||||
Result := TLazDeviceMessage.Create;
|
||||
FMessages.Add(Result);
|
||||
end;
|
||||
|
||||
procedure TLazMessaging.FreeMessage(AMessage: TLazDeviceMessage);
|
||||
begin
|
||||
FMessages.Remove(AMessage);
|
||||
AMessage.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
Loading…
Reference in New Issue
Block a user