Changeset 688


Ignore:
Timestamp:
Jul 23, 2006, 10:58:04 PM (15 years ago)
Author:
livings124
Message:

Reordered code a little.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/BarButton.m

    r687 r688  
    2727@interface BarButton (Private)
    2828
    29 - (void) setText;
     29- (void) createButtons;
    3030
    3131@end
     
    4141        fTrackingTag = 0;
    4242       
    43         NSSize buttonSize = [self frame].size;
    44         fButtonNormal = [[NSImage alloc] initWithSize: buttonSize];
    45         fButtonNormalDim = [[NSImage alloc] initWithSize: buttonSize];
    46         fButtonOver = [[NSImage alloc] initWithSize: buttonSize];
    47         fButtonPressed = [[NSImage alloc] initWithSize: buttonSize];
    48         fButtonSelected = [[NSImage alloc] initWithSize: buttonSize];
    49         fButtonSelectedDim = [[NSImage alloc] initWithSize: buttonSize];
    50        
    51         //rolled over button
    52         NSImage * leftOver = [NSImage imageNamed: @"FilterButtonOverLeft.png"],
    53                 * rightOver = [NSImage imageNamed: @"FilterButtonOverRight.png"],
    54                 * mainOver = [NSImage imageNamed: @"FilterButtonOverMain.png"];
    55        
    56         NSSize endSize = [leftOver size],
    57                 mainSize = NSMakeSize(buttonSize.width - endSize.width * 2.0, endSize.height);
    58         NSPoint leftPoint = NSMakePoint(0, 0),
    59                 rightPoint = NSMakePoint(buttonSize.width - endSize.width, 0),
    60                 mainPoint = NSMakePoint(endSize.width, 0);
    61 
    62         [mainOver setScalesWhenResized: YES];
    63         [mainOver setSize: mainSize];
    64        
    65         [fButtonOver lockFocus];
    66         [leftOver compositeToPoint: leftPoint operation: NSCompositeSourceOver];
    67         [mainOver compositeToPoint: mainPoint operation: NSCompositeSourceOver];
    68         [rightOver compositeToPoint: rightPoint operation: NSCompositeSourceOver];
    69         [fButtonOver unlockFocus];
    70        
    71         //pressed button
    72         NSImage * leftPressed = [NSImage imageNamed: @"FilterButtonPressedLeft.png"],
    73                 * rightPressed = [NSImage imageNamed: @"FilterButtonPressedRight.png"],
    74                 * mainPressed = [NSImage imageNamed: @"FilterButtonPressedMain.png"];
    75        
    76         [mainPressed setScalesWhenResized: YES];
    77         [mainPressed setSize: mainSize];
    78        
    79         [fButtonPressed lockFocus];
    80         [leftPressed compositeToPoint: leftPoint operation: NSCompositeSourceOver];
    81         [mainPressed compositeToPoint: mainPoint operation: NSCompositeSourceOver];
    82         [rightPressed compositeToPoint: rightPoint operation: NSCompositeSourceOver];
    83         [fButtonPressed unlockFocus];
    84        
    85         //selected button
    86         NSImage * leftSelected = [NSImage imageNamed: @"FilterButtonSelectedLeft.png"],
    87                 * rightSelected = [NSImage imageNamed: @"FilterButtonSelectedRight.png"],
    88                 * mainSelected = [NSImage imageNamed: @"FilterButtonSelectedMain.png"];
    89        
    90         [mainSelected setScalesWhenResized: YES];
    91         [mainSelected setSize: mainSize];
    92        
    93         [fButtonSelected lockFocus];
    94         [leftSelected compositeToPoint: leftPoint operation: NSCompositeSourceOver];
    95         [mainSelected compositeToPoint: mainPoint operation: NSCompositeSourceOver];
    96         [rightSelected compositeToPoint: rightPoint operation: NSCompositeSourceOver];
    97         [fButtonSelected unlockFocus];
    98        
    99         //selected and dimmed button
    100         fButtonSelectedDim = [fButtonSelected copy];
    101        
    102         [self setText];
     43        [self createButtons];
    10344       
    10445        [self setImage: fButtonNormal];
     
    11152}
    11253
    113 //call only once to avoid overlapping text
    114 - (void) setText
    115 {
     54//call only once
     55- (void) createButtons
     56{
     57    NSSize buttonSize = [self frame].size;
     58    fButtonNormal = [[NSImage alloc] initWithSize: buttonSize];
     59    fButtonNormalDim = [[NSImage alloc] initWithSize: buttonSize];
     60    fButtonOver = [[NSImage alloc] initWithSize: buttonSize];
     61    fButtonPressed = [[NSImage alloc] initWithSize: buttonSize];
     62    fButtonSelected = [[NSImage alloc] initWithSize: buttonSize];
     63    fButtonSelectedDim = [[NSImage alloc] initWithSize: buttonSize];
     64   
     65    //rolled over button
     66    NSImage * leftOver = [NSImage imageNamed: @"FilterButtonOverLeft.png"],
     67            * rightOver = [NSImage imageNamed: @"FilterButtonOverRight.png"],
     68            * mainOver = [NSImage imageNamed: @"FilterButtonOverMain.png"];
     69   
     70    NSSize endSize = [leftOver size],
     71            mainSize = NSMakeSize(buttonSize.width - endSize.width * 2.0, endSize.height);
     72    NSPoint leftPoint = NSMakePoint(0, 0),
     73            rightPoint = NSMakePoint(buttonSize.width - endSize.width, 0),
     74            mainPoint = NSMakePoint(endSize.width, 0);
     75
     76    [mainOver setScalesWhenResized: YES];
     77    [mainOver setSize: mainSize];
     78   
     79    [fButtonOver lockFocus];
     80    [leftOver compositeToPoint: leftPoint operation: NSCompositeSourceOver];
     81    [mainOver compositeToPoint: mainPoint operation: NSCompositeSourceOver];
     82    [rightOver compositeToPoint: rightPoint operation: NSCompositeSourceOver];
     83    [fButtonOver unlockFocus];
     84   
     85    //pressed button
     86    NSImage * leftPressed = [NSImage imageNamed: @"FilterButtonPressedLeft.png"],
     87            * rightPressed = [NSImage imageNamed: @"FilterButtonPressedRight.png"],
     88            * mainPressed = [NSImage imageNamed: @"FilterButtonPressedMain.png"];
     89   
     90    [mainPressed setScalesWhenResized: YES];
     91    [mainPressed setSize: mainSize];
     92   
     93    [fButtonPressed lockFocus];
     94    [leftPressed compositeToPoint: leftPoint operation: NSCompositeSourceOver];
     95    [mainPressed compositeToPoint: mainPoint operation: NSCompositeSourceOver];
     96    [rightPressed compositeToPoint: rightPoint operation: NSCompositeSourceOver];
     97    [fButtonPressed unlockFocus];
     98   
     99    //selected button
     100    NSImage * leftSelected = [NSImage imageNamed: @"FilterButtonSelectedLeft.png"],
     101            * rightSelected = [NSImage imageNamed: @"FilterButtonSelectedRight.png"],
     102            * mainSelected = [NSImage imageNamed: @"FilterButtonSelectedMain.png"];
     103   
     104    [mainSelected setScalesWhenResized: YES];
     105    [mainSelected setSize: mainSize];
     106   
     107    [fButtonSelected lockFocus];
     108    [leftSelected compositeToPoint: leftPoint operation: NSCompositeSourceOver];
     109    [mainSelected compositeToPoint: mainPoint operation: NSCompositeSourceOver];
     110    [rightSelected compositeToPoint: rightPoint operation: NSCompositeSourceOver];
     111    [fButtonSelected unlockFocus];
     112   
     113    //selected and dimmed button
     114    fButtonSelectedDim = [fButtonSelected copy];
     115
     116    //create button text
    116117    NSString * text = [self title];
    117118
     
    155156   
    156157    NSSize textSizeNormal = [text sizeWithAttributes: normalAttributes],
    157             textSizeBold = [text sizeWithAttributes: highlightedAttributes],
    158             buttonSize = [self frame].size;
     158            textSizeBold = [text sizeWithAttributes: highlightedAttributes];
    159159   
    160160    NSRect textRect = NSMakeRect((buttonSize.width - textSizeNormal.width) * 0.5,
Note: See TracChangeset for help on using the changeset viewer.