Skip to content

Commit

Permalink
8336031: Create implementation of NSAccessibilityStaticText protocol
Browse files Browse the repository at this point in the history
Initial implementation of the protocol.
  • Loading branch information
azuev-java committed Jul 15, 2024
1 parent e0fdb42 commit 07c7003
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -38,7 +38,7 @@ + (void) initializeRolesMap {
/*
* Here we should keep all the mapping between the accessibility roles and implementing classes
*/
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:8];
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:9];

[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"BUTTON"];
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"DECREMENT_BUTTON"];
Expand All @@ -50,6 +50,7 @@ + (void) initializeRolesMap {
[rolesMap setObject:@"JFXRadiobuttonAccessibility" forKey:@"PAGE_ITEM"];
[rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"CHECK_BOX"];
[rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"TOGGLE_BUTTON"];
[rolesMap setObject:@"JFXStaticTextAccessibility" forKey:@"TEXT"];

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "AccessibleBase.h"
#import <AppKit/NSAccessibility.h>

@interface JFXStaticTextAccessibility : AccessibleBase<NSAccessibilityStaticText> {

};
- (NSAccessibilityRole)accessibilityRole;
- (NSString *)accessibilityAttributedStringForRange:(NSRange)range;
- (NSString *)accessibilityValue;
- (NSRange)accessibilityVisibleCharacterRange;
@end

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "JFXStaticTextAccessibility.h"
#import "GlassMacros.h"
#import "GlassAccessible.h"
#import "com_sun_glass_ui_mac_MacAccessible.h"
#import "com_sun_glass_ui_mac_MacVariant.h"
#import "common.h"

@implementation JFXStaticTextAccessibility
- (NSAccessibilityRole)accessibilityRole
{
return NSAccessibilityStaticTextRole;
}

- (id)accessibilityParent
{
return [super accessibilityParent];
}

- (NSRect)accessibilityFrame
{
return [super accessibilityFrame];
}

- (NSString *)accessibilityValue
{
return [super accessibilityValue];
}

- (NSString *)accessibilityAttributedStringForRange:(NSRange)range
{
jobject jresult = NULL;
GET_MAIN_JENV;
if (env == NULL) return NULL;
jresult = (jobject)(*env)->CallLongMethod(env, [self getJAccessible],
jAccessibilityAttributeValueForParameter,
(jlong)"AXAttributedStringForRange",
(jlong)&range);
GLASS_CHECK_EXCEPTION(env);
return variantToID(env, jresult);
}

- (NSRange)accessibilityVisibleCharacterRange
{
return NSMakeRange(0, [[self accessibilityValue] length]);
}
@end

0 comments on commit 07c7003

Please sign in to comment.