From 45beb7cd019518d9108db8badb9d959f2553698f Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Sun, 8 Jan 2012 10:05:55 +0000 Subject: [PATCH] Starts Accessibility API structure and adds a routine to detect if we are on a mobile platform git-svn-id: trunk@34656 - --- lcl/forms.pp | 4 +++- lcl/include/intfbaselcl.inc | 17 +++++++++++++++++ lcl/include/lclintf.inc | 16 ++++++++++++++++ lcl/include/lclintfh.inc | 3 +++ lcl/interfaces/customdrawn/customdrawnint.pas | 3 +-- .../customdrawn/customdrawnlclintf_android.inc | 15 +++++++++++++++ .../customdrawn/customdrawnlclintf_cocoa.inc | 15 +++++++++++++++ .../customdrawn/customdrawnlclintf_win.inc | 15 +++++++++++++++ .../customdrawn/customdrawnlclintf_x11.inc | 15 +++++++++++++++ .../customdrawn/customdrawnlclintfh.inc | 3 +++ .../customdrawn/customdrawnobject_cocoa.inc | 4 +--- .../customdrawn/customdrawnwsforms_cocoa.inc | 5 +++-- lcl/lazdeviceapis.pas | 6 ++++++ 13 files changed, 113 insertions(+), 8 deletions(-) diff --git a/lcl/forms.pp b/lcl/forms.pp index ac51baa5c8..1d8db06f76 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -1211,7 +1211,9 @@ type atPDA, // For smartphones and other devices with touch screen and a small screen atKeyPadDevice,// Devices without any pointing device, such as keypad feature phones or kiosk machines atTablet, // Similar to a PDA/Smartphone, but with a large screen - atTV // The device is a television + atTV, // The device is a television + atMobileEmulator// For desktop platforms. It will create a main windows of 240x320 + // and place all forms there to immitate a mobile platform ); TApplicationShowGlyphs = ( diff --git a/lcl/include/intfbaselcl.inc b/lcl/include/intfbaselcl.inc index b1f0b2f705..982bc33e78 100644 --- a/lcl/include/intfbaselcl.inc +++ b/lcl/include/intfbaselcl.inc @@ -517,6 +517,23 @@ begin Result := False; end; +function TWidgetSet.IsMobilePlatform: Boolean; +begin + Result := False; + // A good default would be: Result := Application.ApplicationType in [atPDA, atKeyPadDevice, atTV, atMobileEmulator]; + // But Forms is not in the uses clause +end; + +procedure TWidgetSet.LazAccessibility_SendTextChangedNotification(const ANewText: string); +begin + +end; + +procedure TWidgetSet.LazAccessibility_SendSelectionChangedNotification(const ASelStart, ASelEnd: Integer); +begin + +end; + procedure TWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); begin diff --git a/lcl/include/lclintf.inc b/lcl/include/lclintf.inc index ed0cda1ae8..3fe7d0e760 100644 --- a/lcl/include/lclintf.inc +++ b/lcl/include/lclintf.inc @@ -350,6 +350,22 @@ begin Result := WidgetSet.IsDesignerDC(WindowHandle, DC); end; +// Indicates of we have fullscreen-only forms like in a mobile platform +function IsMobilePlatform: Boolean; +begin + Result := WidgetSet.IsMobilePlatform(); +end; + +procedure LazAccessibility_SendTextChangedNotification(const ANewText: string); +begin + WidgetSet.LazAccessibility_SendTextChangedNotification(ANewText); +end; + +procedure LazAccessibility_SendSelectionChangedNotification(const ASelStart, ASelEnd: Integer); +begin + WidgetSet.LazAccessibility_SendSelectionChangedNotification(ASelStart, ASelEnd); +end; + procedure LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); begin Widgetset.LazDeviceAPIs_RequestPositionInfo(AMethod); diff --git a/lcl/include/lclintfh.inc b/lcl/include/lclintfh.inc index bd3369eb24..0b4e39384f 100644 --- a/lcl/include/lclintfh.inc +++ b/lcl/include/lclintfh.inc @@ -92,7 +92,10 @@ function GetWindowRelativePosition(Handle : hwnd; var Left, Top: integer): boole function IntfSendsUTF8KeyPress: Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} deprecated; function InvalidateFrame(aHandle : HWND; ARect : pRect; bErase : Boolean; BorderWidth: integer) : Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} function IsDesignerDC(WindowHandle: HWND; DC: HDC): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} +function IsMobilePlatform: Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} +procedure LazAccessibility_SendTextChangedNotification(const ANewText: string); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} +procedure LazAccessibility_SendSelectionChangedNotification(const ASelStart, ASelEnd: Integer); {$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} diff --git a/lcl/interfaces/customdrawn/customdrawnint.pas b/lcl/interfaces/customdrawn/customdrawnint.pas index b91575cb3e..76e61c9c9d 100644 --- a/lcl/interfaces/customdrawn/customdrawnint.pas +++ b/lcl/interfaces/customdrawn/customdrawnint.pas @@ -163,8 +163,7 @@ type // Default Fonts DefaultFont: TFPCustomFont; DefaultFontAndroidSize: Integer; - // Mobile emulator - MobileMode: Boolean; + // Mobile emulator and mobile mode MobileMainForm: TLCLIntfHandle; // For unusual implementations of DebugLn/DebugOut procedure AccumulatingDebugOut(AStr: string); diff --git a/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc b/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc index 8cb4ae53c4..8e01c4109d 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintf_android.inc @@ -163,6 +163,21 @@ begin javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoHideVirtualKeyboard); end; +function TCDWidgetSet.IsMobilePlatform: Boolean; +begin + Result := True; +end; + +procedure TCDWidgetSet.LazAccessibility_SendTextChangedNotification(const ANewText: string); +begin + +end; + +procedure TCDWidgetSet.LazAccessibility_SendSelectionChangedNotification(const ASelStart, ASelEnd: Integer); +begin + +end; + procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); var lPositionMethod: jint; diff --git a/lcl/interfaces/customdrawn/customdrawnlclintf_cocoa.inc b/lcl/interfaces/customdrawn/customdrawnlclintf_cocoa.inc index 43db984fab..6603226c46 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintf_cocoa.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintf_cocoa.inc @@ -113,6 +113,21 @@ begin end; +function TCDWidgetSet.IsMobilePlatform: Boolean; +begin + Result := Application.ApplicationType in [atPDA, atKeyPadDevice, atTV, atMobileEmulator]; +end; + +procedure TCDWidgetSet.LazAccessibility_SendTextChangedNotification(const ANewText: string); +begin + +end; + +procedure TCDWidgetSet.LazAccessibility_SendSelectionChangedNotification(const ASelStart, ASelEnd: Integer); +begin + +end; + procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); begin diff --git a/lcl/interfaces/customdrawn/customdrawnlclintf_win.inc b/lcl/interfaces/customdrawn/customdrawnlclintf_win.inc index b198da3c69..3b27ec986d 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintf_win.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintf_win.inc @@ -114,6 +114,21 @@ begin end; +function TCDWidgetSet.IsMobilePlatform: Boolean; +begin + Result := Application.ApplicationType in [atPDA, atKeyPadDevice, atTV, atMobileEmulator]; +end; + +procedure TCDWidgetSet.LazAccessibility_SendTextChangedNotification(const ANewText: string); +begin + +end; + +procedure TCDWidgetSet.LazAccessibility_SendSelectionChangedNotification(const ASelStart, ASelEnd: Integer); +begin + +end; + procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); begin diff --git a/lcl/interfaces/customdrawn/customdrawnlclintf_x11.inc b/lcl/interfaces/customdrawn/customdrawnlclintf_x11.inc index a50b4fe926..37fe021beb 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintf_x11.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintf_x11.inc @@ -114,6 +114,21 @@ begin end; +function TCDWidgetSet.IsMobilePlatform: Boolean; +begin + Result := Application.ApplicationType in [atPDA, atKeyPadDevice, atTV, atMobileEmulator]; +end; + +procedure TCDWidgetSet.LazAccessibility_SendTextChangedNotification(const ANewText: string); +begin + +end; + +procedure TCDWidgetSet.LazAccessibility_SendSelectionChangedNotification(const ASelStart, ASelEnd: Integer); +begin + +end; + procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); begin diff --git a/lcl/interfaces/customdrawn/customdrawnlclintfh.inc b/lcl/interfaces/customdrawn/customdrawnlclintfh.inc index ecbb6a083a..277c57608c 100644 --- a/lcl/interfaces/customdrawn/customdrawnlclintfh.inc +++ b/lcl/interfaces/customdrawn/customdrawnlclintfh.inc @@ -55,7 +55,10 @@ procedure HideVirtualKeyboard(); (*function IntfSendsUTF8KeyPress: boolean; override; function IsDesignerDC(WindowHandle: HWND; DC: HDC): Boolean; override;*) +function IsMobilePlatform: Boolean; override; +procedure LazAccessibility_SendTextChangedNotification(const ANewText: string); override; +procedure LazAccessibility_SendSelectionChangedNotification(const ASelStart, ASelEnd: Integer); override; procedure LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod); override; procedure LazDeviceAPIs_SendMessage(AMsg: TLazDeviceMessage); override; procedure LazDeviceAPIs_StartReadingAccelerometerData(); override; diff --git a/lcl/interfaces/customdrawn/customdrawnobject_cocoa.inc b/lcl/interfaces/customdrawn/customdrawnobject_cocoa.inc index 89b113e0f4..c6cfa56a5b 100644 --- a/lcl/interfaces/customdrawn/customdrawnobject_cocoa.inc +++ b/lcl/interfaces/customdrawn/customdrawnobject_cocoa.inc @@ -39,8 +39,6 @@ begin if Application.ApplicationType = atDefault then Application.ApplicationType := atDesktop; - MobileMode := Application.ApplicationType in [atPDA, atKeyPadDevice]; - if Application.LayoutAdjustmentPolicy = lapDefault then Application.LayoutAdjustmentPolicy := lapFixedLayout; @@ -63,7 +61,7 @@ begin DebugLn('TCDWidgetSet.AppRun'); {$ENDIF} - if MobileMode and (Application.MainForm <> nil) then + if LCLIntf.IsMobilePlatform() and (Application.MainForm <> nil) then TCDWSCustomForm.DoShowHide(Application.MainForm); { Enters main message loop } diff --git a/lcl/interfaces/customdrawn/customdrawnwsforms_cocoa.inc b/lcl/interfaces/customdrawn/customdrawnwsforms_cocoa.inc index 589916a54b..3eb029f454 100644 --- a/lcl/interfaces/customdrawn/customdrawnwsforms_cocoa.inc +++ b/lcl/interfaces/customdrawn/customdrawnwsforms_cocoa.inc @@ -24,7 +24,8 @@ begin winhandle := TCocoaWindow.Create; winhandle.LCLForm := TCustomForm(AWinControl); - if CDWidgetset.MobileMode then lRect := GetNSRect(200, 200, 240, 320) + if Application.ApplicationType = atMobileEmulator then lRect := GetNSRect(200, 200, 240, 320) + // else ToDo: for atPDA make it fullscreen else lRect := CreateParamsToNSRect(AParams); win:=TCocoaForm(win.initWithContentRect_styleMask_backing_defer(lRect, WinMask, NSBackingStoreBuffered, False)); win.WindowHandle := winhandle; @@ -66,7 +67,7 @@ end; class function TCDWSCustomForm.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; begin - if CDWidgetset.MobileMode then + if LCLIntf.IsMobilePlatform() then begin Result := TLCLIntfhandle(AddNewForm(TCustomForm(AWinControl))); if AWinControl = Application.MainForm then diff --git a/lcl/lazdeviceapis.pas b/lcl/lazdeviceapis.pas index 0c2e52aeee..70711336cd 100644 --- a/lcl/lazdeviceapis.pas +++ b/lcl/lazdeviceapis.pas @@ -63,6 +63,10 @@ type { TLazMessaging } + TLazDeviceMessageKind = LCLType.TLazDeviceMessageKind; + + TLazDeviceMessage = LCLType.TLazDeviceMessage; + TLazMessaging = class private FOnMessagingStatus: TOnMessagingStatus; @@ -81,6 +85,8 @@ type // TLazPositionInfo + TLazPositionMethod = LCLType.TLazPositionMethod; + TLazPositionInfo = class private FOnPositionRetrieved: TNotifyEvent;