[Foundation] Move NSAttributedStringDocumentAttributes.ViewMode to shared code.

This property has also been added on macOS (where it didn't exist before), since
both documentation and headers reveal it's available there.
This commit is contained in:
Rolf Bjarne Kvinge 2022-11-23 21:32:06 +01:00
Родитель cb12b9ebb9
Коммит 22a8aae9e0
3 изменённых файлов: 10 добавлений и 17 удалений

Просмотреть файл

@ -25,7 +25,6 @@ namespace Foundation {
}
// Utility enum, ObjC uses NSString
[NoMac]
public enum NSDocumentViewMode {
Normal,
PageLayout

Просмотреть файл

@ -41,22 +41,6 @@ namespace Foundation {
public partial class NSAttributedStringDocumentAttributes : DictionaryContainer {
#if !MONOMAC && !COREBUILD
public NSDocumentViewMode? ViewMode {
get {
var value = GetInt32Value (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute);
if (value is null)
return null;
else
return (NSDocumentViewMode) value.Value;
}
set {
if (value is null)
RemoveValue (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute);
else
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute, (int) value.Value);
}
}
public bool ReadOnly {
get {
var value = GetInt32Value (NSAttributedStringDocumentAttributeKey.NSReadOnlyDocumentAttribute);

Просмотреть файл

@ -174,6 +174,16 @@ namespace Foundation {
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSViewZoomDocumentAttribute, value);
}
}
public NSDocumentViewMode? ViewMode {
get {
return (NSDocumentViewMode?) GetInt32Value (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute);
}
set {
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute, value is null ? null : (int) value.Value);
}
}
#if !TVOS && !WATCH
// documentation is unclear if an NSString or an NSUrl should be used...
// but providing an `NSString` throws a `NSInvalidArgumentException Reason: (null) is not a file URL`