CPDFListView.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. //
  2. // CPDFListView.h
  3. // ComPDFKit
  4. //
  5. // Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
  6. //
  7. // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  8. // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  9. // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  10. // This notice may not be removed from this file.
  11. //
  12. #import <ComPDFKit/ComPDFKit.h>
  13. #import <Foundation/Foundation.h>
  14. #import <QuartzCore/QuartzCore.h>
  15. #define SKAnnotationKey @"SKAnnotation"
  16. extern NSNotificationName const CPDFListViewSelectionChangedNotification;
  17. extern NSNotificationName const CPDFListViewToolModeChangeNotification;
  18. extern NSNotificationName const CPDFListViewAnnotationTypeChangeNotification;
  19. extern NSNotificationName const CPDFListViewMagnificationChangedNotification;
  20. extern NSNotificationName const CPDFListViewDidAddAnnotationNotification;
  21. extern NSNotificationName const CPDFListViewDidRemoveAnnotationNotification;
  22. extern NSNotificationName const CPDFListViewActiveAnnotationsChangeNotification;
  23. extern NSNotificationName const CPDFListViewAnnotationsAttributeHasChangeNotification;
  24. extern NSNotificationName const KMPDFViewTableAnnotationDidChangeNotification;
  25. typedef NS_ENUM(NSInteger, CPDFViewSidebarSpeedMode) {
  26. CPDFViewSidebarSpeedModeLeft = 0,
  27. CPDFViewSidebarSpeedModeRight
  28. };
  29. typedef NS_ENUM(NSInteger, CAnnotationType) {
  30. CAnnotationTypeUnkown = 0,
  31. CAnnotationTypeAnchored,
  32. CAnnotationTypeLink,
  33. CAnnotationTypeFreeText,
  34. CAnnotationTypeLine,
  35. CAnnotationTypeArrow,
  36. CAnnotationTypeSquare,
  37. CAnnotationTypeCircle,
  38. /*CAnnotationTypePolyGon,*/
  39. /*CAnnotationTypePolyLine,*/
  40. CAnnotationTypeHighlight,
  41. CAnnotationTypeUnderline,
  42. // CAnnotationTypeSquiggly,
  43. CAnnotationTypeStrikeOut,
  44. CAnnotationTypeStamp,
  45. CAnnotationTypeSignSignature,
  46. /*CAnnotationTypeCaret,*/
  47. CAnnotationTypeInk,
  48. /*CAnnotationTypePopUp,*/
  49. /*CAnnotationTypeFileattachment,*/
  50. /*CAnnotationTypeSound,*/
  51. /*CAnnotationTypeMovie,*/
  52. CAnnotationTypeRedact,
  53. CAnnotationTypeEraser,
  54. CAnnotationTypeEditTextImage,
  55. CAnnotationTypeAddText,
  56. CAnnotationTypeAddImage,
  57. CAnnotationTypeRadioButton = 100,
  58. CAnnotationTypeCheckBox,
  59. CAnnotationTypeTextField,
  60. CAnnotationTypeComboBox,
  61. CAnnotationTypeListMenu,
  62. CAnnotationTypeActionButton,
  63. CAnnotationTypeSignature,
  64. CAnnotationTypeSignText = 200,
  65. CAnnotationTypeSignFalse,
  66. CAnnotationTypeSignTure,
  67. CAnnotationTypeSignCircle,
  68. CAnnotationTypeSignLine,
  69. CAnnotationTypeSignDot,
  70. CAnnotationTypeSignConfig,
  71. CAnnotationTypeSignDate,
  72. CAnnotationTypeTable,
  73. };
  74. typedef NS_ENUM(NSInteger, CToolMode) {
  75. CTextToolMode = 0,
  76. CMoveToolMode,
  77. CMagnifyToolMode,
  78. CSelectToolMode,
  79. CNoteToolMode,
  80. CSelectZoomToolMode,
  81. CFormToolMode,
  82. CSelfSignMode,
  83. CRedactToolMode,
  84. CRedactErasureToolMode,
  85. CEditPDFToolMode,
  86. };
  87. typedef NS_ENUM(NSUInteger, KMPDFActiveFormsAlignType) {
  88. KMPDFActiveFormsAlignType_Left = 0,
  89. KMPDFActiveFormsAlignType_Vertical,
  90. KMPDFActiveFormsAlignType_Right,
  91. KMPDFActiveFormsAlignType_Top,
  92. KMPDFActiveFormsAlignType_Horizontally,
  93. KMPDFActiveFormsAlignType_Bottom,
  94. KMPDFActiveFormsAlignType_DisHorizontally,
  95. KMPDFActiveFormsAlignType_DisVertical
  96. };
  97. typedef NS_ENUM(NSUInteger, KMPDFViewActiveFormsType) {
  98. KMPDFViewActiveFormsType_NotAllform = -1,//注释类型不全为form类型
  99. KMPDFViewActiveFormsType_Mix = 0,//包含多种类型的form(全为form)
  100. KMPDFViewActiveFormsType_Pure,//单纯只有一种form(全为form)
  101. KMPDFViewActiveFormsType_PureSingle,//单纯只有一种form(全为form),个数为1
  102. KMPDFViewActiveFormsType_Text,//单纯只有一种form,并且是text(全为form)
  103. KMPDFViewActiveFormsType_TextSingle,//单纯只有一种form,并且是text(全为form),个数为1
  104. KMPDFViewActiveFormsType_None
  105. };
  106. typedef NS_ENUM(NSUInteger, KMPDFViewMode) {
  107. KMPDFViewModeNormal = 0,
  108. KMPDFViewModeSoft,
  109. KMPDFViewModeNight,
  110. KMPDFViewModeGreen,
  111. KMPDFViewModeThemes1,
  112. KMPDFViewModeThemes2,
  113. KMPDFViewModeThemes3,
  114. KMPDFViewModeThemes4,
  115. KMPDFViewModeOther
  116. };
  117. typedef NS_ENUM(NSInteger, KMPDFViewSplitMode) {
  118. KMPDFViewSplitModeDisable = 0,
  119. KMPDFViewSplitModeHorizontal,
  120. KMPDFViewSplitModeVertical
  121. };
  122. @protocol CPDFListViewDelegate;
  123. @class CStampSignatureObject,CPDFListStampAnnotation,CPDFListSignatureAnnotation, KMFormListMenuPopWindowController;
  124. @interface CPDFListView : CPDFView
  125. @property (nonatomic, weak) id<CPDFListViewDelegate>pdfListViewDelegate;
  126. // Methods for The currently selected Annotation.
  127. @property (nonatomic, readonly) NSMutableArray <CPDFAnnotation *>*activeAnnotations;
  128. // Methods for The currently selected Annotation.
  129. @property (nonatomic, readonly) CPDFAnnotation * activeAnnotation;
  130. // Methods for The annotation type currently selected.
  131. @property (nonatomic, assign) CAnnotationType annotationType;
  132. // Method of the currently selected annotation mode.
  133. @property (nonatomic, assign) CToolMode toolMode;
  134. // The magnification times when the current magnifying glass is in mode
  135. @property (nonatomic, readonly) CGFloat magnification;
  136. @property (nonatomic, assign) BOOL isSetLinkDestinationArea;
  137. // Show Annotation or not
  138. @property (nonatomic, assign) BOOL hideNotes;
  139. // Whether to display a Form comment hop number
  140. @property (nonatomic, assign) BOOL showHopnumber;
  141. // Whether to display the Form name
  142. @property (nonatomic, assign) BOOL showFormFieldName;
  143. // Auxiliary reference line
  144. @property (nonatomic, strong) CAShapeLayer *shapeLayerLeftV;
  145. @property (nonatomic, strong) CAShapeLayer *shapeLayerRightV;
  146. @property (nonatomic, strong) CAShapeLayer *shapeLayerTopH;
  147. @property (nonatomic, strong) CAShapeLayer *shapeLayerBottomH;
  148. @property (nonatomic, assign) NSPoint lastAddAnnotationPoint;
  149. @property (nonatomic, assign) BOOL isCreatAnnotation;
  150. @property (nonatomic, assign) NSInteger toolBarCreateAnnotationMenuItem;
  151. @property (nonatomic, assign) BOOL isTakeSnapeSelectConetent;
  152. @property (nonatomic, assign) KMPDFViewMode viewMode;
  153. @property (nonatomic, assign) KMPDFViewSplitMode viewSplitMode;
  154. @property (nonatomic, strong) KMFormListMenuPopWindowController *listWindowController;
  155. @property (nonatomic, strong) NSTrackingArea *trackingArea;
  156. @property (nonatomic, strong) NSImage *originImage;
  157. - (CPDFAnnotation *)addAnnotationWithType:(CAnnotationType)annotationType selection:(CPDFSelection *)selection page:(CPDFPage *)page bounds:(NSRect)bounds;
  158. - (void)addAnnotationWithAnnotation:(CPDFAnnotation *)annotation toPage:(CPDFPage *)page;
  159. // Add stamp Annotation, add directly after mouse click
  160. // a new parameter.
  161. // stampObject - stamp Object.
  162. // isToolModel - Whether it is a pattern
  163. - (void)setAddStampObject:(CStampSignatureObject *)stampObject keepToolModel:(BOOL)isToolModel;
  164. // Add an image Stamp note
  165. - (void)addAnnotationWithImage:(NSImage *)image page:(CPDFPage *)page point:(NSPoint)point;
  166. // Refresh the currently selected Annotation
  167. - (void)updateActiveAnnotations:(NSArray<CPDFAnnotation *> *)activeAnnotation;
  168. // Edit Annotation
  169. - (void)editAnnotation:(CPDFAnnotation *)annotation;
  170. // Rotate Stamp notes, angle 0-360 degrees,Rotation is supported only by the current addition
  171. - (void)rotateStampAnnotation:(CPDFListStampAnnotation *)annotation rotateAngle:(NSInteger)angle;
  172. // Rotate Signature notes, angle 0-360 degrees,Rotation is supported only by the current addition
  173. - (void)rotateSignatureAnnotation:(CPDFListSignatureAnnotation *)annotation rotateAngle:(NSInteger)angle;
  174. // When selecting a region mode, the selected region is obtained
  175. - (NSRect)currentSelectionRect;
  176. // Scale the page to the specified range
  177. - (void)zoomToRect:(NSRect)rect onPage:(CPDFPage *)page;
  178. // Remove Auxiliary reference line
  179. - (void)removeShapeLayer;
  180. // Determines whether the current annotation is consistent with the selected annotation mode
  181. - (BOOL)consistentTypeWithAnnotation:(CPDFAnnotation *)annotation;
  182. - (void)formsAnnotationAlign:(KMPDFActiveFormsAlignType)type;
  183. - (void)addImageAnnotation:(NSImage *)image center:(NSPoint)center isRemoveBGColor:(BOOL)isRemoveBGColor;
  184. - (void)setPageBackgroundColorWithColor:(NSColor *)color viewMode:(KMPDFViewMode)viewMode;
  185. - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types;
  186. @end
  187. @protocol CPDFListViewDelegate <NSObject>
  188. @optional
  189. - (void)PDFListViewChangedSelectionOrMagnification:(CPDFListView *)pdfListView;
  190. - (void)PDFListViewDidSelectionEnd:(CPDFListView *)pdfListView;
  191. - (void)PDFListViewChangedMagnification:(CPDFListView *)pdfListView;
  192. - (void)PDFListViewChangedToolMode:(CPDFListView *)pdfListView forToolMode:(CToolMode)toolMode;
  193. - (void)PDFListViewChangedAnnotationType:(CPDFListView *)pdfListView forAnnotationType:(CAnnotationType)annotationType;
  194. - (NSColor *)PDFListViewBackgroundColor;
  195. - (void)PDFListViewAddAnnotations:(CPDFListView *)pdfListView forAddAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  196. - (void)PDFListViewRemoveAnnotations:(CPDFListView *)pdfListView forRemoveAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  197. - (void)PDFListViewDeleteAnnotations:(CPDFListView *)pdfListView forDeleteAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  198. - (void)PDFListViewChangeatioActiveAnnotations:(CPDFListView *)pdfListView forActiveAnnotations:(NSArray<CPDFAnnotation *> *)annotations isRightMenu:(BOOL)isRightMenu;
  199. - (void)PDFListViewMenuForEvent:(CPDFListView *)pdfListView forEvent:(NSEvent *)theEvent clickMenu:(NSMenu **)menu isMoveSelectAnno:(BOOL)isMoveSelectAnno;
  200. - (BOOL)PDFListViewMenuValidate:(CPDFListView *)pdfListView menuItem:(NSMenuItem *)menuItem isTakesEffect:(BOOL *)isTakesEffect;
  201. - (void)PDFListViewEditAnnotation:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)anotation;
  202. - (BOOL)PDFListViewKeyDownIsContinue:(CPDFListView *)pdfListView theEvent:(NSEvent *)theEvent;
  203. - (NSArray<NSMenuItem *> *)PDFListViewMenuItemsEditingAtPoint:(CGPoint)point forPage:(CPDFPage *)page menuItems:(NSArray <NSMenuItem *>*)menuItems;
  204. - (void)PDFListViewRedactErasure:(CPDFListView *)pdfListView;
  205. - (void)PDFListViewLinkDestinationStart:(CPDFListView *)pdfListView withActiveAnnotation:(CPDFAnnotation *)annotation;
  206. - (void)PDFListViewLinkDestinationEnd:(CPDFListView *)pdfListView withActiveAnnotation:(CPDFAnnotation *)annotation;
  207. - (void)PDFListViewKeyDowClosePanel:(CPDFViewSidebarSpeedMode)speedy event:(NSEvent *)theEvent;
  208. - (NSArray<NSColor *> *)PDFListViewEventMarkupColorWithAnnotation:(CPDFAnnotation *)annotation;
  209. - (BOOL)PDFListViewHaveDocumentAttribute;
  210. // 是否需要绘制注释 【文字、背景】
  211. - (BOOL)PDFListView:(CPDFListView *)pdfListView needDrawAnnotation:(CPDFAnnotation *)annotation;
  212. - (void)PDFListViewAnnotationAttributeHasChange:(CPDFListView *)pdfListView withAnnotation:(CPDFAnnotation *)annotation;
  213. - (void)PDFListView:(CPDFListView *)sender showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
  214. - (void)PDFListView:(CPDFListView *)pdfView documentDataDidChanged:(id)docData withInfo:(NSDictionary *)info;
  215. @end