Browse Source

【OCToSwift】KMCustomButtonPopMenuViewController替换为Swift

wanjun 1 year ago
parent
commit
82b0211521

+ 16 - 10
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -109,9 +109,6 @@
 		89752DB02936F505003FF08E /* KMCustomButtonPopMenuViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89752DAD2936F505003FF08E /* KMCustomButtonPopMenuViewController.xib */; };
 		89752DB12936F505003FF08E /* KMCustomButtonPopMenuViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89752DAD2936F505003FF08E /* KMCustomButtonPopMenuViewController.xib */; };
 		89752DB22936F505003FF08E /* KMCustomButtonPopMenuViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89752DAD2936F505003FF08E /* KMCustomButtonPopMenuViewController.xib */; };
-		89752DB32936F505003FF08E /* KMCustomButtonPopMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89752DAF2936F505003FF08E /* KMCustomButtonPopMenuViewController.m */; };
-		89752DB42936F505003FF08E /* KMCustomButtonPopMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89752DAF2936F505003FF08E /* KMCustomButtonPopMenuViewController.m */; };
-		89752DB52936F505003FF08E /* KMCustomButtonPopMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89752DAF2936F505003FF08E /* KMCustomButtonPopMenuViewController.m */; };
 		89752DEA293875FC003FF08E /* KMMainToolbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89752DE8293875FC003FF08E /* KMMainToolbarController.swift */; };
 		89752DEB293875FC003FF08E /* KMMainToolbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89752DE8293875FC003FF08E /* KMMainToolbarController.swift */; };
 		89752DEC293875FC003FF08E /* KMMainToolbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89752DE8293875FC003FF08E /* KMMainToolbarController.swift */; };
@@ -997,6 +994,12 @@
 		9FCFEC802AD0E74C00EAD2CB /* KMPopMenuButtonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFEC7F2AD0E74C00EAD2CB /* KMPopMenuButtonCell.swift */; };
 		9FCFEC812AD0E74C00EAD2CB /* KMPopMenuButtonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFEC7F2AD0E74C00EAD2CB /* KMPopMenuButtonCell.swift */; };
 		9FCFEC822AD0E74C00EAD2CB /* KMPopMenuButtonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFEC7F2AD0E74C00EAD2CB /* KMPopMenuButtonCell.swift */; };
+		9FCFEC842AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFEC832AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift */; };
+		9FCFEC852AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFEC832AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift */; };
+		9FCFEC862AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFEC832AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift */; };
+		9FCFEC882AD0EF9900EAD2CB /* KMPopMenuButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFEC872AD0EF9900EAD2CB /* KMPopMenuButton.swift */; };
+		9FCFEC892AD0EF9900EAD2CB /* KMPopMenuButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFEC872AD0EF9900EAD2CB /* KMPopMenuButton.swift */; };
+		9FCFEC8A2AD0EF9900EAD2CB /* KMPopMenuButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFEC872AD0EF9900EAD2CB /* KMPopMenuButton.swift */; };
 		9FD0FA2929CD3ED400F2AB0D /* KMRightSideEmptyVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FD0FA2729CD3ED400F2AB0D /* KMRightSideEmptyVC.swift */; };
 		9FD0FA2A29CD3ED400F2AB0D /* KMRightSideEmptyVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FD0FA2729CD3ED400F2AB0D /* KMRightSideEmptyVC.swift */; };
 		9FD0FA2B29CD3ED400F2AB0D /* KMRightSideEmptyVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FD0FA2729CD3ED400F2AB0D /* KMRightSideEmptyVC.swift */; };
@@ -3556,8 +3559,6 @@
 		89752D9E2936EC50003FF08E /* KMToolbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMToolbar.h; sourceTree = "<group>"; };
 		89752DA32936ECD5003FF08E /* Masonry.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Masonry.framework; sourceTree = "<group>"; };
 		89752DAD2936F505003FF08E /* KMCustomButtonPopMenuViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMCustomButtonPopMenuViewController.xib; sourceTree = "<group>"; };
-		89752DAE2936F505003FF08E /* KMCustomButtonPopMenuViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMCustomButtonPopMenuViewController.h; sourceTree = "<group>"; };
-		89752DAF2936F505003FF08E /* KMCustomButtonPopMenuViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMCustomButtonPopMenuViewController.m; sourceTree = "<group>"; };
 		89752DE8293875FC003FF08E /* KMMainToolbarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMainToolbarController.swift; sourceTree = "<group>"; };
 		89752DE9293875FC003FF08E /* KMMainToolbarController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMMainToolbarController.xib; sourceTree = "<group>"; };
 		89752DF029389F81003FF08E /* KMToolbarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMToolbarItem.m; sourceTree = "<group>"; };
@@ -3931,6 +3932,8 @@
 		9FCFEC732AC56ECE00EAD2CB /* CPDFListStampAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPDFListStampAnnotation.swift; sourceTree = "<group>"; };
 		9FCFEC7B2AC579F600EAD2CB /* CPDFListSignatureAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPDFListSignatureAnnotation.swift; sourceTree = "<group>"; };
 		9FCFEC7F2AD0E74C00EAD2CB /* KMPopMenuButtonCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPopMenuButtonCell.swift; sourceTree = "<group>"; };
+		9FCFEC832AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCustomButtonPopMenuViewController.swift; sourceTree = "<group>"; };
+		9FCFEC872AD0EF9900EAD2CB /* KMPopMenuButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPopMenuButton.swift; sourceTree = "<group>"; };
 		9FD0FA2729CD3ED400F2AB0D /* KMRightSideEmptyVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMRightSideEmptyVC.swift; sourceTree = "<group>"; };
 		9FD0FA2829CD3ED400F2AB0D /* KMRightSideEmptyVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMRightSideEmptyVC.xib; sourceTree = "<group>"; };
 		9FD0FA2F29CD947000F2AB0D /* KMOpacityPanel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMOpacityPanel.swift; sourceTree = "<group>"; };
@@ -5159,13 +5162,13 @@
 				89752DE9293875FC003FF08E /* KMMainToolbarController.xib */,
 				89752E022939DB42003FF08E /* KMToolbarViewController.swift */,
 				89752E032939DB42003FF08E /* KMToolbarViewController.xib */,
-				89752DAE2936F505003FF08E /* KMCustomButtonPopMenuViewController.h */,
-				89752DAF2936F505003FF08E /* KMCustomButtonPopMenuViewController.m */,
+				9FCFEC832AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift */,
 				89752DAD2936F505003FF08E /* KMCustomButtonPopMenuViewController.xib */,
 				89752D992936E675003FF08E /* KMToolBarBox.swift */,
 				9FDD0FB5295D5230000C4DAD /* KMToolbarController.swift */,
 				9FDD0FB6295D5230000C4DAD /* KMToolbarController.xib */,
 				9FCFEC7F2AD0E74C00EAD2CB /* KMPopMenuButtonCell.swift */,
+				9FCFEC872AD0EF9900EAD2CB /* KMPopMenuButton.swift */,
 			);
 			path = Toolbar;
 			sourceTree = "<group>";
@@ -10730,6 +10733,7 @@
 				BBD1F78B296FACA300343885 /* KMPageEditExtractSettingView.swift in Sources */,
 				ADBC375029CAE27900D93208 /* KMComparativeOutlineRowView.swift in Sources */,
 				ADB1FE8E29752F7000ED072D /* KMBatchBackgroundView.swift in Sources */,
+				9FCFEC842AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift in Sources */,
 				9FDD0F77294FEF64000C4DAD /* KMConvertPDFManager.swift in Sources */,
 				BBB1A39E29F6128200E54E47 /* KMSystemMenu.swift in Sources */,
 				9F8539D62943180000DF644E /* KMTabAppearance.swift in Sources */,
@@ -10930,7 +10934,6 @@
 				9F0CB49F29683E2600007028 /* KMPropertiesPanelSizeSubVC.swift in Sources */,
 				BB2EDF54296E815E003BCF58 /* KMPageEditBaseItemView.swift in Sources */,
 				9F1FE4EA29406E4700E952CA /* NSBezierPath+MCAdditions.m in Sources */,
-				89752DB32936F505003FF08E /* KMCustomButtonPopMenuViewController.m in Sources */,
 				BBCE57102A72712200508EFC /* NSWindowController+KMExtension.swift in Sources */,
 				BBAFFB1B29CDD19C00C56112 /* KMMergeSelect.swift in Sources */,
 				ADD1B6BB29420B4A00C3FFF7 /* KMPrintPreviewView.swift in Sources */,
@@ -11223,6 +11226,7 @@
 				BBEC00CC295C31F900A26C98 /* KMBatesModel.swift in Sources */,
 				AD0E8AB92A31BDDD00DBFD3C /* KMProduct.swift in Sources */,
 				9F1FE4C929406E4700E952CA /* CTTabContents.m in Sources */,
+				9FCFEC882AD0EF9900EAD2CB /* KMPopMenuButton.swift in Sources */,
 				9F39B9442A661ED500930ACA /* KMHomeScrollView.swift in Sources */,
 				BB89725E294C5DDA0045787C /* KMWatermarkPropertyInfoController.swift in Sources */,
 				BB146FAB299DC0D000784A6A /* GTLRBatchQuery.m in Sources */,
@@ -11751,7 +11755,6 @@
 				ADD1B6BC29420B4A00C3FFF7 /* KMPrintPreviewView.swift in Sources */,
 				AD0FA4F129A8580D00EDEB50 /* KMComparativeTableView.swift in Sources */,
 				BBC348032955403D008D2CD1 /* KMWatermarkFilePropertyInfoController.swift in Sources */,
-				89752DB42936F505003FF08E /* KMCustomButtonPopMenuViewController.m in Sources */,
 				BB147027299DC0D100784A6A /* OIDTokenRequest.m in Sources */,
 				BBFE6E592930724B00142C01 /* KMMergePageModel.swift in Sources */,
 				BB2F61592966B69D001CB369 /* KMWatermarkPropertyHomeController.swift in Sources */,
@@ -11779,6 +11782,7 @@
 				BB162E9C295073B50088E9D1 /* KMWatermarkManager.swift in Sources */,
 				BBD1F79D296FF7A600343885 /* KMPageEditSplitSettingModel.swift in Sources */,
 				BB9807FE29CA93D400BEEB81 /* WelcomeWindowController.m in Sources */,
+				9FCFEC892AD0EF9900EAD2CB /* KMPopMenuButton.swift in Sources */,
 				BB6DD81929348A00001F0544 /* KMSecureEncryptComboBoxCellView.swift in Sources */,
 				BBC2BCC7295DA8F30036B983 /* KMCropPreviewController.swift in Sources */,
 				ADE3C1FE29A5C44700793B13 /* KMLightMemberManager.swift in Sources */,
@@ -11925,6 +11929,7 @@
 				9F0CB4F6298655D500007028 /* KMDesignToken+Fill.swift in Sources */,
 				ADF6B86D2A480C5F0090CB78 /* KMComparativeView.swift in Sources */,
 				BBB7B48E2A0384E100B58A5A /* NSCollectionViewItem+KMExtension.swift in Sources */,
+				9FCFEC852AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift in Sources */,
 				BBA8B7A42935CD740097D183 /* KMRemovePasswordAlertWindowController.swift in Sources */,
 				BB4EEF4D2976544F003A3537 /* KMRedactAligementView.swift in Sources */,
 				F37322EE292DF9410013862C /* CPDFMarkupAnnotation+PDFListView.m in Sources */,
@@ -12218,6 +12223,7 @@
 				9F0CB4B72977BC1000007028 /* KMPropertiesPanelPreviewSubVC.swift in Sources */,
 				BB3A81B72AC2C0F4006FC66C /* NSObject+KMExtension.swift in Sources */,
 				BB9E2F752A495BCD000DC68D /* KMConvertSettingLimitTipView.swift in Sources */,
+				9FCFEC8A2AD0EF9900EAD2CB /* KMPopMenuButton.swift in Sources */,
 				BB6DD80E29347F77001F0544 /* KMSecureEncryptWindowController.swift in Sources */,
 				AD53B70029AC5FCD00D61E81 /* KMLightMemberToken.swift in Sources */,
 				9F1FE4A129406E4700E952CA /* HoverButton.m in Sources */,
@@ -12569,7 +12575,6 @@
 				ADE8BC3D29F9458700570F89 /* KMRecommondManager.m in Sources */,
 				BB6B436D2A04935000E02B54 /* KMPDFThumbViewBaseController.swift in Sources */,
 				BBB9B330299A5D6D004F3235 /* GTMAppAuthFetcherAuthorization.m in Sources */,
-				89752DB52936F505003FF08E /* KMCustomButtonPopMenuViewController.m in Sources */,
 				BB146FBC299DC0D100784A6A /* GTLRBase64.m in Sources */,
 				F34BF928295303E8002C25A2 /* NSCursor+PDFListView.m in Sources */,
 				8942F7FA2926089200389627 /* KMSignatureViewController.swift in Sources */,
@@ -12776,6 +12781,7 @@
 				9F080B16298CFDB300FC27DA /* KMTextImageButtonVC.swift in Sources */,
 				BBFBE74828DD7DB8008B2335 /* AppDelegate.swift in Sources */,
 				BB8B173E2907CDD9001C5EA5 /* NibLoadable.swift in Sources */,
+				9FCFEC862AD0EF6700EAD2CB /* KMCustomButtonPopMenuViewController.swift in Sources */,
 				ADD5AE572A64D31200C14249 /* KMPurchaseAlertView.swift in Sources */,
 				ADCB9964292B8DAB00B51A03 /* KMOCRManager.swift in Sources */,
 				ADF6B86E2A480C5F0090CB78 /* KMComparativeView.swift in Sources */,

+ 20 - 4
PDF Office/PDF Master.xcodeproj/xcuserdata/kdanwj.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -391,16 +391,32 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "FC6B2FFE-583F-4F48-B86F-C9A52C9A6360"
+            uuid = "967FC898-EF8C-4FEF-A1DD-A8D7271A4A43"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "PDF Master/Class/PDFWindowController/Toolbar/KMCustomButtonPopMenuViewController.m"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "30"
-            endingLineNumber = "30"
-            landmarkName = "+cellClass"
+            startingLineNumber = "101"
+            endingLineNumber = "101"
+            landmarkName = "-viewDidLoad"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "1BD97102-B5D6-4018-8329-4E5677852CDE"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Toolbar/KMCustomButtonPopMenuViewController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "39"
+            endingLineNumber = "39"
+            landmarkName = "viewDidLoad()"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>

+ 0 - 39
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMCustomButtonPopMenuViewController.h

@@ -1,39 +0,0 @@
-//
-//  KMPopMenuViewController.h
-//  SignFlow
-//
-//  Created by Kdan on 2020/10/23.
-//
-
-#import <Cocoa/Cocoa.h>
-
-@protocol KMCustomButtonPopMenuViewControllerDataSources <NSObject>
-
-//pop框有多少行
-- (NSInteger)numberOfLine;
-//pop框某行显示的文字
-- (nullable NSString *)stringForLineAtIndex:(NSInteger)index;
-//某行是否需要下划线
-- (BOOL)needInsertSeperateLineAtIndex:(NSInteger)index;
-//某行是否需要选取
-- (BOOL)needHightLightLineAtIndex:(NSInteger)index;
-
-- (nullable NSImage *)imageForLineAtIndex:(NSInteger)index;
-
-- (BOOL)itemEnableAtIndex:(NSInteger)index;
-
-@end
-
-@protocol KMCustomButtonPopMenuViewControllerDelegate <NSObject>
-- (void)customViewButtonPopDidSelectIndex:(NSInteger)index;
-@end
-
-NS_ASSUME_NONNULL_BEGIN
-@interface KMCustomButtonPopMenuViewController : NSViewController
-
-@property (nonatomic, assign)id<KMCustomButtonPopMenuViewControllerDataSources>dataSources;
-@property (nonatomic, assign)id<KMCustomButtonPopMenuViewControllerDelegate>delegate;
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 178
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMCustomButtonPopMenuViewController.m

@@ -1,178 +0,0 @@
-//
-//  KMPopMenuViewController.m
-//  SignFlow
-//
-//  Created by Kdan on 2020/10/23.
-//
-
-#import "KMCustomButtonPopMenuViewController.h"
-#import <Masonry/Masonry.h>
-#import <PDF_Master-Swift.h>
-
-@interface KMPopMenuButton : NSButton
-
-@end
-
-@implementation KMPopMenuButton
-
-- (instancetype)initWithFrame:(NSRect)frameRect {
-    self = [super initWithFrame:frameRect];
-    if (self) {
-        [self addTrackingArea];
-        self.wantsLayer = YES;
-        self.layer.backgroundColor = [NSColor clearColor].CGColor;
-        self.font = [NSFont systemFontOfSize:14];
-    }
-    return self;
-}
-
-+ (Class)cellClass {
-    return [KMPopMenuButtonCell class];
-}
-
-- (void)addTrackingArea {
-    NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds options:NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingActiveAlways |NSTrackingMouseMoved owner:self userInfo:nil];
-    [self addTrackingArea:trackingArea];
-}
-
-- (void)mouseEntered:(NSEvent *)event {
-    [super mouseEntered:event];
-    
-    if (self.enabled) {
-        if (@available(macOS 10.14, *)) {
-            self.layer.backgroundColor = [NSColor controlAccentColor].CGColor;
-        } else {
-            self.layer.backgroundColor = [NSColor blueColor].CGColor;
-        }
-        [self setTitleColorWithColor:[NSColor whiteColor] font:nil];
-    }
-}
-
-- (void)mouseExited:(NSEvent *)event {
-    [super mouseExited:event];
-    
-    if (self.enabled) {
-        self.layer.backgroundColor = [NSColor clearColor].CGColor;
-        [self setTitleColorWithColor:[NSColor labelColor] font:nil];
-    }
-}
-
-- (NSSize)intrinsicContentSize {
-    CGSize size = [super intrinsicContentSize];
-    size.width += 45;
-    return size;
-}
-
-- (void)setState:(NSControlStateValue)state {
-    [super setState:state];
-    if (state == NSControlStateValueOn) {
-        if (@available(macOS 10.14, *)) {
-            self.layer.backgroundColor = [NSColor controlAccentColor].CGColor;
-        } else {
-            self.layer.backgroundColor = [NSColor blueColor].CGColor;
-        }
-        [self setTitleColorWithColor:[NSColor whiteColor] font:nil];
-    } else {
-        self.layer.backgroundColor = [NSColor clearColor].CGColor;
-        [self setTitleColorWithColor:[NSColor labelColor] font:nil];
-    }
-}
-
-- (void)setTitle:(NSString *)title {
-    [super setTitle:title];
-    
-    [self setTitleColorWithColor:[NSColor labelColor] font:nil];
-}
-
-@end
-
-@interface KMCustomButtonPopMenuViewController ()
-
-@end
-
-@implementation KMCustomButtonPopMenuViewController
-
-#pragma mark - Life cycle
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    
-    NSInteger numberOfLine = 0;
-    if ([self.dataSources respondsToSelector:@selector(numberOfLine)]) {
-        numberOfLine = [self.dataSources numberOfLine];
-    }
-    if (numberOfLine < 1) {
-        return;
-    }
-    NSView *referenceView = self.view;
-    for (NSInteger i = 0; i < numberOfLine ; i++) {
-        NSImage *image = nil;
-        NSString *title = nil;
-        if ([self.dataSources respondsToSelector:@selector(imageForLineAtIndex:)]) {
-            image = [self.dataSources imageForLineAtIndex:i];
-        }
-        if ([self.dataSources respondsToSelector:@selector(stringForLineAtIndex:)]) {
-            title = [self.dataSources stringForLineAtIndex:i];
-        }
-
-        KMPopMenuButton *v = nil;
-        if (image) {
-            v = [KMPopMenuButton buttonWithTitle:title image:image target:self action:@selector(buttonClicked:)];
-        } else {
-            v = [KMPopMenuButton buttonWithTitle:title target:self action:@selector(buttonClicked:)];
-        }
-
-        v.bordered = NO;
-        v.tag = i;
-        if ([self.dataSources respondsToSelector:@selector(itemEnableAtIndex:)]) {
-            v.enabled = [self.dataSources itemEnableAtIndex:i];
-        }
-        
-        [self.view addSubview:v];
-        
-        [v mas_makeConstraints:^(MASConstraintMaker *make) {
-            if ([referenceView isEqual:self.view]) {
-                make.top.equalTo(referenceView).offset(10);
-            } else {
-                make.top.equalTo(referenceView.mas_bottom).offset(2);
-            }
-            make.left.right.equalTo(self.view);
-            make.height.offset(24);
-        }];
-        referenceView = v;
-        
-        if ([self.dataSources respondsToSelector:@selector(needHightLightLineAtIndex:)]) {
-            if ([self.dataSources needHightLightLineAtIndex:i]) {
-                v.state = NSControlStateValueOn;
-            }
-        }
-        
-        if ([self.dataSources respondsToSelector:@selector(needInsertSeperateLineAtIndex:)]) {
-            if ([self.dataSources needInsertSeperateLineAtIndex:i]) {
-                NSBox *box = [[NSBox alloc] initWithFrame:CGRectZero];
-                box.boxType = NSBoxSeparator;
-                [self.view addSubview:box];
-                [box mas_makeConstraints:^(MASConstraintMaker *make) {
-                    make.top.equalTo(referenceView.mas_bottom).offset(2);
-                    make.left.equalTo(self.view).offset(21);
-                    make.centerX.equalTo(self.view);
-                }];
-                referenceView = box;
-            }
-        }
-
-        if (i == numberOfLine - 1) {
-            [referenceView mas_updateConstraints:^(MASConstraintMaker *make) {
-                make.bottom.equalTo(self.view).offset(-10);
-            }];
-        } 
-    }
-}
-
-- (void)buttonClicked:(NSButton *)sender {
-    if ([self.delegate respondsToSelector:@selector(customViewButtonPopDidSelectIndex:)]) {
-        [self.delegate customViewButtonPopDidSelectIndex:sender.tag];
-    }
-}
-
-@end

+ 122 - 0
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMCustomButtonPopMenuViewController.swift

@@ -0,0 +1,122 @@
+//
+//  KMCustomButtonPopMenuViewController.swift
+//  PDF Master
+//
+//  Created by wanjun on 2023/10/7.
+//
+
+import Cocoa
+import Masonry
+
+@objc protocol KMCustomButtonPopMenuViewControllerDataSources: AnyObject {
+    // pop框有多少行
+    func numberOfLine() -> Int
+    // pop框某行显示的文字
+    func stringForLine(at index: Int) -> String?
+    // 某行是否需要下划线
+    func needInsertSeperateLine(at index: Int) -> Bool
+    // 某行是否需要选取
+    func needHightLightLine(at index: Int) -> Bool
+    // 某行对应的图片
+    func imageForLine(at index: Int) -> NSImage?
+    // 某行是否可用
+    func itemEnable(at index: Int) -> Bool
+}
+
+@objc protocol KMCustomButtonPopMenuViewControllerDelegate: AnyObject {
+    func customViewButtonPopDidSelectIndex(_ index: Int)
+}
+
+@objc class KMCustomButtonPopMenuViewController: NSViewController {
+
+    weak var dataSources: KMCustomButtonPopMenuViewControllerDataSources?
+    weak var delegate: KMCustomButtonPopMenuViewControllerDelegate?
+
+    @objc override func viewDidLoad() {
+        super.viewDidLoad()
+        // Do view setup here.
+        
+        var numberOfLine = 0
+        if self.responds(to: Selector.init(("numberOfLine"))) {
+            numberOfLine = self.dataSources!.numberOfLine()
+        }
+        if numberOfLine < 1 {
+            return
+        }
+        
+        var referenceView: NSView? = self.view
+        
+        for i in 0..<numberOfLine {
+            var image: NSImage?
+            var title: String?
+            
+            if self.responds(to: Selector.init(("imageForLineAtIndex:"))) {
+                image = self.dataSources?.imageForLine(at: i)
+                title = self.dataSources?.stringForLine(at: i)
+            }
+            if self.responds(to: Selector.init(("stringForLineAtIndex:"))) {
+                title = self.dataSources?.stringForLine(at: i)
+            }
+
+            var v: KMPopMenuButton
+            if let image1 = image {
+                v = KMPopMenuButton(title: title!, image: image1, target: self, action: #selector(buttonClicked(_:)))
+            } else {
+                v = KMPopMenuButton(title: title!, target: self, action: #selector(buttonClicked(_:)))
+            }
+            
+            v.isBordered = false
+            v.tag = i
+            
+            if self.responds(to: Selector.init(("itemEnableAtIndex:"))) {
+                v.isEnabled = ((self.dataSources?.itemEnable(at: i)) != nil)
+            }
+            
+            self.view.addSubview(v)
+            
+            v.mas_makeConstraints { make in
+                if let viewBool = referenceView?.isEqual(self.view) {
+                    make?.top.equalTo()(referenceView)?.offset()(CGFloat(10))
+                } else {
+                    make?.top.equalTo()(referenceView?.mas_bottom)?.offset()(CGFloat(2))
+                }
+                make?.left.right().equalTo()(self.view)
+                make?.height.offset()(24)
+            }
+            referenceView = v
+            
+            if self.responds(to: Selector.init(("needHightLightLineAtIndex:"))) {
+                if let needBool = self.dataSources?.needHightLightLine(at: i) {
+                    v.state = .on
+                }
+            }
+            
+            if self.responds(to: Selector.init(("needInsertSeperateLineAtIndex:"))) {
+                if let needBool = self.dataSources?.needInsertSeperateLine(at: i) {
+                    let box = NSBox(frame: .zero)
+                    box.boxType = .separator
+                    self.view.addSubview(box)
+                    
+                    box.mas_makeConstraints { make in
+                        make?.top.equalTo()(referenceView?.mas_bottom)?.offset()(2)
+                        make?.left.equalTo()(self.view)?.offset()(CGFloat(21))
+                        make?.centerX.equalTo()(self.view)
+                    }
+                    referenceView = box
+                }
+            }
+            
+            if i == numberOfLine - 1 {
+                referenceView?.mas_updateConstraints({ make in
+                    make?.bottom.equalTo()(self.view)?.offset()(-10)
+                })
+            }
+        }
+    }
+    
+    @objc func buttonClicked(_ sender: NSButton) {
+        if self.responds(to: Selector.init(("customViewButtonPopDidSelectIndex:"))) {
+            self.delegate!.customViewButtonPopDidSelectIndex(sender.tag)
+        }
+    }
+}

+ 101 - 0
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMPopMenuButton.swift

@@ -0,0 +1,101 @@
+//
+//  KMPopMenuButton.swift
+//  PDF Master
+//
+//  Created by wanjun on 2023/10/7.
+//
+
+import Cocoa
+
+class KMPopMenuButton: NSButton {
+
+    override init(frame frameRect: NSRect) {
+        super.init(frame: frameRect)
+        self.setupButton()
+    }
+    
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
+        self.setupButton()
+    }
+    
+    private func setupButton() {
+        self.addTrackingArea()
+        self.wantsLayer = true
+        self.layer?.backgroundColor = NSColor.clear.cgColor
+        self.font = NSFont.systemFont(ofSize: 14)
+    }
+    
+//    override class var cellClass: AnyClass? {
+//        return KMPopMenuButtonCell.self
+//    }
+//    
+    func addTrackingArea() {
+        let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .inVisibleRect, .activeAlways, .mouseMoved], owner: self, userInfo: nil)
+        self.addTrackingArea(trackingArea)
+    }
+    
+    override func mouseEntered(with event: NSEvent) {
+        super.mouseEntered(with: event)
+        
+        if self.isEnabled {
+            if #available(macOS 10.14, *) {
+                self.layer?.backgroundColor = NSColor.controlAccentColor.cgColor
+            } else {
+                self.layer?.backgroundColor = NSColor.blue.cgColor
+            }
+            self.setTitleColorWithColor(NSColor.white, font: nil)
+        }
+    }
+    
+    override func mouseExited(with event: NSEvent) {
+        super.mouseExited(with: event)
+        
+        if self.isEnabled {
+            self.layer?.backgroundColor = NSColor.clear.cgColor
+            self.setTitleColorWithColor(NSColor.labelColor, font: nil)
+        }
+    }
+    
+    override var intrinsicContentSize: NSSize {
+        var size = super.intrinsicContentSize
+        size.width += 45
+        return size
+    }
+    
+    override var state: NSControl.StateValue {
+        didSet {
+            if state == .on {
+                if #available(macOS 10.14, *) {
+                    self.layer?.backgroundColor = NSColor.controlAccentColor.cgColor
+                } else {
+                    self.layer?.backgroundColor = NSColor.blue.cgColor
+                }
+                self.setTitleColorWithColor(NSColor.white, font: nil)
+            } else {
+                self.layer?.backgroundColor = NSColor.clear.cgColor
+                self.setTitleColorWithColor(NSColor.labelColor, font: nil)
+            }
+        }
+    }
+    
+//    override func setTitle(_ title: String) {
+//        super.title = title
+//        self.setTitleColorWithColor(NSColor.labelColor, font: nil)
+//    }
+    
+    private func setTitleColorWithColor(_ color: NSColor?, font: NSFont?) {
+        // 设置按钮文本颜色和字体
+        if let color = color {
+            let titleAttributes: [NSAttributedString.Key: Any] = [
+                .foregroundColor: color
+            ]
+            self.attributedTitle = NSAttributedString(string: self.title, attributes: titleAttributes)
+        }
+        if let font = font {
+            self.font = font
+        }
+    }
+
+    
+}

+ 5 - 3
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbar.h

@@ -6,7 +6,6 @@
 //
 
 #import <Cocoa/Cocoa.h>
-#import "KMCustomButtonPopMenuViewController.h"
 
 typedef NS_ENUM(NSInteger, KMToolBoxImagePosition) {
     KMToolBoxImagePosition_Only = 0,
@@ -64,9 +63,12 @@ extern NSString *KMToolbarDividerItemIdentifier;
 @property (nonatomic,retain) NSColor *normalBackgroundColor;
 @property (nonatomic,retain) NSColor *selectedBackgroundColor;
 
+//- (instancetype)initWithItemIdentifier:(NSString *)itemIdentifier
+//                             postition:(KMToolBoxImagePosition)imagePositionImagePosition
+//                           withPopMenu:(KMCustomButtonPopMenuViewController *)popMenuViewController;
 - (instancetype)initWithItemIdentifier:(NSString *)itemIdentifier
-                             postition:(KMToolBoxImagePosition)imagePositionImagePosition
-                           withPopMenu:(KMCustomButtonPopMenuViewController *)popMenuViewController;
+                             postition:(KMToolBoxImagePosition)imagePositionImagePosition;
+
 
 - (instancetype)initWithItemIdentifier:(NSString *)itemIdentifier;