Ignore:
Timestamp:
Jun 20, 2007, 10:53:46 PM (15 years ago)
Author:
livings124
Message:

simplify the mess of code that is the pieces view

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/PiecesView.m

    r2149 r2171  
    3030@implementation PiecesView
    3131
    32 - (id) init
    33 {
    34     if ((self = [super init]))
     32- (id) initWithCoder: (NSCoder *) decoder
     33{
     34    if ((self = [super initWithCoder: decoder]))
    3535    {
    3636        fTorrent = nil;
     
    4444- (void) awakeFromNib
    4545{
    46         #warning NSRectFill
    47        
    48         NSSize size = [fImageView bounds].size;
    49         NSBezierPath * bp = [NSBezierPath bezierPathWithRect: [fImageView bounds]];
     46        NSSize size = [self bounds].size;
     47        NSBezierPath * bp = [NSBezierPath bezierPathWithRect: [self bounds]];
    5048       
    5149        //back image
     
    137135        [fBluePiece unlockFocus];
    138136       
    139         [fImageView setToolTip: [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"]
     137        [self setToolTip: [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"]
    140138                        ? NSLocalizedString(@"Piece Availability", "Inspector -> Activity -> detailed pieces view tooltip")
    141139                        : NSLocalizedString(@"Piece Progress", "Inspector -> Activity -> detailed pieces view tooltip")];
     
    190188            fAcross = MAX_ACROSS;
    191189       
    192         float width = [fImageView bounds].size.width;
     190        float width = [self bounds].size.width;
    193191        fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross;
    194192        fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2;
     
    197195    }
    198196   
    199     [fImageView setHidden: torrent == nil];
     197    [self setHidden: torrent == nil];
    200198}
    201199
     
    206204   
    207205    if (first)
    208         [fImageView setImage: [[fBack copy] autorelease]];
    209     NSImage * image = [fImageView image];
     206        [self setImage: [[fBack copy] autorelease]];
     207    NSImage * image = [self image];
    210208
    211209    int8_t * pieces;
     
    370368    {
    371369        [image unlockFocus];
    372         [fImageView setNeedsDisplay];
     370        [self setNeedsDisplay];
    373371    }
    374372   
     
    379377}
    380378
    381 - (void) toggleView
     379- (BOOL) acceptsFirstMouse: (NSEvent *) event
     380{
     381    return YES;
     382}
     383
     384- (void) mouseDown: (NSEvent *) event
    382385{
    383386    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
     
    386389    [defaults setBool: showAvailability forKey: @"PiecesViewShowAvailability"];
    387390   
    388     [fImageView setToolTip: showAvailability
     391    [self setToolTip: showAvailability
    389392        ? NSLocalizedString(@"Piece Availability", "Inspector -> Activity -> detailed pieces view tooltip")
    390393        : NSLocalizedString(@"Piece Progress", "Inspector -> Activity -> detailed pieces view tooltip")];
    391394   
    392395    [self updateView: YES];
     396   
     397    [super mouseDown: event];
    393398}
    394399
Note: See TracChangeset for help on using the changeset viewer.