diff --git a/.gitattributes b/.gitattributes index 5f4b134126..32c96ccb75 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5568,6 +5568,7 @@ lcl/interfaces/customdrawn/customdrawnwsforms_android.inc svneol=native#text/pas lcl/interfaces/customdrawn/customdrawnwsforms_cocoa.inc svneol=native#text/pascal lcl/interfaces/customdrawn/customdrawnwsforms_win.inc svneol=native#text/pascal lcl/interfaces/customdrawn/customdrawnwsforms_x11.inc svneol=native#text/pascal +lcl/interfaces/customdrawn/customdrawnwslazdeviceapis.pas svneol=native#text/pascal lcl/interfaces/customdrawn/customdrawnwsstdctrls.pas svneol=native#text/pascal lcl/interfaces/customdrawn/interfaces.pas svneol=native#text/pascal lcl/interfaces/customdrawn/wincallback.inc svneol=native#text/pascal @@ -6005,6 +6006,7 @@ lcl/widgetset/wsfactory.pas svneol=native#text/pascal lcl/widgetset/wsforms.pp svneol=native#text/pascal lcl/widgetset/wsgrids.pp svneol=native#text/pascal lcl/widgetset/wsimglist.pp svneol=native#text/pascal +lcl/widgetset/wslazdeviceapis.pas svneol=native#text/pascal lcl/widgetset/wslclclasses.pp svneol=native#text/pascal lcl/widgetset/wsmenus.pp svneol=native#text/pascal lcl/widgetset/wspairsplitter.pp svneol=native#text/pascal diff --git a/lcl/include/intfbaselcl.inc b/lcl/include/intfbaselcl.inc index af75d621aa..a15e907645 100644 --- a/lcl/include/intfbaselcl.inc +++ b/lcl/include/intfbaselcl.inc @@ -524,26 +524,6 @@ begin // But Forms is not in the uses clause end; -procedure TWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); -begin - -end; - -procedure TWidgetSet.LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); -begin - -end; - -procedure TWidgetSet.LazDeviceAPIs_StartReadingAccelerometerData(); -begin - -end; - -procedure TWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData(); -begin - -end; - function TWidgetSet.MoveWindowOrgEx(dc: hdc; dX,dY: Integer): boolean; var P: TPoint; diff --git a/lcl/include/lclintf.inc b/lcl/include/lclintf.inc index 54066ebc88..be5d7d1d19 100644 --- a/lcl/include/lclintf.inc +++ b/lcl/include/lclintf.inc @@ -356,26 +356,6 @@ begin Result := WidgetSet.IsMobilePlatform(); end; -procedure LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); -begin - Widgetset.LazDeviceAPIs_RequestPositionInfo(AMethod); -end; - -procedure LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); -begin - Widgetset.LazDeviceAPIs_SendMessage(AMsg); -end; - -procedure LazDeviceAPIs_StartReadingAccelerometerData(); -begin - Widgetset.LazDeviceAPIs_StartReadingAccelerometerData(); -end; - -procedure LazDeviceAPIs_StopReadingAccelerometerData(); -begin - Widgetset.LazDeviceAPIs_StopReadingAccelerometerData(); -end; - function MoveWindowOrgEx(dc: hdc; dX,dY: Integer): boolean; begin Result := WidgetSet.MoveWindowOrgEx(DC, dX, dY); diff --git a/lcl/include/lclintfh.inc b/lcl/include/lclintfh.inc index c45c6e3bf8..fce97d9ea0 100644 --- a/lcl/include/lclintfh.inc +++ b/lcl/include/lclintfh.inc @@ -94,11 +94,6 @@ function InvalidateFrame(aHandle : HWND; ARect : pRect; bErase : Boolean; Border function IsDesignerDC(WindowHandle: HWND; DC: HDC): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} function IsMobilePlatform: Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} -procedure LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} -procedure LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} -procedure LazDeviceAPIs_StartReadingAccelerometerData(); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} -procedure LazDeviceAPIs_StopReadingAccelerometerData(); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} - function MoveWindowOrgEx(dc : hdc; dX,dY : Integer): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} function PromptUser(const DialogCaption, DialogMessage : String; DialogType : longint; Buttons : PLongint; ButtonCount, DefaultIndex, EscapeResult : Longint) : Longint;{$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} diff --git a/lcl/interfaces/carbon/carbonwsfactory.pas b/lcl/interfaces/carbon/carbonwsfactory.pas index 8f0fc3aee3..d2194f3023 100644 --- a/lcl/interfaces/carbon/carbonwsfactory.pas +++ b/lcl/interfaces/carbon/carbonwsfactory.pas @@ -101,6 +101,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs; implementation @@ -546,4 +548,10 @@ begin Result := False; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + //RegisterWSLazDeviceAPIs(TCDWSLazDeviceAPIs); + Result := False; +end; + end. diff --git a/lcl/interfaces/cocoa/cocoawsfactory.pas b/lcl/interfaces/cocoa/cocoawsfactory.pas index afd03ba3da..457c955bd4 100644 --- a/lcl/interfaces/cocoa/cocoawsfactory.pas +++ b/lcl/interfaces/cocoa/cocoawsfactory.pas @@ -104,6 +104,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs: Boolean; implementation @@ -532,6 +534,11 @@ begin Result := False; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + //RegisterWSLazDeviceAPIs(TCDWSLazDeviceAPIs); + Result := False; +end; end. diff --git a/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc b/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc index ee5b4e491f..0b1ca402a6 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc @@ -168,53 +168,6 @@ begin Result := True; end; -procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); -var - lPositionMethod: jint; -begin - // Prepare the input - case AMethod of - pmGPS: lPositionMethod := 1; - pmNetwork: lPositionMethod := 2; - else - Exit; - end; - javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclkind, lPositionMethod); - // Call the method - javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoRequestPositionInfo); -end; - -procedure TCDWidgetSet.LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); -var - lJavaString: jstring; - lStr: String; -begin - // Prepare the input - // String fields - lStr := AMsg.Body; - lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(lStr)); - javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcltext, lJavaString); - lStr := AMsg.destinationAddress.Text; - lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(lStr)); - javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcldestination, lJavaString); - // Message type - javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclkind, 1); - // Call the method - javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoSendMessage); -end; - -procedure TCDWidgetSet.LazDeviceAPIs_StartReadingAccelerometerData(); -begin - // Call the method - javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoStartReadingAccelerometer); -end; - -procedure TCDWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData(); -begin - // Call the method - javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoStopReadingAccelerometer); -end; - function TCDWidgetSet.PromptUser(const DialogCaption : string; const DialogMessage : string; DialogType : LongInt; diff --git a/lcl/interfaces/customdrawn/customdrawnlclintf_cocoa.inc b/lcl/interfaces/customdrawn/customdrawnlclintf_cocoa.inc index bde6268c97..bd89d65576 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintf_cocoa.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintf_cocoa.inc @@ -118,26 +118,6 @@ begin Result := Application.ApplicationType in [atPDA, atKeyPadDevice, atTV, atMobileEmulator]; end; -procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); -begin - -end; - -procedure TCDWidgetSet.LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); -begin - -end; - -procedure TCDWidgetSet.LazDeviceAPIs_StartReadingAccelerometerData(); -begin - -end; - -procedure TCDWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData(); -begin - -end; - {------------------------------------------------------------------------------ Function: PromptUser Params: diff --git a/lcl/interfaces/customdrawn/customdrawnlclintf_win.inc b/lcl/interfaces/customdrawn/customdrawnlclintf_win.inc index 8af5d90d3a..ac81d2547d 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintf_win.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintf_win.inc @@ -119,26 +119,6 @@ begin Result := Application.ApplicationType in [atPDA, atKeyPadDevice, atTV, atMobileEmulator]; end; -procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); -begin - -end; - -procedure TCDWidgetSet.LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); -begin - -end; - -procedure TCDWidgetSet.LazDeviceAPIs_StartReadingAccelerometerData(); -begin - -end; - -procedure TCDWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData(); -begin - -end; - {------------------------------------------------------------------------------ Function: PromptUser Params: diff --git a/lcl/interfaces/customdrawn/customdrawnlclintf_x11.inc b/lcl/interfaces/customdrawn/customdrawnlclintf_x11.inc index 2eb8ab03f0..66ea60a7ea 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintf_x11.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintf_x11.inc @@ -119,26 +119,6 @@ begin Result := Application.ApplicationType in [atPDA, atKeyPadDevice, atTV, atMobileEmulator]; end; -procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); -begin - -end; - -procedure TCDWidgetSet.LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); -begin - -end; - -procedure TCDWidgetSet.LazDeviceAPIs_StartReadingAccelerometerData(); -begin - -end; - -procedure TCDWidgetSet.LazDeviceAPIs_StopReadingAccelerometerData(); -begin - -end; - {------------------------------------------------------------------------------ Function: PromptUser Params: diff --git a/lcl/interfaces/customdrawn/customdrawnlclintfh.inc b/lcl/interfaces/customdrawn/customdrawnlclintfh.inc index bcceccd55b..6c1aa6e433 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintfh.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintfh.inc @@ -57,11 +57,6 @@ procedure HideVirtualKeyboard(); function IsDesignerDC(WindowHandle: HWND; DC: HDC): Boolean; override;*) function IsMobilePlatform: Boolean; override; -procedure LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); override; -procedure LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); override; -procedure LazDeviceAPIs_StartReadingAccelerometerData(); override; -procedure LazDeviceAPIs_StopReadingAccelerometerData(); override; - function PromptUser(const DialogCaption : string; const DialogMessage : string; DialogType : LongInt; diff --git a/lcl/interfaces/customdrawn/customdrawnwsfactory.pas b/lcl/interfaces/customdrawn/customdrawnwsfactory.pas index 8d45fad578..f0dfa50617 100644 --- a/lcl/interfaces/customdrawn/customdrawnwsfactory.pas +++ b/lcl/interfaces/customdrawn/customdrawnwsfactory.pas @@ -3,6 +3,7 @@ unit CustomDrawnWSFactory; {$mode objfpc}{$H+} interface + uses Classes, Controls, ComCtrls, ImgList, Calendar, StdCtrls, Arrow, Spin, Dialogs, ExtCtrls, Buttons, Forms, Menus, @@ -96,6 +97,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs: Boolean; implementation uses @@ -111,7 +114,8 @@ uses { WinCEWSImgList, WinCEWSMenus, WinCEWSSpin,} - CustomDrawnWSStdCtrls{, + CustomDrawnWSStdCtrls, + CustomDrawnWSLazDeviceAPIs{, WinCEWSGrids}; // imglist @@ -552,4 +556,10 @@ begin Result := False; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + RegisterWSLazDeviceAPIs(TCDWSLazDeviceAPIs); + Result := True; +end; + end. diff --git a/lcl/interfaces/customdrawn/customdrawnwslazdeviceapis.pas b/lcl/interfaces/customdrawn/customdrawnwslazdeviceapis.pas new file mode 100644 index 0000000000..339a822c22 --- /dev/null +++ b/lcl/interfaces/customdrawn/customdrawnwslazdeviceapis.pas @@ -0,0 +1,131 @@ +{ + ***************************************************************************** + * CustomDrawnLazDeviceAPIS.pas * + * ---------- * + * * + * * + ***************************************************************************** + + ***************************************************************************** + * * + * This file is part of the Lazarus Component Library (LCL) * + * * + * See the file COPYING.modifiedLGPL.txt, included in this distribution, * + * for details about the copyright. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * * + ***************************************************************************** +} +unit CustomDrawnWSLazDeviceAPIS; + +{$mode objfpc}{$H+} + +{$I customdrawndefines.inc} + +interface + +uses + // RTL + Types, Math, + {$ifdef CD_Android} + jni, + {$endif} + // LCL + LazDeviceAPIs, + // Widgetset + customdrawnint, WSLCLClasses, WSLazDeviceAPIs; + +type + { TWSLazDeviceAPIS } + + { TCDWSLazDeviceAPIs } + + TCDWSLazDeviceAPIs = class(TWSLazDeviceAPIs) + public + class procedure RequestPositionInfo(AMethod: TLazPositionMethod); override; + class procedure SendMessage(AMsg: TLazDeviceMessage); override; + class procedure StartReadingAccelerometerData(); override; + class procedure StopReadingAccelerometerData(); override; + end; + +implementation + +{ TCDWSLazDeviceAPIs } + +{$if defined(CD_Windows) or defined(CD_Cocoa) or defined(CD_X11)} +class procedure TCDWSLazDeviceAPIs.RequestPositionInfo( + AMethod: TLazPositionMethod); +begin + +end; + +class procedure TCDWSLazDeviceAPIs.SendMessage(AMsg: TLazDeviceMessage); +begin + +end; + +class procedure TCDWSLazDeviceAPIs.StartReadingAccelerometerData; +begin + +end; + +class procedure TCDWSLazDeviceAPIs.StopReadingAccelerometerData; +begin + +end; +{$endif} + +{$ifdef CD_Android} +class procedure TCDWSLazDeviceAPIs.RequestPositionInfo( + AMethod: TLazPositionMethod); +var + lPositionMethod: jint; +begin + // Prepare the input + case AMethod of + pmGPS: lPositionMethod := 1; + pmNetwork: lPositionMethod := 2; + else + Exit; + end; + javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclkind, lPositionMethod); + // Call the method + javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoRequestPositionInfo); +end; + +class procedure TCDWSLazDeviceAPIs.SendMessage(AMsg: TLazDeviceMessage); +var + lJavaString: jstring; + lStr: String; +begin + // Prepare the input + // String fields + lStr := AMsg.Body; + lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(lStr)); + javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcltext, lJavaString); + lStr := AMsg.destinationAddress.Text; + lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(lStr)); + javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcldestination, lJavaString); + // Message type + javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclkind, 1); + // Call the method + javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoSendMessage); +end; + +class procedure TCDWSLazDeviceAPIs.StartReadingAccelerometerData; +begin + // Call the method + javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoStartReadingAccelerometer); +end; + +class procedure TCDWSLazDeviceAPIs.StopReadingAccelerometerData; +begin + // Call the method + javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoStopReadingAccelerometer); +end; +{$endif} + +end. diff --git a/lcl/interfaces/fpgui/fpguiwsfactory.pas b/lcl/interfaces/fpgui/fpguiwsfactory.pas index 6c830f9352..3ee04c1018 100644 --- a/lcl/interfaces/fpgui/fpguiwsfactory.pas +++ b/lcl/interfaces/fpgui/fpguiwsfactory.pas @@ -96,6 +96,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs: Boolean; implementation @@ -535,6 +537,11 @@ begin Result := False; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + //RegisterWSLazDeviceAPIs(TCDWSLazDeviceAPIs); + Result := False; +end; end. diff --git a/lcl/interfaces/gtk/gtkwsfactory.pas b/lcl/interfaces/gtk/gtkwsfactory.pas index b56cab0145..462cb54e96 100644 --- a/lcl/interfaces/gtk/gtkwsfactory.pas +++ b/lcl/interfaces/gtk/gtkwsfactory.pas @@ -13,6 +13,7 @@ uses function RegisterCustomImageList: Boolean; // controls function RegisterDragImageList: Boolean; +function RegisterLazAccessibleObject: Boolean; function RegisterControl: Boolean; function RegisterWinControl: Boolean; function RegisterGraphicControl: Boolean; @@ -96,6 +97,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs: Boolean; implementation uses @@ -133,6 +136,11 @@ begin Result := True; end; +function RegisterLazAccessibleObject: Boolean; alias : 'WSRegisterLazAccessibleObject'; +begin + Result := False; +end; + function RegisterControl: Boolean; alias : 'WSRegisterControl'; begin // RegisterWSComponent(TControl, TGtkWSControl); @@ -615,4 +623,9 @@ begin Result := False; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + Result := False; +end; + end. diff --git a/lcl/interfaces/gtk2/gtk2wsfactory.pas b/lcl/interfaces/gtk2/gtk2wsfactory.pas index acb49ad49a..c351df3916 100644 --- a/lcl/interfaces/gtk2/gtk2wsfactory.pas +++ b/lcl/interfaces/gtk2/gtk2wsfactory.pas @@ -97,6 +97,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs: Boolean; implementation uses @@ -630,4 +632,10 @@ begin Result := False; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + //RegisterWSLazDeviceAPIs(TCDWSLazDeviceAPIs); + Result := False; +end; + end. diff --git a/lcl/interfaces/nogui/noguiwsfactory.pas b/lcl/interfaces/nogui/noguiwsfactory.pas index 2afd5cd3af..d37620bde8 100644 --- a/lcl/interfaces/nogui/noguiwsfactory.pas +++ b/lcl/interfaces/nogui/noguiwsfactory.pas @@ -95,6 +95,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs: Boolean; implementation @@ -494,6 +496,11 @@ begin Result := False; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + //RegisterWSLazDeviceAPIs(TCDWSLazDeviceAPIs); + Result := False; +end; end. diff --git a/lcl/interfaces/qt/qtwsfactory.pas b/lcl/interfaces/qt/qtwsfactory.pas index 8cd50ca4e2..7efcc43bee 100644 --- a/lcl/interfaces/qt/qtwsfactory.pas +++ b/lcl/interfaces/qt/qtwsfactory.pas @@ -96,6 +96,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs: Boolean; implementation uses @@ -557,5 +559,11 @@ begin Result := True; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + //RegisterWSLazDeviceAPIs(TCDWSLazDeviceAPIs); + Result := False; +end; + end. diff --git a/lcl/interfaces/win32/win32wsfactory.pas b/lcl/interfaces/win32/win32wsfactory.pas index bb8c6c6396..17c1e1fc20 100644 --- a/lcl/interfaces/win32/win32wsfactory.pas +++ b/lcl/interfaces/win32/win32wsfactory.pas @@ -96,6 +96,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs: Boolean; implementation uses @@ -563,4 +565,10 @@ begin Result := False; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + RegisterWSLazDeviceAPIs(TCDWSLazDeviceAPIs); + Result := True; +end; + end. diff --git a/lcl/interfaces/wince/wincewsfactory.pas b/lcl/interfaces/wince/wincewsfactory.pas index 795edfdc1e..05172fde72 100644 --- a/lcl/interfaces/wince/wincewsfactory.pas +++ b/lcl/interfaces/wince/wincewsfactory.pas @@ -96,6 +96,8 @@ function RegisterPairSplitterSide: Boolean; function RegisterCustomPairSplitter: Boolean; function RegisterCustomFloatSpinEdit: Boolean; function RegisterCustomRubberBand: Boolean; +// LazDeviceAPIs +function RegisterLazDeviceAPIs: Boolean; implementation uses @@ -551,4 +553,10 @@ begin Result := False; end; +function RegisterLazDeviceAPIs: Boolean; alias : 'WSRegisterLazDeviceAPIs'; +begin + RegisterWSLazDeviceAPIs(TCDWSLazDeviceAPIs); + Result := True; +end; + end. diff --git a/lcl/lazdeviceapis.pas b/lcl/lazdeviceapis.pas index 38e8a50728..6f3adde123 100644 --- a/lcl/lazdeviceapis.pas +++ b/lcl/lazdeviceapis.pas @@ -53,6 +53,29 @@ type // TLazMessaging + TLazDeviceMessageKind = (dmkSMS, dmkMMS, dmkEMail); + + TLazDeviceMessage = class + public + // The coments indicate in which message kind each + // field is available. SMS MMS EMail + bccAddress: TStringList; // N N Y + Body: string; // Y Y Y + callbackNumber: string; // Y N N + ccAddress: TstringList; // N N Y + destinationAddress: TStringList; // Y Y Y + isRead: Boolean; // Y Y Y + messageId: string; // Y Y Y + //messagePriority Y Y Y + messageType: TLazDeviceMessageKind;//Y Y Y + sourceAddress: string; // Y Y Y + Subject: string; // N Y Y + Time: TDateTime; // Y Y Y + validityPeriod:TTime; // Y N N + constructor Create; virtual; + destructor Destroy; override; + end; + TLazMessagingStatus = ( // Message sending status mssSentSuccessfully, mssSendingGeneralError, mssRadioOff, mssNoService, @@ -63,12 +86,6 @@ type TOnMessagingStatus = procedure (AMessage: TLazDeviceMessage; AStatus: TLazMessagingStatus) of object; - { TLazMessaging } - - TLazDeviceMessageKind = LCLType.TLazDeviceMessageKind; - - TLazDeviceMessage = LCLType.TLazDeviceMessage; - TLazMessaging = class private FOnMessagingStatus: TOnMessagingStatus; @@ -87,7 +104,7 @@ type // TLazPositionInfo - TLazPositionMethod = LCLType.TLazPositionMethod; + TLazPositionMethod = (pmGPS, pmNetwork); TLazPositionInfo = class private @@ -114,27 +131,56 @@ var implementation +uses wslazdeviceapis, wslclclasses; + { TLazAccelerometer } procedure TLazAccelerometer.StartReadingAccelerometerData; +var + WidgetsetClass: TWSLazDeviceAPIsClass; begin if FReadingStarted then Exit; - LCLIntf.LazDeviceAPIs_StartReadingAccelerometerData(); + WidgetsetClass := TWSLazDeviceAPIsClass(GetWSLazDeviceAPIs()); + WidgetsetClass.StartReadingAccelerometerData(); FReadingStarted := True; end; procedure TLazAccelerometer.StopReadingAccelerometerData; +var + WidgetsetClass: TWSLazDeviceAPIsClass; begin if not FReadingStarted then Exit; - LCLIntf.LazDeviceAPIs_StopReadingAccelerometerData(); + WidgetsetClass := TWSLazDeviceAPIsClass(GetWSLazDeviceAPIs()); + WidgetsetClass.StopReadingAccelerometerData(); FReadingStarted := False; end; { TLazPositionInfo } procedure TLazPositionInfo.RequestPositionInfo(AMethod: TLazPositionMethod); +var + WidgetsetClass: TWSLazDeviceAPIsClass; begin - LCLIntf.LazDeviceAPIs_RequestPositionInfo(AMethod); + WidgetsetClass := TWSLazDeviceAPIsClass(GetWSLazDeviceAPIs()); + WidgetsetClass.RequestPositionInfo(AMethod); +end; + +{ TLazDeviceMessage } + +constructor TLazDeviceMessage.Create; +begin + inherited Create; + bccAddress := TStringList.Create; + ccAddress := TStringList.Create; + destinationAddress := TStringList.Create; +end; + +destructor TLazDeviceMessage.Destroy; +begin + bccAddress.Free; + ccAddress.Free; + destinationAddress.Free; + inherited Destroy; end; { TLazMessaging } @@ -156,8 +202,11 @@ begin end; procedure TLazMessaging.SendMessage(AMsg: TLazDeviceMessage); +var + WidgetsetClass: TWSLazDeviceAPIsClass; begin - LCLIntf.LazDeviceAPIs_SendMessage(AMsg); + WidgetsetClass := TWSLazDeviceAPIsClass(GetWSLazDeviceAPIs()); + WidgetsetClass.SendMessage(AMsg); end; function TLazMessaging.CreateMessage: TLazDeviceMessage; @@ -173,6 +222,7 @@ begin end; initialization + RegisterLazDeviceAPIs(); Accelerometer := TLazAccelerometer.Create; Messaging := TLazMessaging.Create; PositionInfo := TLazPositionInfo.Create; diff --git a/lcl/lcltype.pp b/lcl/lcltype.pp index fa1f69463b..446fff0d29 100644 --- a/lcl/lcltype.pp +++ b/lcl/lcltype.pp @@ -96,35 +96,6 @@ type TNativeCanvasType = (nctWindowsDC, nctLazCanvas); TNativeCanvasTypes = set of TNativeCanvasType; - // Types for LazDeviceAPIs - - TLazPositionMethod = (pmGPS, pmNetwork); - - { TLazDeviceMessage } - - TLazDeviceMessageKind = (dmkSMS, dmkMMS, dmkEMail); - - TLazDeviceMessage = class - public - // The coments indicate in which message kind each - // field is available. SMS MMS EMail - bccAddress: TStringList; // N N Y - Body: string; // Y Y Y - callbackNumber: string; // Y N N - ccAddress: TstringList; // N N Y - destinationAddress: TStringList; // Y Y Y - isRead: Boolean; // Y Y Y - messageId: string; // Y Y Y - //messagePriority Y Y Y - messageType: TLazDeviceMessageKind;//Y Y Y - sourceAddress: string; // Y Y Y - Subject: string; // N Y Y - Time: TDateTime; // Y Y Y - validityPeriod:TTime; // Y N N - constructor Create; virtual; - destructor Destroy; override; - end; - {$ifndef WINDOWS} THandle = type PtrUInt; // define our own, because the SysUtils.THandle = System.THandle is a longint HANDLE = THandle; @@ -3265,24 +3236,6 @@ begin end; -{ TLazDeviceMessage } - -constructor TLazDeviceMessage.Create; -begin - inherited Create; - bccAddress := TStringList.Create; - ccAddress := TStringList.Create; - destinationAddress := TStringList.Create; -end; - -destructor TLazDeviceMessage.Destroy; -begin - bccAddress.Free; - ccAddress.Free; - destinationAddress.Free; - inherited Destroy; -end; - { TListWithEvent } procedure TListWithEvent.Notify(Ptr: Pointer; AnAction: TListNotification); diff --git a/lcl/widgetset/wsfactory.pas b/lcl/widgetset/wsfactory.pas index 897f55ecaf..e1ba5401f3 100644 --- a/lcl/widgetset/wsfactory.pas +++ b/lcl/widgetset/wsfactory.pas @@ -98,6 +98,8 @@ function WSRegisterCustomPairSplitter: Boolean; external name 'WSRegisterCustomP function WSRegisterCustomFloatSpinEdit: Boolean;external name 'WSRegisterCustomFloatSpinEdit'; // RubberBand function WSRegisterCustomRubberBand: Boolean; external name 'WSRegisterCustomRubberBand'; +// LazDeviceAPIs +function WSRegisterLazDeviceAPIs: Boolean; external name 'WSRegisterLazDeviceAPIs'; implementation diff --git a/lcl/widgetset/wslazdeviceapis.pas b/lcl/widgetset/wslazdeviceapis.pas new file mode 100644 index 0000000000..c1c909cb2f --- /dev/null +++ b/lcl/widgetset/wslazdeviceapis.pas @@ -0,0 +1,105 @@ +{ + ***************************************************************************** + * WSLazDeviceAPIS.pas * + * ---------- * + * * + * * + ***************************************************************************** + + ***************************************************************************** + * * + * This file is part of the Lazarus Component Library (LCL) * + * * + * See the file COPYING.modifiedLGPL.txt, included in this distribution, * + * for details about the copyright. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * * + ***************************************************************************** +} +unit WSLazDeviceAPIS; + +{$mode objfpc}{$H+} + +interface +//////////////////////////////////////////////////// +// I M P O R T A N T +//////////////////////////////////////////////////// +// 1) Only class methods allowed +// 2) Class methods have to be published and virtual +// 3) To get as little as posible circles, the uses +// clause should contain only those LCL units +// needed for registration. WSxxx units are OK +// 4) To improve speed, register only classes in the +// initialization section which actually +// implement something +// 5) To enable your XXX widgetset units, look at +// the uses clause of the XXXintf.pp +//////////////////////////////////////////////////// +uses +//////////////////////////////////////////////////// +// To get as little as posible circles, +// uncomment only when needed for registration +//////////////////////////////////////////////////// + Types, Math, LazDeviceAPIs, +//////////////////////////////////////////////////// + WSLCLClasses, WSControls, WSFactory; + +type + { TWSLazDeviceAPIS } + + TWSLazDeviceAPIsClass = class of TWSLazDeviceAPIs; + TWSLazDeviceAPIs = class(TWSObject) + public + class procedure RequestPositionInfo(AMethod: TLazPositionMethod); virtual; + class procedure SendMessage(AMsg: TLazDeviceMessage); virtual; + class procedure StartReadingAccelerometerData(); virtual; + class procedure StopReadingAccelerometerData(); virtual; + end; + +{ WidgetSetRegistration } +procedure RegisterLazDeviceAPIs; + +implementation + +{ TWSArrow } + + +{ WidgetSetRegistration } + +procedure RegisterLazDeviceAPIs; +const + Done: Boolean = False; +begin + if Done then exit; + WSRegisterLazDeviceAPIs; +// if not WSRegisterArrow then +// RegisterWSComponent(TArrow, TWSArrow); + Done := True; +end; + +{ TWSLazDeviceAPIs } + +class procedure TWSLazDeviceAPIs.RequestPositionInfo(AMethod: TLazPositionMethod); +begin + +end; + +class procedure TWSLazDeviceAPIs.SendMessage(AMsg: TLazDeviceMessage); +begin + +end; + +class procedure TWSLazDeviceAPIs.StartReadingAccelerometerData; +begin + +end; + +class procedure TWSLazDeviceAPIs.StopReadingAccelerometerData; +begin + +end; + +end. diff --git a/lcl/widgetset/wslclclasses.pp b/lcl/widgetset/wslclclasses.pp index 94faf4a5c6..36e388fcf2 100644 --- a/lcl/widgetset/wslclclasses.pp +++ b/lcl/widgetset/wslclclasses.pp @@ -89,6 +89,8 @@ procedure RegisterWSComponent(const AComponent: TComponentClass; // Only for non-TComponent based objects function GetWSLazAccessibleObject: TWSObjectClass; procedure RegisterWSLazAccessibleObject(const AWSObject: TWSObjectClass); +function GetWSLazDeviceAPIs: TWSObjectClass; +procedure RegisterWSLazDeviceAPIs(const AWSObject: TWSObjectClass); implementation @@ -127,6 +129,7 @@ var MComponentIndex: TStringList; MWSRegisterIndex: TStringList; WSLazAccessibleObjectClass: TWSObjectClass; + WSLazDeviceAPIsClass: TWSObjectClass; function FindWSComponentClass( const AComponent: TComponentClass): TWSLCLComponentClass; @@ -443,6 +446,15 @@ begin WSLazAccessibleObjectClass := AWSObject; end; +function GetWSLazDeviceAPIs: TWSObjectClass; +begin + Result := WSLazDeviceAPIsClass; +end; + +procedure RegisterWSLazDeviceAPIs(const AWSObject: TWSObjectClass); +begin + WSLazDeviceAPIsClass := AWSObject; +end; { TWSLCLComponent }