mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 20:39:14 +02:00
LCL-CustomDrawn-Cocoa: Fixes compilation, corrects the AX strings comparisons and makes a connection from the window to the client area
git-svn-id: trunk@36210 -
This commit is contained in:
parent
416d52d6f0
commit
633e9a700f
@ -20,10 +20,12 @@ uses
|
|||||||
|
|
||||||
type
|
type
|
||||||
TCocoaForm = objcclass;
|
TCocoaForm = objcclass;
|
||||||
|
TCocoaCustomControl = objcclass;
|
||||||
|
|
||||||
TCocoaWindow = class(TCDForm)
|
TCocoaWindow = class(TCDForm)
|
||||||
public
|
public
|
||||||
CocoaForm: TCocoaForm;
|
CocoaForm: TCocoaForm;
|
||||||
|
ClientArea: TCocoaCustomControl;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaForm }
|
{ TCocoaForm }
|
||||||
@ -62,6 +64,8 @@ type
|
|||||||
procedure CallbackDeactivate; message 'CallbackDeactivate';
|
procedure CallbackDeactivate; message 'CallbackDeactivate';
|
||||||
procedure CallbackCloseQuery(var CanClose: Boolean); message 'CallbackCloseQuery:';
|
procedure CallbackCloseQuery(var CanClose: Boolean); message 'CallbackCloseQuery:';
|
||||||
procedure CallbackResize; message 'CallbackResize';
|
procedure CallbackResize; message 'CallbackResize';
|
||||||
|
// Accessibility
|
||||||
|
function accessibilityAttributeValue(attribute: NSString): id; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaCustomControl }
|
{ TCocoaCustomControl }
|
||||||
@ -665,6 +669,28 @@ begin
|
|||||||
LCLSendSizeMsg(WindowHandle.LCLForm, Round(sz.width), Round(sz.height), SIZENORMAL);
|
LCLSendSizeMsg(WindowHandle.LCLForm, Round(sz.width), Round(sz.height), SIZENORMAL);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCocoaForm.accessibilityAttributeValue(attribute: NSString): id;
|
||||||
|
var
|
||||||
|
lStrAttr: String;
|
||||||
|
lAResult: NSArray;
|
||||||
|
lMAResult: NSMutableArray;
|
||||||
|
begin
|
||||||
|
Result := inherited accessibilityAttributeValue(attribute);
|
||||||
|
|
||||||
|
//lStrAttr := NSStringToString(attribute);
|
||||||
|
//DebugLn('[TCocoaCustomControl.accessibilityAttributeValue] attribute='+lStrAttr);
|
||||||
|
|
||||||
|
if attribute.isEqualToString(NSAccessibilityChildrenAttribute) then
|
||||||
|
begin
|
||||||
|
// Strangely Cocoa doesn't add automatically the client area to the array
|
||||||
|
DebugLn('[TCocoaForm.accessibilityAttributeValue] NSAccessibilityChildrenAttribute');
|
||||||
|
lAResult := NSArray(Result);
|
||||||
|
lMAResult := lAResult.mutableCopy();
|
||||||
|
lMAResult.addObject(WindowHandle.ClientArea);
|
||||||
|
Result := lMAResult;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaCustomControl }
|
{ TCocoaCustomControl }
|
||||||
|
|
||||||
procedure TCocoaCustomControl.drawRect(dirtyRect:NSRect);
|
procedure TCocoaCustomControl.drawRect(dirtyRect:NSRect);
|
||||||
@ -876,14 +902,14 @@ begin
|
|||||||
lStrAttr := NSStringToString(attribute);
|
lStrAttr := NSStringToString(attribute);
|
||||||
//DebugLn('[TCocoaCustomControl.accessibilityAttributeValue] attribute='+lStrAttr);
|
//DebugLn('[TCocoaCustomControl.accessibilityAttributeValue] attribute='+lStrAttr);
|
||||||
|
|
||||||
if attribute = NSAccessibilityRoleAttribute then
|
if attribute.isEqualToString(NSAccessibilityRoleAttribute) then
|
||||||
begin
|
begin
|
||||||
DebugLn('[TCocoaCustomControl.accessibilityAttributeValue] NSAccessibilityRoleAttribute');
|
DebugLn('[TCocoaCustomControl.accessibilityAttributeValue] NSAccessibilityRoleAttribute');
|
||||||
lForm := WindowHandle.LCLForm;
|
lForm := WindowHandle.LCLForm;
|
||||||
lFormAcc := lForm.GetAccessibleObject();
|
lFormAcc := lForm.GetAccessibleObject();
|
||||||
Result := LazRoleToCocoaRole(lFormAcc.AccessibleRole);
|
Result := LazRoleToCocoaRole(lFormAcc.AccessibleRole);
|
||||||
end
|
end
|
||||||
else if attribute = NSAccessibilityChildrenAttribute then
|
else if attribute.isEqualToString(NSAccessibilityChildrenAttribute) then
|
||||||
begin
|
begin
|
||||||
DebugLn('[TCocoaCustomControl.accessibilityAttributeValue] NSAccessibilityChildrenAttribute');
|
DebugLn('[TCocoaCustomControl.accessibilityAttributeValue] NSAccessibilityChildrenAttribute');
|
||||||
lAResult := NSArray(Result);
|
lAResult := NSArray(Result);
|
||||||
@ -895,7 +921,9 @@ begin
|
|||||||
lChildAcc := lFormAcc.GetChildAccessibleObject(i);
|
lChildAcc := lFormAcc.GetChildAccessibleObject(i);
|
||||||
lAccObject := TCocoaAccessibleObject(lChildAcc.Handle);
|
lAccObject := TCocoaAccessibleObject(lChildAcc.Handle);
|
||||||
lMAResult.addObject(lAccObject);
|
lMAResult.addObject(lAccObject);
|
||||||
|
//Debug(Format(' Adding object %s : %x', [lChildAcc.OwnerControl.ClassName, PtrUInt(lAccObject)]);
|
||||||
end;
|
end;
|
||||||
|
//DebugLn('');
|
||||||
Result := lMAResult;
|
Result := lMAResult;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -910,7 +938,7 @@ begin
|
|||||||
lResult := NSMutableArray.array_();
|
lResult := NSMutableArray.array_();
|
||||||
|
|
||||||
lCocoaRole := TCocoaCustomControl.LazRoleToCocoaRole(LCLAcc.AccessibleRole);
|
lCocoaRole := TCocoaCustomControl.LazRoleToCocoaRole(LCLAcc.AccessibleRole);
|
||||||
if lCocoaRole.caseInsensitiveCompare(NSAccessibilityButtonRole) = NSOrderedSame then
|
if lCocoaRole.isEqualToString(NSAccessibilityButtonRole) then
|
||||||
begin
|
begin
|
||||||
lResult.addObject(NSAccessibilityDescriptionAttribute);
|
lResult.addObject(NSAccessibilityDescriptionAttribute);
|
||||||
lResult.addObject(NSAccessibilityFocusedAttribute);
|
lResult.addObject(NSAccessibilityFocusedAttribute);
|
||||||
@ -948,39 +976,39 @@ begin
|
|||||||
lStrAttr := NSStringToString(attribute);
|
lStrAttr := NSStringToString(attribute);
|
||||||
//DebugLn('[TCocoaAccessibleObject.accessibilityAttributeValue] attribute='+lStrAttr);
|
//DebugLn('[TCocoaAccessibleObject.accessibilityAttributeValue] attribute='+lStrAttr);
|
||||||
|
|
||||||
if attribute.caseInsensitiveCompare(NSAccessibilityRoleAttribute) = NSOrderedSame then
|
if attribute.isEqualToString(NSAccessibilityRoleAttribute) then
|
||||||
begin
|
begin
|
||||||
DebugLn('[TCocoaAccessibleObject.accessibilityAttributeValue] NSAccessibilityRoleAttribute');
|
DebugLn('[TCocoaAccessibleObject.accessibilityAttributeValue] NSAccessibilityRoleAttribute');
|
||||||
Result := TCocoaCustomControl.LazRoleToCocoaRole(LCLAcc.AccessibleRole);
|
Result := TCocoaCustomControl.LazRoleToCocoaRole(LCLAcc.AccessibleRole);
|
||||||
end
|
end
|
||||||
else if attribute.caseInsensitiveCompare(NSAccessibilityRoleDescriptionAttribute) = NSOrderedSame then
|
else if attribute.isEqualToString(NSAccessibilityRoleDescriptionAttribute) then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end
|
end
|
||||||
else if attribute.caseInsensitiveCompare(NSAccessibilityValueAttribute) = NSOrderedSame then
|
else if attribute.isEqualToString(NSAccessibilityValueAttribute) then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end
|
end
|
||||||
{else if attribute = NSAccessibilityMinValueAttribute: NSString; cvar; external;
|
{else if attribute = NSAccessibilityMinValueAttribute: NSString; cvar; external;
|
||||||
NSAccessibilityMaxValueAttribute: NSString; cvar; external;}
|
NSAccessibilityMaxValueAttribute: NSString; cvar; external;}
|
||||||
else if attribute.caseInsensitiveCompare(NSAccessibilityEnabledAttribute) = NSOrderedSame then
|
else if attribute.isEqualToString(NSAccessibilityEnabledAttribute) then
|
||||||
begin
|
begin
|
||||||
Result := NSNumber.numberWithBool(LCLControl.Enabled);
|
Result := NSNumber.numberWithBool(LCLControl.Enabled);
|
||||||
end
|
end
|
||||||
else if attribute.caseInsensitiveCompare(NSAccessibilityFocusedAttribute) = NSOrderedSame then
|
else if attribute.isEqualToString(NSAccessibilityFocusedAttribute) then
|
||||||
begin
|
begin
|
||||||
if LCLControl is TWinControl then
|
if LCLControl is TWinControl then
|
||||||
Result := NSNumber.numberWithBool(TWinControl(LCLControl).Focused)
|
Result := NSNumber.numberWithBool(TWinControl(LCLControl).Focused)
|
||||||
else Result := NSNumber.numberWithBool(False);
|
else Result := NSNumber.numberWithBool(False);
|
||||||
end
|
end
|
||||||
else if attribute.caseInsensitiveCompare(NSAccessibilityParentAttribute) = NSOrderedSame then
|
else if attribute.isEqualToString(NSAccessibilityParentAttribute) then
|
||||||
begin
|
begin
|
||||||
lParent := LCLControl.Parent;
|
lParent := LCLControl.Parent;
|
||||||
if lParent <> nil then
|
if lParent <> nil then
|
||||||
Result := TCocoaAccessibleObject(lParent.GetAccessibleObject().Handle);
|
Result := TCocoaAccessibleObject(lParent.GetAccessibleObject().Handle);
|
||||||
end
|
end
|
||||||
else if (attribute = NSAccessibilityChildrenAttribute)
|
else if attribute.isEqualToString(NSAccessibilityChildrenAttribute)
|
||||||
or (attribute = NSAccessibilityVisibleChildrenAttribute) then
|
or attribute.isEqualToString(NSAccessibilityVisibleChildrenAttribute) then
|
||||||
begin
|
begin
|
||||||
DebugLn('[TCocoaAccessibleObject.accessibilityAttributeValue] NSAccessibilityChildrenAttribute');
|
DebugLn('[TCocoaAccessibleObject.accessibilityAttributeValue] NSAccessibilityChildrenAttribute');
|
||||||
lAResult := NSArray(Result);
|
lAResult := NSArray(Result);
|
||||||
@ -992,20 +1020,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
Result := lMAResult;
|
Result := lMAResult;
|
||||||
end
|
end
|
||||||
else if attribute.caseInsensitiveCompare(NSAccessibilityWindowAttribute) = NSOrderedSame then
|
else if attribute.isEqualToString(NSAccessibilityWindowAttribute) then
|
||||||
begin
|
begin
|
||||||
lForm := Forms.GetParentForm(LCLControl);
|
lForm := Forms.GetParentForm(LCLControl);
|
||||||
Result := TCocoaAccessibleObject(lForm.GetAccessibleObject().Handle);
|
Result := TCocoaAccessibleObject(lForm.GetAccessibleObject().Handle);
|
||||||
end
|
end
|
||||||
else if attribute = NSAccessibilityTopLevelUIElementAttribute then
|
else if attribute.isEqualToString(NSAccessibilityTopLevelUIElementAttribute) then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end
|
end
|
||||||
else if attribute = NSAccessibilitySelectedChildrenAttribute then
|
else if attribute.isEqualToString(NSAccessibilitySelectedChildrenAttribute) then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end
|
end
|
||||||
else if attribute = NSAccessibilityPositionAttribute then
|
else if attribute.isEqualToString(NSAccessibilityPositionAttribute) then
|
||||||
begin
|
begin
|
||||||
lPoint := LCLAcc.Position;
|
lPoint := LCLAcc.Position;
|
||||||
lNSPoint.x := lPoint.X;
|
lNSPoint.x := lPoint.X;
|
||||||
@ -1013,7 +1041,7 @@ begin
|
|||||||
Result := NSValue.valueWithPoint(lNSPoint);
|
Result := NSValue.valueWithPoint(lNSPoint);
|
||||||
DebugLn(Format('[TCocoaAccessibleObject.accessibilityAttributeValue] NSAccessibilityPositionAttribute Result=%d,%d', [lPoint.X, lPoint.Y]));
|
DebugLn(Format('[TCocoaAccessibleObject.accessibilityAttributeValue] NSAccessibilityPositionAttribute Result=%d,%d', [lPoint.X, lPoint.Y]));
|
||||||
end
|
end
|
||||||
else if attribute = NSAccessibilitySizeAttribute then
|
else if attribute.isEqualToString(NSAccessibilitySizeAttribute) then
|
||||||
begin
|
begin
|
||||||
lSize := LCLAcc.Size;
|
lSize := LCLAcc.Size;
|
||||||
lNSSize.width := lSize.CX;
|
lNSSize.width := lSize.CX;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
{ TCDWidgetSet }
|
{ TCDWidgetSet }
|
||||||
|
|
||||||
function TCDWidgetSet.GetAppHandle: THandle; override;
|
function TCDWidgetSet.GetAppHandle: THandle;
|
||||||
begin
|
begin
|
||||||
Result := THandle(NSApp);
|
Result := THandle(NSApp);
|
||||||
end;
|
end;
|
||||||
|
@ -555,6 +555,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCDWidgetSet.GetKeyState(nVirtKey: Integer): Smallint;
|
||||||
|
begin
|
||||||
|
Result := inherited GetKeyState(nVirtKey);
|
||||||
|
end;
|
||||||
|
|
||||||
(*function TCocoaWidgetSet.GetMonitorInfo(hMonitor: HMONITOR; lpmi: PMonitorInfo): Boolean;
|
(*function TCocoaWidgetSet.GetMonitorInfo(hMonitor: HMONITOR; lpmi: PMonitorInfo): Boolean;
|
||||||
var
|
var
|
||||||
ScreenID: NSScreen absolute hMonitor;
|
ScreenID: NSScreen absolute hMonitor;
|
||||||
|
@ -39,6 +39,7 @@ begin
|
|||||||
win.setContentView(cnt);
|
win.setContentView(cnt);
|
||||||
|
|
||||||
winhandle.CocoaForm := win;
|
winhandle.CocoaForm := win;
|
||||||
|
winhandle.ClientArea := cnt;
|
||||||
Result := TLCLIntfHandle(winhandle);
|
Result := TLCLIntfHandle(winhandle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user