KMToolbarItem.m 827 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // KMToolbarItem.m
  3. // SignFlow
  4. //
  5. // Created by 王帅 on 2021/3/26.
  6. //
  7. #import "KMToolbarItem.h"
  8. @implementation KMToolbarItem
  9. - (void)validate {
  10. if ([self view] && [[[self toolbar] delegate] respondsToSelector:@selector(validateToolbarItem:)]) {
  11. BOOL enabled = [(id)[[self toolbar] delegate] validateToolbarItem:self];
  12. [self setEnabled:enabled];
  13. }
  14. [super validate];
  15. }
  16. - (void)setLabels:(NSString *)label {
  17. [self setLabel:label];
  18. [self setPaletteLabel:label];
  19. }
  20. - (void)setViewWithSizes:(NSView *)view {
  21. if ([view isKindOfClass:[NSSegmentedControl class]]) {
  22. [(NSSegmentedControl *)view sizeToFit];
  23. }
  24. [self setView:view];
  25. [self.view setFrame:view.bounds];
  26. }
  27. - (void)setImageNamed:(NSString *)name {
  28. [self setImage:[NSImage imageNamed:name]];
  29. }
  30. @end