CPDFListView.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. CAnnotationTypeAddText,
  53. CAnnotationTypeAddImage,
  54. CAnnotationTypeRadioButton = 100,
  55. CAnnotationTypeCheckBox,
  56. CAnnotationTypeTextField,
  57. CAnnotationTypeComboBox,
  58. CAnnotationTypeListMenu,
  59. CAnnotationTypeActionButton,
  60. CAnnotationTypeSignature,
  61. CAnnotationTypeSignText = 200,
  62. CAnnotationTypeSignFalse,
  63. CAnnotationTypeSignTure,
  64. CAnnotationTypeSignCircle,
  65. CAnnotationTypeSignLine,
  66. CAnnotationTypeSignDot,
  67. CAnnotationTypeSignConfig,
  68. CAnnotationTypeSignDate,
  69. };
  70. typedef NS_ENUM(NSInteger, CToolMode) {
  71. CTextToolMode = 0,
  72. CMoveToolMode,
  73. CMagnifyToolMode,
  74. CSelectToolMode,
  75. CNoteToolMode,
  76. CSelectZoomToolMode,
  77. CFormToolMode,
  78. CSelfSignMode,
  79. CRedactToolMode,
  80. CRedactErasureToolMode,
  81. CEditPDFToolMode,
  82. };
  83. @protocol CPDFListViewDelegate;
  84. @class CStampSignatureObject,CPDFListStampAnnotation,CPDFListSignatureAnnotation;
  85. @interface CPDFListView : CPDFView
  86. @property (nonatomic, weak) id<CPDFListViewDelegate>pdfListViewDelegate;
  87. // Methods for The currently selected Annotation.
  88. @property (nonatomic, readonly) NSMutableArray <CPDFAnnotation *>*activeAnnotations;
  89. // Methods for The currently selected Annotation.
  90. @property (nonatomic, readonly) CPDFAnnotation * activeAnnotation;
  91. // Methods for The annotation type currently selected.
  92. @property (nonatomic, assign) CAnnotationType annotationType;
  93. // Method of the currently selected annotation mode.
  94. @property (nonatomic, assign) CToolMode toolMode;
  95. // The magnification times when the current magnifying glass is in mode
  96. @property (nonatomic, readonly) CGFloat magnification;
  97. @property (nonatomic, assign) BOOL isSetLinkDestinationArea;
  98. // Show Annotation or not
  99. @property (nonatomic, assign) BOOL hideNotes;
  100. // Whether to display a Form comment hop number
  101. @property (nonatomic, assign) BOOL showHopnumber;
  102. // Whether to display the Form name
  103. @property (nonatomic, assign) BOOL showFormFieldName;
  104. // Auxiliary reference line
  105. @property (nonatomic, strong) CAShapeLayer *shapeLayerLeftV;
  106. @property (nonatomic, strong) CAShapeLayer *shapeLayerRightV;
  107. @property (nonatomic, strong) CAShapeLayer *shapeLayerTopH;
  108. @property (nonatomic, strong) CAShapeLayer *shapeLayerBottomH;
  109. - (CPDFAnnotation *)addAnnotationWithType:(CAnnotationType)annotationType selection:(CPDFSelection *)selection page:(CPDFPage *)page bounds:(NSRect)bounds;
  110. // Add stamp Annotation, add directly after mouse click
  111. // a new parameter.
  112. // stampObject - stamp Object.
  113. // isToolModel - Whether it is a pattern
  114. - (void)setAddStampObject:(CStampSignatureObject *)stampObject keepToolModel:(BOOL)isToolModel;
  115. // Add an image Stamp note
  116. - (void)addAnnotationWithImage:(NSImage *)image page:(CPDFPage *)page point:(NSPoint)point;
  117. // Refresh the currently selected Annotation
  118. - (void)updateActiveAnnotations:(NSArray<CPDFAnnotation *> *)activeAnnotation;
  119. // Edit Annotation
  120. - (void)editAnnotation:(CPDFAnnotation *)annotation;
  121. // Rotate Stamp notes, angle 0-360 degrees,Rotation is supported only by the current addition
  122. - (void)rotateStampAnnotation:(CPDFListStampAnnotation *)annotation rotateAngle:(NSInteger)angle;
  123. // Rotate Signature notes, angle 0-360 degrees,Rotation is supported only by the current addition
  124. - (void)rotateSignatureAnnotation:(CPDFListSignatureAnnotation *)annotation rotateAngle:(NSInteger)angle;
  125. // When selecting a region mode, the selected region is obtained
  126. - (NSRect)currentSelectionRect;
  127. // Scale the page to the specified range
  128. - (void)zoomToRect:(NSRect)rect onPage:(CPDFPage *)page;
  129. // Remove Auxiliary reference line
  130. - (void)removeShapeLayer;
  131. @end
  132. @protocol CPDFListViewDelegate <NSObject>
  133. @optional
  134. - (void)PDFListViewChangedSelectionOrMagnification:(CPDFListView *)pdfListView;
  135. - (void)PDFListViewDidSelectionEnd:(CPDFListView *)pdfListView;
  136. - (void)PDFListViewChangedMagnification:(CPDFListView *)pdfListView;
  137. - (void)PDFListViewChangedToolMode:(CPDFListView *)pdfListView forToolMode:(CToolMode)toolMode;
  138. - (void)PDFListViewChangedAnnotationType:(CPDFListView *)pdfListView forAnnotationType:(CAnnotationType)annotationType;
  139. - (NSColor *)PDFListViewBackgroundColor;
  140. - (void)PDFListViewAddAnnotations:(CPDFListView *)pdfListView forAddAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  141. - (void)PDFListViewRemoveAnnotations:(CPDFListView *)pdfListView forRemoveAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  142. - (void)PDFListViewDeleteAnnotations:(CPDFListView *)pdfListView forDeleteAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  143. - (void)PDFListViewChangeatioActiveAnnotations:(CPDFListView *)pdfListView forActiveAnnotations:(NSArray<CPDFAnnotation *> *)annotations isRightMenu:(BOOL)isRightMenu;
  144. - (void)PDFListViewMenuForEvent:(CPDFListView *)pdfListView forEvent:(NSEvent *)theEvent clickMenu:(NSMenu **)menu;
  145. - (BOOL)PDFListViewMenuValidate:(CPDFListView *)pdfListView menuItem:(NSMenuItem *)menuItem isTakesEffect:(BOOL *)isTakesEffect;
  146. - (void)PDFListViewEditAnnotation:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)anotation;
  147. - (BOOL)PDFListViewKeyDownIsContinue:(CPDFListView *)pdfListView theEvent:(NSEvent *)theEvent;
  148. - (NSArray<NSMenuItem *> *)PDFListViewMenuItemsEditingAtPoint:(CGPoint)point forPage:(CPDFPage *)page menuItems:(NSArray <NSMenuItem *>*)menuItems;
  149. - (void)PDFListViewRedactErasure:(CPDFListView *)pdfListView;
  150. - (void)PDFListViewLinkDestinationStart:(CPDFListView *)pdfListView withActiveAnnotation:(CPDFAnnotation *)annotation;
  151. - (void)PDFListViewLinkDestinationEnd:(CPDFListView *)pdfListView withActiveAnnotation:(CPDFAnnotation *)annotation;
  152. - (void)PDFListViewKeyDowClosePanel:(CPDFViewSidebarSpeedMode)speedy event:(NSEvent *)theEvent;
  153. - (NSArray<NSColor *> *)PDFListViewEventMarkupColorWithAnnotation:(CPDFAnnotation *)annotation;
  154. - (BOOL)PDFListViewHaveDocumentAttribute;
  155. // 是否需要绘制注释 【文字、背景】
  156. - (BOOL)PDFListView:(CPDFListView *)pdfListView needDrawAnnotation:(CPDFAnnotation *)annotation;
  157. - (void)PDFListViewAnnotationAttributeHasChange:(CPDFListView *)pdfListView withAnnotation:(CPDFAnnotation *)annotation;
  158. @end