//
//  PDFDrawable.h
//  pdftest
//
//  Created by Ray on 10/11/16.
//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "UIKit/UIDocument.h"
#import "const.h"

//#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]


@class PDFDrawable;
@protocol PDFDrawableDelegate <NSObject>

-(void) outofPage:(CGContextRef) context ;//indexPath :(NSIndexPath*) indexPath;
-(void) addPageCount:(CGContextRef) context ;//indexPath :(NSIndexPath*) indexPath;

@end



@interface PDFDrawable : NSObject
@property (nonatomic,strong) NSMutableDictionary* drawableTemplate;
@property (nonatomic,strong) NSString* hAlign;
@property (nonatomic,strong) NSString* vAlign;
@property double margin_left;
@property double margin_right;
@property double margin_top;
@property double margin_bottom;
@property CGRect rect;

//@property CGRect drawable_rect;
@property (nonatomic, weak) id<PDFDrawableDelegate> delegate;

-(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer;

-(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer;
-(instancetype) init:(NSMutableDictionary *)drawableTemplate;
-(CGRect)to_parent_rect:(CGRect)parentRect pos:(CGRect)rect offsetX:(double)x offsetY:(double)y;
-(CGPoint)to_parent_point:(CGRect)parentRect point:(CGPoint)p offsetX:(double)x offsetY:(double)y;
-(CGRect)parent_to_pdf_rect:(CGRect)rect contextHeight:(double) height;

-(CGRect)to_pdf_rect:(CGRect)parentRect pos:(CGRect)rect contextHeight:(double) height;
-(CGPoint)to_pdf_point:(CGRect)parentRect point:(CGPoint)p contextHeight:(double) height;
+(NSMutableDictionary *) createDrawableTemplate:(CGRect) rect;


-(void) DrawBound:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer;

@end
