KMToolbar.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // KMToolbar.h
  3. //
  4. // Copyright © 2022 Kdan Mobile. All rights reserved.
  5. //
  6. #import <Cocoa/Cocoa.h>
  7. #import "KMCustomButtonPopMenuViewController.h"
  8. typedef NS_ENUM(NSInteger, KMToolBoxImagePosition) {
  9. KMToolBoxImagePosition_Only = 0,
  10. KMToolBoxImagePosition_Left,
  11. KMToolBoxImagePosition_ExpandLeft,
  12. KMToolBoxImagePosition_Above,
  13. };
  14. extern NSString *KMNewToolbarSpaceItemIdentifier;
  15. extern NSString *KMToolbarDividerItemIdentifier;
  16. @interface KMToolbarClickButton : NSButton
  17. @property (nonatomic,assign) id clickObject;
  18. @end
  19. @interface KMToolBoxItem : NSView
  20. @property (nonatomic,retain) NSMenuItem *menuFormRepresentation;
  21. @property (nonatomic,readonly) NSString *itemIdentifier;
  22. @property(nonatomic,readonly) KMToolbarClickButton *clickButton;
  23. @property (nonatomic,assign) BOOL isSelected;
  24. @property (nonatomic,assign) BOOL unEnabled;
  25. @property (nonatomic,assign) BOOL isShowCustomToolTip;
  26. @property (nonatomic,assign) KMToolBoxImagePosition boxImagePosition;
  27. @property (nonatomic,retain) NSImage * image;
  28. @property (nonatomic,retain) NSImage * selectedImage;
  29. @property (nonatomic,retain) NSString * titleName;
  30. @property (nonatomic,retain) NSImage * alternateImage;
  31. @property (nonatomic,assign) id target;
  32. @property (nonatomic,assign) BOOL needExpandAction;
  33. @property (nonatomic,assign) NSInteger btnTag;
  34. @property (nonatomic,assign) SEL btnAction;
  35. @property (nonatomic,retain) NSView *customizeView;
  36. @property (nonatomic,assign) BOOL isMainTool;
  37. @property (nonatomic,retain) NSView *linView;
  38. @property (nonatomic,retain) NSColor *normalBackgroundColor;
  39. @property (nonatomic,retain) NSColor *selectedBackgroundColor;
  40. - (instancetype)initWithItemIdentifier:(NSString *)itemIdentifier
  41. postition:(KMToolBoxImagePosition)imagePositionImagePosition
  42. withPopMenu:(KMCustomButtonPopMenuViewController *)popMenuViewController;
  43. - (instancetype)initWithItemIdentifier:(NSString *)itemIdentifier;
  44. @end
  45. @protocol KMNewToolbarDelegate;
  46. @interface KMToolbar : NSView
  47. @property (nonatomic,readonly) NSString *toolbarIdentifier;
  48. @property (nonatomic,weak) id<KMNewToolbarDelegate> delegate;
  49. @property (nonatomic,readonly) NSArray<KMToolBoxItem *> *items;
  50. - (instancetype)initWithIdentifier:(NSString *)identifier;
  51. - (void)reloadData;
  52. - (KMToolBoxItem * _Nullable)itemForItemIdentifier:(NSString * _Nonnull)itemIdentifier;
  53. @end
  54. @protocol KMNewToolbarDelegate <NSObject>
  55. @optional
  56. - (KMToolBoxItem *)toolbar:(KMToolbar *)toolbar itemForItemIdentifier:(NSString *)identifier;
  57. - (NSArray<NSString *> *)toolbarAllowedItemIdentifiers:(KMToolbar *)toolbar;
  58. - (NSArray<NSString *> *)toolbarDefaultItemIdentifiers:(KMToolbar *)toolbar;
  59. - (NSArray<NSString *> *)toolbarLeftDefaultItemIdentifiers:(KMToolbar *)toolbar;
  60. - (NSArray<NSString *> *)toolbarRightDefaultItemIdentifiers:(KMToolbar *)toolbar;
  61. @end