//
//  GSAlignmentZone.h
//  GlyphsCore
//
//  Created by Georg Seifert on 18.08.10.
//  Copyright 2010 schriftgestaltung.de. All rights reserved.
//

#import <GlyphsCore/GSBase.h>
#import <GlyphsCore/GSContainerProtocol.h>

NS_ASSUME_NONNULL_BEGIN

/// This class defines an alignment zone, which conforms to the GSItemProtocol.
@interface GSAlignmentZone : NSObject <GSItemProtocol> {
	NSString *_name;
	CGFloat _position;
	CGFloat _size;
	NSPredicate *_filter;
	NSMutableDictionary *_options;
}

/// The name of the alignment zone.
@property (nonatomic, strong, nullable) NSString *name;

/// The position of the alignment zone.
@property (nonatomic) CGFloat position;

/// The size of the alignment zone.
@property (nonatomic) CGFloat size;

/// The filter predicate for the alignment zone.
@property (nonatomic, retain, nullable) NSPredicate *filter;

/// The options dictionary for the alignment zone.
@property (nonatomic, retain, nullable) NSDictionary *options;

/// The delta dictionary for the alignment zone.
@property (nonatomic, strong, nullable) NSDictionary *delta;

/**
 Initializes a new instance of the GSAlignmentZone class with an element string.

 @param string The element string to initialize with.
 @return A new instance of the GSAlignmentZone class.
 */
- (instancetype)initWithElementString:(NSString *)string;

/**
 Initializes a new instance of the GSAlignmentZone class with a dictionary and format version.

 @param dict The dictionary to initialize with.
 @param formatVersion The format version to initialize with.
 @return A new instance of the GSAlignmentZone class.
 */
- (instancetype)initWithDict:(NSDictionary *)dict format:(GSFormatVersion)formatVersion;

/**
 Returns the element string representation of the alignment zone.

 @return The element string representation of the alignment zone.
 */
- (NSString *)elementString;

/**
 Performs post-read operations with the specified format version.

 @param formatVersion The format version to use for post-read operations.
 */
- (void)postRead:(GSFormatVersion)formatVersion;

#ifndef GLYPHS_VIEWER
/**
 Saves the alignment zone to a file with the specified format version.

 @param file The file to save to.
 @param formatVersion The format version to use for saving.
 @param error A pointer to an NSError object to store any error that occurs.
 @return YES if the save operation is successful, NO otherwise.
 */
- (BOOL)saveToFile:(FILE *)file format:(GSFormatVersion)formatVersion context:(nullable GSSaveContext *)context error:(out NSError **)error;

/**
 Returns the property list value for the specified format version.

 @param format The format version to use.
 @return The property list value.
 */
- (id)propertyListValueFormat:(GSFormatVersion)format error:(out NSError **)error;

/**
 Returns the object in settings for the specified key.

 @param key The key to retrieve the object for.
 @return The object for the specified key, or nil if not found.
 */
- (id)objectInSettingsForKey:(nullable NSString *)key;

/**
 Sets the object in settings for the specified key.

 @param value The object to set.
 @param key The key to set the object for.
 */
- (void)setObjectInSettings:(nullable id)value forKey:(nullable NSString *)key;
#endif

@end

NS_ASSUME_NONNULL_END
