CPDFListView.h 11 KB

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