Changeset 6959


Ignore:
Timestamp:
Oct 25, 2008, 9:34:30 PM (12 years ago)
Author:
livings124
Message:

update some floats to CGFloats; append "f" to some float constants

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/AboutWindowController.m

    r6737 r6959  
    5454   
    5555    NSRect buttonFrame = [fLicenseButton frame];
    56     buttonFrame.size.width += 10.0;
     56    buttonFrame.size.width += 10.0f;
    5757    buttonFrame.origin.x -= buttonFrame.size.width - oldButtonWidth;
    5858    [fLicenseButton setFrame: buttonFrame];
  • trunk/macosx/BadgeView.h

    r5687 r6959  
    3232    NSDictionary * fAttributes;
    3333   
    34     float fDownloadRate, fUploadRate;
     34    CGFloat fDownloadRate, fUploadRate;
    3535    BOOL fQuitting;
    3636}
     
    3838- (id) initWithFrame: (NSRect) frame lib: (tr_handle *) lib;
    3939
    40 - (BOOL) setRatesWithDownload: (float) downloadRate upload: (float) uploadRate;
     40- (BOOL) setRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate;
    4141- (void) setQuitting;
    4242
  • trunk/macosx/BadgeView.m

    r5740 r6959  
    2626#import "NSStringAdditions.h"
    2727
    28 #define BETWEEN_PADDING 2.0
     28#define BETWEEN_PADDING 2.0f
    2929
    3030@interface BadgeView (Private)
    3131
    32 - (void) badge: (NSImage *) badge string: (NSString *) string atHeight: (float) height adjustForQuit: (BOOL) quit;
     32- (void) badge: (NSImage *) badge string: (NSString *) string atHeight: (CGFloat) height adjustForQuit: (BOOL) quit;
    3333
    3434@end
     
    5555}
    5656
    57 - (BOOL) setRatesWithDownload: (float) downloadRate upload: (float) uploadRate
     57- (BOOL) setRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate
    5858{
    5959    //only needs update if the badges were displayed or are displayed now
     
    8181        NSImage * quitBadge = [NSImage imageNamed: @"QuitBadge.png"];
    8282        [self badge: quitBadge string: NSLocalizedString(@"Quitting", "Dock Badger -> quit")
    83                 atHeight: (rect.size.height - [quitBadge size].height) * 0.5 adjustForQuit: YES];
     83                atHeight: (rect.size.height - [quitBadge size].height) * 0.5f adjustForQuit: YES];
    8484        return;
    8585    }
    8686   
    87     BOOL upload = fUploadRate >= 0.1,
    88         download = fDownloadRate >= 0.1;
    89     float bottom = 0.0;
     87    BOOL upload = fUploadRate >= 0.1f,
     88        download = fDownloadRate >= 0.1f;
     89    CGFloat bottom = 0.0f;
    9090    if (upload)
    9191    {
     
    105105
    106106//dock icon must have locked focus
    107 - (void) badge: (NSImage *) badge string: (NSString *) string atHeight: (float) height adjustForQuit: (BOOL) quit
     107- (void) badge: (NSImage *) badge string: (NSString *) string atHeight: (CGFloat) height adjustForQuit: (BOOL) quit
    108108{
    109109    if (!fAttributes)
    110110    {
    111111        NSShadow * stringShadow = [[NSShadow alloc] init];
    112         [stringShadow setShadowOffset: NSMakeSize(2.0, -2.0)];
    113         [stringShadow setShadowBlurRadius: 4.0];
     112        [stringShadow setShadowOffset: NSMakeSize(2.0f, -2.0f)];
     113        [stringShadow setShadowBlurRadius: 4.0f];
    114114       
    115115        fAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
    116116            [NSColor whiteColor], NSForegroundColorAttributeName,
    117             [NSFont boldSystemFontOfSize: 26.0], NSFontAttributeName, stringShadow, NSShadowAttributeName, nil];
     117            [NSFont boldSystemFontOfSize: 26.0f], NSFontAttributeName, stringShadow, NSShadowAttributeName, nil];
    118118       
    119119        [stringShadow release];
     
    124124    badgeRect.origin.y = height;
    125125   
    126     [badge drawInRect: badgeRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
     126    [badge drawInRect: badgeRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0f];
    127127   
    128128    //string is in center of image
     
    130130   
    131131    NSRect stringRect = badgeRect;
    132     stringRect.origin.x += (badgeRect.size.width - stringSize.width) * 0.5;
    133     stringRect.origin.y += (badgeRect.size.height - stringSize.height) * 0.5 + (quit ? 2.0 : 1.0); //adjust for shadow, extra for quit
     132    stringRect.origin.x += (badgeRect.size.width - stringSize.width) * 0.5f;
     133    stringRect.origin.y += (badgeRect.size.height - stringSize.height) * 0.5f + (quit ? 2.0f : 1.0f); //adjust for shadow, extra for quit
    134134    stringRect.size = stringSize;
    135135   
  • trunk/macosx/MessageWindowController.h

    r5628 r6959  
    3333   
    3434    NSMutableArray * fMessages;
    35     unsigned int fIndex;
     35    NSUInteger fIndex;
    3636   
    3737    NSDictionary * fAttributes;
  • trunk/macosx/MessageWindowController.m

    r6887 r6959  
    176176    BOOL shouldScroll = [scroller floatValue] == 1.0 || [scroller isHidden] || [scroller knobProportion] == 1.0;
    177177   
    178     int total = [fMessages count];
     178    NSUInteger total = [fMessages count];
    179179    if (total > MAX_MESSAGES)
    180180    {
     
    196196}
    197197
    198 - (int) numberOfRowsInTableView: (NSTableView *) tableView
     198- (NSInteger) numberOfRowsInTableView: (NSTableView *) tableView
    199199{
    200200    return [fMessages count];
    201201}
    202202
    203 - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (int) row
     203- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (NSInteger) row
    204204{
    205205    NSString * ident = [column identifier];
     
    229229
    230230#warning don't cut off end
    231 - (float) tableView: (NSTableView *) tableView heightOfRow: (int) row
     231- (float) tableView: (NSTableView *) tableView heightOfRow: (NSInteger) row
    232232{
    233233    NSTableColumn * column = [tableView tableColumnWithIdentifier: @"Message"];
     
    236236        fAttributes = [[[[column dataCell] attributedStringValue] attributesAtIndex: 0 effectiveRange: NULL] retain];
    237237   
    238     int count = [[[fMessages objectAtIndex: row] objectForKey: @"Message"] sizeWithAttributes: fAttributes].width / [column width];
    239     return [tableView rowHeight] * (float)(count+1);
     238    CGFloat count = floorf([[[fMessages objectAtIndex: row] objectForKey: @"Message"] sizeWithAttributes: fAttributes].width
     239                            / [column width]);
     240    return [tableView rowHeight] * (count + 1.0f);
    240241}
    241242
     
    247248
    248249- (NSString *) tableView: (NSTableView *) tableView toolTipForCell: (NSCell *) cell rect: (NSRectPointer) rect
    249                 tableColumn: (NSTableColumn *) column row: (int) row mouseLocation: (NSPoint) mouseLocation
     250                tableColumn: (NSTableColumn *) column row: (NSInteger) row mouseLocation: (NSPoint) mouseLocation
    250251{
    251252    NSDictionary * message = [fMessages objectAtIndex: row];
     
    333334}
    334335
    335 - (void) writeToFileSheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (NSString *) string
     336- (void) writeToFileSheetClosed: (NSSavePanel *) panel returnCode: (NSInteger) code contextInfo: (NSString *) string
    336337{
    337338    if (code == NSOKButton)
  • trunk/macosx/TorrentCell.m

    r6889 r6959  
    3131#import "CTGradientAdditions.h"
    3232
    33 #define BAR_HEIGHT 12.0
    34 
    35 #define IMAGE_SIZE_REG 32.0
    36 #define IMAGE_SIZE_MIN 16.0
    37 
    38 #define NORMAL_BUTTON_WIDTH 14.0
    39 #define ACTION_BUTTON_WIDTH 16.0
     33#define BAR_HEIGHT 12.0f
     34
     35#define IMAGE_SIZE_REG 32.0f
     36#define IMAGE_SIZE_MIN 16.0f
     37
     38#define NORMAL_BUTTON_WIDTH 14.0f
     39#define ACTION_BUTTON_WIDTH 16.0f
    4040
    4141//ends up being larger than font height
    42 #define HEIGHT_TITLE 16.0
    43 #define HEIGHT_STATUS 12.0
    44 
    45 #define PADDING_HORIZONTAL 3.0
    46 #define PADDING_BETWEEN_IMAGE_AND_TITLE 5.0
    47 #define PADDING_BETWEEN_IMAGE_AND_BAR 7.0
    48 #define PADDING_ABOVE_TITLE 4.0
    49 #define PADDING_ABOVE_MIN_STATUS 4.0
    50 #define PADDING_BETWEEN_TITLE_AND_MIN_STATUS 2.0
    51 #define PADDING_BETWEEN_TITLE_AND_PROGRESS 1.0
    52 #define PADDING_BETWEEN_PROGRESS_AND_BAR 2.0
    53 #define PADDING_BETWEEN_TITLE_AND_BAR_MIN 3.0
    54 #define PADDING_BETWEEN_BAR_AND_STATUS 2.0
    55 
    56 #define PIECES_TOTAL_PERCENT 0.6
     42#define HEIGHT_TITLE 16.0f
     43#define HEIGHT_STATUS 12.0f
     44
     45#define PADDING_HORIZONTAL 3.0f
     46#define PADDING_BETWEEN_IMAGE_AND_TITLE 5.0f
     47#define PADDING_BETWEEN_IMAGE_AND_BAR 7.0f
     48#define PADDING_ABOVE_TITLE 4.0f
     49#define PADDING_ABOVE_MIN_STATUS 4.0f
     50#define PADDING_BETWEEN_TITLE_AND_MIN_STATUS 2.0f
     51#define PADDING_BETWEEN_TITLE_AND_PROGRESS 1.0f
     52#define PADDING_BETWEEN_PROGRESS_AND_BAR 2.0f
     53#define PADDING_BETWEEN_TITLE_AND_BAR_MIN 3.0f
     54#define PADDING_BETWEEN_BAR_AND_STATUS 2.0f
     55
     56#define PIECES_TOTAL_PERCENT 0.6f
    5757
    5858#define MAX_PIECES (18*18)
     
    9292   
    9393        fTitleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    94                                 [NSFont messageFontOfSize: 12.0], NSFontAttributeName,
     94                                [NSFont messageFontOfSize: 12.0f], NSFontAttributeName,
    9595                                paragraphStyle, NSParagraphStyleAttributeName, nil];
    9696        fStatusAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    97                                 [NSFont messageFontOfSize: 9.0], NSFontAttributeName,
     97                                [NSFont messageFontOfSize: 9.0f], NSFontAttributeName,
    9898                                paragraphStyle, NSParagraphStyleAttributeName, nil];
    9999        [paragraphStyle release];
    100100       
    101         fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
    102         fBarBorderColor = [[NSColor colorWithDeviceWhite: 0.0 alpha: 0.2] retain];
     101        fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0f green: 0.4f blue: 0.8f alpha: 1.0f] retain];
     102        fBarBorderColor = [[NSColor colorWithDeviceWhite: 0.0f alpha: 0.2f] retain];
    103103    }
    104104        return self;
     
    107107- (NSRect) iconRectForBounds: (NSRect) bounds
    108108{
    109     float imageSize = [fDefaults boolForKey: @"SmallView"] ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG;
     109    CGFloat imageSize = [fDefaults boolForKey: @"SmallView"] ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG;
    110110   
    111111    NSRect result = bounds;
    112112    result.origin.x += PADDING_HORIZONTAL;
    113     result.origin.y += floorf((result.size.height - imageSize) * 0.5);
     113    result.origin.y += floorf((result.size.height - imageSize) * 0.5f);
    114114    result.size = NSMakeSize(imageSize, imageSize);
    115115   
     
    155155        result.origin.y += PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS + PADDING_BETWEEN_PROGRESS_AND_BAR;
    156156   
    157     result.size.width = round(NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL - 2.0 * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH));
     157    result.size.width = round(NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL - 2.0f * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH));
    158158   
    159159    return result;
     
    173173    result.size.height = NORMAL_BUTTON_WIDTH;
    174174    result.size.width = NORMAL_BUTTON_WIDTH;
    175     result.origin.x = NSMaxX(bounds) - 2.0 * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
    176    
    177     result.origin.y += PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5;
     175    result.origin.x = NSMaxX(bounds) - 2.0f * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
     176   
     177    result.origin.y += PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5f;
    178178    if ([fDefaults boolForKey: @"SmallView"])
    179179        result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN;
     
    191191    result.origin.x = NSMaxX(bounds) - (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
    192192   
    193     result.origin.y += PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5;
     193    result.origin.y += PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5f;
    194194    if ([fDefaults boolForKey: @"SmallView"])
    195195        result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN;
     
    205205    if (![fDefaults boolForKey: @"SmallView"])
    206206    {
    207         result.origin.x += (result.size.width - ACTION_BUTTON_WIDTH) * 0.5;
    208         result.origin.y += (result.size.height - ACTION_BUTTON_WIDTH) * 0.5;
     207        result.origin.x += (result.size.width - ACTION_BUTTON_WIDTH) * 0.5f;
     208        result.origin.y += (result.size.height - ACTION_BUTTON_WIDTH) * 0.5f;
    209209        result.size.width = ACTION_BUTTON_WIDTH;
    210210        result.size.height = ACTION_BUTTON_WIDTH;
     
    384384    NSRect iconRect = [self iconRectForBounds: cellFrame];
    385385   
    386     int groupValue = [torrent groupValue];
     386    NSInteger groupValue = [torrent groupValue];
    387387    if (groupValue != -1)
    388388    {
    389         NSRect groupRect = NSInsetRect(iconRect, -1.0, -2.0);
     389        NSRect groupRect = NSInsetRect(iconRect, -1.0f, -2.0f);
    390390        if (!minimal)
    391391        {
     
    393393            groupRect.origin.y--;
    394394        }
    395         float radius = minimal ? 3.0 : 6.0;
     395        CGFloat radius = minimal ? 3.0f : 6.0f;
    396396       
    397397        NSColor * groupColor = [[GroupsController groups] colorForIndex: groupValue],
    398                 * darkGroupColor = [groupColor blendedColorWithFraction: 0.2 ofColor: [NSColor whiteColor]];
     398                * darkGroupColor = [groupColor blendedColorWithFraction: 0.2f ofColor: [NSColor whiteColor]];
    399399       
    400400        //border
    401401        NSBezierPath * bp = [NSBezierPath bezierPathWithRoundedRect: groupRect radius: radius];
    402402        [darkGroupColor set];
    403         [bp setLineWidth: 2.0];
     403        [bp setLineWidth: 2.0f];
    404404        [bp stroke];
    405405       
    406406        //inside
    407407        bp = [NSBezierPath bezierPathWithRoundedRect: groupRect radius: radius];
    408         CTGradient * gradient = [CTGradient gradientWithBeginningColor: [groupColor blendedColorWithFraction: 0.7
     408        CTGradient * gradient = [CTGradient gradientWithBeginningColor: [groupColor blendedColorWithFraction: 0.7f
    409409                                    ofColor: [NSColor whiteColor]] endingColor: darkGroupColor];
    410         [gradient fillBezierPath: bp angle: 90.0];
     410        [gradient fillBezierPath: bp angle: 90.0f];
    411411    }
    412412   
     
    423423    {
    424424        NSImage * icon = (minimal && error) ? fErrorImage : [torrent icon];
    425         [icon drawInRect: iconRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
     425        [icon drawInRect: iconRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0f];
    426426    }
    427427   
     
    430430        NSRect errorRect = NSMakeRect(NSMaxX(iconRect) - IMAGE_SIZE_MIN, NSMaxY(iconRect) - IMAGE_SIZE_MIN,
    431431                                        IMAGE_SIZE_MIN, IMAGE_SIZE_MIN);
    432         [fErrorImage drawInRect: errorRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
     432        [fErrorImage drawInRect: errorRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0f];
    433433    }
    434434   
     
    498498    [controlImage setFlipped: YES];
    499499    [controlImage drawInRect: [self controlButtonRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver
    500         fraction: 1.0];
     500        fraction: 1.0f];
    501501   
    502502    //reveal button
     
    512512    [revealImage setFlipped: YES];
    513513    [revealImage drawInRect: [self revealButtonRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver
    514         fraction: 1.0];
     514        fraction: 1.0f];
    515515   
    516516    //action button
     
    528528        [actionImage setFlipped: YES];
    529529        [actionImage drawInRect: [self actionButtonRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver
    530             fraction: 1.0];
     530            fraction: 1.0f];
    531531    }
    532532   
     
    545545- (void) drawBar: (NSRect) barRect
    546546{
    547     float piecesBarPercent = [(TorrentTableView *)[self controlView] piecesBarPercent];
    548     if (piecesBarPercent > 0.0)
     547    CGFloat piecesBarPercent = [(TorrentTableView *)[self controlView] piecesBarPercent];
     548    if (piecesBarPercent > 0.0f)
    549549    {
    550550        NSRect regularBarRect = barRect, piecesBarRect = barRect;
     
    564564   
    565565    [fBarBorderColor set];
    566     [NSBezierPath strokeRect: NSInsetRect(barRect, 0.5, 0.5)];
     566    [NSBezierPath strokeRect: NSInsetRect(barRect, 0.5f, 0.5f)];
    567567}
    568568
     
    571571    Torrent * torrent = [self representedObject];
    572572   
    573     int leftWidth = barRect.size.width;
    574     float progress = [torrent progress];
    575    
    576     if (progress < 1.0)
    577     {
    578         float rightProgress = 1.0 - progress, progressLeft = [torrent progressLeft];
    579         int rightWidth = leftWidth * rightProgress;
     573    NSInteger leftWidth = barRect.size.width;
     574    CGFloat progress = [torrent progress];
     575   
     576    if (progress < 1.0f)
     577    {
     578        CGFloat rightProgress = 1.0f - progress, progressLeft = [torrent progressLeft];
     579        NSInteger rightWidth = leftWidth * rightProgress;
    580580        leftWidth -= rightWidth;
    581581       
    582582        if (progressLeft < rightProgress)
    583583        {
    584             int rightNoIncludeWidth = rightWidth * ((rightProgress - progressLeft) / rightProgress);
     584            NSInteger rightNoIncludeWidth = rightWidth * ((rightProgress - progressLeft) / rightProgress);
    585585            rightWidth -= rightNoIncludeWidth;
    586586           
     
    597597                && [fDefaults boolForKey: @"DisplayProgressBarAvailable"])
    598598            {
    599                 int notAvailableWidth = ceil(rightWidth * [torrent notAvailableDesired]);
     599                NSInteger notAvailableWidth = ceil(rightWidth * [torrent notAvailableDesired]);
    600600                if (notAvailableWidth > 0)
    601601                {
     
    632632            else if ([torrent isSeeding])
    633633            {
    634                 int ratioLeftWidth = leftWidth * (1.0 - [torrent progressStopRatio]);
     634                NSInteger ratioLeftWidth = leftWidth * (1.0f - [torrent progressStopRatio]);
    635635                leftWidth -= ratioLeftWidth;
    636636               
     
    658658            if ([torrent waitingToStart])
    659659            {
    660                 if ([torrent progressLeft] <= 0.0)
     660                if ([torrent progressLeft] <= 0.0f)
    661661                    [[CTGradient progressDarkGreenGradient] fillRect: completeRect angle: 90];
    662662                else
     
    673673    Torrent * torrent = [self representedObject];
    674674   
    675     int pieceCount = MIN([torrent pieceCount], MAX_PIECES);
    676     float * piecesPercent = malloc(pieceCount * sizeof(float));
     675    NSInteger pieceCount = MIN([torrent pieceCount], MAX_PIECES);
     676    CGFloat * piecesPercent = malloc(pieceCount * sizeof(CGFloat));
    677677    [torrent getAmountFinished: piecesPercent size: pieceCount];
    678678   
     
    687687    {
    688688        NSColor * pieceColor;
    689         if (piecesPercent[i] == 1.0)
     689        if (piecesPercent[i] == 1.0f)
    690690        {
    691691            if (previousFinishedIndexes && ![previousFinishedIndexes containsIndex: i])
Note: See TracChangeset for help on using the changeset viewer.